gongdecai 2 years ago
parent
commit
255a7ec99f

+ 2 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/TranProcessInfoServiceImpl.java

@@ -733,6 +733,7 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
                 }
             // 批次开启审核流
             if("1".equals(flagBatch)){
+                batchReviewInfo.setCompId(AuthSecurityUtils.getCurrentUserInfo().getCompId());
                 batchReviewInfoService.insert(batchReviewInfo);
                 boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(batchReviewInfo.getWorkflowId());
                 // 不是退回的单子
@@ -763,7 +764,7 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
                         settlementReport.setStatus(batchReviewInfo.getStatus());
                         settlementReport.setApproveStatus(batchReviewInfo.getApproveStatus());
                     }
-                    tranSettlementReportService.insertBatch(tranSettlementReports);
+                    tranSettlementReportService.updateBatchById(tranSettlementReports);
                 }
             }
         }

+ 39 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/TranSettlementReportServiceImpl.java

@@ -64,14 +64,50 @@ public class TranSettlementReportServiceImpl extends ServiceImpl<TranSettlementR
     /**
      * 审核数据
      *
-     * @param tranSettlementReport
+     * @param tranSettlementReport1
      * @return
      */
     @Override
-    public List<TranSettlementReport> getTranSettlementReport(TranSettlementReport tranSettlementReport) {
+    public List<TranSettlementReport> getTranSettlementReport(TranSettlementReport tranSettlementReport1) {
 
         List<TranSettlementReport> tranSettlementReports = this.selectList(new EntityWrapper<TranSettlementReport>()
-        .eq("batch_id",tranSettlementReport.getBatchId()));
+        .eq("batch_id",tranSettlementReport1.getBatchId()));
+        if(!CollectionUtils.isEmpty(tranSettlementReports)){
+            for(int i=0;i<tranSettlementReports.size();i++){
+                TranSettlementReport tranSettlementReport= tranSettlementReports.get(i);
+                TranCarInfo tranCarInfo=tranCarInfoService.selectById(tranSettlementReport.getCarId());
+                if (tranCarInfo!=null){
+                    TranProcessInfo tranProcessInfo=tranProcessInfoService.selectById(tranCarInfo.getProcessId());
+                    if (tranProcessInfo!=null){
+                        tranSettlementReport.setSend(tranProcessInfo.getSendPrivate()+tranProcessInfo.getSendCity()+tranProcessInfo.getSendArea()+tranProcessInfo.getSendDetailedAddress());
+                        tranSettlementReport.setReceive(tranProcessInfo.getReceivePrivate()+tranProcessInfo.getReceiveCity()+tranProcessInfo.getReceiveArea()+tranProcessInfo.getReceiveDetailedAddress());
+                    }
+                }
+                ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
+                        .eq("comp_id", tranSettlementReport.getCompId())
+                        .eq("contract_no", tranSettlementReport.getContractNo())
+                        .eq("delete_flag", "0"));
+                //合同类型
+                if(contractManagementInfo!=null) {
+                    //销售
+                    if ("1".equals(contractManagementInfo.getContractType())) {
+                        tranSettlementReport.setCustomer(contractManagementInfo.getBuyer());
+                    } else {
+                        tranSettlementReport.setCustomer(contractManagementInfo.getSeller());
+                    }
+                }
+
+                String taskId = "";
+                // 只有待审核状态才有taskId
+                if (StringUtils.isNotBlank(tranSettlementReport.getWorkflowId())&&StringUtils.isNotBlank(tranSettlementReport.getBatchId())) {
+
+                    JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(tranSettlementReport.getWorkflowId()), tranSettlementReport.getBatchId());
+                    taskId = jsonObject.getString("taskId");
+                    tranSettlementReport.setTaskId(taskId);
+                }
+            }
+
+        }
         return tranSettlementReports;
     }
 

+ 16 - 7
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/workflow/TranSettlementReportListener.java

