From 3b35c592bfa4cb429e8fe6c956fc9c9d80854928 Mon Sep 17 00:00:00 2001 From: linfso Date: Wed, 18 Jun 2025 15:04:33 +0800 Subject: [PATCH] md --- .../EmisWaybillAjustApplyServiceImpl.java | 198 +++++++++--------- 1 file changed, 100 insertions(+), 98 deletions(-) diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillAjustApplyServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillAjustApplyServiceImpl.java index f75d34fb4..808fd3d2d 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillAjustApplyServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisWaybillAjustApplyServiceImpl.java @@ -209,6 +209,8 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements throw new EmisBizError(EmisBizErrorType.FAIL,"已审核!"); } + + emisWaybillAjustApply.setBlDestConfirmed("1"); emisWaybillAjustApply.setDestConfirmManCode(getCurrentUser().getEmpCode()); @@ -242,6 +244,8 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements @Override public int auditCenterPass(EmisWaybillAjustApply emisWaybillAjustApply) throws EmisBizError { + boolean isDZZS=false; + // 重新从数据库取信息 emisWaybillAjustApply = emisWaybillAjustApplyMapper.selectEmisWaybillAjustApplyById(emisWaybillAjustApply.getId()); @@ -252,56 +256,72 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements emisWaybillAjustApply.setBlCenterConfirmed("1"); emisWaybillAjustApply.setCenterConfirmManCode(getCurrentUser().getEmpCode()); - - - // 获取账单状态,若账单处于非未确认状态,不允许审核 - List emisSettleSubBillList=getSettleSubBillListByBillCode(emisWaybillAjustApply.getBillCode()); - if(!CollectionUtils.isEmpty(emisSettleSubBillList)){ - - if(emisSettleSubBillList.size()>1){ - throw new EmisBizError(EmisBizErrorType.FAIL,"已拆子账单,不允许修改!"); + // 判断申请人是否是[单证专属]岗位 + SysUser opUser = getEmisStaffByCode(emisWaybillAjustApply.getApplyManCode()); + if (opUser != null) { + // 判断申请人是否是单证专属 + List postIds = postMapper.selectPostListByUserId(opUser.getUserId()); + if (!CollectionUtils.isEmpty(postIds)) { + for (Long poId : postIds) { + if (poId == 18) { + isDZZS = true; + break; + } + } } + } - for (EmisSettleSubBill emisSettleSubBill:emisSettleSubBillList) { - if("1".equals(emisSettleSubBill.getBlConfirmCenter())){ - throw new EmisBizError(EmisBizErrorType.FAIL,"财务已确认账单,不允许审核,请先取消财务确认!"); + // 非单证专属则判断 + if(!isDZZS) { + // 获取账单状态,若账单处于非未确认状态,不允许审核 + List emisSettleSubBillList = getSettleSubBillListByBillCode(emisWaybillAjustApply.getBillCode()); + if (!CollectionUtils.isEmpty(emisSettleSubBillList)) { + + if (emisSettleSubBillList.size() > 1) { + throw new EmisBizError(EmisBizErrorType.FAIL, "已拆子账单,不允许修改!"); } - // 如果已定制账单,并且新的销售联系人、回款联系人不一致,必须从定制账单中移除 - if("1".equals(emisSettleSubBill.getBlMerge())){ - // 判断是否调整销售联系人或回款联系人,如调整,需要先从账单里移除 - - String newDataStr=emisWaybillAjustApply.getJsonData(); - JSONObject jObj = JSONObject.parseObject(newDataStr); - JSONObject jobjOldValue=jObj.getJSONObject("oldValue"); - JSONObject jobjNewValue=jObj.getJSONObject("newValue"); - - String oldPaymentType = jobjOldValue.getString("paymentType"); - String oldCustNo = jobjOldValue.getString("custNo"); - String oldPayee=emisSettleSubBill.getPayee(); - String oldSalesmen=emisSettleSubBill.getSalesmen(); - - String newPaymentType = jobjNewValue.getString("paymentType"); - String newCustNo = jobjNewValue.getString("custNo"); - String newPayee=jobjNewValue.getString("payee"); - String newSalesmen=jobjNewValue.getString("salesmen"); - - if( !oldPayee.equals(newPayee) || !oldSalesmen.equals(newSalesmen) ){ - throw new EmisBizError(EmisBizErrorType.FAIL,"已定制账单,销售联系/回款联系人发生改变,请从原账单移除,单号:"+emisSettleSubBill.getBillNo()); + for (EmisSettleSubBill emisSettleSubBill : emisSettleSubBillList) { + if ("1".equals(emisSettleSubBill.getBlConfirmCenter())) { + throw new EmisBizError(EmisBizErrorType.FAIL, "财务已确认账单,不允许审核,请先取消财务确认!"); } - // bug: 1412 支付方式发生改变,需要从账单中移除 - if( !oldPaymentType.equals(newPaymentType)){ - throw new EmisBizError(EmisBizErrorType.FAIL,"已定制账单,支付方式发生改变,请从原账单移除,单号:"+emisSettleSubBill.getBillNo()); - } + // 如果已定制账单,并且新的销售联系人、回款联系人不一致,必须从定制账单中移除 + if ("1".equals(emisSettleSubBill.getBlMerge())) { + // 判断是否调整销售联系人或回款联系人,如调整,需要先从账单里移除 - // bug: 1412 月结客户发生改变,都需要从账单中移除 - if(!StringUtils.isEmpty(newCustNo)){ - if( !newCustNo.equals(oldCustNo)){ - throw new EmisBizError(EmisBizErrorType.FAIL,"已定制账单,月结客户发生改变,请从原账单移除,单号:"+emisSettleSubBill.getBillNo()); + String newDataStr = emisWaybillAjustApply.getJsonData(); + JSONObject jObj = JSONObject.parseObject(newDataStr); + JSONObject jobjOldValue = jObj.getJSONObject("oldValue"); + JSONObject jobjNewValue = jObj.getJSONObject("newValue"); + + String oldPaymentType = jobjOldValue.getString("paymentType"); + String oldCustNo = jobjOldValue.getString("custNo"); + String oldPayee = emisSettleSubBill.getPayee(); + String oldSalesmen = emisSettleSubBill.getSalesmen(); + + String newPaymentType = jobjNewValue.getString("paymentType"); + String newCustNo = jobjNewValue.getString("custNo"); + String newPayee = jobjNewValue.getString("payee"); + String newSalesmen = jobjNewValue.getString("salesmen"); + + if (!oldPayee.equals(newPayee) || !oldSalesmen.equals(newSalesmen)) { + throw new EmisBizError(EmisBizErrorType.FAIL, "已定制账单,销售联系/回款联系人发生改变,请从原账单移除,单号:" + emisSettleSubBill.getBillNo()); } - } + // bug: 1412 支付方式发生改变,需要从账单中移除 + if (!oldPaymentType.equals(newPaymentType)) { + throw new EmisBizError(EmisBizErrorType.FAIL, "已定制账单,支付方式发生改变,请从原账单移除,单号:" + emisSettleSubBill.getBillNo()); + } + + // bug: 1412 月结客户发生改变,都需要从账单中移除 + if (!StringUtils.isEmpty(newCustNo)) { + if (!newCustNo.equals(oldCustNo)) { + throw new EmisBizError(EmisBizErrorType.FAIL, "已定制账单,月结客户发生改变,请从原账单移除,单号:" + emisSettleSubBill.getBillNo()); + } + } + + } } } } @@ -342,77 +362,59 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements // 审核通过 emisWaybillAjustApplyMapper.auditCenterPass(emisWaybillAjustApply); - // 财务中心费用审核:数据部人员通过岗位登记的费用申请:修改项目“运费调整”,财务审批通过后数据直接修改不用再进行层层审核; + //bug:1610 财务中心费用审核:数据部人员通过岗位登记的费用申请:修改项目“运费调整”,财务审批通过后数据直接修改不用再进行层层审核; // 运费调整类型 if("9".equals(emisWaybillAjustApply.getApplyType())){ + // 若是单证专属则自动确认账单 + if(isDZZS) { + // 自动确认账单 + EmisSettleSubBill oldSubBill = emisBaseService.getSettleSubBillBySubBillNo(emisWaybillAjustApply.getBillCode()); + if (oldSubBill != null) { + // 触发业务自动确认 + EmisSettleSubBill updSubBillBySite = new EmisSettleSubBill(); + updSubBillBySite.setId(oldSubBill.getId()); + updSubBillBySite.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode()); + updSubBillBySite.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode()); + updSubBillBySite.setConfirmSiteNote("[单证专属]申请调整费用-自动确认"); + emisBaseService.confirmBillBySite(updSubBillBySite); - SysUser opUser=getEmisStaffByCode(emisWaybillAjustApply.getApplyManCode()); - if(opUser!=null){ - // 判断申请人是否是单证专属 - boolean isDZZS=false; - List postIds=postMapper.selectPostListByUserId(opUser.getUserId()); - if(!CollectionUtils.isEmpty(postIds)){ - for(Long poId:postIds){ - if(poId==18){ - isDZZS=true; - break; - } - } - } + // 触发财务自动确认 + EmisSettleSubBill updSubBillByCenter = new EmisSettleSubBill(); + updSubBillByCenter.setConfirmCenterManCode(getCurrentUser().getEmpCode()); + updSubBillByCenter.setConfirmCenterCode(getCurrentUser().getOwnerSiteCode()); + updSubBillByCenter.setConfirmCenterNote("[单证专属]申请调整费用-自动确认"); + updSubBillByCenter.setId(oldSubBill.getId()); - // 若是单证专属则自动确认账单 - if(isDZZS) { - // 自动确认账单 - EmisSettleSubBill oldSubBill = emisBaseService.getSettleSubBillBySubBillNo(emisWaybillAjustApply.getBillCode()); - if (oldSubBill != null) { - // 触发业务自动确认 - EmisSettleSubBill updSubBillBySite = new EmisSettleSubBill(); - updSubBillBySite.setId(oldSubBill.getId()); - updSubBillBySite.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode()); - updSubBillBySite.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode()); - updSubBillBySite.setConfirmSiteNote("[单证专属]申请调整费用-自动确认"); - emisBaseService.confirmBillBySite(updSubBillBySite); + emisBaseService.confirmBillByCenter(updSubBillByCenter); - // 触发财务自动确认 - EmisSettleSubBill updSubBillByCenter = new EmisSettleSubBill(); - updSubBillByCenter.setConfirmCenterManCode(getCurrentUser().getEmpCode()); - updSubBillByCenter.setConfirmCenterCode(getCurrentUser().getOwnerSiteCode()); - updSubBillByCenter.setConfirmCenterNote("[单证专属]申请调整费用-自动确认"); - updSubBillByCenter.setId(oldSubBill.getId()); + // 判断账单是否已经被合并,若被合并则需要重新计算费用 + // 重新计算总账单费用 + // 获取账单是否已经被合并,若合并则更新账单费用 + if (!StringUtils.isEmpty(oldSubBill.getSettleBillNo())) { + EmisSettleBill oldSettleBill = emisSettleBillService.selectEmisSettleBillBySettleBillNo(oldSubBill.getSettleBillNo()); + if (oldSettleBill != null) { + // 触发业务账单自动确认 + EmisSettleBill emisSettleBill = new EmisSettleBill(); + emisSettleBill.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode()); + emisSettleBill.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode()); + emisSettleBill.setBlConfirmSite("1"); + emisSettleBill.setConfirmSiteDate(new Date()); + emisSettleBill.setId(oldSettleBill.getId()); + emisSettleBill.setConfirmSiteNote("[单证专属]申请调整费用-自动确认"); + emisSettleBillService.updateEmisSettleBill(emisSettleBill); - emisBaseService.confirmBillByCenter(updSubBillByCenter); + // 重新计算账单费用,计算开票状态,计算收款状态 + emisSettleBillService.reCalcSettleBillFee(oldSettleBill); - // 判断账单是否已经被合并,若被合并则需要重新计算费用 - // 重新计算总账单费用 - // 获取账单是否已经被合并,若合并则更新账单费用 - if (!StringUtils.isEmpty(oldSubBill.getSettleBillNo())) { - EmisSettleBill oldSettleBill = emisSettleBillService.selectEmisSettleBillBySettleBillNo(oldSubBill.getSettleBillNo()); - if (oldSettleBill != null) { - // 触发业务账单自动确认 - EmisSettleBill emisSettleBill = new EmisSettleBill(); - emisSettleBill.setConfirmSiteManCode(emisWaybillAjustApply.getApplyManCode()); - emisSettleBill.setConfirmSiteCode(emisWaybillAjustApply.getApplySiteCode()); - emisSettleBill.setBlConfirmSite("1"); - emisSettleBill.setConfirmSiteDate(new Date()); - emisSettleBill.setId(oldSettleBill.getId()); - emisSettleBill.setConfirmSiteNote("[单证专属]申请调整费用-自动确认"); - emisSettleBillService.updateEmisSettleBill(emisSettleBill); + emisSettleBillService.reCalcSettleBillInvoiceStatus(oldSubBill.getSettleBillNo()); - // 重新计算账单费用,计算开票状态,计算收款状态 - emisSettleBillService.reCalcSettleBillFee(oldSettleBill); - - emisSettleBillService.reCalcSettleBillInvoiceStatus(oldSubBill.getSettleBillNo()); - - emisSettleBillService.reCalcSettleBillPayStatus(oldSubBill.getSettleBillNo()); - } + emisSettleBillService.reCalcSettleBillPayStatus(oldSubBill.getSettleBillNo()); } } } } - } - return 1; }