zhangyuewww 3 rokov pred
rodič
commit
ac2b474e26

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

@@ -185,93 +185,96 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
                     if (tranCarInfo.getLoadNetWeight() > 0) {
                         tranCarInfo.setStatusFlag(StatusEnum.LOADED.getFlag());
                         tranCarInfo.setStatus(StatusEnum.LOADED.getName());
-                        List<TranSettlementReport> tranSettlementReportList = tranSettlementReportService.selectList(new EntityWrapper<TranSettlementReport>()
-                                .eq("car_id", tranCarInfo.getId()));
-                        if (!CollectionUtils.isEmpty(tranSettlementReportList)) {
-                            if (tranCarInfo.getUnloadNetWeight() > 0) {
-                                for (TranSettlementReport tranSettlementReport : tranSettlementReportList) {
-                                    tranSettlementReport.setLoadingImg(tranCarInfo.getLoadPoundImg());
-                                    tranSettlementReport.setUnloadingWeight(tranCarInfo.getUnloadNetWeight());
-                                    tranSettlementReport.setUnloadingImg(tranCarInfo.getUnloadPoundImg());
-                                    //损耗
-                                    tranSettlementReport.setLossWeight(tranCarInfo.getLoadNetWeight() - tranCarInfo.getUnloadNetWeight());
-                                    //结算重量
-                                    if ("0".equals(tranSettlementReport.getManualFlag())) {
-                                        //卸车不为空时,结算重量=装卸取小
-                                        tranSettlementReport.setSettlementWeight(tranCarInfo.getLoadNetWeight() > tranCarInfo.getUnloadNetWeight() ? tranCarInfo.getUnloadNetWeight() : tranCarInfo.getLoadNetWeight());
+                        //汽运类型
+                        if (tranCarInfo.getTranType().equals(NumberConstant.CONSTANT1)) {
+                            List<TranSettlementReport> tranSettlementReportList = tranSettlementReportService.selectList(new EntityWrapper<TranSettlementReport>()
+                                    .eq("car_id", tranCarInfo.getId()));
+                            if (!CollectionUtils.isEmpty(tranSettlementReportList)) {
+                                if (tranCarInfo.getUnloadNetWeight() > 0) {
+                                    for (TranSettlementReport tranSettlementReport : tranSettlementReportList) {
+                                        tranSettlementReport.setLoadingImg(tranCarInfo.getLoadPoundImg());
+                                        tranSettlementReport.setUnloadingWeight(tranCarInfo.getUnloadNetWeight());
+                                        tranSettlementReport.setUnloadingImg(tranCarInfo.getUnloadPoundImg());
+                                        //损耗
+                                        tranSettlementReport.setLossWeight(tranCarInfo.getLoadNetWeight() - tranCarInfo.getUnloadNetWeight());
+                                        //结算重量
+                                        if ("0".equals(tranSettlementReport.getManualFlag())) {
+                                            //卸车不为空时,结算重量=装卸取小
+                                            tranSettlementReport.setSettlementWeight(tranCarInfo.getLoadNetWeight() > tranCarInfo.getUnloadNetWeight() ? tranCarInfo.getUnloadNetWeight() : tranCarInfo.getLoadNetWeight());
+                                        }
+                                        //扣款
+                                        if (tranSettlementReport.getLossWeight() <= (tranCarInfo.getLoadNetWeight() / 1000)) {
+                                            tranSettlementReport.setDeductionAmount("0");
+                                            //应付=单价x结算重量-扣款
+                                            tranSettlementReport.setAmountIngPayable(tranSettlementReport.getTransportPrice() * tranSettlementReport.getSettlementWeight());
+                                        } else {
+                                            tranSettlementReport.setDeductionAmount(String.format("%.2f", (Float.valueOf(tranCarInfo.getLoadNetWeight() - tranCarInfo.getUnloadNetWeight()) - (tranCarInfo.getLoadNetWeight() / 1000)) * Float.valueOf(tranCarInfo.getTranPrice())));
+                                            //应付=单价x结算重量-扣款
+                                            tranSettlementReport.setAmountIngPayable(tranSettlementReport.getTransportPrice() * tranSettlementReport.getSettlementWeight() - Float.valueOf(tranSettlementReport.getDeductionAmount()));
+                                        }
+                                        tranSettlementReportService.updateById(tranSettlementReport);
                                     }
-                                    //扣款
-                                    if (tranSettlementReport.getLossWeight() <= (tranCarInfo.getLoadNetWeight() / 1000)) {
-                                        tranSettlementReport.setDeductionAmount("0");
-                                        //应付=单价x结算重量-扣款
-                                        tranSettlementReport.setAmountIngPayable(tranSettlementReport.getTransportPrice() * tranSettlementReport.getSettlementWeight());
-                                    } else {
-                                        tranSettlementReport.setDeductionAmount(String.format("%.2f", (Float.valueOf(tranCarInfo.getLoadNetWeight() - tranCarInfo.getUnloadNetWeight()) - (tranCarInfo.getLoadNetWeight() / 1000)) * Float.valueOf(tranCarInfo.getTranPrice())));
-                                        //应付=单价x结算重量-扣款
-                                        tranSettlementReport.setAmountIngPayable(tranSettlementReport.getTransportPrice() * tranSettlementReport.getSettlementWeight() - Float.valueOf(tranSettlementReport.getDeductionAmount()));
-                                    }
-                                    tranSettlementReportService.updateById(tranSettlementReport);
                                 }
-                            }
-                        } else {
-                            //生成汽运报表
-                            TranSettlementReport tranSettlementReport = new TranSettlementReport();
-                            TranTaskInfo tranTaskInfo = tranTaskInfoService.selectById(tranProcessInfo.getInfoId());
-                            tranSettlementReport.setCompId(tranTaskInfo.getCompId());
-                            tranSettlementReport.setCarId(tranCarInfo.getId());
-                            tranSettlementReport.setId(IdGenerator.generateUUID());
-                            tranSettlementReport.setContractNo(tranTaskInfo.getContractNo());
-                            tranSettlementReport.setProcessNo(tranProcessInfo.getProcessNo());
-                            tranSettlementReport.setName(tranCarInfo.getDriver());
-                            tranSettlementReport.setPhone(tranCarInfo.getDriverPhone());
-                            tranSettlementReport.setCarNo(tranCarInfo.getCarNo());
-                            //查询账户信息
-                            List<DriverViewInfo> driverViewInfoList = driverViewInfoService.selectList(new EntityWrapper<DriverViewInfo>()
-                                    .eq("driver_name", tranCarInfo.getDriver())
-                                    .eq("delete_flag", "0"));
-                            if (!CollectionUtils.isEmpty(driverViewInfoList)) {
-                                for (DriverViewInfo driverViewInfo : driverViewInfoList) {
-                                    List<DriverPayeeInfo> driverPayeeInfoList = driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
-                                            .eq("driver_id", driverViewInfo.getId())
-                                            .eq("delete_flag", "0"));
-                                    if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
-                                        //本次收款账户
-                                        tranSettlementReport.setCardNo(driverPayeeInfoList.get(0).getBankCard());
+                            } else {
+                                //生成汽运报表
+                                TranSettlementReport tranSettlementReport = new TranSettlementReport();
+                                TranTaskInfo tranTaskInfo = tranTaskInfoService.selectById(tranProcessInfo.getInfoId());
+                                tranSettlementReport.setCompId(tranTaskInfo.getCompId());
+                                tranSettlementReport.setCarId(tranCarInfo.getId());
+                                tranSettlementReport.setId(IdGenerator.generateUUID());
+                                tranSettlementReport.setContractNo(tranTaskInfo.getContractNo());
+                                tranSettlementReport.setProcessNo(tranProcessInfo.getProcessNo());
+                                tranSettlementReport.setName(tranCarInfo.getDriver());
+                                tranSettlementReport.setPhone(tranCarInfo.getDriverPhone());
+                                tranSettlementReport.setCarNo(tranCarInfo.getCarNo());
+                                //查询账户信息
+                                List<DriverViewInfo> driverViewInfoList = driverViewInfoService.selectList(new EntityWrapper<DriverViewInfo>()
+                                        .eq("driver_name", tranCarInfo.getDriver())
+                                        .eq("delete_flag", "0"));
+                                if (!CollectionUtils.isEmpty(driverViewInfoList)) {
+                                    for (DriverViewInfo driverViewInfo : driverViewInfoList) {
+                                        List<DriverPayeeInfo> driverPayeeInfoList = driverPayeeInfoService.selectList(new EntityWrapper<DriverPayeeInfo>()
+                                                .eq("driver_id", driverViewInfo.getId())
+                                                .eq("delete_flag", "0"));
+                                        if (!CollectionUtils.isEmpty(driverPayeeInfoList)) {
+                                            //本次收款账户
+                                            tranSettlementReport.setCardNo(driverPayeeInfoList.get(0).getBankCard());
+                                        }
                                     }
                                 }
-                            }
-                            tranSettlementReport.setSettlementWeight(tranCarInfo.getLoadNetWeight());
-                            //应付
-                            tranSettlementReport.setAmountIngPayable(tranProcessInfo.getTranPrice() * tranSettlementReport.getSettlementWeight());
-                            tranSettlementReport.setTranCarNo(tranCarInfo.getTranCarNo());
-                            tranSettlementReport.setLoadingWeight(tranCarInfo.getLoadNetWeight());
-                            tranSettlementReport.setLoadingImg(tranCarInfo.getLoadPoundImg());
-                            tranSettlementReport.setTransportPrice(tranProcessInfo.getTranPrice());
-                            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);
+                                tranSettlementReport.setSettlementWeight(tranCarInfo.getLoadNetWeight());
+                                //应付
+                                tranSettlementReport.setAmountIngPayable(tranProcessInfo.getTranPrice() * tranSettlementReport.getSettlementWeight());
+                                tranSettlementReport.setTranCarNo(tranCarInfo.getTranCarNo());
+                                tranSettlementReport.setLoadingWeight(tranCarInfo.getLoadNetWeight());
+                                tranSettlementReport.setLoadingImg(tranCarInfo.getLoadPoundImg());
+                                tranSettlementReport.setTransportPrice(tranProcessInfo.getTranPrice());
+                                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 {
 
-                                    // 设置状态 已提交审核
-                                    tranSettlementReport.setWorkflowId(workflow.getId());
                                     tranSettlementReportService.updateById(tranSettlementReport);
-                                    workflowService.startInstance(workflow.getId(), tranSettlementReport.getId());
+                                    workflowService.activateInstance(tranSettlementReport.getWorkflowId(), tranSettlementReport.getId());
                                 }
                             }
-                            // 退回的单子 再启用
-                            else {
-
-                                tranSettlementReportService.updateById(tranSettlementReport);
-                                workflowService.activateInstance(tranSettlementReport.getWorkflowId(), tranSettlementReport.getId());
-                            }
                         }
                     }
                     //卸车反馈时状态改为已送达