zhangyuewww 1 year ago
parent
commit
3f6b369ae7

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

@@ -1088,6 +1088,13 @@ public class ContractManagementInfoServiceImpl extends ServiceImpl<ContractManag
         List<ContractManagementInfo> dataList = baseMapper.getListByCondition(pageView);
         if (!CollectionUtils.isEmpty(dataList)) {
             for (ContractManagementInfo contractManagementInfo1 : dataList) {
+                String taskId = "";
+                // 只有待审核状态才有taskId
+                if (StringUtils.isNotBlank(contractManagementInfo1.getWorkflowId())) {
+                    JSONObject jsonObject = workflowService.getActiveTask(Lists.newArrayList(contractManagementInfo1.getWorkflowId()), contractManagementInfo1.getId());
+                    taskId = jsonObject.getString("taskId");
+                    contractManagementInfo1.setTaskId(taskId);
+                }
                 //现货自运采购合同
                 if ("1".equals(contractManagementInfo1.getGoodsType()) && "1".equals(contractManagementInfo1.getDeliverType()) && "2".equals(contractManagementInfo1.getContractType())) {
                     //定义出库量

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

@@ -345,6 +345,7 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
                                 tranSettlementReport.setId(IdGenerator.generateUUID());
                                 tranSettlementReport.setTranType("汽运");
                                 tranSettlementReport.setTranTypeKey("1");
+                                tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                                 tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
                                 tranSettlementReport.setContractNo(tranTaskInfo.getContractNo());
                                 ContractManagementInfo contractManagementInfo = contractManagementInfoService.selectOne(new EntityWrapper<ContractManagementInfo>()
@@ -509,67 +510,69 @@ public class TranProcessInfoServiceImpl extends ServiceImpl<TranProcessInfoMappe
                         TranSettlementReport tranSettlementReport1 = tranSettlementReportService.selectOne(new EntityWrapper<TranSettlementReport>()
                                     .eq("car_id", tranCarInfo.getId()));
                         if (tranSettlementReport1!=null) {
-                            if (tranCarInfo.getUnloadNetWeight() > 0&&tranProcessInfo.getFlag()!=null) {
-                                tranSettlementReport1.setLoadingImg(tranCarInfo.getLoadPoundImg());
-                                tranSettlementReport1.setUnloadingWeight(tranCarInfo.getUnloadNetWeight());
-                                tranSettlementReport1.setUnloadingImg(tranCarInfo.getUnloadPoundImg());
-                                //损耗
-                                tranSettlementReport1.setLossWeight(tranCarInfo.getLoadNetWeight() - tranCarInfo.getUnloadNetWeight());
-                                //汽运类型
-                                if (tranCarInfo.getTranType().equals(NumberConstant.CONSTANT1)) {
-                                    //结算重量
-                                    if ("0".equals(tranSettlementReport1.getManualFlag())) {
-                                        //卸车不为空时,结算重量=装卸取小
-                                        tranSettlementReport1.setSettlementWeight(tranCarInfo.getLoadNetWeight() > tranCarInfo.getUnloadNetWeight() ? tranCarInfo.getUnloadNetWeight() : tranCarInfo.getLoadNetWeight());
-                                        tranSettlementReport1.setTransportDamage(tranSettlementReport1.getSettlementWeight()*0.001);
-                                    }
-                                    if(tranSettlementReport1.getLossWeight()<0){
-                                        tranSettlementReport1.setActualLoss(0d);
-                                        tranSettlementReport1.setDeductionAmount(0d);
-                                    }
-                                    //损耗大于结算重量的1‰时
-                                    else if (tranSettlementReport1.getLossWeight()>tranSettlementReport1.getSettlementWeight()*0.001){
-                                        //货损=损耗-结算重量x1‰
-                                        tranSettlementReport1.setCargoDamage(tranSettlementReport1.getLossWeight()-tranSettlementReport1.getSettlementWeight()*0.001);
-                                        //实际损耗默认为结算重量的1‰
-                                        tranSettlementReport1.setActualLoss(tranSettlementReport1.getSettlementWeight()*0.001);
-                                        if (tranSettlementReport1.getGrainPrice()!=null){
-                                            tranSettlementReport1.setDeductionAmount(tranSettlementReport1.getCargoDamage()*tranSettlementReport1.getGrainPrice());
+                            //已卸车过的不重复更新
+                            if (tranSettlementReport1.getUnloadingWeight()==null) {
+                                if (tranCarInfo.getUnloadNetWeight() > 0 && tranProcessInfo.getFlag() != null) {
+                                    tranSettlementReport1.setLoadingImg(tranCarInfo.getLoadPoundImg());
+                                    tranSettlementReport1.setUnloadingWeight(tranCarInfo.getUnloadNetWeight());
+                                    tranSettlementReport1.setUnloadingImg(tranCarInfo.getUnloadPoundImg());
+                                    //损耗
+                                    tranSettlementReport1.setLossWeight(tranCarInfo.getLoadNetWeight() - tranCarInfo.getUnloadNetWeight());
+                                    //汽运类型
+                                    if (tranCarInfo.getTranType().equals(NumberConstant.CONSTANT1)) {
+                                        //结算重量
+                                        if ("0".equals(tranSettlementReport1.getManualFlag())) {
+                                            //卸车不为空时,结算重量=装卸取小
+                                            tranSettlementReport1.setSettlementWeight(tranCarInfo.getLoadNetWeight() > tranCarInfo.getUnloadNetWeight() ? tranCarInfo.getUnloadNetWeight() : tranCarInfo.getLoadNetWeight());
+                                            tranSettlementReport1.setTransportDamage(tranSettlementReport1.getSettlementWeight() * 0.001);
                                         }
-                                        else{
+                                        if (tranSettlementReport1.getLossWeight() < 0) {
+                                            tranSettlementReport1.setActualLoss(0d);
                                             tranSettlementReport1.setDeductionAmount(0d);
                                         }
+                                        //损耗大于结算重量的1‰时
+                                        else if (tranSettlementReport1.getLossWeight() > tranSettlementReport1.getSettlementWeight() * 0.001) {
+                                            //货损=损耗-结算重量x1‰
+                                            tranSettlementReport1.setCargoDamage(tranSettlementReport1.getLossWeight() - tranSettlementReport1.getSettlementWeight() * 0.001);
+                                            //实际损耗默认为结算重量的1‰
+                                            tranSettlementReport1.setActualLoss(tranSettlementReport1.getSettlementWeight() * 0.001);
+                                            if (tranSettlementReport1.getGrainPrice() != null) {
+                                                tranSettlementReport1.setDeductionAmount(tranSettlementReport1.getCargoDamage() * tranSettlementReport1.getGrainPrice());
+                                            } else {
+                                                tranSettlementReport1.setDeductionAmount(0d);
+                                            }
+                                        }
+                                        //0<损耗<结算重量的1‰时
+                                        else if (tranSettlementReport1.getLossWeight() > 0 && tranSettlementReport1.getLossWeight() < tranSettlementReport1.getSettlementWeight() * 0.001) {
+                                            //实际损耗默认为损耗
+                                            tranSettlementReport1.setActualLoss(Double.valueOf(String.valueOf(tranSettlementReport1.getLossWeight())));
+                                            tranSettlementReport1.setDeductionAmount(0d);
+                                        }
+                                        //扣款
+                                        if (tranSettlementReport1.getLossWeight() <= (tranCarInfo.getLoadNetWeight() / 1000)) {
+                                            //应付=单价x结算重量-扣款
+                                            tranSettlementReport1.setAmountIngPayable(tranSettlementReport1.getTransportPrice() * tranSettlementReport1.getSettlementWeight());
+                                            //实付金额
+                                            tranSettlementReport1.setAmountActuallyPaid(Double.valueOf(tranSettlementReport1.getTransportPrice()) * tranSettlementReport1.getSettlementWeight()
+                                                    - tranSettlementReport1.getServiceCharge());
+                                        } else {
+                                            //应付=单价x结算重量-扣款
+                                            tranSettlementReport1.setAmountIngPayable(tranSettlementReport1.getTransportPrice() * tranSettlementReport1.getSettlementWeight() - Float.valueOf(String.valueOf(tranSettlementReport1.getDeductionAmount())));
+                                            //实付金额
+                                            tranSettlementReport1.setAmountActuallyPaid(Double.valueOf(tranSettlementReport1.getTransportPrice()) * tranSettlementReport1.getSettlementWeight()
+                                                    - Double.valueOf(tranSettlementReport1.getDeductionAmount()) - tranSettlementReport1.getServiceCharge());
+                                        }
+                                        //税点
+                                        tranSettlementReport1.setTaxPoint(tranSettlementReport1.getAmountActuallyPaid() / 0.946 * 0.054);
+                                        //合计应付
+                                        tranSettlementReport1.setTotalPayable(tranSettlementReport1.getAmountActuallyPaid() + tranSettlementReport1.getTaxPoint());
+                                        //未付
+                                        tranSettlementReport1.setAmountNotPayable(Float.valueOf(String.valueOf(tranSettlementReport1.getTotalPayable())));
                                     }
-                                    //0<损耗<结算重量的1‰时
-                                    else if(tranSettlementReport1.getLossWeight()>0&&tranSettlementReport1.getLossWeight()<tranSettlementReport1.getSettlementWeight()*0.001){
-                                        //实际损耗默认为损耗
-                                        tranSettlementReport1.setActualLoss(Double.valueOf(String.valueOf(tranSettlementReport1.getLossWeight())));
-                                        tranSettlementReport1.setDeductionAmount(0d);
-                                    }
-                                    //扣款
-                                    if (tranSettlementReport1.getLossWeight() <= (tranCarInfo.getLoadNetWeight() / 1000)) {
-                                        //应付=单价x结算重量-扣款
-                                        tranSettlementReport1.setAmountIngPayable(tranSettlementReport1.getTransportPrice() * tranSettlementReport1.getSettlementWeight());
-                                        //实付金额
-                                        tranSettlementReport1.setAmountActuallyPaid(Double.valueOf(tranSettlementReport1.getTransportPrice()) * tranSettlementReport1.getSettlementWeight()
-                                                - tranSettlementReport1.getServiceCharge());
-                                    } else {
-                                        //应付=单价x结算重量-扣款
-                                        tranSettlementReport1.setAmountIngPayable(tranSettlementReport1.getTransportPrice() * tranSettlementReport1.getSettlementWeight() - Float.valueOf(String.valueOf(tranSettlementReport1.getDeductionAmount())));
-                                        //实付金额
-                                        tranSettlementReport1.setAmountActuallyPaid(Double.valueOf(tranSettlementReport1.getTransportPrice()) * tranSettlementReport1.getSettlementWeight()
-                                                - Double.valueOf(tranSettlementReport1.getDeductionAmount()) - tranSettlementReport1.getServiceCharge());
-                                    }
-                                    //税点
-                                    tranSettlementReport1.setTaxPoint(tranSettlementReport1.getAmountActuallyPaid()/0.946*0.054);
-                                    //合计应付
-                                    tranSettlementReport1.setTotalPayable(tranSettlementReport1.getAmountActuallyPaid()+tranSettlementReport1.getTaxPoint());
-                                    //未付
-                                    tranSettlementReport1.setAmountNotPayable(Float.valueOf(String.valueOf(tranSettlementReport1.getTotalPayable())));
-                                }
-                                tranSettlementReportService.updateById(tranSettlementReport1);
+                                    tranSettlementReportService.updateById(tranSettlementReport1);
                                 }
                             }
+                        }
                         else {
                             TranSettlementReport tranSettlementReport=new TranSettlementReport();
                             //生成汽运报表

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

@@ -1529,6 +1529,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                                         tranSettlementReport.setTranType("汽运");
                                         tranSettlementReport.setTranTypeKey("1");
                                         tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
+                                        tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                                         tranSettlementReport.setSettlementWeight(Float.valueOf(String.valueOf(warehouseInOutInfo.getNetWeight())));
                                         tranSettlementReport.setServiceCharge(20d);
                                         //运输单价不为空
@@ -1729,6 +1730,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                                 if (tranCarInfo!=null){
                                     TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranCarInfo.getInfoId());
                                     tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
+                                    tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                                 }
                                 //运输单价不为空
                                 if (tranCarInfo!=null&&tranCarInfo.getTranPrice()!=null){
@@ -2281,6 +2283,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                             if (tranCarInfo!=null){
                                 TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranCarInfo.getInfoId());
                                 tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
+                                tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                             }
                             //运输单价不为空
                             if (tranCarInfo!=null&&tranCarInfo.getTranPrice()!=null){
@@ -4518,6 +4521,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                                     tranSettlementReport.setId(IdGenerator.generateUUID());
                                     if ("汽运".equals(warehouseInOutInfo.getOutType())) {
                                         tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
+                                        tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                                         tranSettlementReport.setGrainPrice(contractManagementInfo1.getUnitContractPrice());
                                         tranSettlementReport.setTranType("汽运");
                                         tranSettlementReport.setTranTypeKey("1");
@@ -4744,6 +4748,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                                 if (tranCarInfo!=null){
                                     TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranCarInfo.getInfoId());
                                     tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
+                                    tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                                 }
                                 //运输单价不为空
                                 if (tranCarInfo!=null&&tranCarInfo.getTranPrice()!=null){
@@ -5370,6 +5375,7 @@ public class WarehouseInOutInfoServiceImpl extends ServiceImpl<WarehouseInOutInf
                             if (tranCarInfo!=null){
                                 TranTaskInfo tranTaskInfo=tranTaskInfoService.selectById(tranCarInfo.getInfoId());
                                 tranSettlementReport.setTaskNo(tranTaskInfo.getTaskNo());
+                                tranSettlementReport.setStartAddress(tranTaskInfo.getSendWarehouse());
                             }
                             //运输单价不为空
                             if (tranCarInfo!=null&&tranCarInfo.getTranPrice()!=null){

+ 9 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/workflow/ExepenseYunListener.java

@@ -63,6 +63,15 @@ public class ExepenseYunListener extends AbstractWorkflowTaskListener {
         expenseInfo.setStatusFlag(StatusEnum.PURCHASE_FAILED.getFlag());
         expenseInfo.setStatus(StatusEnum.PURCHASE_FAILED.getName());
         expenseInfo.setApproveStatus(null);
+        List<TranSettlementReport> tranSettlementReports = tranSettlementReportService.selectList(new EntityWrapper<TranSettlementReport>()
+                .eq("expense_id", expenseInfo.getId()));
+        if (!CollectionUtils.isEmpty(tranSettlementReports)) {
+            for (TranSettlementReport tranSettlementReport:tranSettlementReports){
+                tranSettlementReport.setStatusFlag(StatusEnum.ORDER_REJECTED.getFlag());
+                tranSettlementReport.setStatus(StatusEnum.ORDER_REJECTED.getName());
+                tranSettlementReportService.updateById(tranSettlementReport);
+            }
+        }
         expenseInfoService.updateAllColumnById(expenseInfo);
 //        auditHistoryService.delete(new EntityWrapper<AuditHistory>()
 //                .eq("business_id",businessKey));