From ad2dab2d9faad3a97b77588e36d99d4e7c7f1a08 Mon Sep 17 00:00:00 2001 From: erdanergou Date: Sat, 5 Nov 2022 17:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BA=93=E5=AD=98=E7=9B=98?= =?UTF-8?q?=E7=82=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/StockTakingServiceImpl.java | 234 +++++++++++- .../stockTaking/stockTakingComplete.html | 350 ++++++++++++++++++ 2 files changed, 575 insertions(+), 9 deletions(-) create mode 100644 src/main/resources/templates/pages/stockTaking/stockTakingComplete.html diff --git a/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java b/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java index 57ce13de..b926ec66 100644 --- a/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java +++ b/src/main/java/com/dreamchaser/depository_manage/service/impl/StockTakingServiceImpl.java @@ -258,7 +258,7 @@ public class StockTakingServiceImpl implements StockTakingService { Map result = new HashMap<>(); StringBuilder QyWxUid = new StringBuilder(); - Integer state = ObjectFormatUtil.toInteger(map.get("state")); + Integer departmentManagerState = ObjectFormatUtil.toInteger(map.get("departmentManagerState")); Object o = (map.get("mainId")); Integer res = 0; if (o == null) { @@ -281,7 +281,7 @@ public class StockTakingServiceImpl implements StockTakingService { UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(s), userToken); QyWxUid.append(userByPort.getWorkwechat()).append(","); } - if (Integer.compare(state, 1) == 0) { + if (Integer.compare(departmentManagerState, 1) == 0) { // 如果审核通过 stockTakingResult = "通过"; @@ -425,8 +425,9 @@ public class StockTakingServiceImpl implements StockTakingService { } } - - + else{ + map.put("state",departmentManagerState); + } // 更新结果 map.put("id", mainId); String simpleTime = DateUtil.getSimpleTime(new Date()); @@ -434,7 +435,7 @@ public class StockTakingServiceImpl implements StockTakingService { map.put("departmentManager",userToken.getId()); stockTakingMapper.updateStockTaking(map); - // 更新 + // 更新其他卡片 String finalStockTakingResult = stockTakingResult; new Thread(new Runnable() { @Override @@ -447,9 +448,218 @@ public class StockTakingServiceImpl implements StockTakingService { } }).start(); + // 抄送盘点调账记录给盘点人员 + new Thread(new Runnable() { + @Override + public void run() { + + } + }).start(); + + return result; } + + + /** + * 对盘点进行处理 + * @param map + * @param userToken + * @return + */ + @Transactional + @Override + public Map completeStockTaking(Map map, UserByPort userToken) { + + + Map result = new HashMap<>(); + + StringBuilder QyWxUid = new StringBuilder(); + Integer state = ObjectFormatUtil.toInteger(map.get("state")); + Object o = (map.get("mainId")); + Integer res = 0; + if (o == null) { + throw new MyException("缺少必要参数"); + } + String stockTakingResult = "驳回"; + // 获取主表编号 + Integer mainId = ObjectFormatUtil.toInteger(o); + // 获取主单 + StockTaking mainRecord = stockTakingMapper.selectStockTakingById(mainId); + + // 获取负责人 + String departmentManager = mainRecord.getDepartmentManager(); + String[] split = departmentManager.split(","); + for (int i = 0; i < split.length; i++) { + String s = split[i]; + if("".equals(s)){ + continue; + } + UserByPort userByPort = PageController.FindUserById(ObjectFormatUtil.toInteger(s), userToken); + QyWxUid.append(userByPort.getWorkwechat()).append(","); + } + + // 如果审核通过 + stockTakingResult = "通过"; + + // 定义错误信息 + Map errMsg = new HashMap<>(); + // 定义出错单号 + List errIds = new ArrayList<>(); + // 定义出错信息 + List err = new ArrayList<>(); + + Integer placeId = mainRecord.getPlaceId(); + // 获取库位详情 + Place placeById = placeMapper.findPlaceById(placeId); + Integer depositoryId = mainRecord.getDepositoryId(); + // 获取仓库详情 + Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); + + // 获取所有子单 + List minRecordList = stockTakingMapper.selectStockTakingChildByMainId(mainId); + for (int i = 0; i < minRecordList.size(); i++) { + // 获取子单详情 + StockTakingChildP minRecord = minRecordList.get(i); + // 获取盘点的物料详情 + + // 获取当前盘点结果 + String takingResult = minRecord.getTakingResult(); + if ("Inventory_normal".equals(takingResult)) { + // 如果盘点结果正常 + continue; + } + + // 获取盈亏数量 + Integer inventory = minRecord.getInventory(); + + + Material materialById = materialMapper.findMaterialById(minRecord.getMid()); + + Map paramForMaterialAndPlace = new HashMap<>(); + paramForMaterialAndPlace.put("mid", materialById.getId()); + paramForMaterialAndPlace.put("pid", placeById.getId()); + // 获取物料与库位的对应关系 + MaterialAndPlace placeAndMaterialByMidAndPid = placeMapper.findPlaceAndMaterialByMidAndPid(paramForMaterialAndPlace); + + // 根据盘点结果重新计算物料的单价 + + // 数据库中的总额 + Double amounts = (materialById.getAmounts() / 100); + + Integer newInventory = minRecord.getNewInventory(); + Double avgPrice = 0.0; + if (Integer.compare(newInventory, 0) != 0) { + // 如果新的库存不是0 + + // 新的均价 + avgPrice = (amounts / newInventory) * 100; + } + + + materialById.setPrice(avgPrice); + + // 获取当前库位上物料数量 + Integer oldQuantity = materialById.getQuantity() - placeAndMaterialByMidAndPid.getQuantity(); + + materialById.setQuantity(oldQuantity + newInventory); + + + + // 用于计算新的库位数量 + Integer newNumberForPlace = 0; + // 用于计算新的库位与物料对应关系的数量 + Integer newNumberForMatrialAndPlace = 0; + if ("Inventory_up".equals(takingResult)) { + // 如果盘盈 + + // 更新当前库位数量 + newNumberForPlace = placeById.getQuantity() + inventory; + + if (newNumberForPlace < placeById.getMax()) { + + // 如果更新后的库位数量没有上溢 + + // 更新当前库位的数量 + placeById.setQuantity(newNumberForPlace); + } else { + // 添加错误信息 + errIds.add(minRecord.getId()); + err.add("当前库位数量溢出,需要转移"); + + continue; + } + + newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() + inventory; + // 更新物料与库位对应关系的数量 + placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); + + } else { + + // 如果盘亏 + newNumberForPlace = placeById.getQuantity() - inventory; + + if (newNumberForPlace > placeById.getMin()) { + //如果更新后的库位数量没有下溢 + + // 更新当前库位数量 + placeById.setQuantity(newNumberForPlace); + + // 更新物料与库位对应关系的数量 + newNumberForMatrialAndPlace = placeAndMaterialByMidAndPid.getQuantity() - inventory; + + } else { + placeById.setQuantity(0); + newNumberForMatrialAndPlace = 0; + } + + + placeAndMaterialByMidAndPid.setQuantity(newNumberForMatrialAndPlace); + + } + + + // 更新库位 + placeMapper.UpdatePlace(placeById); + + + // 更新库位与物料的对应关系 + placeMapper.updateMaterialAndPlace(placeAndMaterialByMidAndPid); + + + // 更新当前物料信息 + materialMapper.updateMaterial(materialById); + + + if (errIds.size() > 0) { + // 如果有出错的情况 + + errMsg.put("errIds", errIds); + errMsg.put("errMsg", err); + + result.put("errMsg", errMsg); + } + + } + // 更新结果 + map.put("id", mainId); + String simpleTime = DateUtil.getSimpleTime(new Date()); + map.put("completeTime", DateUtil.DateTimeToTimeStamp(simpleTime)); + map.put("departmentManager",userToken.getId()); + stockTakingMapper.updateStockTaking(map); + + // 抄送盘点记录给负责人 + new Thread(new Runnable() { + @Override + public void run() { + + } + }).start(); + + + return result; + } /** * 用于进行盘点结果转移 * @param map @@ -682,16 +892,16 @@ public class StockTakingServiceImpl implements StockTakingService { Map map = new HashMap<>(); // 获取主表编号 - String o = templateCard.getEventKey().split("wms_pass_StockTakingId")[1]; + String o = templateCard.getEventKey().split("StockTakingId")[1]; Integer mainId = ObjectFormatUtil.toInteger(o); // 获取主单 StockTaking mainRecord = stockTakingMapper.selectStockTakingById(mainId); - Integer state = 2; + Integer departmentManagerState = 2; if ("pass".equals(clickKey)) { // 如果审核通过 - state = 1; + departmentManagerState = 1; // 定义错误信息 Map errMsg = new HashMap<>(); // 定义出错单号 @@ -832,10 +1042,13 @@ public class StockTakingServiceImpl implements StockTakingService { } } + else{ + map.put("state",departmentManagerState); + } // 更新结果 map.put("id", mainId); - map.put("state",state); + map.put("departmentManagerState",departmentManagerState); String simpleTime = DateUtil.getSimpleTime(new Date()); map.put("completeTime", DateUtil.DateTimeToTimeStamp(simpleTime)); map.put("departmentManager",userByPort.getId()); @@ -844,6 +1057,9 @@ public class StockTakingServiceImpl implements StockTakingService { } + + + public String createTakingCode(String depositoryName) { String key = "wms_stockTakingNumber"; RLock lock = redissonClient.getLock(key); diff --git a/src/main/resources/templates/pages/stockTaking/stockTakingComplete.html b/src/main/resources/templates/pages/stockTaking/stockTakingComplete.html new file mode 100644 index 00000000..8688354d --- /dev/null +++ b/src/main/resources/templates/pages/stockTaking/stockTakingComplete.html @@ -0,0 +1,350 @@ + + + + + 仓库盘点 + + + + + + + + + +
+
+ +
+
+ + + + + \ No newline at end of file