From 35fe93b6ec7c2694ff213ada492bf1cd52111cec Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Fri, 5 Jun 2026 13:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AC=E6=A0=87=E4=B8=80=E9=94=AE=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=A2=9E=E5=8A=A0=E5=90=88=E5=90=8C=E5=A4=8D=E9=80=89?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=8B=BE=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CoDelExcelTXServiceImpl.java | 66 ++++++++++++------ .../ecss/service/impl/CoDelServiceImpl.java | 59 ++++++++++------ .../resources/mapper/ecss/CoDelMapper.xml | 14 ++-- .../ALPHA/declaration-all-template.xlsx | Bin 282201 -> 282217 bytes .../declaration-packingList-template.xlsx | Bin 184641 -> 184674 bytes .../TX/declaration-all-template.xlsx | Bin 155565 -> 155560 bytes .../TX/declaration-packingList-template.xlsx | Bin 184493 -> 184525 bytes .../templates/TX/declaration-template.xlsx | Bin 89604 -> 90074 bytes .../YB/declaration-all-template-pdf.xlsx | Bin 303571 -> 289113 bytes .../YB/declaration-all-template.xlsx | Bin 306664 -> 292447 bytes .../YB/declaration-packingList-template.xlsx | Bin 184063 -> 184102 bytes 11 files changed, 90 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java index 6c2d0140..f3460a76 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelExcelTXServiceImpl.java @@ -1488,7 +1488,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { extractedContract(data, templateAdapter); template.render(5);*/ } else if (isHardtag) { - ExcelTemplateYB template = ExcelTemplateYB.load(new ClassPathResource("templates/YB/declaration-all-template.xlsx").getInputStream()); + ExcelTemplateYB template = ExcelTemplateYB.load(new ClassPathResource( + data.getContractFlag()!=null && data.getContractFlag()?"templates/YB/declaration-all-template-invoice.xlsx" + :"templates/YB/declaration-all-template.xlsx").getInputStream()); ExcelTemplateAdapter templateAdapter = new Yb2ExcelTemplateAdapter(template); // 第一个sheet - 出口货物委托书 @@ -1514,14 +1516,21 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { templateAdapter.clearAll(); extractedElements(data, templateAdapter); template.render(4); - // 第六个sheet - 合同 - templateAdapter.clearAll(); - extractedContract(data, templateAdapter); - template.render(5); - // 第7个sheet - 出货通知 - templateAdapter.clearAll(); - extractedShippingNotice(templateAdapter, notifyHeader); - template.render(6); + if (data.getContractFlag()!=null && data.getContractFlag()) { + // 第六个sheet - 合同 + templateAdapter.clearAll(); + extractedContract(data, templateAdapter); + template.render(5); + // 第7个sheet - 出货通知 + templateAdapter.clearAll(); + extractedShippingNotice(templateAdapter, notifyHeader); + template.render(6); + } else { + // 第六个sheet - 出货通知 + templateAdapter.clearAll(); + extractedShippingNotice(templateAdapter, notifyHeader); + template.render(5); + } } else { ExcelTemplateALPHA template = ExcelTemplateALPHA.load(new ClassPathResource("templates/ALPHA/declaration-all-template.xlsx").getInputStream()); ExcelTemplateAdapter templateAdapter = new YbExcelTemplateAdapter(template); @@ -1606,7 +1615,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { template.render(3); } else if (isHardtag) { - String xlsx = "templates/YB/declaration-all-template-pdf.xlsx"; + String xlsx = data.getContractFlag()!=null && data.getContractFlag()?"templates/YB/declaration-all-template-invoice-pdf.xlsx":"templates/YB/declaration-all-template-pdf.xlsx"; ExcelTemplateYB template = ExcelTemplateYB.load(new ClassPathResource(xlsx).getInputStream()); ExcelTemplateAdapter templateAdapter = new Yb2ExcelTemplateAdapter(template); @@ -1629,10 +1638,21 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { extractedElements(data, templateAdapter); template.render(3); - // 第五个sheet - 合同 - templateAdapter.clearAll(); - extractedContract(data, templateAdapter); - template.render(4); + if (data.getContractFlag()!=null && data.getContractFlag()) { + // 合同 + templateAdapter.clearAll(); + extractedContract(data, templateAdapter); + template.render(4); + // 出货通知 + templateAdapter.clearAll(); + extractedShippingNotice(templateAdapter, notifyHeader); + template.render(5); + } else { + // 出货通知 + templateAdapter.clearAll(); + extractedShippingNotice(templateAdapter, notifyHeader); + template.render(4); + } } else { String xlsx = "templates/ALPHA/declaration-all-template-pdf.xlsx"; ExcelTemplateALPHA template = ExcelTemplateALPHA.load(new ClassPathResource(xlsx).getInputStream()); @@ -1809,13 +1829,15 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { for (int i = 0; i < detailList.size(); i++) { Map eorder = detailList.get(i); eorder.put("row_num", i + 1); - if (data.getDeclarationWeight()!=null && data.getDeclarationWeight().equals("显示")) { + /* if (data.getDeclarationWeight()!=null && data.getDeclarationWeight().equals("显示")) { eorder.put("net_weight", eorder.get("net_weight") != null ? eorder.get("net_weight").toString() : ""); eorder.put("weight_unit", eorder.get("weight_unit") != null ? eorder.get("weight_unit").toString() : ""); } else { eorder.put("net_weight", ""); eorder.put("weight_unit", ""); - } + }*/ + eorder.put("net_weight", eorder.get("net_weight") != null ? eorder.get("net_weight").toString() : ""); + eorder.put("weight_unit", eorder.get("weight_unit") != null ? eorder.get("weight_unit").toString() : ""); if (eorder.get("currency") != null) { String currency = stringInput((String) eorder.get("currency")); if (currency.toUpperCase().startsWith("RMB")) { @@ -1947,7 +1969,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { return ""; } - final int maxCharsPerLine = 85; + final int maxCharsPerLine = 100; StringBuilder result = new StringBuilder(); int currentLineLength = 0; @@ -1996,7 +2018,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { template.addVar("localShipAddress", notifyHeader.getLocalShipAddress()); template.addVar("ccusname", stringInput(notifyHeader.getOverseasShipper())); template.addVar("cDeliverAdd", stringInput(notifyHeader.getOverseasAddress())); - template.addVar("invoiceTitle", data.getContractFlag()!=null && data.getContractFlag()? "合同" : "INVOICE No."); + template.addVar("invoiceTitle", "INVOICE No."); template.addVar("cmc_invoice", notifyHeader.getCmcInvoice()); template.addVar("dateStr", notifyHeader.getReadyDate() == null ? "" : new java.text.SimpleDateFormat("d-MMM-yyyy", java.util.Locale.ENGLISH).format(notifyHeader.getReadyDate())); @@ -2214,7 +2236,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { // 构建artNo内容 String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n" - + "PO#" + eorder.get("po_no") + + + " PO#" + eorder.get("po_no") + (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?" HS CODE#" + eorder.get("hsCode"):""); eorder.put("artNo", artNoContent); // 计算artNo内容的行数,动态设置行高 @@ -2462,7 +2484,9 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { eorder.put("net_weight", isFirstRow ? ((BigDecimal) list.get(m).get("net_weight")).setScale(2, RoundingMode.HALF_UP) : ""); // 构建artNo内容 - String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") ; + String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n" + + " PO:" + eorder.get("po_no") + + (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?" HS CODE:" + eorder.get("hsCode"):""); eorder.put("artNo", artNoContent); // 计算artNo内容的行数,动态设置行高 int lineCount = calculateLineCount(artNoContent); @@ -2707,7 +2731,7 @@ public class CoDelExcelTXServiceImpl implements CoDelExcelTXService { // 构建artNo内容 String artNoContent = eorder.get("pn")+" " + eorder.get("part_description") + "\n" - + "PO:" + eorder.get("po_no") + + + " PO:" + eorder.get("po_no") + (data.getHsCodeFlag()!=null && data.getHsCodeFlag()?" HS CODE:" + eorder.get("hsCode"):""); eorder.put("artNo", artNoContent); // 计算artNo内容的行数,动态设置行高 diff --git a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java index f34db763..1e1a0690 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java +++ b/src/main/java/com/xujie/sys/modules/ecss/service/impl/CoDelServiceImpl.java @@ -420,9 +420,18 @@ public class CoDelServiceImpl implements CoDelService { public void saveHSCodeData(EcssHsCodeData inData) { SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal(); String site = coDelMapper.getSiteByBu(inData.getBuNo()); - List checkModel = coDelMapper.checkPropertiesModel(site, inData.getBuNo(), inData.getCodeNo(), "ECSS"); - if (checkModel.size() == 0) { - throw new RuntimeException("属性模板不存在。"); + String codeNo = inData.getCodeNo(); + if (codeNo == null) { + codeNo = ""; + } + codeNo = codeNo.trim(); + inData.setCodeNo(codeNo); + boolean hasCodeNo = StringUtils.isNotBlank(codeNo); + if (hasCodeNo) { + List checkModel = coDelMapper.checkPropertiesModel(site, inData.getBuNo(), inData.getCodeNo(), "ECSS"); + if (checkModel.size() == 0) { + throw new RuntimeException("属性模板不存在。"); + } } if (inData.getAddFlag() == 0) { //0是新增 @@ -433,14 +442,16 @@ public class CoDelServiceImpl implements CoDelService { throw new RuntimeException("该BU已经存在了这个品名,请检查数据。"); } coDelMapper.insertHsCodeData(inData); - PartSubPropertiesValueData propertiesData = new PartSubPropertiesValueData(); - propertiesData.setSite(site); - propertiesData.setBuNo(inData.getBuNo()); - propertiesData.setCodeNo(inData.getCodeNo()); - propertiesData.setRecordType("ECSS"); - propertiesData.setPartNo(inData.getHsCodeDesc()); - partInformationMapper.savePartSubPropertiesValueHeader(propertiesData); - partInformationMapper.savePartSubPropertiesValue(propertiesData); + if (hasCodeNo) { + PartSubPropertiesValueData propertiesData = new PartSubPropertiesValueData(); + propertiesData.setSite(site); + propertiesData.setBuNo(inData.getBuNo()); + propertiesData.setCodeNo(inData.getCodeNo()); + propertiesData.setRecordType("ECSS"); + propertiesData.setPartNo(inData.getHsCodeDesc()); + partInformationMapper.savePartSubPropertiesValueHeader(propertiesData); + partInformationMapper.savePartSubPropertiesValue(propertiesData); + } } else { inData.setUpdateBy(currentUser.getUsername()); inData.setSite(site); @@ -449,18 +460,20 @@ public class CoDelServiceImpl implements CoDelService { throw new RuntimeException("这个品名已经不存在,请检查数据。"); } coDelMapper.updateHsCodeData(inData); - PartSubPropertiesValueData propertiesData = new PartSubPropertiesValueData(); - propertiesData.setSite(site); - propertiesData.setBuNo(inData.getBuNo()); - propertiesData.setCodeNo(inData.getCodeNo()); - propertiesData.setRecordType("ECSS"); - propertiesData.setPartNo(inData.getHsCodeDesc()); - List checkValueHeaderData = partInformationMapper.checkValueHeaderData(propertiesData); - if (checkValueHeaderData.size() == 0) { - partInformationMapper.deletePartSubPropertiesValueHeader(propertiesData); - partInformationMapper.deletePartSubPropertiesValue(propertiesData); - partInformationMapper.savePartSubPropertiesValueHeader(propertiesData); - partInformationMapper.savePartSubPropertiesValue(propertiesData); + if (hasCodeNo) { + PartSubPropertiesValueData propertiesData = new PartSubPropertiesValueData(); + propertiesData.setSite(site); + propertiesData.setBuNo(inData.getBuNo()); + propertiesData.setCodeNo(inData.getCodeNo()); + propertiesData.setRecordType("ECSS"); + propertiesData.setPartNo(inData.getHsCodeDesc()); + List checkValueHeaderData = partInformationMapper.checkValueHeaderData(propertiesData); + if (checkValueHeaderData.size() == 0) { + partInformationMapper.deletePartSubPropertiesValueHeader(propertiesData); + partInformationMapper.deletePartSubPropertiesValue(propertiesData); + partInformationMapper.savePartSubPropertiesValueHeader(propertiesData); + partInformationMapper.savePartSubPropertiesValue(propertiesData); + } } diff --git a/src/main/resources/mapper/ecss/CoDelMapper.xml b/src/main/resources/mapper/ecss/CoDelMapper.xml index bfc942f2..b317358a 100644 --- a/src/main/resources/mapper/ecss/CoDelMapper.xml +++ b/src/main/resources/mapper/ecss/CoDelMapper.xml @@ -366,6 +366,12 @@ AND a.HsCode like #{query.hsCode} + + AND a.HsCodeDesc like #{query.hsCodeDesc} + + + AND ISNULL(a.brand,'无') = ISNULL(#{query.brand},'无') + order by a.CreateDate ,a.HsCode @@ -374,9 +380,7 @@ - delete from ecss_hsCode where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc} + delete from ecss_hsCode where site=#{site} and buNo=#{buNo} and hsCodeDesc=#{hsCodeDesc} and ISNULL(brand,'无') = ISNULL(#{brand},'无')