Browse Source

Merge branch 'master' of http://47.100.3.209:3000/gdc/yiliangyiyun

ccjgmwz 3 years ago
parent
commit
9dc2ecf111

+ 57 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehouseInOutInfoServiceImpl.java

@@ -101,6 +101,8 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
     @Autowired
     private ITranProcessInfoService tranProcessInfoService;
     @Autowired
+    private ITranSettlementReportService tranSettlementReportService;
+    @Autowired
     private WebSocket webSocket;
 
     /**
@@ -1425,6 +1427,61 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                             }
                         }
                     }
+                    //运费大于0生成运费结算报表数据
+                    if (warehouseInOutInfo.getFreight()!=null&&warehouseInOutInfo.getFreight()>0){
+                        //生成汽运报表
+                        TranSettlementReport tranSettlementReport = new TranSettlementReport();
+                        tranSettlementReport.setCompId(warehouseBaseInfo.getCompId());
+                        tranSettlementReport.setCarId(warehouseInOutInfo.getCarId());
+                        tranSettlementReport.setId(IdGenerator.generateUUID());
+                        if ("汽运".equals(warehouseInOutInfo.getOutType())){
+                            tranSettlementReport.setTranType("汽运");
+                            tranSettlementReport.setTranTypeKey("1");
+                        }
+                        else if ("火运".equals(warehouseInOutInfo.getOutType())){
+                            tranSettlementReport.setTranType("火运");
+                            tranSettlementReport.setTranTypeKey("2");
+                        }
+                        else {
+                            tranSettlementReport.setTranType("船运");
+                            tranSettlementReport.setTranTypeKey("3");
+                        }
+                        tranSettlementReport.setContractNo(warehouseInOutInfo.getContractNo());
+                        tranSettlementReport.setCarNo(warehouseInOutInfo.getCarNo());
+                        tranSettlementReport.setSettlementWeight(Float.valueOf(String.valueOf(warehouseInOutInfo.getNetWeight())));
+                        //应付
+                        tranSettlementReport.setAmountIngPayable(Float.valueOf(warehouseInOutInfo.getFreight()) * tranSettlementReport.getSettlementWeight());
+                        //未付
+                        tranSettlementReport.setAmountNotPayable(Float.valueOf(warehouseInOutInfo.getFreight()) * tranSettlementReport.getSettlementWeight());
+                        tranSettlementReport.setLoadingWeight(Float.valueOf(String.valueOf(warehouseInOutInfo.getNetWeight())));
+                        tranSettlementReport.setLoadingImg(warehouseInOutInfo.getAddressUrl());
+                        tranSettlementReport.setTransportPrice(Float.valueOf(warehouseInOutInfo.getFreight()));
+                        tranSettlementReportService.insert(tranSettlementReport);
+                        boolean isStartWorkflow = org.apache.commons.lang3.StringUtils.isBlank(tranSettlementReport.getWorkflowId());
+                        // 不是退回的单子
+                        if (isStartWorkflow) {
+                            Workflow workflow = workflowService
+                                    .findLatestWorkflowByBusinessCodeByApp(tranSettlementReport.getCompId(), "TRANSPORTATION-SETTLEMENT-REPORT");
+                            // 没配置审核流程,直接结束并处理信息
+                            if (workflow == null) {
+                                throw new YException(YExceptionEnum.PURCHASE_ORDER_ERROR);
+                            }
+                            // 开启审核流
+                            else {
+
+                                // 设置状态 已提交审核
+                                tranSettlementReport.setWorkflowId(workflow.getId());
+                                tranSettlementReportService.updateById(tranSettlementReport);
+                                workflowService.startInstance(workflow.getId(), tranSettlementReport.getId());
+                            }
+                        }
+                        // 退回的单子 再启用
+                        else {
+
+                            tranSettlementReportService.updateById(tranSettlementReport);
+                            workflowService.activateInstance(tranSettlementReport.getWorkflowId(), tranSettlementReport.getId());
+                        }
+                    }
                     TranCarInfo tranCarInfo = tranCarInfoService.selectById(warehouseInOutInfo.getCarId());
                     if (tranCarInfo != null) {
                         //将发货数据同步到派车表