|
|
|
@ -492,10 +492,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
data.getCmcInvoice()+"】<span style='color:red'>订单取消</span>" + "</div>"; |
|
|
|
String textHead = data.getCmcInvoice()+"【发票:"+ data.getCmcInvoice()+"】订单取消"; |
|
|
|
String[] mailAddress = coDelMapper.queryUsersByRoleName("关务仓库",data.getSite()).stream().map(SysUserEntity::getEmail).toArray(String[]::new); |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(data.getCreateBy()); |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
new String[]{creator.getEmail()} : new String[]{}; |
|
|
|
String[] mailAddressAll = ArrayUtils.addAll(mailAddress, mailAddress2); |
|
|
|
if (mailAddressAll.length>0) { |
|
|
|
@ -516,10 +516,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
data.getCmcInvoice()+"】<span style='color:green'>取消废弃,恢复正常</span>" + "</div>"; |
|
|
|
String textHead = data.getCmcInvoice()+"【发票:"+ data.getCmcInvoice()+"】取消废弃"; |
|
|
|
String[] mailAddress = coDelMapper.queryUsersByRoleName("关务仓库",data.getSite()).stream().map(SysUserEntity::getEmail).toArray(String[]::new); |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(data.getCreateBy()); |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
new String[]{creator.getEmail()} : new String[]{}; |
|
|
|
String[] mailAddressAll = ArrayUtils.addAll(mailAddress, mailAddress2); |
|
|
|
if (mailAddressAll.length>0) { |
|
|
|
@ -634,15 +634,15 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
boolean qtyChanged = ecssCoDelNotifyDetail.get(0).getQty().compareTo(data.getQty()) != 0; |
|
|
|
// 判断PN是否变化 |
|
|
|
boolean pnChanged = !ecssCoDelNotifyDetail.get(0).getPn().equals(data.getPn()); |
|
|
|
|
|
|
|
|
|
|
|
if (qtyChanged || pnChanged) { |
|
|
|
data.setModifyFlag(true); |
|
|
|
|
|
|
|
|
|
|
|
// 只有数量变化时才设置 modifyQtyFlag=true |
|
|
|
if (qtyChanged) { |
|
|
|
data.setModifyQtyFlag(true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 取消订单 通知仓库和单证人员 |
|
|
|
//设置邮件内容 |
|
|
|
String text = "<!DOCTYPE>" + "<div>发货通知单" +data.getDelNo()+"【发票:"+ data.getCmcInvoice()+"】改单" + "</div>"+ |
|
|
|
@ -651,10 +651,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
+" 变更后数量:<span style='color:red'>"+data.getQty()+"</span></div>"; |
|
|
|
String textHead = data.getDelNo()+"【发票:"+ data.getCmcInvoice()+"】改单[发货数量变更]"; |
|
|
|
String[] mailAddress = coDelMapper.queryUsersByRoleName("关务仓库",data.getSite()).stream().map(SysUserEntity::getEmail).toArray(String[]::new); |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(checkHeader.get(0).getCreateBy()); |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
new String[]{creator.getEmail()} : new String[]{}; |
|
|
|
String[] mailAddressAll = ArrayUtils.addAll(mailAddress, mailAddress2); |
|
|
|
if (mailAddressAll.length>0) { |
|
|
|
@ -678,10 +678,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
"</span><span style='color:red'> 新增发货</span></div>"; |
|
|
|
String textHead = data.getDelNo()+"【发票:"+ data.getCmcInvoice()+"】改单[新增发货]"; |
|
|
|
String[] mailAddress = coDelMapper.queryUsersByRoleName("关务仓库",data.getSite()).stream().map(SysUserEntity::getEmail).toArray(String[]::new); |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(checkHeader.get(0).getCreateBy()); |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
new String[]{creator.getEmail()} : new String[]{}; |
|
|
|
String[] mailAddressAll = ArrayUtils.addAll(mailAddress, mailAddress2); |
|
|
|
if (mailAddressAll.length>0) { |
|
|
|
@ -719,10 +719,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
"</span><span style='color:red'> 取消发货</span></div>"; |
|
|
|
String textHead = data.getDelNo()+"【发票:"+ data.getCmcInvoice()+"】改单[取消发货]"; |
|
|
|
String[] mailAddress = coDelMapper.queryUsersByRoleName("关务仓库",data.getSite()).stream().map(SysUserEntity::getEmail).toArray(String[]::new); |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(checkHeader.get(0).getCreateBy()); |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
new String[]{creator.getEmail()} : new String[]{}; |
|
|
|
String[] mailAddressAll = ArrayUtils.addAll(mailAddress, mailAddress2); |
|
|
|
if (mailAddressAll.length>0) { |
|
|
|
@ -745,7 +745,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
//设置邮件内容 |
|
|
|
String text = "<!DOCTYPE>" + "<div>发货通知单" +data.getDelNo()+"【发票:"+ data.getCmcInvoice()+"】仓库已确认" + "</div>"; |
|
|
|
String textHead = "发货通知单"+data.getDelNo()+"【发票:"+ data.getCmcInvoice()+"】仓库已确认"; |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(checkHeader.get(0).getCreateBy()); |
|
|
|
if (creator != null && creator.getEmail() != null && !creator.getEmail().trim().isEmpty()) { |
|
|
|
@ -808,23 +808,23 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
|
|
|
|
// 先删除全部明细,再新建明细 |
|
|
|
coDelMapper.deleteAllEcssDelDetail(headerData); |
|
|
|
|
|
|
|
|
|
|
|
// 构建原数据Map,使用itemNo作为唯一标识 |
|
|
|
// 注意:不能用pn作为key,因为同一个pn可能有多行记录,每行都需要独立比较 |
|
|
|
Map<Integer, EcssCoDelNotifyDetailData> originalDataMap = dbData.stream() |
|
|
|
.collect(Collectors.toMap(EcssCoDelNotifyDetail::getItemNo, detail -> detail, (v1, v2) -> v1)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < excelList.size(); i++) { |
|
|
|
excelList.get(i).setDelNo(headerData.getDelNo()); |
|
|
|
excelList.get(i).setItemNo(i + 1); |
|
|
|
excelList.get(i).setModifyFlag(true); |
|
|
|
|
|
|
|
|
|
|
|
// 判断数量是否变化:按itemNo匹配原数据,比较同一行的数量是否变化 |
|
|
|
Integer itemNo = i + 1; |
|
|
|
EcssCoDelNotifyDetailData originalDetail = originalDataMap.get(itemNo); |
|
|
|
|
|
|
|
|
|
|
|
// 如果原数据中不存在该itemNo(新增行),或者pn不同(换料),或者数量不同,则标记modifyQtyFlag=true |
|
|
|
if (originalDetail == null || |
|
|
|
if (originalDetail == null || |
|
|
|
!originalDetail.getPn().equals(excelList.get(i).getPn()) || |
|
|
|
!originalDetail.getQty().equals(excelList.get(i).getQty())) { |
|
|
|
excelList.get(i).setModifyQtyFlag(true); |
|
|
|
@ -841,12 +841,12 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
|
|
|
|
String textHead = headerData.getDelNo()+"【发票:"+ headerData.getCmcInvoice()+"】改单"; |
|
|
|
String[] mailAddress = coDelMapper.queryUsersByRoleName("关务仓库",headerData.getSite()).stream().map(SysUserEntity::getEmail).toArray(String[]::new); |
|
|
|
|
|
|
|
|
|
|
|
// 安全获取创建人邮箱,防止用户不存在或邮箱为空的空指针异常 |
|
|
|
SysUserEntity creator = coDelMapper.queryByUserName(headerData.getCreateBy()); |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
String[] mailAddress2 = (creator != null && creator.getEmail() != null) ? |
|
|
|
new String[]{creator.getEmail()} : new String[]{}; |
|
|
|
|
|
|
|
|
|
|
|
// 合并 + 去重 |
|
|
|
String[] mailAddressAll = Stream.concat(Arrays.stream(mailAddress), Arrays.stream(mailAddress2)) |
|
|
|
.filter(Objects::nonNull) // 防止 null |
|
|
|
@ -869,7 +869,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
List<EcssCoDelNotifyDetailData> dbData, |
|
|
|
List<EcssCoDelNotifyDetailData> newData) { |
|
|
|
StringBuilder emailContent = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
|
|
// HTML头部和样式 |
|
|
|
emailContent.append("<!DOCTYPE html>"); |
|
|
|
emailContent.append("<html>"); |
|
|
|
@ -887,7 +887,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
emailContent.append("</style>"); |
|
|
|
emailContent.append("</head>"); |
|
|
|
emailContent.append("<body>"); |
|
|
|
|
|
|
|
|
|
|
|
// 邮件标题 |
|
|
|
emailContent.append("<h2>发货通知单改单通知</h2>"); |
|
|
|
emailContent.append("<p><strong>发货通知单号:</strong>").append(newHeaderData.getDelNo()).append("</p>"); |
|
|
|
@ -936,13 +936,13 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
// 处理明细变更 - 生成对比表格 |
|
|
|
emailContent.append("<div class='section-title'>明细数据对比</div>"); |
|
|
|
emailContent.append(generateDetailComparisonTable(dbData, newData)); |
|
|
|
|
|
|
|
|
|
|
|
emailContent.append("</body>"); |
|
|
|
emailContent.append("</html>"); |
|
|
|
|
|
|
|
return emailContent; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 生成明细对比表格 |
|
|
|
* @param dbData 原数据 |
|
|
|
@ -952,21 +952,21 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
private String generateDetailComparisonTable(List<EcssCoDelNotifyDetailData> dbData, |
|
|
|
List<EcssCoDelNotifyDetailData> newData) { |
|
|
|
StringBuilder table = new StringBuilder(); |
|
|
|
|
|
|
|
|
|
|
|
// 注意:不能用pn作为key,因为同一个pn可能有多行记录 |
|
|
|
// 应该用itemNo进行一对一匹配,比较每一行的变化 |
|
|
|
Map<Integer, EcssCoDelNotifyDetailData> dbMap = dbData.stream() |
|
|
|
.collect(Collectors.toMap(EcssCoDelNotifyDetail::getItemNo, detail -> detail, (v1, v2) -> v1)); |
|
|
|
Map<Integer, EcssCoDelNotifyDetailData> newMap = newData.stream() |
|
|
|
.collect(Collectors.toMap(EcssCoDelNotifyDetail::getItemNo, detail -> detail, (v1, v2) -> v1)); |
|
|
|
|
|
|
|
|
|
|
|
// 获取所有itemNo |
|
|
|
Set<Integer> allItemNos = new HashSet<>(); |
|
|
|
allItemNos.addAll(dbMap.keySet()); |
|
|
|
allItemNos.addAll(newMap.keySet()); |
|
|
|
List<Integer> sortedItemNos = new ArrayList<>(allItemNos); |
|
|
|
sortedItemNos.sort(Integer::compareTo); |
|
|
|
|
|
|
|
|
|
|
|
table.append("<table>"); |
|
|
|
table.append("<tr>"); |
|
|
|
table.append("<th>项次</th>"); |
|
|
|
@ -975,14 +975,14 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
table.append("<th>数量(新)</th>"); |
|
|
|
table.append("<th>变更说明</th>"); |
|
|
|
table.append("</tr>"); |
|
|
|
|
|
|
|
|
|
|
|
for (Integer itemNo : sortedItemNos) { |
|
|
|
EcssCoDelNotifyDetailData oldDetail = dbMap.get(itemNo); |
|
|
|
EcssCoDelNotifyDetailData newDetail = newMap.get(itemNo); |
|
|
|
|
|
|
|
|
|
|
|
table.append("<tr>"); |
|
|
|
table.append("<td>").append(itemNo).append("</td>"); |
|
|
|
|
|
|
|
|
|
|
|
// 判断变更类型 |
|
|
|
if (oldDetail == null) { |
|
|
|
// 新增行 |
|
|
|
@ -1015,10 +1015,10 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
table.append("<td>").append(newDetail.getQty().setScale(0, RoundingMode.HALF_UP)).append("</td>"); |
|
|
|
table.append("<td>-</td>"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
table.append("</tr>"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
table.append("</table>"); |
|
|
|
return table.toString(); |
|
|
|
} |
|
|
|
@ -2380,7 +2380,7 @@ public class CoDelServiceImpl implements CoDelService { |
|
|
|
fscWeight(partNoAndItemNoMap,partNo, totalQty, nodifyData.getLossratio()); |
|
|
|
} |
|
|
|
String hsCodeDesc = data.getHsCodeDesc()!=null&& data.getHsCodeDesc()? |
|
|
|
("\n"+(data.getHsCodeDescType()!=null&& data.getHsCodeDescType().equals("N") |
|
|
|
("\n"+(data.getHsCodeDescTypeInvoice()!=null&& data.getHsCodeDescTypeInvoice().equals("N") |
|
|
|
?eorder.get("hsCodeDescEn") :eorder.get("hsCodeDesc"))):""; |
|
|
|
eorder.put("designation", eorder.get("part_description") + "\n" + "PO:" + eorder.get("customerPO") |
|
|
|
+ (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?" HS Code:" + eorder.get("hsCode"):"")+hsCodeDesc+ lossratio); |
|
|
|
|