@@ -32,11 +32,13 @@ public class TranSettlementReportListener extends AbstractWorkflowTaskListener {
         if (batchReviewInfo == null) {
             return;
         }
+        int flag = 0;
         if (processIsEnd) {
             batchReviewInfo.setStatusFlag(StatusEnum.ORDER_PASSED.getFlag());
             batchReviewInfo.setStatus(StatusEnum.ORDER_PASSED.getName());
             batchReviewInfo.setWorkflowId(null);
             batchReviewInfo.setApproveStatus(null);
+            flag =1;
         } else {
             batchReviewInfo.setApproveStatus(status);
         }
@@ -45,16 +47,23 @@ public class TranSettlementReportListener extends AbstractWorkflowTaskListener {
         //  更新详细状态
 //        batchReviewInfo = batchReviewInfoService.selectById(batchReviewInfo.getId());
         List<TranSettlementReport> tranSettlementReports = tranSettlementReportService.selectList(new EntityWrapper<TranSettlementReport>()
-                .eq("batch_id",batchReviewInfo.getId()));
+                .eq("batch_id",businessKey));
         if(!CollectionUtils.isEmpty(tranSettlementReports)){
             for(int i=0;i<tranSettlementReports.size();i++){
                 TranSettlementReport settlementReport = tranSettlementReports.get(i);
-                settlementReport.setWorkflowId(batchReviewInfo.getWorkflowId());
-                settlementReport.setStatus(batchReviewInfo.getStatus());
-                settlementReport.setApproveStatus(batchReviewInfo.getApproveStatus());
+                if(flag==1){
+                    settlementReport.setWorkflowId(null);
+                    settlementReport.setStatus(batchReviewInfo.getStatus());
+                    settlementReport.setApproveStatus(null);
+                }
+                else{
+                    settlementReport.setWorkflowId(batchReviewInfo.getWorkflowId());
+                    settlementReport.setStatus(batchReviewInfo.getStatus());
+                    settlementReport.setApproveStatus(batchReviewInfo.getApproveStatus());
+                }
 
             }
-            tranSettlementReportService.insertBatch(tranSettlementReports);
+            tranSettlementReportService.updateBatchById(tranSettlementReports);
 
         }
     }
@@ -73,7 +82,7 @@ public class TranSettlementReportListener extends AbstractWorkflowTaskListener {
         //  更新详细状态
 //        batchReviewInfo = batchReviewInfoService.selectById(batchReviewInfo.getId());
         List<TranSettlementReport> tranSettlementReports = tranSettlementReportService.selectList(new EntityWrapper<TranSettlementReport>()
-                .eq("batch_id",batchReviewInfo.getId()));
+                .eq("batch_id",businessKey));
         if(!CollectionUtils.isEmpty(tranSettlementReports)){
             for(int i=0;i<tranSettlementReports.size();i++){
                 TranSettlementReport settlementReport = tranSettlementReports.get(i);
@@ -82,7 +91,7 @@ public class TranSettlementReportListener extends AbstractWorkflowTaskListener {
                 settlementReport.setApproveStatus(batchReviewInfo.getApproveStatus());
 
             }
-            tranSettlementReportService.insertBatch(tranSettlementReports);
+            tranSettlementReportService.updateBatchById(tranSettlementReports);
 
         }
 

+ 3 - 2
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/TranSettlementReportMapper.xml

@@ -35,7 +35,7 @@
         <if test="businessKeys != null and businessKeys.size > 0">
             and(
             <foreach collection="businessKeys" item="businessValue" open="(" close=")" separator="or">
-                id = #{businessValue}
+                batch_id = #{businessValue}
             </foreach>
             )
         </if>
@@ -61,6 +61,7 @@
         box_no as boxNo,
         task_no as taskNo,
         ship_type as shipType,
+        batch_id as batchId,
         phone,
         name as name,
         tran_car_no as tranCarNo,
@@ -116,7 +117,7 @@
         <if test="businessKeys != null and businessKeys.size > 0">
             and(
             <foreach collection="businessKeys" item="businessValue" open="(" close=")" separator="or">
-                id = #{businessValue}
+                batch_id = #{businessValue}
             </foreach>
             )
         </if>