Quellcode durchsuchen

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	ruoyi-admin/src/main/resources/mapper/inventory/TbAssetInventoryMapper.xml
“study” vor 1 Jahr
Ursprung
Commit
caaed467bb

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

@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.ruoyi.common.code.QRCodeUtils;
 import com.ruoyi.common.code.QrDTO;
 import com.ruoyi.common.utils.file.Folder2ZipUtils;
+import com.ruoyi.inventory.domain.dto.DepAssetLossResultDto;
 import com.ruoyi.inventory.domain.dto.TakeStockDTO;
 import com.ruoyi.inventory.domain.dto.TbAssetInventoryDTO;
 import com.ruoyi.inventory.domain.enums.InventoryPlanResult;
@@ -30,7 +31,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
 
 /**
  * 资产盘点记录Controller
- * 
+ *
  * @author ydl
  * @date 2023-06-01
  */
@@ -169,4 +170,23 @@ public class TbAssetInventoryController extends BaseController
         qrDTO.setValue(tbAssetInventory.getOrderNumber());
         QRCodeUtils.createCodeToOutputStream(qrDTO, response.getOutputStream());
     }
+
+    /**
+     * 查询部门资产报表(两次盘点间的资产损耗)
+     * @param depId 部门ID
+     * @return
+     */
+//    我粘贴过来的 @PreAuthorize("@ss.hasPermi('inventory:inventory:query')")
+    @GetMapping("/getDepAssetLossTb")
+    public AjaxResult getDepAssetLossTb(String depId){
+        List<DepAssetLossResultDto> results = tbAssetInventoryService.inventoryDepAssetById(depId);
+        return success(results);
+    }
+
+    @PostMapping("/exportDepAssetLossTb/{deptId}")
+    public void exportDepAssetLossTb(HttpServletResponse response, @PathVariable("deptId") String depId){
+        List<DepAssetLossResultDto> results = tbAssetInventoryService.inventoryDepAssetById(depId);
+        ExcelUtil<DepAssetLossResultDto> util = new ExcelUtil<DepAssetLossResultDto>(DepAssetLossResultDto.class);
+        util.exportExcel(response, results, "近两次资产盘点损耗统计");
+    }
 }

+ 16 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/dto/AssetInvOrderDto.java

@@ -0,0 +1,16 @@
+package com.ruoyi.inventory.domain.dto;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public class AssetInvOrderDto {
+
+    private String orderNumber;
+    private String inventDate;
+}

+ 43 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/dto/DepAssetLossDto.java

@@ -0,0 +1,43 @@
+package com.ruoyi.inventory.domain.dto;
+
+import com.ruoyi.common.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * 部门资产损耗数据对象
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DepAssetLossDto  {
+
+    /** 资产名称 */
+    @Excel(name = "资产名称")
+    private String assetName;
+
+    /** 位置 */
+    @Excel(name = "位置")
+    private List<String> locations;
+
+    /** 类别 */
+    @Excel(name = "类别")
+    private String category;
+
+    /** 现存数量 */
+    @Excel(name = "现存数量")
+    private int nowQuantity;
+
+    /** 损耗数量 */
+    @Excel(name = "损耗数量")
+    private int lossQuantity;
+
+    /** 损耗值 */
+    @Excel(name = "损耗值")
+    private double lossVal;
+
+
+}

+ 34 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/dto/DepAssetLossResultDto.java

@@ -0,0 +1,34 @@
+package com.ruoyi.inventory.domain.dto;
+
+import com.ruoyi.common.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Data
+public class DepAssetLossResultDto {
+
+    /**
+     * 此次盘点计算出的损耗总值
+     */
+    @Excel(name = "损耗总值")
+    private double totalLossVal;
+
+    /**
+     * 盘点时间
+     */
+    @Excel(name = "盘点时间")
+    private String date;
+
+    /**
+     * 资产盘点结果集
+     */
+    @Excel(name = "资产盘点结果集")
+    private List<DepAssetLossDto> assetResultList;
+
+
+}

