|
|
@ -38,6 +38,9 @@ public class DepositoryController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
RoleService roleService; |
|
|
RoleService roleService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
StockTakingService stockTakingService; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取本月之前的月份 |
|
|
* 获取本月之前的月份 |
|
|
* |
|
|
* |
|
|
@ -1415,8 +1418,7 @@ public class DepositoryController { |
|
|
*/ |
|
|
*/ |
|
|
@GetMapping("/findMaterialByDepository") |
|
|
@GetMapping("/findMaterialByDepository") |
|
|
public RestResponse FindMaterialByDepository(@RequestParam("depositoryId") String depositoryId, HttpServletRequest request) { |
|
|
public RestResponse FindMaterialByDepository(@RequestParam("depositoryId") String depositoryId, HttpServletRequest request) { |
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
Boolean allSonDepository = findAllSonDepositoryOfRelevancy(depositoryId, request); |
|
|
Boolean allSonDepository = findAllSonDepository(depositoryId, userToken); |
|
|
|
|
|
return new RestResponse(allSonDepository); |
|
|
return new RestResponse(allSonDepository); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1475,25 +1477,25 @@ public class DepositoryController { |
|
|
/** |
|
|
/** |
|
|
* 根据父级编号查询所有关联信息 |
|
|
* 根据父级编号查询所有关联信息 |
|
|
* |
|
|
* |
|
|
* @param parentid |
|
|
* @param did |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public Boolean findAllSonDepositoryOfRelevancy(String parentid, HttpServletRequest request) { |
|
|
public Boolean findAllSonDepositoryOfRelevancy(String did, HttpServletRequest request) { |
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
// 判断当前仓库是否存在物料
|
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
boolean materialByDepository = findMaterialByDepository(did); |
|
|
param.put("parentId", parentid); |
|
|
// 判断当前仓库是否有相关订单
|
|
|
param.put("state", 1); |
|
|
boolean depositoryRecord = findDepositoryRecord(did, request); |
|
|
boolean materialByDepository = findMaterialByDepository(parentid); |
|
|
|
|
|
Boolean depositoryRecord = findDepositoryRecord(parentid, request); |
|
|
|
|
|
if (materialByDepository || depositoryRecord) { |
|
|
if (materialByDepository || depositoryRecord) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
List<Depository> depositoryRecordPByCondition = depositoryService.findDepositoryByCondition(param, userToken); |
|
|
// 查询当前仓库
|
|
|
for (int i = 0; i < depositoryRecordPByCondition.size(); i++) { |
|
|
Depository depositoryById = depositoryService.findDepositoryById(ObjectFormatUtil.toInteger(did)); |
|
|
String depositoryId = depositoryRecordPByCondition.get(i).getId().toString(); |
|
|
// 查询当前仓库及子仓库
|
|
|
if (!findMaterialByDepository(depositoryId) && !findDepositoryRecord(depositoryId, request)) { |
|
|
List<Integer> childForDepositoryByParent = findChildForDepositoryByParent(depositoryById); |
|
|
findAllSonDepositoryOfRelevancy(depositoryRecordPByCondition.get(i).getId().toString(), request); |
|
|
List<Depository> depositories = depositoryService.selectDepositoryRecordByIds(childForDepositoryByParent); |
|
|
} else { |
|
|
for (Depository depository : depositories) { |
|
|
|
|
|
String depositoryId = depository.getId().toString(); |
|
|
|
|
|
if (findMaterialByDepository(depositoryId) || findDepositoryRecord(depositoryId, request)) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -1503,39 +1505,33 @@ public class DepositoryController { |
|
|
/** |
|
|
/** |
|
|
* 根据仓库编号判断该仓库是否有物品 |
|
|
* 根据仓库编号判断该仓库是否有物品 |
|
|
* |
|
|
* |
|
|
* @param parentId |
|
|
* @param depositoryId 待查询仓库id |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public boolean findMaterialByDepository(String parentId) { |
|
|
public boolean findMaterialByDepository(String depositoryId) { |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
param.put("state", 1); |
|
|
param.put("state", 1); |
|
|
param.put("depositoryId", parentId); |
|
|
param.put("depositoryId", depositoryId); |
|
|
List<InventoryP> materialPByCondition = materialService.findInventory(param); |
|
|
List<InventoryP> materialPByCondition = materialService.findInventory(param); |
|
|
if (materialPByCondition.size() > 0) { |
|
|
return materialPByCondition.size() > 0; |
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据仓库编号查询与其有关的订单信息 |
|
|
* 根据仓库编号查询与其有关的订单信息 |
|
|
* |
|
|
* @param depositoryId 待查询仓库id |
|
|
* @param depositoryId |
|
|
|
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public Boolean findDepositoryRecord(String depositoryId, HttpServletRequest request) { |
|
|
public Boolean findDepositoryRecord(String depositoryId, HttpServletRequest request) { |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
Map<String, Object> param = new HashMap<>(); |
|
|
param.put("depositoryId", depositoryId); |
|
|
param.put("depositoryId", depositoryId); |
|
|
List<DepositoryRecordP> recordPByCondition = depositoryRecordService.findDepositoryRecordPByCondition(param, request); |
|
|
List<ApplicationInRecordP> inRecordPList = depositoryRecordService.findApplicationInRecordByDepository(depositoryId); |
|
|
if (recordPByCondition.size() > 0) { |
|
|
List<ApplicationOutRecordP> outRecordPList = depositoryRecordService.findApplicationOutRecordByDepository(depositoryId); |
|
|
return true; |
|
|
List<StockTaking> stockTakingList = stockTakingService.findStockTakingByCondition(param); |
|
|
} |
|
|
return inRecordPList.size() > 0 || outRecordPList.size() > 0 || stockTakingList.size() > 0; |
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询当前仓库子仓库 |
|
|
* 查询当前仓库子仓库 |
|
|
* |
|
|
|
|
|
* @param parentId |
|
|
* @param parentId |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
@ -1548,6 +1544,12 @@ public class DepositoryController { |
|
|
return new RestResponse(depositoryRecordPByCondition, depositoryService.findCountByCondition(param), 200); |
|
|
return new RestResponse(depositoryRecordPByCondition, depositoryService.findCountByCondition(param), 200); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询当前仓库的管理员 |
|
|
|
|
|
* @param did 待查询仓库 |
|
|
|
|
|
* @param request |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
@GetMapping("/findManagerByDid") |
|
|
@GetMapping("/findManagerByDid") |
|
|
public RestResponse FindManagerByDid(@RequestParam("did") Integer did, HttpServletRequest request) { |
|
|
public RestResponse FindManagerByDid(@RequestParam("did") Integer did, HttpServletRequest request) { |
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
UserByPort userToken = (UserByPort) request.getAttribute("userToken"); |
|
|
@ -1626,4 +1628,44 @@ public class DepositoryController { |
|
|
return new RestResponse("err: " + e.getMessage(), 678, new StatusInfo("失败", "请联系开发人员")); |
|
|
return new RestResponse("err: " + e.getMessage(), 678, new StatusInfo("失败", "请联系开发人员")); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于获取当前仓库的所有子类 |
|
|
|
|
|
* @param d 待查询仓库 |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public List<Integer> findChildForDepositoryByParent(Depository d) { |
|
|
|
|
|
// 用于存储最终返回结果
|
|
|
|
|
|
List<Integer> result = new ArrayList<>(); |
|
|
|
|
|
result.add(d.getId()); |
|
|
|
|
|
// 父级
|
|
|
|
|
|
List<Integer> parentId = new ArrayList<>(); |
|
|
|
|
|
parentId.add(d.getId()); |
|
|
|
|
|
// 查询所有仓库正常使用的仓库
|
|
|
|
|
|
List<Depository> depositoryAll = depositoryService.findDepositoryAll(); |
|
|
|
|
|
for (Depository depository : depositoryAll) { |
|
|
|
|
|
if (isTrueForParent(parentId, depository.getParentId())) { |
|
|
|
|
|
parentId.add(depository.getId()); |
|
|
|
|
|
result.add(depository.getId()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 判断当前id是否在ids中 |
|
|
|
|
|
* |
|
|
|
|
|
* @param parentList 父级列表 |
|
|
|
|
|
* @param id 待判断id |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
public Boolean isTrueForParent(List<Integer> parentList, Integer id) { |
|
|
|
|
|
for (Integer aLong : parentList) { |
|
|
|
|
|
if (Long.compare(aLong, id) == 0) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|