From dbe6cbbbf27e0d7692c72f22dc4f818ff522a47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Mon, 13 Nov 2023 00:26:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8D=95=E6=8D=AE=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E5=AF=BC=E5=85=A5=E6=8E=A5=E5=8F=A3=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/constants/ExceptionConstants.java | 3 ++ .../erp/controller/DepotItemController.java | 29 +++++++++++++++---- .../service/depotItem/DepotItemService.java | 19 ++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java index daf6509c..61758e2c 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java @@ -432,6 +432,9 @@ public class ExceptionConstants { //单据明细-明细中商品不存在 public static final int DEPOT_ITEM_BARCODE_IS_NOT_EXIST_CODE = 9000003; public static final String DEPOT_ITEM_BARCODE_IS_NOT_EXIST_MSG = "抱歉,商品条码:%s在商品管理中不存在"; + //单据明细-明细中仓库不存在 + public static final int DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_CODE = 9000004; + public static final String DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_MSG = "抱歉,仓库:%s在基础资料-仓库信息中不存在"; /** * 财务信息 diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java index 6b09331b..44934773 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -906,12 +906,31 @@ public class DepotItemController { } else { List> detailList = new ArrayList<>(); for (int i = 2; i < src.getRows(); i++) { - String barCode = ExcelUtils.getContent(src, i, 0); - String num = ExcelUtils.getContent(src, i, 2); - String unitPrice = ExcelUtils.getContent(src, i, 3); - String taxRate = ExcelUtils.getContent(src, i, 4); - String remark = ExcelUtils.getContent(src, i, 5); + String depotName = "", barCode = "", num = "", unitPrice = "", taxRate = "", remark = ""; + if("CGDD".equals(prefixNo) || "XSDD".equals(prefixNo)) { + barCode = ExcelUtils.getContent(src, i, 0); + num = ExcelUtils.getContent(src, i, 2); + unitPrice = ExcelUtils.getContent(src, i, 3); + taxRate = ExcelUtils.getContent(src, i, 4); + remark = ExcelUtils.getContent(src, i, 5); + } + if("CGRK".equals(prefixNo) || "XSCK".equals(prefixNo)) { + depotName = ExcelUtils.getContent(src, i, 0); + barCode = ExcelUtils.getContent(src, i, 1); + num = ExcelUtils.getContent(src, i, 3); + unitPrice = ExcelUtils.getContent(src, i, 4); + taxRate = ExcelUtils.getContent(src, i, 5); + remark = ExcelUtils.getContent(src, i, 6); + } + if("QTRK".equals(prefixNo) || "QTCK".equals(prefixNo)) { + depotName = ExcelUtils.getContent(src, i, 0); + barCode = ExcelUtils.getContent(src, i, 1); + num = ExcelUtils.getContent(src, i, 3); + unitPrice = ExcelUtils.getContent(src, i, 4); + remark = ExcelUtils.getContent(src, i, 5); + } Map materialMap = new HashMap<>(); + materialMap.put("depotName", depotName); materialMap.put("barCode", barCode); materialMap.put("num", num); materialMap.put("unitPrice", unitPrice); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java index 16fb7ba2..c73fb421 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotItem/DepotItemService.java @@ -1125,15 +1125,34 @@ public class DepotItemService { JSONArray arr = new JSONArray(); List list = depotItemMapperEx.getBillItemByParam(barCodes); Map materialMap = new HashMap<>(); + Map depotMap = new HashMap<>(); for (MaterialVo4Unit material: list) { materialMap.put(material.getmBarCode(), material); } + JSONArray depotArr = depotService.findDepotByCurrentUser(); + for (Object depotObj: depotArr) { + if(depotObj!=null) { + JSONObject depotObject = JSONObject.parseObject(depotObj.toString()); + depotMap.put(depotObject.getString("depotName"), depotObject.getLong("id")); + } + } for (Map detailMap: detailList) { JSONObject item = new JSONObject(); String barCode = detailMap.get("barCode"); if(StringUtil.isNotEmpty(barCode)) { MaterialVo4Unit m = materialMap.get(barCode); if(m!=null) { + //判断仓库是否存在 + String depotName = detailMap.get("depotName"); + if(StringUtil.isNotEmpty(depotName)) { + if(depotMap.get(depotName)!=null) { + item.put("depotName", depotName); + item.put("depotId", depotMap.get(depotName)); + } else { + throw new BusinessRunTimeException(ExceptionConstants.DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_CODE, + String.format(ExceptionConstants.DEPOT_ITEM_DEPOTNAME_IS_NOT_EXIST_MSG, depotName)); + } + } item.put("barCode", barCode); item.put("name", m.getName()); item.put("standard", m.getStandard());