Browse Source

部门资产报表-查询与导出(第三版-plus)

asce 1 year ago
parent
commit
5bc922fd1a

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbAssetInventoryController.java

@@ -194,7 +194,7 @@ public class TbAssetInventoryController extends BaseController
 
         List<DepAssetLossResultDto> result = null;
         try {
-            result = tbAssetInventoryService.inventoryDepAssetById(depId);
+            result = tbAssetInventoryService.inventoryDepAssetById(deptId);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 5 - 12
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbAssetInventoryServiceImpl.java

@@ -470,18 +470,9 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
      */
     public List<DepAssetLossResultDto> inventoryDepAssetById(String depId) throws Exception {
 
-       /* 本想这样写sql的:
-        select inventory_metadata metadata
-        from tb_inventory_detail
-        where order_number in
-            (select order_number
-            from tb_asset_inventory
-            where inventory_status = 2 and inventory_department = 206
-            order by inventory_date desc
-            limit 0,2)
-        但是,语法不支持,会报错:This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
-        暂时选择以下方法解决,要连接四次数据库,很可能需要优化
-        */
+        /**
+           在for循环中查询数据库,数据量多的时候时间花销大
+         */
 
         List<String> childDeptIdList = tbAssetInventoryMapper.getChildDeptId(depId);
         if(childDeptIdList == null || childDeptIdList.size()==0){
@@ -508,6 +499,8 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
                 resultDto.setDeptName(new_inv.getDeptName());
             }
             resultDtoList.add(resultDto);
+            //清空列表数据
+            invs.clear();
         }