+ 15 - 8
ruoyi-admin/src/main/java/com/ruoyi/inventory/mapper/TbAssetInventoryMapper.java

@@ -2,20 +2,23 @@ package com.ruoyi.inventory.mapper;
 
 import java.util.List;
 import com.ruoyi.inventory.domain.TbAssetInventory;
+import com.ruoyi.inventory.domain.TbInventoryDetail;
+import com.ruoyi.inventory.domain.dto.AssetInvOrderDto;
+import com.ruoyi.inventory.domain.dto.DepAssetLossDto;
 import com.ruoyi.inventory.domain.dto.TbAssetInventoryDTO;
 import org.apache.ibatis.annotations.Param;
 
 /**
  * 资产盘点记录Mapper接口
- * 
+ *
  * @author ydl
  * @date 2023-06-01
  */
-public interface TbAssetInventoryMapper 
+public interface TbAssetInventoryMapper
 {
     /**
      * 查询资产盘点记录
-     * 
+     *
      * @param id 资产盘点记录主键
      * @return 资产盘点记录
      */
@@ -27,7 +30,7 @@ public interface TbAssetInventoryMapper
 
     /**
      * 查询资产盘点记录列表
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 资产盘点记录集合
      */
@@ -40,7 +43,7 @@ public interface TbAssetInventoryMapper
     public List<TbAssetInventory> selectTbAssetInventoryListBy();
     /**
      * 新增资产盘点记录
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 结果
      */
@@ -48,7 +51,7 @@ public interface TbAssetInventoryMapper
 
     /**
      * 修改资产盘点记录
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 结果
      */
@@ -56,7 +59,7 @@ public interface TbAssetInventoryMapper
 
     /**
      * 删除资产盘点记录
-     * 
+     *
      * @param id 资产盘点记录主键
      * @return 结果
      */
@@ -64,7 +67,7 @@ public interface TbAssetInventoryMapper
 
     /**
      * 批量删除资产盘点记录
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
@@ -77,4 +80,8 @@ public interface TbAssetInventoryMapper
      * @return 资产盘点记录集合
      */
     public List<TbAssetInventoryDTO> selectTbAssetInventoryDTOList(TbAssetInventoryDTO dto);
+
+    List<String> getDepAssetByOrderNumber(String orderNumber);
+
+    List<AssetInvOrderDto> getOrderNumberByDepId(@Param("depId") String depId);
 }

+ 11 - 8
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/ITbAssetInventoryService.java

@@ -9,15 +9,15 @@ import javax.servlet.http.HttpServletResponse;
 
 /**
  * 资产盘点记录Service接口
- * 
+ *
  * @author ydl
  * @date 2023-06-01
  */
-public interface ITbAssetInventoryService 
+public interface ITbAssetInventoryService
 {
     /**
      * 查询资产盘点记录
-     * 
+     *
      * @param id 资产盘点记录主键
      * @return 资产盘点记录
      */
@@ -26,7 +26,7 @@ public interface ITbAssetInventoryService
     TbAssetInventory selectTbAssetInventoryByNumber(String num);
     /**
      * 查询资产盘点记录列表
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 资产盘点记录集合
      */
@@ -34,7 +34,7 @@ public interface ITbAssetInventoryService
 
     /**
      * 新增资产盘点记录
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 结果
      */
@@ -50,7 +50,7 @@ public interface ITbAssetInventoryService
 
     /**
      * 修改资产盘点记录
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 结果
      */
@@ -58,7 +58,7 @@ public interface ITbAssetInventoryService
 
     /**
      * 批量删除资产盘点记录
-     * 
+     *
      * @param ids 需要删除的资产盘点记录主键集合
      * @return 结果
      */
@@ -66,7 +66,7 @@ public interface ITbAssetInventoryService
 
     /**
      * 删除资产盘点记录信息
-     * 
+     *
      * @param id 资产盘点记录主键
      * @return 结果
      */
@@ -79,4 +79,7 @@ public interface ITbAssetInventoryService
      * @return 资产盘点记录集合
      */
     public List<TbAssetInventoryDTO> selectTbAssetInventoryDTOList(TbAssetInventoryDTO dto);
+
+
+    List inventoryDepAssetById(String depId);
 }

