diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java index 72ef40f7..68db7590 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java @@ -429,7 +429,7 @@ public class DepositoryRecordController { } }).start();*/ - // 开启一个线程开启审批 + /* // 开启一个线程开启审批 new Thread(new Runnable() { @Override public void run() { @@ -442,7 +442,7 @@ public class DepositoryRecordController { // 设置过期为7天 redisTemplateForHash.expire(sp_no, 7, TimeUnit.DAYS); } - }).start(); + }).start();*/ } diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java index eb2c3216..50cdfaf0 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -173,7 +173,7 @@ public class MaterialController { list.addAll(inventory); total += materialService.findInventoryCount(map); } - for (InventoryP inventoryP :list + for (InventoryP inventoryP : list ) { inventoryP.setSplitInfoList(splitUnitService.findSplitInfoByMid(inventoryP.getMid())); } @@ -253,7 +253,8 @@ public class MaterialController { list = materialService.InitTreeMenus(mname, depositoryId, placeId); }*/ if (!"".equals(mname)) { - list = materialService.InitTreeForSelectName(mname.split(",")[0], type); + // 如果是出入库 + list = materialService.InitTreeForSelectName(mname.split(",")[0], type,map); } else { list = materialService.InitTreeMenus_Test(); } @@ -261,13 +262,6 @@ public class MaterialController { } - @PostMapping("/treeMenus_Test") - public RestResponse TreeMenus_Test(@RequestBody Map map, HttpServletRequest request) { - List list = new ArrayList<>(); - list = materialService.InitMaterialTree_New(); - return new RestResponse(list); - } - /** * 根据id获取物料 @@ -326,8 +320,8 @@ public class MaterialController { * @param mid * @return */ - @GetMapping("/findMatrialByIdAndPid") - public RestResponse findMatrialByIdAndPid(@RequestParam(value = "mid", required = false) String mid, + @GetMapping("/findInventoryByIdAndPid") + public RestResponse findInventoryByIdAndPid(@RequestParam(value = "mid", required = false) String mid, @RequestParam(value = "pid", required = false) String pid, HttpServletRequest request) { UserByPort userToken = (UserByPort) request.getAttribute("userToken"); @@ -335,23 +329,23 @@ public class MaterialController { return new RestResponse("", 0, 200); } Map map = new HashMap<>(); - Material materialById = materialService.findMaterialById(ObjectFormatUtil.toInteger(mid)); + Inventory inventory = materialService.findInventoryById(ObjectFormatUtil.toInteger(mid)); List placePList = new ArrayList<>(); List depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userToken.getMaindeparment().toString()); - for (int i = 0; i < depositoryByAdminorg.size(); i++) { - List placeByMidAndDid = placeService.findPlaceByMidAndDid(ObjectFormatUtil.toInteger(mid), depositoryByAdminorg.get(i).getId()); + for (Depository depository : depositoryByAdminorg) { + List placeByMidAndDid = placeService.findPlaceByMidAndDid(ObjectFormatUtil.toInteger(mid), depository.getId()); placePList.addAll(placeByMidAndDid); } Map param = new HashMap<>(); - param.put("code", materialById.getCode()); + param.put("code", inventory.getCode()); Map paramByBarcode = new HashMap<>(); - paramByBarcode.put("mcode", materialById.getCode()); + paramByBarcode.put("mcode", inventory.getCode()); List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(paramByBarcode); - materialById.setMaterialAndBarCodeList(materialByBarCodeByCondition); - MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(pid), materialById.getId()); - materialById.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); + inventory.setMaterialAndBarCodeList(materialByBarCodeByCondition); + MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(pid), inventory.getId()); + inventory.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); - List materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(materialById.getId()); + List materialAndProducedDateByMid = materialService.findMaterialAndProducedDateByMid(inventory.getId()); List producedDateList = new ArrayList<>(); // 用于标志是否要更改数量 boolean flagForQuantity = true; @@ -359,13 +353,16 @@ public class MaterialController { // 获取当前生产日期 producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate())); if (flagForQuantity) { - materialById.setQuantity(materialAndProducedDate.getInventory()); + inventory.setQuantity(materialAndProducedDate.getInventory()); flagForQuantity = false; } } - map.put("materialById", materialById); + List splitInfoList = splitUnitService.findSplitInfoByMid(inventory.getMid()); + inventory.setSplitInfoList(splitInfoList); + map.put("materialById", inventory); map.put("producedDateList", producedDateList); map.put("placeList", placePList); + return new RestResponse(map, 1, 200); } @@ -997,7 +994,7 @@ public class MaterialController { // 如果当前物料不在该库位 flag = false; } else { - mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); + materialP.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); } } else { MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(0, materialP.getId()); @@ -1005,7 +1002,7 @@ public class MaterialController { // 如果当前物料不在该库位 flag = false; } else { - mp.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); + materialP.setQuantity(placeAndMaterialByMidAndPid.getQuantity()); } } mp = materialP; @@ -1023,6 +1020,8 @@ public class MaterialController { producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate())); } mp.setProducedDateList(producedDateList); + List splitInfoList = splitUnitService.findSplitInfoByMid(mp.getMid()); + mp.setSplitInfoList(splitInfoList); return new RestResponse(mp); } return new RestResponse(null); @@ -1423,6 +1422,8 @@ public class MaterialController { producedDateList.add(DateUtil.TimeStampToDateTimeForDay(materialAndProducedDate.getProducedDate())); material.setQuantity(materialAndProducedDate.getInventory()); } + List splitInfoByMid = splitUnitService.findSplitInfoByMid(material.getMid()); + material.setSplitInfoList(splitInfoByMid); material.setProducedDateList(producedDateList); } result.put("material", material); @@ -1504,13 +1505,16 @@ public class MaterialController { } else { // 获取当前物料 InventoryP materialP = inventory.get(0); - MaterialAndPlace pm = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(placeById), materialP.getId()); + MaterialAndPlace pm = placeService.findPlaceAndMaterialByMidAndPid(ObjectFormatUtil.toInteger(placeById.getId()), materialP.getId()); if (pm != null) { // 如果成功获取 Map paramForCode = new HashMap<>(); paramForCode.put("mcode", materialP.getCode()); List materialByBarCodeByCondition = materialService.findMaterialByBarCodeByCondition(paramForCode); + List splitInfoByMid = splitUnitService.findSplitInfoByMid(materialP.getMid()); + materialP.setSplitInfoList(splitInfoByMid); materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition); + materialP.setQuantity(pm.getQuantity()); return new RestResponse(materialP, 1, 200); } else { return new RestResponse("", 0, 200); @@ -1593,6 +1597,8 @@ public class MaterialController { } } mp.setProducedDateList(producedDateList); + List splitInfoByMid = splitUnitService.findSplitInfoByMid(mp.getMid()); + mp.setSplitInfoList(splitInfoByMid); } return new RestResponse(mp, 1, 200); @@ -1739,7 +1745,6 @@ public class MaterialController { * @param request * @return */ - @PostMapping("/editPlaceMaterial") public RestResponse editPlaceMaterial(@RequestBody Map map, HttpServletRequest request) { Integer integer = materialService.editPlaceMaterial(map); @@ -1749,4 +1754,51 @@ public class MaterialController { return CrudUtil.putHandle(1, integer); } } + + /** + * 用于根据当前单位查询对应数量的库存 + * + * @param map + * @return + */ + @PostMapping("/findQuantityByUnit") + public RestResponse findQuantityByUnit(@RequestBody Map map) { + if (map.containsKey("placeId")) { + // 定义最终数量 + Integer quantity = 0; + // 获取当前的计量单位 + String unit = (String) map.get("unit"); + // 获取当前库存id + Integer id = ObjectFormatUtil.toInteger(map.get("mid")); + // 获取当前判断库位 + Integer placeId = ObjectFormatUtil.toInteger(map.get("placeId")); + // 获取当前库存所在库位的对应信息 + MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(placeId, id); + if ("-1".equals(unit)) { + // 如果盘点的是默认单位 + quantity = placeAndMaterialByMidAndPid.getQuantity(); + } else { + // 如果不是 + + // 获取当前库存信息 + Inventory inventory = materialService.findInventoryById(id); + + // 用于获取对应拆单记录 + Map paramForSplitInfo = new HashMap<>(); + paramForSplitInfo.put("newUnit", unit); + paramForSplitInfo.put("mid", inventory.getMid()); + // 获取拆单记录 + SplitInfo splitInfo = splitUnitService.findSplitInfoByMidAndUnit(paramForSplitInfo); + // 获取当前拆单记录对应的库存数量 + SplitInventory splitInventoryByIidAndSid = splitUnitService.findSplitInventoryByIidAndSid(placeAndMaterialByMidAndPid.getId(), splitInfo.getId()); + quantity = splitInventoryByIidAndSid.getSaveQuantity(); + } + return new RestResponse(quantity); + } else { + throw new MyException("缺少必要参数"); + } + + } + + } diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java b/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java index c1a219d9..e040dcc9 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/StockTakingController.java @@ -94,17 +94,18 @@ public class StockTakingController { param.put("state",3); param.put("departmentManagerState",3); param.put("originator",userToken.getId()); - for (int i = 0; i < params.size(); i++) { - Integer temp = ObjectFormatUtil.toInteger(params.get(i)); + for (Object o : params) { + Integer temp = ObjectFormatUtil.toInteger(o); map.remove("code"); - param.put("mid",map.get("mid"+temp)); - param.put("barCode",map.get("barCode"+temp)); - param.put("oldInventory",map.get("oldInventory"+temp)); - param.put("newInventory",map.get("newInventory"+temp)); - param.put("takingResult",map.get("takingResult"+temp)); - param.put("inventory",map.get("inventory"+temp)); - param.put("producedDate",map.get("producedDate"+temp)); - param.put("temp",temp); + param.put("mid", map.get("mid" + temp)); + param.put("barCode", map.get("barCode" + temp)); + param.put("oldInventory", map.get("oldInventory" + temp)); + param.put("newInventory", map.get("newInventory" + temp)); + param.put("takingResult", map.get("takingResult" + temp)); + param.put("inventory", map.get("inventory" + temp)); + param.put("producedDate", map.get("producedDate" + temp)); + param.put("unit",map.get("unit"+temp)); + param.put("temp", temp); success += stockTakingService.insertStockTaking(param); param.remove("id"); } @@ -116,6 +117,7 @@ public class StockTakingController { param.put("takingResult",map.get("takingResult")); param.put("inventory",map.get("inventory")); param.put("producedDate",map.get("producedDate")); + param.put("unit",map.get("unit")); success += stockTakingService.insertStockTaking(param); Object mainId = param.get("mainId"); @@ -139,7 +141,7 @@ public class StockTakingController { }).start();*/ // 用于发送审批 - new Thread(new Runnable() { + /*new Thread(new Runnable() { @Override public void run() { JSONObject jsonObject = qyWxOperationService.sendApprovalTemplateStockTaking(crypt, userToken, ObjectFormatUtil.toInteger(mainId), QyWxDepartmentManager.toString()); @@ -152,7 +154,7 @@ public class StockTakingController { redisTemplateForHash.expire(sp_no,7,TimeUnit.DAYS); } }).start(); - +*/ } else{ @@ -177,7 +179,7 @@ public class StockTakingController { }).start();*/ // 用于发送审批 - new Thread(new Runnable() { + /*new Thread(new Runnable() { @Override public void run() { JSONObject jsonObject = qyWxOperationService.sendApprovalTemplateStockTaking(crypt, userToken, ObjectFormatUtil.toInteger(mainId), QyWxDepartmentManager.toString()); @@ -189,7 +191,7 @@ public class StockTakingController { // 设置过期时间为7天 redisTemplateForHash.expire(sp_no,7,TimeUnit.DAYS); } - }).start(); + }).start();*/ } diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml index 68aac456..c2694529 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/StockTakingMapper.xml @@ -31,6 +31,7 @@ + @@ -47,7 +48,7 @@ - id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate + id,mid,oldInventory,newInventory,inventory,mainId,takingResult,mname,mtId,tname,mcode,mversion,munit,mtexture,producedDate,stcUnit @@ -68,9 +69,9 @@ - INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate) + INSERT INTO stocktakingchild (id,mid,oldInventory,newInventory,takingResult,inventory,mainId,producedDate,unit) values ( - #{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate} + #{id},#{mid},#{oldInventory},#{newInventory},#{takingResult},#{inventory},#{mainId},#{producedDate},#{unit} ) @@ -163,7 +164,10 @@ mainId = #{mainId}, - producedDate = #{producedDate} + producedDate = #{producedDate}, + + + unit = #{unit} where id = #{id} @@ -257,6 +261,9 @@ and producedDate = #{producedDate} + + and unit = #{unit} + +
@@ -69,17 +70,24 @@ 出库申请 - +
- +