瀏覽代碼

仓库设置审核

zhangyuewww 3 年之前
父節點
當前提交
62e02b9c0a

+ 27 - 37
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/PurchasePriceServiceImpl.java

@@ -49,8 +49,6 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
     private IWarehouseBaseInfoService warehouseBaseInfoService;
     @Autowired
     private INewWorkflowService workflowService;
-    @SofaReference
-    private ICommonRoleResourceService roleResourceService;
     @Override
     public Page<PurchasePrice> purchasePriceList(PurchasePrice purchasePrice) {
 
@@ -58,22 +56,12 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
         pageView.put("startRecord", (purchasePrice.getCurrentPage() - 1)
                 * purchasePrice.getPageSize());
         //公司id
-        List<String> statusSet = new ArrayList<>();
-        List<String> resourceIdList = this.getResourceIdList();
-        if (resourceIdList.contains("procurementInReport-Edit")) { // 填写,提交    权限做完以后替换
-            List<String> statusList = Lists.newArrayList(StatusEnum.PUR_RETURN.getFlag());
-            statusSet.addAll(statusList);
-        }
         pageView.put("compId", purchasePrice.getCompId());
         pageView.put("warehouseId", purchasePrice.getWarehouseId());
         pageView.put("pageSize", purchasePrice.getPageSize());
         pageView.put("currentPage", purchasePrice.getCurrentPage());
-        pageView.put("statusSet", statusSet);
         List<PurchasePrice> dataList = this.baseMapper.purchasePriceList(pageView);
-
-
         Integer dataCount = this.baseMapper.purchasePriceListCount(pageView);
-
         if (!CollectionUtils.isEmpty(dataList)) {
             dataList.forEach(purchasePrice1 -> {
                 String taskId = "";
@@ -84,7 +72,6 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
                     purchasePrice1.setTaskId(taskId);
                 }
             });
-
         }
         Page<PurchasePrice> page = new Page<>();
         page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
@@ -93,12 +80,6 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
         page.setSize(purchasePrice.getPageSize());
         return page;
     }
-    private List<String> getResourceIdList() {
-        User currentUser = AuthSecurityUtils.getCurrentUserInfo();
-        // 当前登录人主要角色
-        return roleResourceService.getBindResourcesByUserId(currentUser.getUserId()).stream()
-                .map(CommonRoleResource::getResourceId).collect(Collectors.toList());
-    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -166,7 +147,14 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
 
     @Override
     public PurchasePrice purchasePriceLook(PurchasePrice purchasePrice) {
-        purchasePrice = this.baseMapper.selectById(purchasePrice.getId());
+        purchasePrice = this.selectById(purchasePrice.getId());
+        String taskId = "";
+        // 只有待审核状态才有taskId
+        if (StringUtils.isNotBlank(purchasePrice.getWorkflowId())) {
+            JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(purchasePrice.getWorkflowId()), purchasePrice.getId());
+            taskId = jsonObject.getString("taskId");
+            purchasePrice.setTaskId(taskId);
+        }
         List<PurchasePriceDetail> details = this.purchasePriceDetailService.selectList(new EntityWrapper<PurchasePriceDetail>().eq("main_id",purchasePrice.getId()));
         purchasePrice.setDetails(details);
         List<PurchasePriceDetailPrint> detailPrints = this.purchasePriceDetailPrintService.selectList(new EntityWrapper<PurchasePriceDetailPrint>().eq("main_id",purchasePrice.getId()));
@@ -196,29 +184,31 @@ public class PurchasePriceServiceImpl extends ServiceImpl<PurchasePriceMapper, P
             this.purchasePriceDetailPrintService.insert(tmp);
         }
         boolean isStartWorkflow = StringUtils.isBlank(purchasePrice.getWorkflowId());
-        // 不是退回的单子
-        if (isStartWorkflow) {
-            Workflow workflow = workflowService
-                    .findLatestWorkflowByBusinessCodeByApp(purchasePrice.getCompId(), "PROCUREMENT-PRICE-APPROVE");
-            // 没配置审核流程,直接结束并处理信息
-            if (workflow == null) {
-                throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+        if(StatusEnum.PURCHASE_FAILED.getFlag().equals(purchasePrice.getStatusFlag())) {
+            // 不是退回的单子
+            if (isStartWorkflow) {
+                Workflow workflow = workflowService
+                        .findLatestWorkflowByBusinessCodeByApp(purchasePrice.getCompId(), "PROCUREMENT-PRICE-APPROVE");
+                // 没配置审核流程,直接结束并处理信息
+                if (workflow == null) {
+                    throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+                }
+                // 开启审核流
+                else {
+
+                    // 设置状态 已提交审核
+                    purchasePrice.setWorkflowId(workflow.getId());
+                    this.updateById(purchasePrice);
+                    workflowService.startInstance(workflow.getId(), purchasePrice.getId());
+                }
             }
-            // 开启审核流
+            // 退回的单子 再启用
             else {
 
-                // 设置状态 已提交审核
-                purchasePrice.setWorkflowId(workflow.getId());
                 this.updateById(purchasePrice);
-                workflowService.startInstance(workflow.getId(), purchasePrice.getId());
+                workflowService.activateInstance(purchasePrice.getWorkflowId(), purchasePrice.getId());
             }
         }
-        // 退回的单子 再启用
-        else {
-
-            this.updateById(purchasePrice);
-            workflowService.activateInstance(purchasePrice.getWorkflowId(), purchasePrice.getId());
-        }
         return "ok";
     }
 

+ 6 - 25
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/PurchasePriceMapper.xml

@@ -17,28 +17,19 @@
         pp.sale_limit as saleLimit,
         pp.`status`,
         pp.status_flag AS statusFlag,
-        pp.pass_date AS passDate
+        pp.pass_date AS passDate,
+        workflow_id as workflowId
         FROM
         purchase_price pp
         LEFT JOIN warehouse_base_info wbi ON pp.warehouse_id = wbi.id
         WHERE
         wbi.comp_id = #{compId}
         and pp.comp_id = #{compId}
+        and wbi.delete_flag = '0'
+        and pp.delete_flag = '0'
         <if test="warehouseId != null and warehouseId != ''">
             AND pp.warehouse_id = #{warehouseId}
         </if>
-        <if test="statusSet != null and statusSet.size > 0">
-            or (
-            <foreach collection="statusSet" item="statusId" separator="or" open="(" close=")">
-                status_flag =
-                <if test="statusId != null">
-                    #{statusId}
-                </if>
-            </foreach>
-            )
-        </if>
-        and wbi.delete_flag = '0'
-        and pp.delete_flag = '0'
         ORDER BY pp.warehouse_name DESC
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
@@ -53,21 +44,11 @@
         WHERE
         wbi.comp_id = #{compId}
         and pp.comp_id = #{compId}
+        and wbi.delete_flag = '0'
+        and pp.delete_flag = '0'
         <if test="warehouseId != null and warehouseId != ''">
             AND pp.warehouse_id = #{warehouseId}
         </if>
-        <if test="statusSet != null and statusSet.size > 0">
-            or (
-            <foreach collection="statusSet" item="statusId" separator="or" open="(" close=")">
-                status_flag =
-                <if test="statusId != null">
-                    #{statusId}
-                </if>
-            </foreach>
-            )
-        </if>
-        and wbi.delete_flag = '0'
-        and pp.delete_flag = '0'
         ORDER BY pp.warehouse_name DESC
     </select>
 </mapper>