+ 145 - 9
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbAssetInventoryServiceImpl.java

@@ -1,9 +1,11 @@
 package com.ruoyi.inventory.service.impl;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.ruoyi.asset.domain.TbAssetInformation;
@@ -11,8 +13,7 @@ import com.ruoyi.asset.domain.TbLocation;
 import com.ruoyi.asset.mapper.TbAssetInformationMapper;
 import com.ruoyi.asset.mapper.TbLocationMapper;
 import com.ruoyi.inventory.domain.TbInventoryDetail;
-import com.ruoyi.inventory.domain.dto.TakeStockDTO;
-import com.ruoyi.inventory.domain.dto.TbAssetInventoryDTO;
+import com.ruoyi.inventory.domain.dto.*;
 import com.ruoyi.inventory.mapper.TbInventoryDetailMapper;
 import com.ruoyi.utils.IDUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
 import com.ruoyi.inventory.mapper.TbAssetInventoryMapper;
 import com.ruoyi.inventory.domain.TbAssetInventory;
 import com.ruoyi.inventory.service.ITbAssetInventoryService;
+import org.springframework.web.bind.annotation.RequestMapping;
 
 import static com.ruoyi.inventory.domain.enums.InventoryPlanResult.*;
 import static com.ruoyi.inventory.domain.enums.InventoryPlanStatus.PLAN_FINISH;
@@ -29,7 +31,7 @@ import static com.ruoyi.inventory.domain.enums.InventoryStatus.UNCOUNTED;
 
 /**
  * 资产盘点记录Service业务层处理
- * 
+ *
  * @author ydl
  * @date 2023-06-01
  */
@@ -50,7 +52,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
     /**
      * 查询资产盘点记录
-     * 
+     *
      * @param id 资产盘点记录主键
      * @return 资产盘点记录
      */
@@ -75,7 +77,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
     /**
      * 查询资产盘点记录列表
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 资产盘点记录
      */
@@ -111,7 +113,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
     /**
      * 新增资产盘点记录
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 结果
      */
@@ -358,7 +360,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
     /**
      * 修改资产盘点记录
-     * 
+     *
      * @param tbAssetInventory 资产盘点记录
      * @return 结果
      */
@@ -412,7 +414,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
     /**
      * 批量删除资产盘点记录
-     * 
+     *
      * @param ids 需要删除的资产盘点记录主键
      * @return 结果
      */
@@ -426,7 +428,7 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
 
     /**
      * 删除资产盘点记录信息
-     * 
+     *
      * @param id 资产盘点记录主键
      * @return 结果
      */
@@ -458,4 +460,138 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         String locationName = Arrays.toString(tbLocations.stream().map(TbLocation::getName).toArray());
         tbAssetInventoryDTO.setInventoryLocationName(locationName);
     }
