diff --git a/src/main/java/com/xujie/sys/common/utils/ExcelTemplate.java b/src/main/java/com/xujie/sys/common/utils/ExcelTemplate.java index 325dac6c..7aa73bb5 100644 --- a/src/main/java/com/xujie/sys/common/utils/ExcelTemplate.java +++ b/src/main/java/com/xujie/sys/common/utils/ExcelTemplate.java @@ -308,7 +308,7 @@ public class ExcelTemplate { style2.setWrapText(true); c2.setCellStyle(style2); if (priceRight) { //仅供发票excel使用,第6、7、8是价格列居右 - for (int i = 6; i < 9; i++) { + for (int i = 6; i < 11; i++) { XSSFRow row = sheet.getRow(dtlRow); if (row == null) { continue; diff --git a/src/main/java/com/xujie/sys/modules/ecss/entity/EcssDeclarationHeaderData.java b/src/main/java/com/xujie/sys/modules/ecss/entity/EcssDeclarationHeaderData.java index 5460f0ac..4d389ddb 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/entity/EcssDeclarationHeaderData.java +++ b/src/main/java/com/xujie/sys/modules/ecss/entity/EcssDeclarationHeaderData.java @@ -63,4 +63,5 @@ public class EcssDeclarationHeaderData extends EcssDeclarationHeader{ private String declarationWeight; private String destination; private Boolean highPalletFlag; + private Boolean showWeight; } 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 f190876c..48607a60 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 @@ -1596,7 +1596,6 @@ public class CoDelServiceImpl implements CoDelService { } // 装箱数据 List palletHeaderDataList = coDelMapper.searchEcssCoDelPalletHeaderData(notifyHeaderData); - List palletDetailList = coDelMapper.exportCoDelPalletDetail(notifyHeaderData); Integer totalPlt = palletHeaderDataList.stream() .map(EcssCoDelPalletHeaderData::getPalletQty) .filter(Objects::nonNull) // 防止空指针 @@ -1816,6 +1815,10 @@ public class CoDelServiceImpl implements CoDelService { // RFID和RF不需要po,合同带印章(declaration-invoice-seal-template.xlsx),发票号不带章declaration-invoice-template.xlsx String xlsx = notifyHeader.getBuNo().equals("04-MHM") || notifyHeader.getBuNo().equals("02-Hardtag")? "templates/declaration-invoice2-template.xlsx":"templates/declaration-invoice-template.xlsx"; + if (data.getShowWeight()!=null && data.getShowWeight()) { + xlsx = "templates/declaration-invoice-showWeight-template.xlsx"; + + } ExcelTemplate template = ExcelTemplate.load(new ClassPathResource(xlsx).getInputStream()); extractedInvoice(data, template, notifyHeader); try (XSSFWorkbook workbook = template.render(0)) { @@ -1973,6 +1976,10 @@ public class CoDelServiceImpl implements CoDelService { // 硬标天线需要po(declaration-all2-template.xlsx),且多一个合同sheet xlsx = "templates/declaration-all2-template.xlsx"; } + if (data.getShowWeight()!=null && data.getShowWeight()) { + xlsx = "templates/declaration-all-showWeight-template.xlsx"; + + } XSSFWorkbook workbook = null; try { ExcelTemplate template = ExcelTemplate.load(new ClassPathResource(xlsx).getInputStream()); @@ -2036,14 +2043,11 @@ public class CoDelServiceImpl implements CoDelService { EcssCoDelNotifyHeaderData notifyHeader = coDelMapper.getEcssCoDelNotifyHeader(data.getSite(), data.getDelNo()); // RFID和RF和硬标天线使用的模版不一样 // RFID和RF如果勾选了合同,导出需要带公章(declaration-all-seal-template.xlsx) - String xlsx; - if (notifyHeader.getBuNo().equals("03-RFID") || notifyHeader.getBuNo().equals("01-Label")) { - xlsx = "templates/declaration-all-template-pdf.xlsx"; - } else { - // 硬标天线需要po(declaration-all2-template.xlsx),且多一个合同sheet - xlsx = "templates/declaration-all2-template.xlsx"; - } + String xlsx = "templates/declaration-all-template-pdf.xlsx"; + if (data.getShowWeight()!=null && data.getShowWeight()) { + xlsx = "templates/declaration-all-showWeight-template-pdf.xlsx"; + } XSSFWorkbook excelWorkbook = null; try { ExcelTemplate template = ExcelTemplate.load(new ClassPathResource(xlsx).getInputStream()); @@ -2387,6 +2391,13 @@ public class CoDelServiceImpl implements CoDelService { eorder.put("totalPrice", (((BigDecimal) eorder.get("qty")).multiply((BigDecimal) eorder.get("unitPrice"))). setScale(2, RoundingMode.HALF_UP)); allPrice = allPrice.add(((BigDecimal) eorder.get("qty")).multiply((BigDecimal) eorder.get("unitPrice"))); + if (data.getShowWeight()!=null && data.getShowWeight()) { + // 根据发货通知单明细查找装箱明细,获取重量和净重,保留2位小数 + eorder.put("grossWeight", pm != null && pm.get("gross_weight") != null ? + new BigDecimal(pm.get("gross_weight").toString()).setScale(2, RoundingMode.HALF_UP) : ""); + eorder.put("netWeight", pm != null && pm.get("net_weight") != null ? + new BigDecimal(pm.get("net_weight").toString()).setScale(2, RoundingMode.HALF_UP) : ""); + } } // RFID需要的 if (notifyHeader.getBuNo().equals("01-Label") || notifyHeader.getBuNo().equals("03-RFID")) { @@ -2669,18 +2680,6 @@ public class CoDelServiceImpl implements CoDelService { template.addVar("hs_code", stringInput(hsCodes)); Map poNoMap = new HashMap<>(); BigDecimal ttlAmount = BigDecimal.ZERO; - BigDecimal grossWeight = BigDecimal.valueOf(0.0); - BigDecimal netWeight = BigDecimal.valueOf(0.0); - for (Map map : nodifyDetailList) { - String partNo = (String) map.get("part_no"); - poNoMap.put(map.get("customerPO"), map.get("customerPO")); - ttlAmount = ttlAmount.add((BigDecimal) map.get("ttl_amount")); - Map pm = palletMap.get(partNo); - if (pm != null && !pm.isEmpty()) { - grossWeight = grossWeight.add((BigDecimal) pm.get("gross_weight")); - netWeight = netWeight.add((BigDecimal) pm.get("net_weight")); - } - } StringBuilder ponos = new StringBuilder(); poNoMap.forEach((key, value) -> ponos.append(key).append("\n")); template.addVar("poNo", ponos); @@ -2716,9 +2715,6 @@ public class CoDelServiceImpl implements CoDelService { template.addVar("price", ttlAmount.setScale(2, RoundingMode.HALF_UP)); template.addVar("total_qty", totalQty); - //BigDecimal grossWeight = ecHeader.getGrossWeight() != null ? ecHeader.getGrossWeight() : BigDecimal.ZERO; - //template.addVar("grossWeight", (grossWeight.add(palletWeight)).setScale(2, RoundingMode.HALF_UP)); - //template.addVar("netWeight", ecHeader.getNetWeight() != null ? ecHeader.getNetWeight().setScale(2, RoundingMode.HALF_UP) : ""); // 托盘重量=根据每个pallet的重量*数量累加 BigDecimal palletWeight = BigDecimal.ZERO; for (EcssCoDelPalletHeaderData palletHeader : palletHeaderDataList) { diff --git a/src/main/resources/mapper/ecss/CoDelMapper.xml b/src/main/resources/mapper/ecss/CoDelMapper.xml index c6919319..32c0265b 100644 --- a/src/main/resources/mapper/ecss/CoDelMapper.xml +++ b/src/main/resources/mapper/ecss/CoDelMapper.xml @@ -843,27 +843,78 @@ left join ecss_CoDelNotifyHeader noHeader on a.site=noHeader.site and a.delNo=no