From a3f9ec0bff3b0fd1021745f407b9f1e6e7d274f0 Mon Sep 17 00:00:00 2001 From: aike <17730485278@139.com> Date: Fri, 12 Sep 2025 15:22:28 +0800 Subject: [PATCH] =?UTF-8?q?demand:=20=20TMS=E7=B3=BB=E7=BB=9F=20-=20?= =?UTF-8?q?=E7=BD=91=E7=82=B9=E8=B4=B9=E7=94=A8=E7=94=B3=E8=AF=B7=20-=20?= =?UTF-8?q?=E8=B4=B9=E7=94=A8=E5=8F=91=E7=94=9F=E5=8F=98=E5=8C=96=E6=97=B6?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E4=BB=8E=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=90=8D=E7=A7=B0=EF=BC=8C=E4=B8=94=E5=91=8A?= =?UTF-8?q?=E7=9F=A5=E8=B4=B9=E7=94=A8=E5=8F=98=E5=8C=96=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit committer: heyu --- .../EmisWaybillAjustApplyServiceImpl.java | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 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 6efc9671f..5e5fc31ed 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 @@ -62,7 +62,6 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements @Autowired private SysPostMapper postMapper; - @Autowired private IEmisSettleSubBillService emisSettleSubBillService; @@ -584,19 +583,44 @@ public class EmisWaybillAjustApplyServiceImpl extends EmisBaseService implements } } - // 5. 查询去重后的emp_name对应的emp_code + // 5. 查询去重后的emp_name对应的emp_code,并构建empCode->empName映射,避免后续重复查询 Set notifyEmpCodes = new HashSet<>(); - for (String empName : empNames) { - List empCodes = getEmpCodesByEmpName(empName); - notifyEmpCodes.addAll(empCodes); + java.util.Map empCodeToName = new java.util.HashMap<>(); + for (String name : empNames) { + SysUser cond = new SysUser(); + cond.setEmpName(name); + List users = sysUserMapper.selectUserList(cond); + if (!CollectionUtils.isEmpty(users)) { + for (SysUser u : users) { + if (u != null && !StringUtils.isEmpty(u.getEmpCode())) { + notifyEmpCodes.add(u.getEmpCode()); + if (!StringUtils.isEmpty(u.getEmpName())) { + empCodeToName.put(u.getEmpCode(), u.getEmpName()); + } + } + } + } } - // 6. 分别调用sendNoticeToEmpUser发送通知 + // 6. 循环外预先计算申请人姓名与费用变更字符串,减少重复计算 + SysUser applyUser = getEmisStaffByCode(emisWaybillAjustApply.getApplyManCode()); + String applyManName = (applyUser != null && !StringUtils.isEmpty(applyUser.getEmpName())) + ? applyUser.getEmpName() + : emisWaybillAjustApply.getApplyManCode(); + BigDecimal oldFreight = emisWaybillOld != null ? emisWaybillOld.getFreight() : null; + BigDecimal newFreight = emisWaybillSave != null ? emisWaybillSave.getFreight() : null; + String oldFreightStr = oldFreight == null ? "-" : oldFreight.stripTrailingZeros().toPlainString(); + String newFreightStr = newFreight == null ? "-" : newFreight.stripTrailingZeros().toPlainString(); + + // 7. 分别调用sendNoticeToEmpUser发送通知 if (!notifyEmpCodes.isEmpty()) { for (String empCode : notifyEmpCodes) { if (!StringUtils.isEmpty(empCode)) { - String title = emisWaybillAjustApply.getApplyManCode() + "已对运单费用进行调整," + "请" + empCode + "仔细核对," - + "单号【" + emisWaybillAjustApply.getBillCode() + "】"; + String empName = !StringUtils.isEmpty(empCodeToName.get(empCode)) ? empCodeToName.get(empCode) + : empCode; + String title = applyManName + "已对运单费用进行调整," + "请" + empName + "仔细核对," + + "单号【" + emisWaybillAjustApply.getBillCode() + "】" + ",运费由" + oldFreightStr + "调整为" + + newFreightStr; sendNoticeToEmpUser(empCode, title, "", clickPath); }