|
|
|
@ -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<String, Object> map) { |
|
|
|
if(map.containsKey("materialTypeId")){ |
|
|
|
Long materialTypeId = ObjectFormatUtil.toLong(map.get("materialTypeId")); |
|
|
|
List<Long> childForMaterialTypeByParent = materialTypeService.findChildForMaterialTypeByParent(materialTypeId); |
|
|
|
map.put("materialTypeIds",childForMaterialTypeByParent); |
|
|
|
map.remove("materialTypeId"); |
|
|
|
} |
|
|
|
List<Material> 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<Integer> 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<Integer> allChildDepositoryById = depositoryService.findAllChildDepositoryById(depositoryId, userToken); |
|
|
|
map.put("depositoryIds", allChildDepositoryById); |
|
|
|
map.remove("depositoryId"); |
|
|
|
} |
|
|
|
if(map.containsKey("materialTypeId")){ |
|
|
|
Long materialTypeId = ObjectFormatUtil.toLong(map.get("materialTypeId")); |
|
|
|
List<Long> 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<Integer> depositoryIdList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userToken); |
|
|
|
List<Integer> tempDepositoryID = new ArrayList<>(); |
|
|
|
for (InventoryP inventory:inventoryPS |
|
|
|
) { |
|
|
|
for (InventoryP inventory : inventoryPS |
|
|
|
) { |
|
|
|
tempDepositoryID.add(inventory.getDepositoryId()); |
|
|
|
} |
|
|
|
tempDepositoryID = (List<Integer>) CollectionUtils.union(depositoryIdList,tempDepositoryID); |
|
|
|
tempDepositoryID = (List<Integer>) CollectionUtils.union(depositoryIdList, tempDepositoryID); |
|
|
|
List<Depository> depositoryByIds = depositoryService.findDepositoryByIds(tempDepositoryID); |
|
|
|
InventoryP materialP = inventoryPS.get(0); |
|
|
|
materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition); |
|
|
|
@ -427,14 +449,14 @@ public class MaterialController { |
|
|
|
List<Integer> depositoryIdList = roleService.findDepositoryIdForUserHas(userToken); |
|
|
|
// 获取该用户额外可见的仓库
|
|
|
|
List<Integer> tempDepositoryIdlist = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userToken); |
|
|
|
depositoryIdList= (List<Integer>) CollectionUtils.union(tempDepositoryIdlist,depositoryIdList); |
|
|
|
depositoryIdList = (List<Integer>) CollectionUtils.union(tempDepositoryIdlist, depositoryIdList); |
|
|
|
// 用于存储存在库存的仓库id
|
|
|
|
List<Integer> showDepository = new ArrayList<>(); |
|
|
|
for (Integer depositoryId : depositoryIdList |
|
|
|
) { |
|
|
|
param.put("depositoryId", depositoryId); |
|
|
|
List<InventoryP> 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<Depository> 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<Integer> depositoryIdList = roleService.findDepositoryIdForUserHas(userToken); |
|
|
|
|
|
|
|
List<Integer> tempDepositoryIDList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userToken); |
|
|
|
depositoryIdList = (List<Integer>) CollectionUtils.union(tempDepositoryIDList,depositoryIdList); |
|
|
|
depositoryIdList = (List<Integer>) 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<Depository> 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<Integer> depositoryIdList = roleService.findDepositoryIdForUserHas(userByPort); |
|
|
|
List<Integer> tempDepositoryIdList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userByPort); |
|
|
|
depositoryIdList = (List<Integer>) CollectionUtils.union(depositoryIdList,tempDepositoryIdList); |
|
|
|
depositoryIdList = (List<Integer>) CollectionUtils.union(depositoryIdList, tempDepositoryIdList); |
|
|
|
|
|
|
|
|
|
|
|
for (Integer depositoryId : depositoryIdList) { |
|
|
|
@ -1063,7 +1083,7 @@ public class MaterialController { |
|
|
|
if (materialByBarCode != null) { |
|
|
|
List<Integer> depositoryIdList = roleService.findDepositoryIdForUserHas(userByPort); |
|
|
|
List<Integer> tempDepositoryIdList = roleService.findDepositoryIdForWareHouseVisiblePermissionByUser(userByPort); |
|
|
|
depositoryIdList = (List<Integer>) CollectionUtils.union(depositoryIdList,tempDepositoryIdList); |
|
|
|
depositoryIdList = (List<Integer>) CollectionUtils.union(depositoryIdList, tempDepositoryIdList); |
|
|
|
List<PlaceP> placePList = new ArrayList<>(); |
|
|
|
for (Integer depositoryId : depositoryIdList) { |
|
|
|
boolean isExist = false; |
|
|
|
|