|
@@ -468,7 +468,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
|
|
|
* @param depId
|
|
|
* @return
|
|
|
*/
|
|
|
- public DepAssetLossResultDto inventoryDepAssetById(String depId){
|
|
|
+ public List<DepAssetLossResultDto> inventoryDepAssetById(String depId) throws Exception {
|
|
|
|
|
|
/* 本想这样写sql的:
|
|
|
select inventory_metadata metadata
|
|
@@ -483,27 +483,38 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
|
|
|
暂时选择以下方法解决,要连接四次数据库,很可能需要优化
|
|
|
*/
|
|
|
|
|
|
+ List<String> childDeptIdList = tbAssetInventoryMapper.getChildDeptId(depId);
|
|
|
+ if(childDeptIdList == null || childDeptIdList.size()==0){
|
|
|
+ throw new Exception("不存在该部门id");
|
|
|
+ }
|
|
|
+ List<DepAssetLossResultDto> resultDtoList = new ArrayList<>();
|
|
|
//历史盘点计划编码和日期
|
|
|
- List<AssetInvOrderDto> invs = tbAssetInventoryMapper.getOrderNumberByDepId(depId);
|
|
|
-
|
|
|
- //前前一次盘点计划编码和日期
|
|
|
-// TbAssetInventoryDTO old_inv = tbAssetInventoryMapper.getOrderNumberByDepId(depId);
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(invs) || invs.size()==0) return null;
|
|
|
+ List<AssetInvOrderDto> invs;
|
|
|
+ for (String ch_depId : childDeptIdList) {
|
|
|
+ invs = tbAssetInventoryMapper.getOrderNumberByDepId(ch_depId);
|
|
|
+ if (ObjectUtil.isEmpty(invs) || invs.size()==0){
|
|
|
+ continue;
|
|
|
+ };
|
|
|
|
|
|
- AssetInvOrderDto new_inv = invs.get(0);
|
|
|
+ AssetInvOrderDto new_inv = invs.get(0);
|
|
|
// System.out.println("new-盘点计划:"+new_inv);
|
|
|
- AssetInvOrderDto old_inv = null;
|
|
|
- if (invs.size()>1) old_inv = invs.get(1);
|
|
|
+ AssetInvOrderDto old_inv = null;
|
|
|
+ if (invs.size()>1) old_inv = invs.get(1);
|
|
|
|
|
|
- DepAssetLossResultDto resultDto = null;
|
|
|
+ DepAssetLossResultDto resultDto = null;
|
|
|
|
|
|
- if (!ObjectUtil.isNull(new_inv)) {
|
|
|
- resultDto = compareResult(new_inv,old_inv);
|
|
|
+ if (!ObjectUtil.isNull(new_inv)) {
|
|
|
+ resultDto = compareResult(new_inv,old_inv);
|
|
|
+ resultDto.setDeptName(new_inv.getDeptName());
|
|
|
+ }
|
|
|
+ resultDtoList.add(resultDto);
|
|
|
}
|
|
|
|
|
|
|
|
|
- return resultDto;
|
|
|
+ //前前一次盘点计划编码和日期
|
|
|
+// TbAssetInventoryDTO old_inv = tbAssetInventoryMapper.getOrderNumberByDepId(depId);
|
|
|
+
|
|
|
+ return resultDtoList;
|
|
|
}
|
|
|
|
|
|
/**
|