From 326942ffa5f90b238a67aee5c2bfd416d40bdfcf Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Wed, 18 Jun 2025 13:43:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ecss/data/EcssCoDelPalletHeaderData.java | 3 +- .../ecss/service/impl/CoDelServiceImpl.java | 88 ++++++++----------- .../mapper/ecss/EcssCommonMapper.xml | 2 +- 3 files changed, 38 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/xujie/sys/modules/ecss/data/EcssCoDelPalletHeaderData.java b/src/main/java/com/xujie/sys/modules/ecss/data/EcssCoDelPalletHeaderData.java index 49cdfe63..753a98d4 100644 --- a/src/main/java/com/xujie/sys/modules/ecss/data/EcssCoDelPalletHeaderData.java +++ b/src/main/java/com/xujie/sys/modules/ecss/data/EcssCoDelPalletHeaderData.java @@ -5,6 +5,7 @@ import lombok.Data; import org.apache.ibatis.type.Alias; import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; @Data @@ -12,7 +13,7 @@ import java.util.List; public class EcssCoDelPalletHeaderData extends EcssCoDelPalletHeader { private Integer addFlag; - private List notifyDetailList; + private List notifyDetailList = new ArrayList<>(); private String walMartOrderFlag; } 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 0b491dd4..a9dce897 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 @@ -96,6 +96,8 @@ public class CoDelServiceImpl implements CoDelService { // 读取工作簿 XSSFWorkbook workbook = new XSSFWorkbook(is); importNotifyExcel(inData, workbook, site, currentUser, excelList); + } catch (NullPointerException e) { + throw new RuntimeException("导入失败:网络错误,请重新上传文档"); } catch (Exception e) { throw new RuntimeException("导入失败:" + e.getMessage()); } @@ -151,22 +153,7 @@ public class CoDelServiceImpl implements CoDelService { // 读取工作表 XSSFSheet sheet = workbook.getSheetAt(s); // 剔除空行 - for (int i = 0; i <= sheet.getLastRowNum(); i++) { - XSSFRow row = sheet.getRow(i); - boolean isEmptyRow = true; - if (row != null) { - for (Cell cell : row) { - if (cell.getCellType() != CellType.BLANK && cell.getCellType() != CellType.ERROR && - !StringUtils.isBlank(String.valueOf(cell))) { - isEmptyRow = false; - break; - } - } - if (isEmptyRow) { - sheet.removeRow(row); // 删除空行 - } - } - } + deleteEmptyRow(sheet); // 获取行数 int rows = sheet.getPhysicalNumberOfRows(); // 遍历每一行(从第二行开始) @@ -528,6 +515,8 @@ public class CoDelServiceImpl implements CoDelService { // 读取工作簿 XSSFWorkbook workbook = new XSSFWorkbook(is); importNotifyExcel(inData, workbook, site, currentUser, excelList); + } catch (NullPointerException e) { + throw new RuntimeException("导入失败:网络错误,请重新上传文档"); } catch (Exception e) { throw new RuntimeException("导入失败:" + e.getMessage()); } @@ -792,22 +781,7 @@ public class CoDelServiceImpl implements CoDelService { // 读取工作表 XSSFSheet sheet = workbook.getSheetAt(0); // 剔除空行 - for (int i = 0; i <= sheet.getLastRowNum(); i++) { - XSSFRow row = sheet.getRow(i); - boolean isEmptyRow = true; - if (row != null) { - for (Cell cell : row) { - if (cell.getCellType() != CellType.BLANK && cell.getCellType() != CellType.ERROR && - !StringUtils.isBlank(String.valueOf(cell))) { - isEmptyRow = false; - break; - } - } - if (isEmptyRow) { - sheet.removeRow(row); // 删除空行 - } - } - } + deleteEmptyRow(sheet); // 获取行数 int rows = sheet.getPhysicalNumberOfRows(); // 遍历每一行(从第二行开始) @@ -857,6 +831,8 @@ public class CoDelServiceImpl implements CoDelService { } excelList.add(excelData); } + } catch (NullPointerException e) { + throw new RuntimeException("导入失败:网络错误,请重新上传文档"); } catch (Exception e) { throw new RuntimeException("导入失败:" + e.getMessage()); } @@ -1044,7 +1020,7 @@ public class CoDelServiceImpl implements CoDelService { BigDecimal totalGrossWeight = new BigDecimal(0); EcssWalMartOrder task = new EcssWalMartOrder(); for (EcssCoDelNotifyDetailData detailData : notifys) { - totalQty = totalQty + detailData.getQty().intValue(); + totalQty = totalQty + (detailData.getQty()!=null?detailData.getQty().intValue():0); if (inData.getWalMartOrderFlag()!=null && inData.getWalMartOrderFlag().equals("Y")) { task.setSku(detailData.getPn()); task.setQty(detailData.getQty()); @@ -1066,8 +1042,7 @@ public class CoDelServiceImpl implements CoDelService { // 根据partNo获取hsCode List packageNoList = coDelMapper.getPackageNoByPartNo(inData.getSite(), partNoList); Map partPackageMap = new HashMap<>(); - for (int i = 0; i < packageNoList.size(); i++) { - Map eorder = packageNoList.get(i); + for (Map eorder : packageNoList) { if (!partPackageMap.containsKey(eorder.get("packageNo"))) { partPackageMap.put((String) eorder.get("packageNo"), (String) eorder.get("partNo")); } @@ -1079,7 +1054,7 @@ public class CoDelServiceImpl implements CoDelService { if (!packageData.isPresent()) { throw new RuntimeException("箱号信息不存在!"); } - String partNo = partPackageMap.get(packageData.get().getPackageNo()).toString(); + String partNo = partPackageMap.get(packageData.get().getPackageNo()); // 关务物料属性 List propertiesValues = coDelMapper.getPropertiesListByTypeAndCodeNo( inData.getSite(), "ECSSPART","BG001",inData.getBuNo(), partNo); @@ -1876,7 +1851,8 @@ public class CoDelServiceImpl implements CoDelService { boolean hasDicimal = false; if (pm!=null && !pm.isEmpty()) { totalQty = Integer.parseInt(pm.get("total_qty").toString()); - BigDecimal noCartons = (BigDecimal) pm.get("box_qty"); + BigDecimal noCartons = pm.get("box_qty")!=null?(BigDecimal) pm.get("box_qty"):BigDecimal.ZERO; + // 显示箱数零头 有小数 if (ecHeader.getBoxChange()!=null && ecHeader.getBoxChange() && noCartons.stripTrailingZeros().scale()>0) { noCartons = noCartons.setScale(0, RoundingMode.DOWN); hasDicimal = true; @@ -1988,7 +1964,8 @@ public class CoDelServiceImpl implements CoDelService { int totalQty=palletDetailList.stream().mapToInt(o -> Integer.parseInt(o.get("total_qty").toString())).sum(); Map palletMap = palletDetailList.stream().collect(Collectors.toMap( o -> o.get("part_no"), o -> o)); template.addVar("hs_code_desc", stringInput(data.getHsCodeDescType()!=null&& data.getHsCodeDescType().equals("N")? - nodifyDetailList.get(0).get("hsCodeDescEn").toString():nodifyDetailList.get(0).get("hsCodeDesc").toString())); + (nodifyDetailList.get(0).get("hsCodeDescEn")!=null?nodifyDetailList.get(0).get("hsCodeDescEn").toString():""): + (nodifyDetailList.get(0).get("hsCodeDesc")!=null?nodifyDetailList.get(0).get("hsCodeDesc").toString():""))); template.addVar("hs_code", stringInput(nodifyDetailList.get(0).get("hsCode").toString())); Map poNoMap = new HashMap<>(); BigDecimal ttlAmount = BigDecimal.ZERO; @@ -2352,21 +2329,7 @@ public class CoDelServiceImpl implements CoDelService { // 读取工作表 XSSFSheet sheet = workbook.getSheetAt(0); // 剔除空行 - for (int i = 0; i <= sheet.getLastRowNum(); i++) { - XSSFRow row = sheet.getRow(i); - boolean isEmptyRow = true; - if (row != null) { - for (Cell cell : row) { - if (cell.getCellType() != CellType.BLANK) { - isEmptyRow = false; - break; - } - } - if (isEmptyRow) { - sheet.removeRow(row); // 删除空行 - } - } - } + deleteEmptyRow(sheet); // 获取行数 int rows = sheet.getPhysicalNumberOfRows(); // 遍历每一行(从第二行开始) @@ -2415,6 +2378,25 @@ public class CoDelServiceImpl implements CoDelService { } } + private static void deleteEmptyRow(XSSFSheet sheet) { + for (int i = 0; i <= sheet.getLastRowNum(); i++) { + XSSFRow row = sheet.getRow(i); + boolean isEmptyRow = true; + if (row != null) { + for (Cell cell : row) { + if (cell.getCellType() != CellType.BLANK && cell.getCellType() != CellType.ERROR && + !StringUtils.isBlank(String.valueOf(cell))) { + isEmptyRow = false; + break; + } + } + if (isEmptyRow) { + sheet.removeRow(row); // 删除空行 + } + } + } + } + @Override public List getPropertiesListByDeclaration(EcssDeclarationHeaderData data) { // 获取partNo列表 diff --git a/src/main/resources/mapper/ecss/EcssCommonMapper.xml b/src/main/resources/mapper/ecss/EcssCommonMapper.xml index 782ab811..9de4b5af 100644 --- a/src/main/resources/mapper/ecss/EcssCommonMapper.xml +++ b/src/main/resources/mapper/ecss/EcssCommonMapper.xml @@ -46,7 +46,7 @@