+
+    /**
+     * 根据部门id统计最近两次盘点间的部门资产损耗情况
+     * @param depId
+     * @return
+     */
+    public List<DepAssetLossResultDto> inventoryDepAssetById(String depId){
+
+       /* 本想这样写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'
+        暂时选择以下方法解决,但要连接四次数据库,很可能需要优化
+        */
+
+        //历史盘点计划编码和日期
+        List<AssetInvOrderDto> invs = tbAssetInventoryMapper.getOrderNumberByDepId(depId);
+        //前前一次盘点计划编码和日期
+//        TbAssetInventoryDTO old_inv = tbAssetInventoryMapper.getOrderNumberByDepId(depId);
+
+        if (ObjectUtil.isEmpty(invs) || invs.size()==0) return null;
+
+        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);
+
+        DepAssetLossResultDto old_resultDto = null;
+        DepAssetLossResultDto new_resultDto = null;
+        if (new_inv!=null){
+            new_resultDto = lossResult(new_inv);
+        }
+        if (!ObjectUtil.isNull(old_inv)) old_resultDto = lossResult(old_inv);
+
+        List<DepAssetLossResultDto> results = new ArrayList<>();
+        results.add(old_resultDto);
+        results.add(new_resultDto);
+        return results;
+    }
+
+    /**
+     * 处理资产信息,统计每一样资产的损耗情况
+     * @param assetInfos
+     * @param assetMap
+     * @param lossValMap
+     */
+    private void handleAssetInfo(List<TbAssetInformation> assetInfos,
+                                 Map<String, DepAssetLossDto> assetMap,
+                                 Map<String, Double> lossValMap){
+        for (TbAssetInformation asset : assetInfos) {
+            if (!assetMap.containsKey(asset.getName())){
+
+                DepAssetLossDto lossDto = new DepAssetLossDto();
+                lossDto.setAssetName(asset.getName());
+                lossDto.setCategory(asset.getCategoryName());
+                lossDto.setNowQuantity(asset.getQuantity());
+
+                List<String> locations = new ArrayList<>();
+                if (asset.getManageStatus()==7) {
+                    lossDto.setLossQuantity(asset.getQuantity());
+                    locations.add(asset.getAncestorLocationName()+asset.getParentLocationName()+asset.getLocationName());
+                    lossDto.setLocations(locations);
+                    lossValMap.put(asset.getName(),(asset.getOriginalValue()-asset.getNetValue())*asset.getQuantity());
+                }
+                assetMap.put(asset.getName(),lossDto);
+            } else {
+                DepAssetLossDto lossDto = assetMap.get(asset.getName());
+                lossDto.setNowQuantity(lossDto.getNowQuantity()+asset.getQuantity());
+                if (asset.getManageStatus()==7) {
+                    lossDto.setLossQuantity(lossDto.getLossQuantity()+asset.getQuantity());
+                    lossDto.getLocations()
+                            .add(asset.getAncestorLocationName()+asset.getParentLocationName()+asset.getLocationName());
+                    lossValMap.put(asset.getName(),
+                                   Double.sum(lossValMap.get(asset.getName()),
+                                           (asset.getOriginalValue()-asset.getNetValue())*asset.getQuantity()));
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 根据盘点计划的编号查询出资产元数据,并统计损耗
+     * @param invPlan
+     * @return
+     */
+    private DepAssetLossResultDto lossResult(AssetInvOrderDto invPlan){
+
+        List<String> asset_list = tbAssetInventoryMapper.getDepAssetByOrderNumber(invPlan.getOrderNumber());
+        //盘点资产详细信息-元数据
+        List<TbAssetInformation> assetInfos = new ArrayList<>();
+        //json数据 --> java对象
+        for (String asset : asset_list) {
+            System.out.println(asset);
+            assetInfos.add(JSONUtil.toBean(asset, TbAssetInformation.class));
+        }
+
+        Map<String, DepAssetLossDto> assetMap = new HashMap<>();
+        //各资产损耗值map
+        HashMap<String, Double> lossValMap = new HashMap<>();
+        //统计两次盘点计划每一样资产(同资产名)的相关信息
+        handleAssetInfo(assetInfos,assetMap,lossValMap);
+        //将map中统计好的资产信息转到list
+        ArrayList<DepAssetLossDto> assetResultList = new ArrayList<>();
+        Set<Map.Entry<String, DepAssetLossDto>> entrySet = assetMap.entrySet();
+        for (Map.Entry<String, DepAssetLossDto> entry : entrySet) {
+            DepAssetLossDto dto = entry.getValue();
+            if (lossValMap.containsKey(dto.getAssetName()))dto.setLossVal(lossValMap.get(dto.getAssetName()));
+            assetResultList.add(dto);
+        }
+        //计算损耗总值
+        Set<Map.Entry<String, Double>> lossValSet = lossValMap.entrySet();
+        double lossVal = 0.0;
+        for (Map.Entry<String, Double> entry : lossValSet) {
+            lossVal+=entry.getValue();
+        }
+
+//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        //封装结果
+        DepAssetLossResultDto resultDto = new DepAssetLossResultDto();
+        resultDto.setTotalLossVal(lossVal);
+        resultDto.setAssetResultList(assetResultList);
+        resultDto.setDate(invPlan.getInventDate());
+
+        return resultDto;
+    }
+
+
 }

+ 7 - 7
ruoyi-admin/src/main/resources/application-druid.yml

@@ -8,16 +8,16 @@ spring:
             master:
 #                url: jdbc:mysql://139.9.50.163:3306/rfid_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
 #                password: ydl@123456
-                url: jdbc:mysql://127.0.0.1:3306/rfid-hotel-manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-                password: mysql@123456
+                url: jdbc:mysql://139.9.50.163:3306/rfid_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+                password: ydl@123456
                 username: root
             # 从库数据源
             slave:
                 # 从数据源开关/默认关闭
                 enabled: false
-                url: 
-                username: 
-                password: 
+                url:
+                username:
+                password:
             # 初始连接数
             initialSize: 5
             # 最小连接池数量
@@ -41,7 +41,7 @@ spring:
             testWhileIdle: true
             testOnBorrow: false
             testOnReturn: false
-            webStatFilter: 
+            webStatFilter:
                 enabled: true
             statViewServlet:
                 enabled: true
@@ -60,4 +60,4 @@ spring:
                     merge-sql: true
                 wall:
                     config:
-                        multi-statement-allow: true
+                        multi-statement-allow: true

+ 6 - 6
ruoyi-admin/src/main/resources/application.yml

@@ -60,7 +60,7 @@ spring:
   messages:
     # 国际化资源文件路径
     basename: i18n/messages
-  profiles: 
+  profiles:
     active: druid
   # 文件上传
   servlet:
@@ -79,7 +79,7 @@ spring:
     # 地址
     host: 127.0.0.1
     # 密码
-    password: redis@123456
+    password:
     # 端口,默认为6379
     port: 6379
     # 数据库索引
@@ -105,7 +105,7 @@ token:
     secret: abcdefghijklmnopqrstuvwxyz
     # 令牌有效期(默认30分钟)
     expireTime: 30
-  
+
 # MyBatis配置
 mybatis:
     # 搜索指定包别名
@@ -116,10 +116,10 @@ mybatis:
     configLocation: classpath:mybatis/mybatis-config.xml
 
 # PageHelper分页插件
-pagehelper: 
+pagehelper:
   helperDialect: mysql
   supportMethodsArguments: true
-  params: count=countSql 
+  params: count=countSql
 
 # Swagger配置
 swagger:
@@ -129,7 +129,7 @@ swagger:
   pathMapping: /dev-api
 
 # 防止XSS攻击
-xss: 
+xss:
   # 过滤开关
   enabled: true
   # 排除链接(多个用逗号分隔)

+ 17 - 1
ruoyi-admin/src/main/resources/mapper/inventory/TbAssetInventoryMapper.xml

@@ -188,4 +188,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="recordStatus != null "> and a.record_status = #{recordStatus}</if>
         </where>
     </select>
-</mapper>
+
+
+
+    <select id="getDepAssetByOrderNumber" parameterType="String" resultType="String">
+        select inventory_metadata metadata
+        from tb_inventory_detail
+        where order_number = #{orderNumber}
+    </select>
+
+    <select id="getOrderNumberByDepId" parameterType="String" resultType="com.ruoyi.inventory.domain.dto.AssetInvOrderDto">
+        select order_number orderNumber,inventory_date inventDate
+        from tb_asset_inventory
+        where inventory_status = 2 and inventory_department = #{depId}
+        order by inventory_date desc
+    </select>
+    <!-- limit #{whichOne},1 -->
+</mapper>

+ 9 - 0
ruoyi-ui/src/api/inventory/inventory.js

@@ -55,3 +55,12 @@ export function delInventory(id) {
 export function selectQrCode(number, v) {
   return `/inventory/inventory/code/${number}?v=${v}`
 }
+
+
+// 删除资产盘点记录
+export function getDepAssetLossTb(id) {
+  return request({
+    url: '/inventory/inventory/getDepAssetLossTb?depId=' + id,
+    method: 'get'
+  })
+}

+ 96 - 1
ruoyi-ui/src/views/inventory/inventory/index.vue

@@ -134,6 +134,16 @@
           v-hasPermi="['inventory:inventory:export']"
         >导出报表</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="onOpenLoss"
+          v-hasPermi="['inventory:inventory:export']"
+        >资产报表</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -278,6 +288,51 @@
       <UserSearch @submit="onSelectUser" @cancel="() => {openUserSearch = false}" v-if="openUserSearch"></UserSearch>
     </el-dialog>
 
+    <el-dialog :visible.sync="openLoss" title="资产报表查看">
+      <el-row>
+        <el-form>
+          <el-form-item label="盘点部门" prop="inventoryDepartment">
+            <treeselect
+              v-model="deptId"
+              :options="deptOptions"
+              placeholder="选择盘点部门"
+              @keyup.enter.native="onQueryLoss"
+            />
+          </el-form-item>
+        </el-form>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="onQueryLoss">搜索</el-button>
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="onLossExport"
+          v-hasPermi="['inventory:inventory:export']"
+        >导出</el-button>
+      </el-row>
+      <el-row>
+        <el-table :data="lossData">
+          <el-table-column
+            prop="totalLossVal"
+            label="损耗总额"
+            width="100">
+          </el-table-column>
+          <el-table-column
+            prop="date"
+            label="盘点时间"
+            width="100">
+          </el-table-column>
+          <el-table-column label="资产盘点结果集">
+            <el-table-column
+              prop="date"
+              label="盘点时间"
+              width="100">
+            </el-table-column>
+          </el-table-column>
+        </el-table>
+      </el-row>
+    </el-dialog>
+
     <el-dialog title="导出报表" :visible.sync="openExport" width="360px">
       <el-form ref="form" :model="exportParams" label-width="80px">
         <el-form-item label="盘点部门" prop="inventoryDepartment">
@@ -310,7 +365,7 @@
 
 <script>
 import { deptTreeSelect } from '@/api/system/user.js'
-import { listInventory, getInventory, delInventory, addInventory, updateInventory,selectQrCode } from "@/api/inventory/inventory";
+import { listInventory, getInventory, delInventory, addInventory, updateInventory,selectQrCode,getDepAssetLossTb } from "@/api/inventory/inventory";
 import { treeSelect } from "@/api/asset/location";
 import { listDept } from "@/api/system/dept";
 import UserSearch from '@/components/SysUserSearch/index.vue'
@@ -371,6 +426,23 @@ export default {
         inventoryLocation: null,
         recordStatus: 1,
       },
+      openLoss: false,
+      deptId: null,
+      lossData: [
+        {
+          totalLossVal: null,
+          date: null,
+          assetResultList: [
+            {
+              assetName: null,
+              category: null,
+              nowQuantity: null,
+              lossQuantity: null,
+              lossVal: null
+            }
+          ]
+        }
+      ],
       pickerOptions: {
         disabledDate(time) {
           return time.getTime() < Date.now() - 8.64e7;
@@ -430,6 +502,29 @@ export default {
       }, `资产盘点报表_${new Date().getTime()}.xlsx`)
       this.openExport = false
     },
+    onOpenLoss() {
+      this.openLoss = true
+    },
+    onQueryLoss() {
+      if (this.deptId === null) {
+        this.$modal.msgWarning("部门不能为空");
+        return
+      }
+      getDepAssetLossTb(this.deptId).then(res => {
+        this.lossData = res.data
+        console.log('资产报表', this.lossData)
+      })
+    },
+    onLossExport() {
+      if (this.deptId === null) {
+        this.$modal.msgWarning("部门不能为空");
+        return
+      }
+      const deptId = this.deptId
+      this.download('inventory/inventory/exportDepAssetLossTb/' + deptId, {
+      }, `资产报表_${new Date().getTime()}.xlsx`)
+      this.openExport = false
+    },
     /** 查询部门下拉树结构 */
     getDeptTree() {
       deptTreeSelect().then((response) => {