diff --git a/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java b/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java index 8b3e9ab4..1d62f4ea 100644 --- a/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java +++ b/src/main/java/com/dreamchaser/depository_manage/config/PortConfig.java @@ -28,8 +28,7 @@ public class PortConfig { // 接口地址 public static String external_url = "http://172.20.2.87:39168"; // public static String external_url = "http://127.0.0.1:39168"; - public static String external_url_6666 = "http://172.20.2.87:6666"; -// public static String external_url_6666 = "http://127.0.0.1:6666"; + public static String external_url_6666 = "http://kpi.hxgk.group/kpiapi"; /** 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 3f25d37a..b2e2f7f5 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; import com.dreamchaser.depository_manage.config.JM_3DES; import com.dreamchaser.depository_manage.entity.*; import com.dreamchaser.depository_manage.exception.MyException; +import com.dreamchaser.depository_manage.mapper.MaterialTypeMapper; import com.dreamchaser.depository_manage.pojo.*; import com.dreamchaser.depository_manage.security.pool.AuthenticationTokenPool; import com.dreamchaser.depository_manage.service.*; @@ -52,6 +53,9 @@ public class MaterialController { @Autowired SplitUnitService splitUnitService; + @Autowired + MaterialTypeService materialTypeService; + /** * 根据物料进行查询 @@ -61,6 +65,12 @@ public class MaterialController { */ @GetMapping("/material") public RestResponse findMaterial(@RequestParam Map map) { + if(map.containsKey("materialTypeId")){ + Long materialTypeId = ObjectFormatUtil.toLong(map.get("materialTypeId")); + List childForMaterialTypeByParent = materialTypeService.findChildForMaterialTypeByParent(materialTypeId); + map.put("materialTypeIds",childForMaterialTypeByParent); + map.remove("materialTypeId"); + } List materialPByCondition = materialService.findMaterialPByConditionForTable(map); return new RestResponse(materialPByCondition, materialService.findCountByCondition(map), 200); } @@ -159,16 +169,28 @@ public class MaterialController { if (isadmin == null) { isadmin = 1; } + if (isadmin != 4 && Integer.compare(userToken.getMaindeparment(), 361) != 0) { List didList = roleService.findDepositoryIdForUserHas(userToken); map.put("depositoryIds", didList); - - list = materialService.findInventoryByDids(map); - total = materialService.findInventoryCountByDids(map); - } else { - list = materialService.findInventory(map); - total = materialService.findInventoryCount(map); } + if(map.containsKey("depositoryId")){ + // 如果包含仓库id + Integer depositoryId = ObjectFormatUtil.toInteger(map.get("depositoryId")); + // 获取当前仓库下所有可见的仓库 + List allChildDepositoryById = depositoryService.findAllChildDepositoryById(depositoryId, userToken); + map.put("depositoryIds", allChildDepositoryById); + map.remove("depositoryId"); + } + if(map.containsKey("materialTypeId")){ + Long materialTypeId = ObjectFormatUtil.toLong(map.get("materialTypeId")); + List childForMaterialTypeByParent = materialTypeService.findChildForMaterialTypeByParent(materialTypeId); + map.put("materialTypeIds", childForMaterialTypeByParent); + map.remove("materialTypeId"); + } + list = materialService.findInventory(map); + total = materialService.findInventoryCount(map); + return new RestResponse(list, total, 200); } @@ -314,11 +336,11 @@ public class MaterialController { if (inventoryPS.size() > 0) { List depositoryIdList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userToken); List tempDepositoryID = new ArrayList<>(); - for (InventoryP inventory:inventoryPS - ) { + for (InventoryP inventory : inventoryPS + ) { tempDepositoryID.add(inventory.getDepositoryId()); } - tempDepositoryID = (List) CollectionUtils.union(depositoryIdList,tempDepositoryID); + tempDepositoryID = (List) CollectionUtils.union(depositoryIdList, tempDepositoryID); List depositoryByIds = depositoryService.findDepositoryByIds(tempDepositoryID); InventoryP materialP = inventoryPS.get(0); materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition); @@ -427,14 +449,14 @@ public class MaterialController { List depositoryIdList = roleService.findDepositoryIdForUserHas(userToken); // 获取该用户额外可见的仓库 List tempDepositoryIdlist = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userToken); - depositoryIdList= (List) CollectionUtils.union(tempDepositoryIdlist,depositoryIdList); + depositoryIdList = (List) CollectionUtils.union(tempDepositoryIdlist, depositoryIdList); // 用于存储存在库存的仓库id List showDepository = new ArrayList<>(); for (Integer depositoryId : depositoryIdList ) { param.put("depositoryId", depositoryId); List inventoryPS = materialService.findInventory(param); - if(inventoryPS.size() > 0){ + if (inventoryPS.size() > 0) { showDepository.add(depositoryId); } inventoryPByCondition.addAll(inventoryPS); @@ -464,8 +486,7 @@ public class MaterialController { List depositoryByIds = depositoryService.findDepositoryByIds(showDepository); ip.setDepositoryList(depositoryByIds); return new RestResponse(ip, 1, 200); - } - else if ("in".equals(type)) { + } else if ("in".equals(type)) { param.put("code", code); materialPByCondition = materialService.findMaterialPByCondition(param); if (materialPByCondition.size() > 0) { @@ -514,7 +535,7 @@ public class MaterialController { List depositoryIdList = roleService.findDepositoryIdForUserHas(userToken); List tempDepositoryIDList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userToken); - depositoryIdList = (List) CollectionUtils.union(tempDepositoryIDList,depositoryIdList); + depositoryIdList = (List) CollectionUtils.union(tempDepositoryIDList, depositoryIdList); for (Integer depositoryId : depositoryIdList ) { map.put("depositoryId", depositoryId); @@ -705,7 +726,7 @@ public class MaterialController { if (Integer.compare(placeId, -1) == 0) { // 如果是查询所有库存 List depositoryByAdminorg = depositoryService.findDepositoryByAdminorg(userByPort.getMaindeparment().toString()); - if(map.containsKey("depositoryId")){ + if (map.containsKey("depositoryId")) { Depository depositoryById = depositoryService.findDepositoryById(ObjectFormatUtil.toInteger(map.get("depositoryId"))); depositoryByAdminorg = new ArrayList<>(); depositoryByAdminorg.add(depositoryById); @@ -756,8 +777,7 @@ public class MaterialController { } } } - } - else { + } else { // 获取当前要转移的库位 Place place = placeService.findPlaceById(placeId); if (Integer.compare(place.getId(), 0) != 0) { @@ -771,7 +791,7 @@ public class MaterialController { MaterialAndPlace placeAndMaterialByMidAndPid = placeService.findPlaceAndMaterialByMidAndPid(placeId, inventoryP.getId()); if ("-1".equals(unit)) { // 如果是基础单位 - if (quantity <= placeAndMaterialByMidAndPid.getQuantity()) { // 如果当前数量合适则跳出循环 + if (quantity <= (placeAndMaterialByMidAndPid.getQuantity() / 100)) { // 如果当前数量合适则跳出循环 flag = true; break; } @@ -901,7 +921,7 @@ public class MaterialController { boolean flag = false; List depositoryIdList = roleService.findDepositoryIdForUserHas(userByPort); List tempDepositoryIdList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userByPort); - depositoryIdList = (List) CollectionUtils.union(depositoryIdList,tempDepositoryIdList); + depositoryIdList = (List) CollectionUtils.union(depositoryIdList, tempDepositoryIdList); for (Integer depositoryId : depositoryIdList) { @@ -1063,7 +1083,7 @@ public class MaterialController { if (materialByBarCode != null) { List depositoryIdList = roleService.findDepositoryIdForUserHas(userByPort); List tempDepositoryIdList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userByPort); - depositoryIdList = (List) CollectionUtils.union(depositoryIdList,tempDepositoryIdList); + depositoryIdList = (List) CollectionUtils.union(depositoryIdList, tempDepositoryIdList); List placePList = new ArrayList<>(); for (Integer depositoryId : depositoryIdList) { boolean isExist = false; diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.java b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.java index 97449d4b..930f258d 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.java +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.java @@ -154,6 +154,15 @@ public interface DepositoryMapper { */ InventoryByMTAndDepository getTodayInventoryByDidAndMt(Map map); + /** + * 获取当前仓库下的库存数量 + * @param map 待查询数据 + * @return + */ + List getTodayInventoryByDid(Map map); + + + /** * 根据条件修改状态 diff --git a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.xml b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.xml index bea434a4..7ab60819 100644 --- a/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.xml +++ b/src/main/java/com/dreamchaser/depository_manage/mapper/DepositoryMapper.xml @@ -400,6 +400,21 @@ + +