Ver código fonte

优化前端盘点计划字段展示、盘点记录信息展示

LinWuTai 1 ano atrás
pai
commit
d564806aaa
28 arquivos alterados com 922 adições e 550 exclusões
  1. 15 2
      ruoyi-admin/src/main/java/com/ruoyi/asset/controller/TbAssetInformationController.java
  2. 101 8
      ruoyi-admin/src/main/java/com/ruoyi/asset/domain/TbAssetInformation.java
  3. 13 0
      ruoyi-admin/src/main/java/com/ruoyi/asset/domain/dto/AssetEpcInfo.java
  4. 1 1
      ruoyi-admin/src/main/java/com/ruoyi/asset/mapper/TbLocationMapper.java
  5. 42 37
      ruoyi-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetInformationServiceImpl.java
  6. 24 9
      ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbAssetInventoryController.java
  7. 89 2
      ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbInventoryDetailController.java
  8. 12 138
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/TbAssetInventory.java
  9. 13 5
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/TbInventoryDetail.java
  10. 77 0
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/dto/AssetInventoryStatement.java
  11. 50 0
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryPlanResult.java
  12. 47 0
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryPlanStatus.java
  13. 47 0
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryResult.java
  14. 47 0
      ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryStatus.java
  15. 16 0
      ruoyi-admin/src/main/java/com/ruoyi/inventory/mapper/TbInventoryDetailMapper.java
  16. 3 1
      ruoyi-admin/src/main/java/com/ruoyi/inventory/service/ITbAssetInventoryService.java
  17. 167 249
      ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbAssetInventoryServiceImpl.java
  18. 4 7
      ruoyi-admin/src/main/java/com/ruoyi/visitor/controller/VController.java
  19. 3 10
      ruoyi-admin/src/main/resources/mapper/asset/TbAssetInformationMapper.xml
  20. 37 17
      ruoyi-admin/src/main/resources/mapper/inventory/TbAssetInventoryMapper.xml
  21. 22 3
      ruoyi-admin/src/main/resources/mapper/inventory/TbInventoryDetailMapper.xml
  22. 2 2
      ruoyi-common/pom.xml
  23. 1 1
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  24. 4 0
      ruoyi-ui/src/api/inventory/inventory.js
  25. 2 0
      ruoyi-ui/src/components/asset/assetCard.vue
  26. 4 4
      ruoyi-ui/src/views/asset/information/index.vue
  27. 45 14
      ruoyi-ui/src/views/inventory/detail/index.vue
  28. 34 40
      ruoyi-ui/src/views/inventory/inventory/index.vue

+ 15 - 2
ruoyi-admin/src/main/java/com/ruoyi/asset/controller/TbAssetInformationController.java

@@ -11,6 +11,7 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.ruoyi.asset.domain.TbLocation;
+import com.ruoyi.asset.domain.dto.AssetEpcInfo;
 import com.ruoyi.asset.domain.dto.PrintDTO;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.label.domain.TbLabelModelInfo;
@@ -131,8 +132,20 @@ public class TbAssetInformationController extends BaseController
         for (TbAssetInformation tbAssetInformation : tbAssetInformationList) {
             // 然后再转回对象,便不会影响到原对象
             PTXLabelInfo ptxLabelInfo = JSONUtil.toBean(ptxLabelInfoModel, PTXLabelInfo.class);
-            ptxLabelInfo = ptxService.filterInfo(ptxLabelInfo, tbAssetInformation);
-            ptxLabelInfos.add(ptxLabelInfo);
+            Integer quantity = tbAssetInformation.getQuantity();
+            if (quantity != null && quantity > 1) {
+                List<AssetEpcInfo> childNumberInfo = tbAssetInformation.getChildNumberInfo();
+                for (AssetEpcInfo assetEpcInfo : childNumberInfo) {
+                    tbAssetInformation.setNumber(assetEpcInfo.getNumber());
+                    tbAssetInformation.setEpc(assetEpcInfo.getEpc());
+                    tbAssetInformation.setEpcReplenishLength(assetEpcInfo.getEpcReplenishLength());
+                    ptxLabelInfo = ptxService.filterInfo(ptxLabelInfo, tbAssetInformation);
+                    ptxLabelInfos.add(ptxLabelInfo);
+                }
+            } else {
+                ptxLabelInfo = ptxService.filterInfo(ptxLabelInfo, tbAssetInformation);
+                ptxLabelInfos.add(ptxLabelInfo);
+            }
         }
 
         for (PTXLabelInfo ptxLabelInfo : ptxLabelInfos) {

+ 101 - 8
ruoyi-admin/src/main/java/com/ruoyi/asset/domain/TbAssetInformation.java

@@ -1,12 +1,12 @@
 package com.ruoyi.asset.domain;
 
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
+import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.core.util.HexUtil;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.asset.domain.dto.AssetEpcInfo;
 import lombok.*;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
@@ -222,7 +222,7 @@ public class TbAssetInformation extends BaseEntity
 
     /** 数量 */
     @Excel(name = "数量")
-    private String quantity;
+    private Integer quantity;
 
     /** 计量单位 */
     @Excel(name = "计量单位")
@@ -246,7 +246,100 @@ public class TbAssetInformation extends BaseEntity
     @Excel(name = "开始使用日期", width = 40, dateFormat = "yyyy-MM-dd")
     private Date startDate;
 
-    /** 预留字段j */
-   // @Excel(name = "预留字段j")
-    private String reservedColumnJ;
+    /** 子编码信息 */
+    private List<AssetEpcInfo> childNumberInfo;
+
+    /**
+     * 设置epc相关信息
+     */
+    public void setEpcInfo() {
+        // 将编码转为16进制
+        String epc = HexUtil.encodeHexStr(number, CharsetUtil.CHARSET_UTF_8);
+        // epc补充位
+        int epcReplenishLength = epc.length() % 4;
+        int remainder = epcReplenishLength % 4;
+        if (remainder != 0) {
+            int padding = 4 - remainder;
+            epc = epc + "0".repeat(padding);
+        }
+        // 将epc大写
+        epc = epc.toUpperCase();
+
+        setEpc(epc);
+        setEpcReplenishLength(epcReplenishLength);
+    }
+
+    /**
+     * 解析子编码EPC
+     *
+     * @param epc 子编码epc
+     * @return 资产epc
+     */
+    public static String encodeChildEpc2Epc(String epc) {
+        // 将epc转为编码
+        String hexStr = HexUtil.decodeHexStr(epc);
+        // 分割子编码
+        String[] split = hexStr.split("-");
+        // 将资产编码转换为epc
+        epc = HexUtil.encodeHexStr(split[0], CharsetUtil.CHARSET_UTF_8);
+
+        // epc补充位
+        int epcReplenishLength = epc.length() % 4;
+        int remainder = epcReplenishLength % 4;
+        if (remainder != 0) {
+            int padding = 4 - remainder;
+            epc = epc + "0".repeat(padding);
+        }
+
+        // 将epc大写
+        epc = epc.toUpperCase();
+
+        return epc;
+    }
+
+    /**
+     * 设置子编码
+     */
+    public void setChildNumberInfo() {
+        List<AssetEpcInfo> assetEpcInfos = new ArrayList<>();
+
+        if (quantity == null || quantity <= 1) {
+            AssetEpcInfo assetEpcInfo = new AssetEpcInfo();
+            assetEpcInfo.setNumber(number);
+            assetEpcInfo.setEpc(epc);
+            assetEpcInfo.setEpcReplenishLength(epcReplenishLength);
+
+            assetEpcInfos.add(assetEpcInfo);
+
+            setChildNumberInfo(assetEpcInfos);
+            return;
+        }
+
+        for (int i = 1; i <= quantity; i++) {
+            AssetEpcInfo assetEpcInfo = new AssetEpcInfo();
+
+            String childNumberStr = number + "-" + i;
+            assetEpcInfo.setNumber(childNumberStr);
+
+            // 将编码转为16进制
+            String epc = HexUtil.encodeHexStr(childNumberStr, CharsetUtil.CHARSET_UTF_8);
+            // epc补充位
+            int epcReplenishLength = epc.length() % 4;
+            int remainder = epcReplenishLength % 4;
+            if (remainder != 0) {
+                int padding = 4 - remainder;
+                epc = epc + "0".repeat(padding);
+            }
+
+            // 将epc大写
+            epc = epc.toUpperCase();
+
+            assetEpcInfo.setEpc(epc);
+            assetEpcInfo.setEpcReplenishLength(epcReplenishLength);
+
+            assetEpcInfos.add(assetEpcInfo);
+        }
+
+        setChildNumberInfo(assetEpcInfos);
+    }
 }

+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/asset/domain/dto/AssetEpcInfo.java

@@ -0,0 +1,13 @@
+package com.ruoyi.asset.domain.dto;
+
+
+import lombok.Data;
+
+@Data
+public class AssetEpcInfo {
+    private String number;
+
+    private String epc;
+
+    private Integer epcReplenishLength;
+}

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/asset/mapper/TbLocationMapper.java

@@ -49,7 +49,7 @@ public interface TbLocationMapper
 
     /**
      * 根据Id查询位置及子位置编码
-     * @param id
+     * @param ids
      * @return
      */
     List<String> selectChildTbLocationByIds(@Param("ids") Collection<Long> ids);

+ 42 - 37
ruoyi-admin/src/main/java/com/ruoyi/asset/service/impl/TbAssetInformationServiceImpl.java

@@ -1,27 +1,18 @@
 package com.ruoyi.asset.service.impl;
 
-import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
-import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.util.CharsetUtil;
 import cn.hutool.core.util.HexUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
-import com.ruoyi.asset.domain.TbLocation;
 import com.ruoyi.asset.mapper.TbLocationMapper;
-import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.bean.BeanValidators;
-import com.ruoyi.ptxlib.domain.PTXLabelCode;
-import com.ruoyi.ptxlib.domain.PTXLabelInfo;
-import com.ruoyi.ptxlib.domain.PTXLabelText;
 import com.ruoyi.utils.RecursionUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
@@ -63,17 +54,25 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
     @Override
     public TbAssetInformation selectTbAssetInformationById(Long id)
     {
-        return tbAssetInformationMapper.selectTbAssetInformationById(id);
+        TbAssetInformation tbAssetInformation = tbAssetInformationMapper.selectTbAssetInformationById(id);
+        tbAssetInformation.setChildNumberInfo();
+        return tbAssetInformation;
     }
 
     @Override
     public List<TbAssetInformation> selectTbAssetInformationByIds(List<Long> ids) {
-        return tbAssetInformationMapper.selectTbAssetInformationByIds(ids);
+        List<TbAssetInformation> tbAssetInformations = tbAssetInformationMapper.selectTbAssetInformationByIds(ids);
+        for (TbAssetInformation tbAssetInformation : tbAssetInformations) {
+            tbAssetInformation.setChildNumberInfo();
+        }
+        return tbAssetInformations;
     }
 
     @Override
     public TbAssetInformation selectTbAssetAdjustmentByAssetNumber(String assetNumber) {
-        return tbAssetInformationMapper.selectTbAssetInformationByAssetNumber(assetNumber);
+        TbAssetInformation tbAssetInformation = tbAssetInformationMapper.selectTbAssetInformationByAssetNumber(assetNumber);
+        tbAssetInformation.setChildNumberInfo();
+        return tbAssetInformation;
     }
 
     /**
@@ -90,7 +89,11 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
         tbAssetInformation.setNlist(childrens);
 
         PageUtils.startPage();
-        return tbAssetInformationMapper.selectTbAssetInformationList(tbAssetInformation);
+        List<TbAssetInformation> tbAssetInformations = tbAssetInformationMapper.selectTbAssetInformationList(tbAssetInformation);
+        for (TbAssetInformation assetInformation : tbAssetInformations) {
+            assetInformation.setChildNumberInfo();
+        }
+        return tbAssetInformations;
     }
 
     @Override
@@ -98,7 +101,11 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
         String locationNumber = tbAssetInformation.getLocationNumber();
         List<String> childrens = new RecursionUtil().getNumberWithChildren(locationMapper, locationNumber);
         tbAssetInformation.setNlist(childrens);
-        return tbAssetInformationMapper.selectTbAssetInformationList(tbAssetInformation);
+        List<TbAssetInformation> tbAssetInformations = tbAssetInformationMapper.selectTbAssetInformationList(tbAssetInformation);
+        for (TbAssetInformation assetInformation : tbAssetInformations) {
+            assetInformation.setChildNumberInfo();
+        }
+        return tbAssetInformations;
     }
 
     @Override
@@ -106,7 +113,11 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
         String locationNumber = tbAssetInformation.getLocationNumber();
         List<String> childrens = new RecursionUtil().getNumberWithChildren(locationMapper, locationNumber);
         tbAssetInformation.setNlist(childrens);
-        return tbAssetInformationMapper.selectInfoList(tbAssetInformation);
+        List<TbAssetInformation> tbAssetInformations = tbAssetInformationMapper.selectInfoList(tbAssetInformation);
+        for (TbAssetInformation assetInformation : tbAssetInformations) {
+            assetInformation.setChildNumberInfo();
+        }
+        return tbAssetInformations;
     }
 
 
@@ -122,7 +133,19 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
         tbAssetInformation.setCreateTime(DateUtils.getNowDate());
         tbAssetInformation.setCreateBy(SecurityUtils.getUsername());
 
-        setEpc(tbAssetInformation);
+        if (StrUtil.isBlank(tbAssetInformation.getDepartment())) {
+            tbAssetInformation.setDepartment(tbAssetInformation.getUserDepartment());
+        }
+
+        String number = tbAssetInformation.getNumber();
+        tbAssetInformation.setCode(number);
+
+        String locationNumber = tbAssetInformation.getLocationNumber();
+        if (StrUtil.isBlank(locationNumber)) {
+            tbAssetInformation.setLocationNumber(null);
+        }
+        tbAssetInformation.setEpcInfo();
+        tbAssetInformation.setChildNumberInfo();
 
         return tbAssetInformationMapper.insertTbAssetInformation(tbAssetInformation);
     }
@@ -136,13 +159,6 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
     @Override
     public int updateTbAssetInformation(TbAssetInformation tbAssetInformation)
     {
-        setEpc(tbAssetInformation);
-
-        tbAssetInformation.setUpdateTime(DateUtils.getNowDate());
-        return tbAssetInformationMapper.updateTbAssetInformation(tbAssetInformation);
-    }
-
-    private void setEpc(TbAssetInformation tbAssetInformation) {
         String number = tbAssetInformation.getNumber();
         tbAssetInformation.setCode(number);
 
@@ -150,21 +166,10 @@ public class TbAssetInformationServiceImpl implements ITbAssetInformationService
         if (StrUtil.isBlank(locationNumber)) {
             tbAssetInformation.setLocationNumber(null);
         }
+        tbAssetInformation.setEpcInfo();
 
-        // 将编码转为16进制
-        String epc = HexUtil.encodeHexStr(number, CharsetUtil.CHARSET_UTF_8);
-        // epc补充位
-        int epcReplenishLength = epc.length() % 4;
-        int remainder = epcReplenishLength % 4;
-        if (remainder != 0) {
-            int padding = 4 - remainder;
-            epc = epc + "0".repeat(padding);
-        }
-        // 将epc大写
-        epc = epc.toUpperCase();
-
-        tbAssetInformation.setEpc(epc);
-        tbAssetInformation.setEpcReplenishLength(epcReplenishLength);
+        tbAssetInformation.setUpdateTime(DateUtils.getNowDate());
+        return tbAssetInformationMapper.updateTbAssetInformation(tbAssetInformation);
     }
 
     /**

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

@@ -1,21 +1,21 @@
 package com.ruoyi.inventory.controller;
 
+import java.io.IOException;
+import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 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.TakeStockDTO;
 import com.ruoyi.inventory.domain.dto.TbAssetInventoryDTO;
 import com.ruoyi.system.service.ISysDeptService;
+import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -93,7 +93,7 @@ public class TbAssetInventoryController extends BaseController
     @GetMapping(value = "/info/{orderNumber}")
     public AjaxResult getInfo2(@PathVariable("orderNumber") String orderNumber)
     {
-        return success(tbAssetInventoryService.selectTbAssetInventoryByNum(orderNumber));
+        return success(tbAssetInventoryService.selectTbAssetInventoryByNumber(orderNumber));
     }
 
     /**
@@ -140,4 +140,19 @@ public class TbAssetInventoryController extends BaseController
     {
         return toAjax(tbAssetInventoryService.deleteTbAssetInventoryByIds(ids));
     }
+
+    /**
+     * 查看计划二维码
+     */
+    @GetMapping(value = "/code/{number}", produces = MediaType.IMAGE_PNG_VALUE)
+    public void selectQrCode(HttpServletResponse response, @PathVariable("number") String orderNumber, @RequestParam("v") String v) throws IOException {
+        TbAssetInventory tbAssetInventory = tbAssetInventoryService.selectTbAssetInventoryByNumber(orderNumber);
+        if (tbAssetInventory == null) {
+            return;
+        }
+        QrDTO qrDTO = new QrDTO();
+        qrDTO.setName(tbAssetInventory.getName());
+        qrDTO.setValue(tbAssetInventory.getOrderNumber());
+        QRCodeUtils.createCodeToOutputStream(qrDTO, response.getOutputStream());
+    }
 }

+ 89 - 2
ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbInventoryDetailController.java

@@ -1,7 +1,18 @@
 package com.ruoyi.inventory.controller;
 
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
+import com.ruoyi.asset.domain.TbAssetInformation;
+import com.ruoyi.inventory.domain.TbAssetInventory;
+import com.ruoyi.inventory.domain.dto.AssetInventoryStatement;
+import com.ruoyi.inventory.domain.enums.InventoryResult;
+import com.ruoyi.inventory.domain.enums.InventoryStatus;
+import com.ruoyi.inventory.mapper.TbAssetInventoryMapper;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -46,6 +57,9 @@ public class TbInventoryDetailController extends BaseController
         return getDataTable(list);
     }
 
+    @Autowired
+    private TbAssetInventoryMapper tbAssetInventoryMapper;
+
     /**
      * 导出资产盘点明细列表
      */
@@ -55,8 +69,81 @@ public class TbInventoryDetailController extends BaseController
     public void export(HttpServletResponse response, TbInventoryDetail tbInventoryDetail)
     {
         List<TbInventoryDetail> list = tbInventoryDetailService.selectTbInventoryDetailList(tbInventoryDetail);
-        ExcelUtil<TbInventoryDetail> util = new ExcelUtil<TbInventoryDetail>(TbInventoryDetail.class);
-        util.exportExcel(response, list, "资产盘点明细数据");
+        List<AssetInventoryStatement> assetInventoryStatements = new ArrayList<>();
+
+        String orderNumber = tbInventoryDetail.getOrderNumber();
+        if (StrUtil.isBlank(orderNumber)) {
+            throw new RuntimeException("盘点计划编码不能为空");
+        }
+
+        TbAssetInventory tbAssetInventory = tbAssetInventoryMapper.selectTbAssetInventoryByNumber(orderNumber);
+
+        for (TbInventoryDetail inventoryDetail : list) {
+            AssetInventoryStatement assetInventoryStatement = new AssetInventoryStatement();
+            // 设置计划编码
+            assetInventoryStatement.setOrderNumber(inventoryDetail.getOrderNumber());
+
+            // 设置盘点名称
+            assetInventoryStatement.setInventoryName(tbAssetInventory.getName());
+
+            // 设置盘点部门
+            assetInventoryStatement.setInventoryDepartmentName(tbAssetInventory.getInventoryDepartmentName());
+
+            // 解析资产信息
+            TbAssetInformation assetInformation = JSONUtil.toBean(inventoryDetail.getInventoryMetadata(), TbAssetInformation.class);
+
+            // 设置资产编码
+            assetInventoryStatement.setAssetNumber(assetInformation.getNumber());
+
+            // 设置资产名称
+            assetInventoryStatement.setAssetName(assetInformation.getName());
+
+            // 设置所在位置
+            String ancestorLocationName = assetInformation.getAncestorLocationName();
+            if (StrUtil.isBlank(ancestorLocationName)) {
+                ancestorLocationName = "";
+            }
+            String parentLocationName = assetInformation.getParentLocationName();
+            if (StrUtil.isBlank(parentLocationName)) {
+                parentLocationName = "";
+            }
+            String locationName = assetInformation.getLocationName();
+            assetInventoryStatement.setAssetLocation(ancestorLocationName + parentLocationName + locationName);
+
+            // 设置资产分类
+            String categoryName = assetInformation.getCategoryName();
+            assetInventoryStatement.setAssetCategory(categoryName);
+
+            // 设置盘点状态
+            Integer inventoryStatus = inventoryDetail.getInventoryStatus();
+            String inventoryStatusName = InventoryStatus.getName(inventoryStatus);
+            assetInventoryStatement.setInventoryStatus(inventoryStatusName);
+
+            // 设置资产数量
+            assetInventoryStatement.setQuantity(assetInformation.getQuantity());
+
+            // 设置盘点数量
+            assetInventoryStatement.setInventoryQuantity(inventoryDetail.getInventoryQuantity());
+
+            // 设置计量单位
+            assetInventoryStatement.setUnits(assetInformation.getUnits());
+
+            // 设置盘点结果
+            Integer inventoryResult = inventoryDetail.getInventoryResult();
+            String inventoryResultName = InventoryResult.getName(inventoryResult);
+            assetInventoryStatement.setInventoryResult(inventoryResultName);
+
+            // 设置盘点时间
+            assetInventoryStatement.setInventoryDate(tbAssetInventory.getInventoryDate());
+
+            // 设置备注
+            assetInventoryStatement.setRemark(inventoryDetail.getRemark());
+
+            assetInventoryStatements.add(assetInventoryStatement);
+        }
+
+        ExcelUtil<AssetInventoryStatement> util = new ExcelUtil<>(AssetInventoryStatement.class);
+        util.exportExcel(response, assetInventoryStatements, "资产盘点报表");
     }
 
     /**

+ 12 - 138
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/TbAssetInventory.java

@@ -2,6 +2,7 @@ package com.ruoyi.inventory.domain;
 
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
@@ -13,6 +14,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
  * @author ydl
  * @date 2023-06-01
  */
+@Data
 public class TbAssetInventory extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
@@ -32,6 +34,10 @@ public class TbAssetInventory extends BaseEntity
     @Excel(name = "盘点部门")
     private String inventoryDepartment;
 
+    /** 盘点部门 */
+    @Excel(name = "盘点部门")
+    private String inventoryDepartmentName;
+
     /** 盘点人 */
     @Excel(name = "盘点人")
     private String inventoryBy;
@@ -41,11 +47,11 @@ public class TbAssetInventory extends BaseEntity
     @Excel(name = "盘点日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date inventoryDate;
 
-    /** 盘点位置 */
-    @Excel(name = "盘点位置")
+    /** 盘点位置ID */
+    @Excel(name = "盘点位置ID")
     private String inventoryLocation;
-
-    @Excel(name = "盘点位置(导出)")
+    /** 盘点位置名称 */
+    @Excel(name = "盘点位置名称(导出)")
     private String inventoryLocationName;
 
     /** 盘点状态,0:盘点编制,1:盘点执行,2:盘点完毕,3:盘点暂停 */
@@ -66,139 +72,7 @@ public class TbAssetInventory extends BaseEntity
     private Date createdTime;
 
     /** 记录更新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "记录更新时间", width = 30, dateFormat = "yyyy-MM-dd")
     private Date updatedTime;
-
-    public void setId(Long id) 
-    {
-        this.id = id;
-    }
-
-    public Long getId() 
-    {
-        return id;
-    }
-    public void setOrderNumber(String orderNumber) 
-    {
-        this.orderNumber = orderNumber;
-    }
-
-    public String getOrderNumber() 
-    {
-        return orderNumber;
-    }
-    public void setName(String name) 
-    {
-        this.name = name;
-    }
-
-    public String getName() 
-    {
-        return name;
-    }
-    public void setInventoryDepartment(String inventoryDepartment) 
-    {
-        this.inventoryDepartment = inventoryDepartment;
-    }
-
-    public String getInventoryDepartment() 
-    {
-        return inventoryDepartment;
-    }
-    public void setInventoryBy(String inventoryBy) 
-    {
-        this.inventoryBy = inventoryBy;
-    }
-
-    public String getInventoryBy() 
-    {
-        return inventoryBy;
-    }
-    public void setInventoryDate(Date inventoryDate) 
-    {
-        this.inventoryDate = inventoryDate;
-    }
-
-    public Date getInventoryDate() 
-    {
-        return inventoryDate;
-    }
-    public void setInventoryLocation(String inventoryLocation) 
-    {
-        this.inventoryLocation = inventoryLocation;
-    }
-
-    public String getInventoryLocation() 
-    {
-        return inventoryLocation;
-    }
-
-    public String getInventoryLocationName() {
-        return inventoryLocationName;
-    }
-
-    public void setInventoryLocationName(String inventoryLocationName) {
-        this.inventoryLocationName = inventoryLocationName;
-    }
-
-    public Integer getInventoryStatus() {
-        return inventoryStatus;
-    }
-
-    public void setInventoryStatus(Integer inventoryStatus) {
-        this.inventoryStatus = inventoryStatus;
-    }
-
-    public Integer getInventoryResult() {
-        return inventoryResult;
-    }
-
-    public void setInventoryResult(Integer inventoryResult) {
-        this.inventoryResult = inventoryResult;
-    }
-
-    public Integer getRecordStatus() {
-        return recordStatus;
-    }
-
-    public void setRecordStatus(Integer recordStatus) {
-        this.recordStatus = recordStatus;
-    }
-
-    public void setCreatedTime(Date createdTime)
-    {
-        this.createdTime = createdTime;
-    }
-
-    public Date getCreatedTime() 
-    {
-        return createdTime;
-    }
-    public void setUpdatedTime(Date updatedTime) 
-    {
-        this.updatedTime = updatedTime;
-    }
-
-    public Date getUpdatedTime() 
-    {
-        return updatedTime;
-    }
-
-    @Override
-    public String toString() {
-        return "TbAssetInventory{" +
-                "id=" + id +
-                ", orderNumber='" + orderNumber + '\'' +
-                ", name='" + name + '\'' +
-                ", inventoryDepartment='" + inventoryDepartment + '\'' +
-                ", inventoryBy='" + inventoryBy + '\'' +
-                ", inventoryDate=" + inventoryDate +
-                ", inventoryLocation='" + inventoryLocation + '\'' +
-                ", inventoryLocationName='" + inventoryLocationName + '\'' +
-                ", inventoryStatus=" + inventoryStatus +
-                ", inventoryResult=" + inventoryResult +
-                ", recordStatus=" + recordStatus +
-                ", createdTime=" + createdTime +
-                ", updatedTime=" + updatedTime +
-                '}';
-    }
 }

+ 13 - 5
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/TbInventoryDetail.java

@@ -36,10 +36,18 @@ public class TbInventoryDetail extends BaseEntity
     @Excel(name = "盘点元数据")
     private String inventoryMetadata;
 
-    /** 盘点状态 0:异常 1:已盘点 2:未盘点 */
-    @Excel(name = "盘点状态 0:异常 1:已盘点 2:未盘点")
+    /** 盘点状态 -1:异常 0:未盘点 1:已盘点 */
+    @Excel(name = "盘点状态 -1:异常 0:未盘点 1:已盘点")
     private Integer inventoryStatus;
 
+    /** 盘点结果 */
+    @Excel(name = "盘点结果 -1:盘亏 0:正常 1:盘盈")
+    private Integer inventoryResult;
+
+    /** 盘点数量 */
+    @Excel(name = "盘点数量")
+    private Integer inventoryQuantity;
+
     /**
      * 未盘点详细
      * @param orderNumber
@@ -47,7 +55,7 @@ public class TbInventoryDetail extends BaseEntity
      * @return
      */
     public static TbInventoryDetail uncounted(String orderNumber, TbAssetInformation assetInformation) {
-        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 2);
+        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 0, null, null);
     }
 
     /**
@@ -57,7 +65,7 @@ public class TbInventoryDetail extends BaseEntity
      * @return
      */
     public static TbInventoryDetail counted(String orderNumber, TbAssetInformation assetInformation) {
-        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 1);
+        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 1, null, null);
     }
 
     /**
@@ -67,6 +75,6 @@ public class TbInventoryDetail extends BaseEntity
      * @return
      */
     public static TbInventoryDetail errCounted(String orderNumber, TbAssetInformation assetInformation) {
-        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), 0);
+        return new TbInventoryDetail(null, orderNumber, JSONUtil.toJsonStr(assetInformation), -1, null, null);
     }
 }

+ 77 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/dto/AssetInventoryStatement.java

@@ -0,0 +1,77 @@
+package com.ruoyi.inventory.domain.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 资产盘点报表
+ *
+ * @author 原动力林武泰
+ * @date 2023年12月27日
+ */
+@Data
+public class AssetInventoryStatement {
+    /** 资产编码 */
+    @Excel(name = "资产编码")
+    private String assetNumber;
+
+    /** 资产名称 */
+    @Excel(name = "资产名称", width = 24)
+    private String assetName;
+
+    /** 所在位置 */
+    @Excel(name = "所在位置", width = 30)
+    private String assetLocation;
+
+    /** 资产分类 */
+    @Excel(name = "资产分类")
+    private String assetCategory;
+
+    /** 盘点状态 */
+    @Excel(name = "盘点状态")
+    private String inventoryStatus;
+
+    /** 资产数量 */
+    @Excel(name = "账面数量")
+    private Integer quantity;
+
+    /** 盘点数量 */
+    @Excel(name = "实盘数量")
+    private Integer inventoryQuantity;
+
+    /** 计量单位 */
+    @Excel(name = "计量单位")
+    private String units;
+
+    /** 盘点结果 */
+    @Excel(name = "盘点结果")
+    private String inventoryResult;
+
+    /** 盘点日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "盘点日期", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date inventoryDate;
+
+    /** 盘点计划编码 */
+    @Excel(name = "计划编码")
+    private String orderNumber;
+
+    /** 盘点计划名称 */
+    @Excel(name = "盘点名称")
+    private String inventoryName;
+
+    /** 盘点位置 */
+    @Excel(name = "盘点位置")
+    private String inventoryLocation;
+
+    /** 盘点部门 */
+    @Excel(name = "盘点部门")
+    private String inventoryDepartmentName;
+
+    /** 备注 */
+    @Excel(name = "备注")
+    private String remark;
+}

+ 50 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryPlanResult.java

@@ -0,0 +1,50 @@
+package com.ruoyi.inventory.domain.enums;
+
+/**
+ * 盘点计划结果
+ */
+public enum InventoryPlanResult {
+    // 盘点结果,0:未开始,1:盘盈,2:盘亏,3:正常
+    /** 盘盈 */
+    PLAN_NOT_STARTED(0, "未开始"),
+    /** 盘盈 */
+    PLAN_INVENTORY_PROFIT(1, "盘盈"),
+    /** 盘亏 */
+    PLAN_INVENTORY_SHORTAGES(2, "盘亏"),
+    /** 正常 */
+    PLAN_INVENTORY_NORMAL(3, "正常");
+
+    /** 特定代码 */
+    private final Integer code;
+
+    /** 名称 */
+    private final String name;
+
+    InventoryPlanResult(Integer code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 根据特定代码返回名称
+     *
+     * @param code 特定代码
+     * @return 名称/null
+     */
+    public static String getName(Integer code) {
+        for (InventoryPlanResult value : InventoryPlanResult.values()) {
+            if (value.code.equals(code)) {
+                return value.getName();
+            }
+        }
+        return null;
+    }
+}

+ 47 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryPlanStatus.java

@@ -0,0 +1,47 @@
+package com.ruoyi.inventory.domain.enums;
+
+/** 盘点计划状态 */
+public enum InventoryPlanStatus {
+    /** 盘点编制 */
+    PLAN_REDACT(0, "盘点编制"),
+    /** 盘点执行 */
+    PLAN_EXECUTE(1, "盘点执行"),
+    /** 盘点完毕 */
+    PLAN_FINISH(2, "盘点完毕"),
+    /** 盘点暂停 */
+    PLAN_SUSPEND(3, "盘点暂停");
+
+    /** 特定代码 */
+    private final Integer code;
+
+    /** 名称 */
+    private final String name;
+
+    InventoryPlanStatus(Integer code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 根据特定代码返回名称
+     *
+     * @param code 特定代码
+     * @return 名称/null
+     */
+    public static String getName(Integer code) {
+        for (InventoryPlanStatus value : InventoryPlanStatus.values()) {
+            if (value.code.equals(code)) {
+                return value.getName();
+            }
+        }
+        return null;
+    }
+}

+ 47 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryResult.java

@@ -0,0 +1,47 @@
+package com.ruoyi.inventory.domain.enums;
+
+/**
+ * 盘点结果
+ */
+public enum InventoryResult {
+    /** 盘亏 */
+    INVENTORY_SHORTAGES(-1, "盘亏"),
+    /** 正常 */
+    INVENTORY_NORMAL(0, "正常"),
+    /** 盘盈 */
+    INVENTORY_PROFIT(1, "盘盈");
+
+    /** 特定代码 */
+    private final Integer code;
+
+    /** 名称 */
+    private final String name;
+
+    InventoryResult(Integer code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 根据特定代码返回名称
+     *
+     * @param code 特定代码
+     * @return 名称/null
+     */
+    public static String getName(Integer code) {
+        for (InventoryResult value : InventoryResult.values()) {
+            if (value.code.equals(code)) {
+                return value.getName();
+            }
+        }
+        return null;
+    }
+}

+ 47 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/enums/InventoryStatus.java

@@ -0,0 +1,47 @@
+package com.ruoyi.inventory.domain.enums;
+
+/**
+ * 盘点状态
+ */
+public enum InventoryStatus {
+    /** 异常 */
+    ERROR(-1, "异常"),
+    /** 未盘点 */
+    UNCOUNTED(0, "未盘点"),
+    /** 已盘点 */
+    COUNTED(1, "已盘点");
+
+    /** 特定代码 */
+    private final Integer code;
+
+    /** 名称 */
+    private final String name;
+
+    InventoryStatus(Integer code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * 根据特定代码返回名称
+     *
+     * @param code 特定代码
+     * @return 名称/null
+     */
+    public static String getName(Integer code) {
+        for (InventoryStatus value : InventoryStatus.values()) {
+            if (value.code.equals(code)) {
+                return value.getName();
+            }
+        }
+        return null;
+    }
+}

+ 16 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/mapper/TbInventoryDetailMapper.java

@@ -43,6 +43,20 @@ public interface TbInventoryDetailMapper
     public int countUncounted(@Param("orderNumber") String orderNumber);
 
     /**
+     * 统计盘亏
+     * @param orderNumber 盘点编码
+     * @return
+     */
+    public int countInventoryShortages(@Param("orderNumber") String orderNumber);
+
+    /**
+     * 统计盘盈
+     * @param orderNumber 盘点编码
+     * @return
+     */
+    public int countInventoryProfit(@Param("orderNumber") String orderNumber);
+
+    /**
      * 新增资产盘点明细
      * 
      * @param tbInventoryDetail 资产盘点明细
@@ -66,6 +80,8 @@ public interface TbInventoryDetailMapper
      */
     public int deleteTbInventoryDetailById(Long id);
 
+    public int deleteTbInventoryDetailByOrderNumber(@Param("orderNumber") String orderNumber);
+
     /**
      * 删除资产盘点明细
      *

+ 3 - 1
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/ITbAssetInventoryService.java

@@ -5,6 +5,8 @@ import com.ruoyi.inventory.domain.TbAssetInventory;
 import com.ruoyi.inventory.domain.dto.TakeStockDTO;
 import com.ruoyi.inventory.domain.dto.TbAssetInventoryDTO;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 资产盘点记录Service接口
  * 
@@ -21,7 +23,7 @@ public interface ITbAssetInventoryService
      */
     public TbAssetInventory selectTbAssetInventoryById(Long id);
 
-    TbAssetInventory selectTbAssetInventoryByNum(String num);
+    TbAssetInventory selectTbAssetInventoryByNumber(String num);
     /**
      * 查询资产盘点记录列表
      * 

+ 167 - 249
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbAssetInventoryServiceImpl.java

@@ -1,12 +1,8 @@
 package com.ruoyi.inventory.service.impl;
 
-import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.logging.SimpleFormatter;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
-import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
@@ -14,21 +10,22 @@ import com.ruoyi.asset.domain.TbAssetInformation;
 import com.ruoyi.asset.domain.TbLocation;
 import com.ruoyi.asset.mapper.TbAssetInformationMapper;
 import com.ruoyi.asset.mapper.TbLocationMapper;
-import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.inventory.domain.TagInfo;
 import com.ruoyi.inventory.domain.TbInventoryDetail;
 import com.ruoyi.inventory.domain.dto.TakeStockDTO;
 import com.ruoyi.inventory.domain.dto.TbAssetInventoryDTO;
 import com.ruoyi.inventory.mapper.TbInventoryDetailMapper;
 import com.ruoyi.utils.IDUtil;
-import com.ruoyi.utils.RecursionUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.inventory.mapper.TbAssetInventoryMapper;
 import com.ruoyi.inventory.domain.TbAssetInventory;
 import com.ruoyi.inventory.service.ITbAssetInventoryService;
 
-import javax.annotation.Resource;
+import static com.ruoyi.inventory.domain.enums.InventoryPlanResult.*;
+import static com.ruoyi.inventory.domain.enums.InventoryPlanStatus.PLAN_FINISH;
+import static com.ruoyi.inventory.domain.enums.InventoryResult.*;
+import static com.ruoyi.inventory.domain.enums.InventoryStatus.COUNTED;
+import static com.ruoyi.inventory.domain.enums.InventoryStatus.UNCOUNTED;
 
 /**
  * 资产盘点记录Service业务层处理
@@ -61,24 +58,18 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
     public TbAssetInventory selectTbAssetInventoryById(Long id)
     {
         TbAssetInventory tbAssetInventory = tbAssetInventoryMapper.selectTbAssetInventoryById(id);
-        setLocationName(tbAssetInventory);
-
-        return tbAssetInventory;
-    }
-
-    private void setLocationName(TbAssetInventory tbAssetInventory) {
         String inventoryLocation = tbAssetInventory.getInventoryLocation();
-        String[] strLocationIds = inventoryLocation.split(",");
-        List<TbLocation> tbLocations = locationMapper.selectTbLocationByIds(List.of(strLocationIds));
-        String locationName = Arrays.toString(tbLocations.stream().map(TbLocation::getName).toArray());
+        String locationName = getLocationName(inventoryLocation);
         tbAssetInventory.setInventoryLocationName(locationName);
+        return tbAssetInventory;
     }
 
-
     @Override
-    public TbAssetInventory selectTbAssetInventoryByNum(String num) {
+    public TbAssetInventory selectTbAssetInventoryByNumber(String num) {
         TbAssetInventory tbAssetInventory = tbAssetInventoryMapper.selectTbAssetInventoryByNumber(num);
-        setLocationName(tbAssetInventory);
+        String inventoryLocation = tbAssetInventory.getInventoryLocation();
+        String locationName = getLocationName(inventoryLocation);
+        tbAssetInventory.setInventoryLocationName(locationName);
         return tbAssetInventory;
     }
 
@@ -91,7 +82,31 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
     @Override
     public List<TbAssetInventory> selectTbAssetInventoryList(TbAssetInventory tbAssetInventory)
     {
-        return tbAssetInventoryMapper.selectTbAssetInventoryList(tbAssetInventory);
+        List<TbAssetInventory> tbAssetInventories = tbAssetInventoryMapper.selectTbAssetInventoryList(tbAssetInventory);
+        for (TbAssetInventory assetInventory : tbAssetInventories) {
+            String inventoryLocation = assetInventory.getInventoryLocation();
+            String locationName = getLocationName(inventoryLocation);
+            assetInventory.setInventoryLocationName(locationName);
+        }
+        return tbAssetInventories;
+    }
+
+    private String getLocationName(String locationIds) {
+        String[] ids = locationIds.split(",");
+        if (ids.length < 1) {
+            return "";
+        }
+        List<TbLocation> tbLocations = locationMapper.selectTbLocationByIds(List.of(ids));
+        StringBuilder stringBuilder = new StringBuilder();
+        for (int i = 0; i < tbLocations.size(); i++) {
+            if (i == tbLocations.size() - 1) {
+                stringBuilder.append(tbLocations.get(i).getName());
+                continue;
+            }
+            stringBuilder.append(tbLocations.get(i).getName());
+            stringBuilder.append(",");
+        }
+        return stringBuilder.toString();
     }
 
     /**
@@ -114,27 +129,14 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         }
 
         String inventoryLocation = tbAssetInventory.getInventoryLocation();
-        String[] locationIds = inventoryLocation.split(",");
-        Set<String> locationNumberSet = new HashSet<>();
-        for (String locationId : locationIds) {
-            List<String> locationNumberList = locationMapper.selectChildTbLocationById(Long.valueOf(locationId));
-            locationNumberSet.addAll(locationNumberList);
-        }
-        List<TbAssetInformation> tbAssetInformationList = informationMapper.selectAssetInformationByLocations(locationNumberSet);
-
-        List<TbInventoryDetail> tbInventoryDetails = new ArrayList<>();
-        for (TbAssetInformation tbAssetInformation : tbAssetInformationList) {
-            // 未盘点
-            TbInventoryDetail uncounted = TbInventoryDetail.uncounted(orderNumber, tbAssetInformation);
-            tbInventoryDetails.add(uncounted);
-        }
+        List<TbInventoryDetail> inventoryDetails = getInventoryDetails(orderNumber, inventoryLocation);
 
         int insertTbAssetInventory = tbAssetInventoryMapper.insertTbAssetInventory(tbAssetInventory);
         if (insertTbAssetInventory == 0) {
             return 0;
         }
 
-        for (TbInventoryDetail tbInventoryDetail : tbInventoryDetails) {
+        for (TbInventoryDetail tbInventoryDetail : inventoryDetails) {
             tbInventoryDetailMapper.insertTbInventoryDetail(tbInventoryDetail);
         }
 
@@ -234,10 +236,6 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         String orderNumber = tbAssetInventory.getOrderNumber();
 
         int result = 0;
-        // 设置盘点状态:盘点完毕
-        tbAssetInventory.setInventoryStatus(2);
-        // 记录已盘点epc
-        Set<String> epcRecord = new HashSet<>();
 
         // 根据盘点单号获取盘点资产详细
         List<TbInventoryDetail> tbInventoryDetails = tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
@@ -246,20 +244,43 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
             String inventoryMetadata = tbInventoryDetail.getInventoryMetadata();
             // 将元数据转换为资产信息
             TbAssetInformation assetInformation = JSONUtil.toBean(inventoryMetadata, TbAssetInformation.class);
-            // 判断是否盘点到该epc
-            boolean flag = epcSet.stream().anyMatch(epc -> epc.equals(assetInformation.getEpc()));
-            if (flag) {
+            Integer assetQuantity = assetInformation.getQuantity();
+
+            // 实际盘点数量统计
+            int inventoryQuantity;
+
+            // 获取该资产的所有epc
+            Set<String> assetEpcSet = epcSet
+                    .stream()
+                    .filter(epc -> TbAssetInformation.encodeChildEpc2Epc(epc).equals(assetInformation.getEpc()))
+                    .collect(Collectors.toSet());
+
+            inventoryQuantity = assetEpcSet.size();
+            // 删除已盘点epc
+            epcSet.removeAll(assetEpcSet);
+
+            if (inventoryQuantity > 0) {
                 // 设置盘点更新状态:已盘点
-                tbInventoryDetail.setInventoryStatus(1);
-                int update = tbInventoryDetailMapper.updateTbInventoryDetail(tbInventoryDetail);
-                if (update > 0) {
-                    // 新增已盘点epc
-                    epcRecord.add(assetInformation.getEpc());
-                    // 删除已盘点epc
-                    epcSet.remove(assetInformation.getEpc());
-                    if (result < 1) {
-                        result = 1;
-                    }
+                tbInventoryDetail.setInventoryStatus(COUNTED.getCode());
+                // 设置盘点数量
+                tbInventoryDetail.setInventoryQuantity(inventoryQuantity);
+
+                if (inventoryQuantity > assetQuantity) { // 盘盈: 实际盘点数量 大于 资产账面数量
+                    tbInventoryDetail.setInventoryResult(INVENTORY_PROFIT.getCode());
+                } else if (inventoryQuantity == assetQuantity) { // 正常: 实际盘点数量 等于 资产账面数量
+                    tbInventoryDetail.setInventoryResult(INVENTORY_NORMAL.getCode());
+                } else {  // 盘亏: 实际盘点数量 小于 资产账面数量
+                    tbInventoryDetail.setInventoryResult(INVENTORY_SHORTAGES.getCode());
+                }
+            } else {
+                // 设置盘点更新状态:未盘点
+                tbInventoryDetail.setInventoryStatus(UNCOUNTED.getCode());
+            }
+
+            int update = tbInventoryDetailMapper.updateTbInventoryDetail(tbInventoryDetail);
+            if (update > 0) {
+                if (result < 1) {
+                    result = 1;
                 }
             }
         }
@@ -267,71 +288,70 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         // 统计未盘点
         int uncountedCount = tbInventoryDetailMapper.countUncounted(orderNumber);
 
-        // 获取盘点位置
-        String inventoryLocation = tbAssetInventory.getInventoryLocation();
-        List<Long> locationIds = Arrays.stream(inventoryLocation.split(",")).map(Long::valueOf).collect(Collectors.toList());
-        List<String> locationNumbers = locationMapper.selectChildTbLocationByIds(locationIds);
-
-        // 根据盘点位置获取位置下的资产信息
-        List<TbAssetInformation> locationAssetInformationList = informationMapper.selectAssetInformationByLocations(locationNumbers);
-
-        if (!locationAssetInformationList.isEmpty()) {
-            // 获取该位置下的全部资产epc
-            Set<String> newEpcSet = locationAssetInformationList.stream().map(TbAssetInformation::getEpc).collect(Collectors.toSet());
-            // 删除已盘点epc
-            newEpcSet.removeAll(epcRecord);
-
-            if (!newEpcSet.isEmpty()) {
-                // 获取存在该位置且未盘点资产信息
-                List<TbAssetInformation> newEpcAssetInformationList = locationAssetInformationList.stream().map(tbAssetInformation -> {
-                    for (String newEpc : newEpcSet) {
-                        if (tbAssetInformation.getEpc().equals(newEpc)) {
-                            return tbAssetInformation;
-                        }
-                    }
-                    return null;
-                }).collect(Collectors.toList());
-
-                for (TbAssetInformation tbAssetInformation : newEpcAssetInformationList) {
-                    if (tbAssetInformation == null) {
-                        continue;
-                    }
-                    String newEpc = tbAssetInformation.getEpc();
-                    // 判断是否盘点到该epc
-                    boolean flag = epcSet.stream().anyMatch(epc -> epc.equals(newEpc));
-                    if (flag) {
-                        // 已盘点资产详细
-                        TbInventoryDetail counted = TbInventoryDetail.counted(orderNumber, tbAssetInformation);
-                        int inserted = tbInventoryDetailMapper.insertTbInventoryDetail(counted);
-                        if (inserted > 0) {
-                            // 新增已盘点epc
-                            epcRecord.add(newEpc);
-                            // 删除已盘点epc
-                            epcSet.remove(newEpc);
-                            if (result < 1) {
-                                result = 1;
-                            }
-                        }
-                    }
+        if (uncountedCount > 0) { // 存在未盘点 盘亏
+            tbAssetInventory.setInventoryResult(PLAN_INVENTORY_SHORTAGES.getCode());
+        } else { // 不存在未盘点
+            // 统计盘亏
+            int inventoryShortagesCount = tbInventoryDetailMapper.countInventoryShortages(orderNumber);
+            // 是否存在盘亏
+            if (inventoryShortagesCount > 0) {
+                tbAssetInventory.setInventoryResult(PLAN_INVENTORY_SHORTAGES.getCode());
+            } else {
+                // 统计盘盈
+                int inventoryProfitCount = tbInventoryDetailMapper.countInventoryProfit(orderNumber);
+                // 是否存在盘盈
+                if (inventoryProfitCount > 0) {
+                    tbAssetInventory.setInventoryResult(PLAN_INVENTORY_PROFIT.getCode());
+                } else {
+                    tbAssetInventory.setInventoryResult(PLAN_INVENTORY_NORMAL.getCode());
                 }
             }
         }
 
-        // 根据未盘点资产epc获取资产信息
-        List<TbAssetInformation> tbAssetInformationList = informationMapper.selectTbAssetInformationByEpcList(epcSet);
-        for (TbAssetInformation tbAssetInformation : tbAssetInformationList) {
-            TbInventoryDetail tbInventoryDetail = TbInventoryDetail.errCounted(orderNumber, tbAssetInformation);
-            tbInventoryDetailMapper.insertTbInventoryDetail(tbInventoryDetail);
+        // 意外盘点资产EPC
+        Set<String> unCountEpcSet = new HashSet<>();
+        for (String epc : epcSet) {
+            String unCountEpc = TbAssetInformation.encodeChildEpc2Epc(epc);
+            // 存入未盘点资产epc中
+            unCountEpcSet.add(unCountEpc);
         }
 
-        if (uncountedCount > 0) { // 未盘点统计大于0时 盘亏
-            tbAssetInventory.setInventoryResult(2);
-        } else if (epcRecord.size() > tbInventoryDetails.size()) { // 未盘点统计0,且实际已盘点数大于计划盘点数 盘盈
-            tbAssetInventory.setInventoryResult(1);
-        } else { // 未盘点统计0,且实际已盘点数等于计划盘点数 正常
-            tbAssetInventory.setInventoryResult(3);
+        // 根据意外资产epc获取资产信息
+        List<TbAssetInformation> tbAssetInformationList = informationMapper.selectTbAssetInformationByEpcList(unCountEpcSet);
+        for (TbAssetInformation tbAssetInformation : tbAssetInformationList) { // 盘点异常
+            // 盘点意外的资产信息
+            TbInventoryDetail tbInventoryDetail = TbInventoryDetail.errCounted(orderNumber, tbAssetInformation);
+
+            Integer assetQuantity = tbAssetInformation.getQuantity();
+
+            // 实际盘点数量统计
+            int inventoryQuantity;
+
+            // 获取该资产的所有epc
+            Set<String> assetEpcSet = epcSet
+                    .stream()
+                    .filter(epc -> TbAssetInformation.encodeChildEpc2Epc(epc).equals(tbAssetInformation.getEpc()))
+                    .collect(Collectors.toSet());
+
+            inventoryQuantity = assetEpcSet.size();
+            // 删除已盘点epc
+            epcSet.removeAll(assetEpcSet);
+
+            // 设置盘点数量
+            tbInventoryDetail.setInventoryQuantity(inventoryQuantity);
+            if (inventoryQuantity > assetQuantity) { // 盘盈: 实际盘点数量 大于 资产账面数量
+                tbInventoryDetail.setInventoryResult(INVENTORY_PROFIT.getCode());
+            } else if (inventoryQuantity == assetQuantity) { // 正常: 实际盘点数量 等于 资产账面数量
+                tbInventoryDetail.setInventoryResult(INVENTORY_NORMAL.getCode());
+            } else {  // 盘亏: 实际盘点数量 小于 资产账面数量
+                tbInventoryDetail.setInventoryResult(INVENTORY_SHORTAGES.getCode());
+            }
+
+            tbInventoryDetailMapper.insertTbInventoryDetail(tbInventoryDetail);
         }
 
+        // 设置盘点状态:盘点完毕
+        tbAssetInventory.setInventoryStatus(PLAN_FINISH.getCode());
         tbAssetInventoryMapper.updateTbAssetInventory(tbAssetInventory);
         return result;
     }
@@ -351,7 +371,43 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         } else {
             tbAssetInventory.setInventoryStatus(0);
         }
-        return tbAssetInventoryMapper.updateTbAssetInventory(tbAssetInventory);
+
+        int update = tbAssetInventoryMapper.updateTbAssetInventory(tbAssetInventory);
+        if (update < 1) {
+            return 0;
+        }
+
+        String orderNumber = tbAssetInventory.getOrderNumber();
+        tbInventoryDetailMapper.deleteTbInventoryDetailByOrderNumber(orderNumber);
+
+        String inventoryLocation = tbAssetInventory.getInventoryLocation();
+        List<TbInventoryDetail> inventoryDetails = getInventoryDetails(orderNumber, inventoryLocation);
+
+        for (TbInventoryDetail tbInventoryDetail : inventoryDetails) {
+            tbInventoryDetailMapper.insertTbInventoryDetail(tbInventoryDetail);
+        }
+
+        return 1;
+    }
+
+    private List<TbInventoryDetail> getInventoryDetails(String orderNumber, String inventoryLocation) {
+        String[] locationIds = inventoryLocation.split(",");
+
+        Set<String> locationNumberSet = new HashSet<>();
+        for (String locationId : locationIds) {
+            List<String> locationNumberList = locationMapper.selectChildTbLocationById(Long.valueOf(locationId));
+            locationNumberSet.addAll(locationNumberList);
+        }
+        List<TbAssetInformation> tbAssetInformationList = informationMapper.selectAssetInformationByLocations(locationNumberSet);
+
+        List<TbInventoryDetail> tbInventoryDetails = new ArrayList<>();
+        for (TbAssetInformation tbAssetInformation : tbAssetInformationList) {
+            // 未盘点
+            TbInventoryDetail uncounted = TbInventoryDetail.uncounted(orderNumber, tbAssetInformation);
+            tbInventoryDetails.add(uncounted);
+        }
+
+        return tbInventoryDetails;
     }
 
     /**
@@ -402,142 +458,4 @@ public class TbAssetInventoryServiceImpl implements ITbAssetInventoryService
         String locationName = Arrays.toString(tbLocations.stream().map(TbLocation::getName).toArray());
         tbAssetInventoryDTO.setInventoryLocationName(locationName);
     }
-
-    // 旧手持机盘点
-    public int addByTakeStock(List<TakeStockDTO> _dto){
-        int result = 0;
-        for (TakeStockDTO dto : _dto) {
-            //解析实体
-            List<TagInfo> list = dto.getAssetList();
-            String location = dto.getInventoryLocation();
-            String orderNumber = dto.getOrderNumber();
-            //提取epc rfid
-            ArrayList<String> epcList = new ArrayList<>();
-            for (TagInfo tagInfo : list) {
-                String epc = tagInfo.getEpc();
-                // 删除字符串中前导的零
-                epc = epc.replaceFirst("^0+", "");
-                epcList.add(epc);
-            }
-            //根据位置获取包含自身及子位置,递归
-            List<String> locations = new RecursionUtil().getNumberWithChildren(locationMapper, location);
-            //获取所在位置内的资产
-            // List<String> rfidList = informationMapper.selectNumberByLocations(locations);
-            List<TbAssetInformation> informationList = informationMapper.selectAssetInformationByLocations(locations);
-            List<String> rfidList = informationList.stream().map(TbAssetInformation::getEpc).collect(Collectors.toList());
-
-            //对比盘点
-            List<String> intersection = new ArrayList<>(rfidList);
-            intersection.retainAll(epcList);
-            if (intersection.size() < rfidList.size()) {
-                //盘亏
-                if (!orderNumber.isEmpty()) {
-                    result = takeStock(orderNumber, epcList, 2);
-                } else {
-                    result = takeStock2(location, 2, epcList);
-                }
-            } else if (list.size() > intersection.size()) {
-                //盘盈
-                if (!orderNumber.isEmpty()) {
-                    result = takeStock(orderNumber, epcList, 1);
-                } else {
-                    result = takeStock2(location, 1, epcList);
-                }
-            } else if (intersection.size() == rfidList.size()) {
-                //正常
-                if (!orderNumber.isEmpty()) {
-                    result = takeStock(orderNumber, epcList, 3);
-                } else {
-                    result = takeStock2(location, 3, epcList);
-                }
-            } else {
-                result = 0;
-            }
-        }
-        return result;
-    }
-
-    // 旧手持机盘点
-    private int takeStock(String orderNumber, List<String> list, Integer result){
-        TbAssetInventory inventory = tbAssetInventoryMapper.selectTbAssetInventoryByNumber(orderNumber);
-        if (inventory.getRecordStatus() == 1) {
-            //插入盘点
-            inventory.setInventoryStatus(2);
-            inventory.setInventoryResult(result);
-            //插入明细
-            setDetail(orderNumber, list);
-            return updateTbAssetInventory(inventory);
-        }else {
-            return 0;
-        }
-    }
-
-    // 旧手持机盘点
-    private int takeStock2(String location, Integer result, List<String> list){
-        TbAssetInventory inventory = new TbAssetInventory();
-        inventory.setInventoryStatus(2);
-        inventory.setInventoryResult(result);
-        inventory.setRecordStatus(1);
-        inventory.setInventoryLocation(location);
-        inventory.setInventoryDate(new Date());
-        SimpleDateFormat formatter = new SimpleDateFormat("yyMMdd HH:mm:ss");
-        String format = formatter.format(new Date());
-        inventory.setName("线下自测"+format);
-        int i = insertTbAssetInventory(inventory);
-        if(i < 1){
-            throw new ServiceException("生成盘点记录失败");
-        }
-        String orderNumber = inventory.getOrderNumber();
-        //插入盘点明细
-        setDetail(orderNumber, list);
-        return 1;
-    }
-
-    // 旧手持机盘点
-    private void setDetail(String orderNumber, List<String> list){
-        //该位置下的资产
-        TbAssetInventory _inventory = tbAssetInventoryMapper.selectTbAssetInventoryByNumber(orderNumber);
-        TbAssetInformation information = new TbAssetInformation();
-        String location = _inventory.getInventoryLocation();
-        information.setLocationNumber(location);
-        List<String> childrens = new RecursionUtil().getNumberWithChildren(locationMapper, location);
-        information.setNlist(childrens);
-        List<TbAssetInformation> informations = informationMapper.selectTbAssetInformationList(information);
-        if (informations == null || informations.isEmpty() ){
-            return ;
-        }
-        //该位置下资产rfid list
-        List<String> _list = informations.stream().map(TbAssetInformation::getEpc).collect(Collectors.toList());
-
-        //已盘点,1
-        List<String> green = (List<String>) CollectionUtil.intersection(_list, list);
-        //未盘点,2
-        List<String> red = new ArrayList<>(_list);
-        red.removeAll(list);
-        //异常(多余),0
-        List<String> yellow = new ArrayList<>(list);
-        yellow.removeAll(_list);
-        //插入详细盘点信息
-        TbInventoryDetail detail = new TbInventoryDetail();
-        //已盘
-        setInventoryDetail(green, detail, orderNumber, 1);
-        //未盘
-        setInventoryDetail(red, detail, orderNumber, 2);
-        //异常
-        setInventoryDetail(yellow, detail, orderNumber, 0);
-    }
-
-    // 旧手持机盘点
-    private void setInventoryDetail(List<String> list, TbInventoryDetail detail, String orderNumber, Integer isUpdate){
-        for (String epc : list) {
-            detail.setOrderNumber(orderNumber);
-            TbAssetInformation tbAssetInformation = informationMapper.selectTbAssetInformationByEpc(epc);
-            if (tbAssetInformation == null) {
-                continue;
-            }
-            detail.setInventoryMetadata(JSONUtil.toJsonStr(tbAssetInformation));
-            detail.setInventoryStatus(isUpdate);
-            tbInventoryDetailMapper.insertTbInventoryDetail(detail);
-        }
-    }
 }

+ 4 - 7
ruoyi-admin/src/main/java/com/ruoyi/visitor/controller/VController.java

@@ -1,7 +1,10 @@
 package com.ruoyi.visitor.controller;
 
+import cn.hutool.core.util.CharsetUtil;
+import cn.hutool.core.util.HexUtil;
 import com.ruoyi.asset.domain.TbAssetInformation;
 import com.ruoyi.asset.domain.dto.TbLocationDTO;
+import com.ruoyi.asset.mapper.TbAssetInformationMapper;
 import com.ruoyi.asset.service.ITbAssetInformationService;
 import com.ruoyi.asset.service.ITbLocationService;
 import com.ruoyi.common.core.controller.BaseController;
@@ -11,9 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @RestController
@@ -48,8 +49,4 @@ public class VController extends BaseController {
         System.out.println(tbLocationDTO.getNumbers());
         return success(locationService.selectTbLocationListByNumbers(tbLocationDTO.getNumbers()));
     }
-
-
-
-
 }

+ 3 - 10
ruoyi-admin/src/main/resources/mapper/asset/TbAssetInformationMapper.xml

@@ -52,11 +52,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="lifeExpectancy"    column="life_expectancy"    />
         <result property="lifeUnits"    column="life_units"    />
         <result property="startDate"    column="start_date"    />
-        <result property="reservedColumnJ"    column="reserved_column_j"    />
     </resultMap>
 
     <sql id="selectTbAssetInformationVo">
-        select id, code, name, number, image_url, category_number, specifications_model, abc_category, manage_status, user_department, department, responsible_person, location_number, property, purchase_date, commissioning_date, original_value, durable_years, net_value, residual_value, accumulated_depreciation, last_depreciation_date, depreciation_method, contract_number, factory_number, manufacturer, supplier, purpose, maintenance_date, maintenance_tel, maintenance_user, corporation, record_status, remark, create_by, create_time, update_by, update_time, is_whitelist, quantity, units, payment_receiving_time, epc, epc_replenish_length, life_expectancy, life_units, start_date, reserved_column_j from tb_asset_information
+        select id, code, name, number, image_url, category_number, specifications_model, abc_category, manage_status, user_department, department, responsible_person, location_number, property, purchase_date, commissioning_date, original_value, durable_years, net_value, residual_value, accumulated_depreciation, last_depreciation_date, depreciation_method, contract_number, factory_number, manufacturer, supplier, purpose, maintenance_date, maintenance_tel, maintenance_user, corporation, record_status, remark, create_by, create_time, update_by, update_time, is_whitelist, quantity, units, payment_receiving_time, epc, epc_replenish_length, life_expectancy, life_units, start_date from tb_asset_information
     </sql>
 
     <sql id="selectTbAssetInformation">
@@ -237,7 +236,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <!--            <if test="corporation != null  and corporation != ''"> and corporation = #{corporation}</if>-->
 <!--            <if test="recordStatus != null "> and record_status = #{recordStatus}</if>-->
 <!--            <if test="isWhitelist != null  and isWhitelist != ''"> and is_whitelist = #{isWhitelist}</if>-->
-<!--            <if test="quantity != null  and quantity != ''"> and quantity = #{quantity}</if>-->
+<!--            <if test="quantity != null"> and quantity = #{quantity}</if>-->
 <!--            <if test="units != null  and units != ''"> and units = #{units}</if>-->
 <!--            <if test="paymentReceivingTime != null"> and payment_receiving_time = #{paymentReceivingTime}</if>-->
 <!--            <if test="reservedColumnE != null  and reservedColumnE != ''"> and reserved_column_e = #{reservedColumnE}</if>-->
@@ -245,7 +244,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <!--            <if test="lifeExpectancy != null  and lifeExpectancy != ''"> and life_expectancy = #{lifeExpectancy}</if>-->
 <!--            <if test="lifeUnits != null  and lifeUnits != ''"> and life_units = #{lifeUnits}</if>-->
 <!--            <if test="startDate != null"> and start_date = #{startDate}</if>-->
-<!--            <if test="reservedColumnJ != null  and reservedColumnJ != ''"> and reserved_column_j = #{reservedColumnJ}</if>-->
 <!--        </where>-->
 <!--    </select>-->
 
@@ -288,7 +286,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="corporation != null  and corporation != ''"> and a.corporation = #{corporation}</if>
             <if test="recordStatus != null "> and a.record_status = #{recordStatus}</if>
             <if test="isWhitelist != null  and isWhitelist != ''"> and a.is_whitelist = #{isWhitelist}</if>
-            <if test="quantity != null  and quantity != ''"> and a.quantity = #{quantity}</if>
+            <if test="quantity != null"> and a.quantity = #{quantity}</if>
             <if test="units != null  and units != ''"> and a.units = #{units}</if>
             <if test="paymentReceivingTime != null"> and a.payment_receiving_time = #{paymentReceivingTime}</if>
             <if test="epc != null  and epc != ''"> and a.epc = #{epc}</if>
@@ -296,10 +294,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lifeExpectancy != null"> and a.life_expectancy = #{lifeExpectancy}</if>
             <if test="lifeUnits != null  and lifeUnits != ''"> and a.life_units = #{lifeUnits}</if>
             <if test="startDate != null"> and a.start_date = #{startDate}</if>
-            <if test="reservedColumnJ != null  and reservedColumnJ != ''"> and a.reserved_column_j = #{reservedColumnJ}</if>
         </where>
     </select>
-
     <select id="selectNumberByLocations" parameterType="String" resultType="String">
         select a.number from tb_asset_information a
         where a.location_number in
@@ -415,7 +411,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lifeExpectancy != null">life_expectancy,</if>
             <if test="lifeUnits != null">life_units,</if>
             <if test="startDate != null">start_date,</if>
-            <if test="reservedColumnJ != null">reserved_column_j,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="code != null">#{code},</if>
@@ -464,7 +459,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lifeExpectancy != null">#{lifeExpectancy},</if>
             <if test="lifeUnits != null">#{lifeUnits},</if>
             <if test="startDate != null">#{startDate},</if>
-            <if test="reservedColumnJ != null">#{reservedColumnJ},</if>
          </trim>
     </insert>
 
@@ -517,7 +511,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="lifeExpectancy != null">life_expectancy = #{lifeExpectancy},</if>
             <if test="lifeUnits != null">life_units = #{lifeUnits},</if>
             <if test="startDate != null">start_date = #{startDate},</if>
-            <if test="reservedColumnJ != null">reserved_column_j = #{reservedColumnJ},</if>
         </trim>
         where id = #{id}
     </update>

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

@@ -24,24 +24,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select id, order_number, name, inventory_department, inventory_by, inventory_date, inventory_location, inventory_status, inventory_result, record_status, remark, created_time, updated_time from tb_asset_inventory
     </sql>
 
-    <select id="selectTbAssetInventoryList" parameterType="TbAssetInventory" resultMap="TbAssetInventoryResult">
-        <include refid="selectTbAssetInventoryVo"/>
+    <sql id="selectTbAssetInventory">
+        select
+            a.id,
+            a.order_number orderNumber,
+            a.name,
+            a.inventory_department inventoryDepartment,
+            b.dept_name inventoryDepartmentName,
+            a.inventory_by inventoryBy,
+            a.inventory_date inventoryDate,
+            a.inventory_location inventoryLocation,
+            a.inventory_status inventoryStatus,
+            a.inventory_result inventoryResult,
+            a.record_status recordStatus,
+            a.remark,
+            a.created_time createdTime,
+            a.updated_time updatedTime
+        from tb_asset_inventory a
+        LEFT JOIN sys_dept b ON b.dept_id = a.inventory_department
+    </sql>
+
+    <select id="selectTbAssetInventoryList" parameterType="TbAssetInventory" resultType="TbAssetInventory">
+        <include refid="selectTbAssetInventory"/>
         <where>  
-            <if test="orderNumber != null  and orderNumber != ''"> and order_number = #{orderNumber}</if>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="inventoryDepartment != null  and inventoryDepartment != ''"> and inventory_department = #{inventoryDepartment}</if>
-            <if test="inventoryBy != null  and inventoryBy != ''"> and inventory_by = #{inventoryBy}</if>
-            <if test="inventoryDate != null "> and inventory_date = #{inventoryDate}</if>
-            <if test="inventoryLocation != null  and inventoryLocation != ''"> and inventory_location = #{inventoryLocation}</if>
-            <if test="inventoryStatus != null "> and inventory_status = #{inventoryStatus}</if>
-            <if test="inventoryResult != null "> and inventory_result = #{inventoryResult}</if>
-            <if test="recordStatus != null "> and record_status = #{recordStatus}</if>
+            <if test="orderNumber != null  and orderNumber != ''"> and a.order_number = #{orderNumber}</if>
+            <if test="name != null  and name != ''"> and a.name like concat('%', #{name}, '%')</if>
+            <if test="inventoryDepartment != null  and inventoryDepartment != ''"> and a.inventory_department = #{inventoryDepartment}</if>
+            <if test="inventoryBy != null  and inventoryBy != ''"> and a.inventory_by = #{inventoryBy}</if>
+            <if test="inventoryDate != null "> and a.inventory_date = #{inventoryDate}</if>
+            <if test="inventoryLocation != null  and inventoryLocation != ''"> and a.inventory_location = #{inventoryLocation} or c.sequence like concat('%', #{inventoryLocation}, '%')</if>
+            <if test="inventoryStatus != null "> and a.inventory_status = #{inventoryStatus}</if>
+            <if test="inventoryResult != null "> and a.inventory_result = #{inventoryResult}</if>
+            <if test="recordStatus != null "> and a.record_status = #{recordStatus}</if>
         </where>
     </select>
     
-    <select id="selectTbAssetInventoryById" parameterType="Long" resultMap="TbAssetInventoryResult">
-        <include refid="selectTbAssetInventoryVo"/>
-        where id = #{id}
+    <select id="selectTbAssetInventoryById" parameterType="Long" resultType="TbAssetInventory">
+        <include refid="selectTbAssetInventory"/>
+        where a.id = #{id}
     </select>
 
     <select id="selectOrderNumberByIds" parameterType="Long" resultType="String">
@@ -52,9 +72,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </select>
 
-    <select id="selectTbAssetInventoryByNumber" parameterType="String" resultMap="TbAssetInventoryResult">
-        <include refid="selectTbAssetInventoryVo"/>
-        where order_number = #{orderNumber}
+    <select id="selectTbAssetInventoryByNumber" parameterType="String" resultType="TbAssetInventory">
+        <include refid="selectTbAssetInventory"/>
+        where a.order_number = #{orderNumber}
     </select>
         
     <insert id="insertTbAssetInventory" parameterType="TbAssetInventory" useGeneratedKeys="true" keyProperty="id">

+ 22 - 3
ruoyi-admin/src/main/resources/mapper/inventory/TbInventoryDetailMapper.xml

@@ -3,19 +3,20 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.inventory.mapper.TbInventoryDetailMapper">
-    
     <resultMap type="TbInventoryDetail" id="TbInventoryDetailResult">
         <result property="id"    column="id"    />
         <result property="orderNumber"    column="order_number"    />
         <result property="inventoryMetadata"    column="inventory_metadata"    />
         <result property="inventoryStatus"    column="inventory_status"    />
+        <result property="inventoryResult"    column="inventory_result"    />
+        <result property="inventoryQuantity"    column="inventory_quantity"    />
         <result property="remark"    column="remark"    />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
     </resultMap>
 
     <sql id="selectTbInventoryDetailVo">
-        select id, order_number, inventory_metadata, inventory_status, remark, create_time, create_by from tb_inventory_detail
+        select id, order_number, inventory_metadata, inventory_status, inventory_result, inventory_quantity, remark, create_time, create_by from tb_inventory_detail
     </sql>
 
     <select id="selectTbInventoryDetailList" parameterType="TbInventoryDetail" resultMap="TbInventoryDetailResult">
@@ -37,7 +38,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="countUncounted" parameterType="String" resultType="Integer">
-        SELECT COUNT(0) FROM tb_inventory_detail WHERE order_number = #{orderNumber} and inventory_status &lt;&gt; 1;
+        SELECT COUNT(0) FROM tb_inventory_detail WHERE order_number = #{orderNumber} and inventory_status = 0;
+    </select>
+
+    <select id="countInventoryShortages" parameterType="String" resultType="Integer">
+        SELECT COUNT(0) FROM tb_inventory_detail WHERE order_number = #{orderNumber} and inventory_result = -1 and inventory_status &lt;&gt; -1;
+    </select>
+
+    <select id="countInventoryProfit" parameterType="String" resultType="Integer">
+        SELECT COUNT(0) FROM tb_inventory_detail WHERE order_number = #{orderNumber} and inventory_result = 1 and inventory_status &lt;&gt; -1;
     </select>
         
     <insert id="insertTbInventoryDetail" parameterType="TbInventoryDetail" useGeneratedKeys="true" keyProperty="id">
@@ -46,12 +55,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderNumber != null and orderNumber != ''">order_number,</if>
             <if test="inventoryMetadata != null and inventoryMetadata != ''">inventory_metadata,</if>
             <if test="inventoryStatus != null">inventory_status,</if>
+            <if test="inventoryResult != null">inventory_result,</if>
+            <if test="inventoryQuantity != null">inventory_quantity,</if>
             <if test="remark != null">remark,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="orderNumber != null and orderNumber != ''">#{orderNumber},</if>
             <if test="inventoryMetadata != null and inventoryMetadata != ''">#{inventoryMetadata},</if>
             <if test="inventoryStatus != null">#{inventoryStatus},</if>
+            <if test="inventoryResult != null">#{inventoryResult},</if>
+            <if test="inventoryQuantity != null">#{inventoryQuantity},</if>
             <if test="remark != null">#{remark},</if>
          </trim>
     </insert>
@@ -62,6 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderNumber != null and orderNumber != ''">order_number = #{orderNumber},</if>
             <if test="inventoryMetadata != null and inventoryMetadata != ''">inventory_metadata = #{inventoryMetadata},</if>
             <if test="inventoryStatus != null">inventory_status = #{inventoryStatus},</if>
+            <if test="inventoryResult != null">inventory_result = #{inventoryResult},</if>
+            <if test="inventoryQuantity != null">inventory_quantity = #{inventoryQuantity},</if>
             <if test="remark != null">remark = #{remark},</if>
         </trim>
         where id = #{id}
@@ -71,6 +86,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from tb_inventory_detail where id = #{id}
     </delete>
 
+    <delete id="deleteTbInventoryDetailByOrderNumber" parameterType="String">
+        delete from tb_inventory_detail where order_number = #{orderNumber}
+    </delete>
+
     <delete id="deleteTbInventoryDetailByOrderNumbers" parameterType="String">
         delete from tb_inventory_detail where order_number in
         <foreach item="orderNumber" collection="orderNumbers" open="(" separator="," close=")">

+ 2 - 2
ruoyi-common/pom.xml

@@ -20,8 +20,8 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>8</source>
-                    <target>8</target>
+                    <source>11</source>
+                    <target>11</target>
                 </configuration>
             </plugin>
         </plugins>

+ 1 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -113,7 +113,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 .antMatchers("/login", "/register", "/captchaImage","/inventory/inventory/takeStock", "/inventory/inventory/info/**", "/asset/location/tree","/visitor/**", "/print/**").permitAll()
                 // 静态资源,可匿名访问
-                .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**", "/asset/location/code/**").permitAll()
+                .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**", "/asset/location/code/**", "/inventory/inventory/code/**").permitAll()
                 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()

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

@@ -51,3 +51,7 @@ export function delInventory(id) {
     method: 'delete'
   })
 }
+
+export function selectQrCode(number, v) {
+  return `/inventory/inventory/code/${number}?v=${v}`
+}

+ 2 - 0
ruoyi-ui/src/components/asset/assetCard.vue

@@ -7,6 +7,8 @@
       <el-descriptions-item label="epc补充长度" v-if="assetInfo.epcReplenishLength">{{assetInfo.epcReplenishLength}}</el-descriptions-item>
       <el-descriptions-item label="资产编号" v-if="assetInfo.number">{{assetInfo.number}}</el-descriptions-item>
       <el-descriptions-item label="资产名称" v-if="assetInfo.name">{{assetInfo.name}}</el-descriptions-item>
+      <el-descriptions-item label="数量" v-if="assetInfo.quantity">{{assetInfo.quantity}}</el-descriptions-item>
+      <el-descriptions-item label="计量单位" v-if="assetInfo.units">{{assetInfo.units}}</el-descriptions-item>
       <el-descriptions-item label="分类ID" v-if="assetInfo.categoryId">{{assetInfo.categoryId}}</el-descriptions-item>
       <el-descriptions-item label="分类编号" v-if="assetInfo.categoryNumber">{{assetInfo.categoryNumber}}</el-descriptions-item>
       <el-descriptions-item label="分类名称" v-if="assetInfo.categoryName">{{assetInfo.categoryName}}</el-descriptions-item>

+ 4 - 4
ruoyi-ui/src/views/asset/information/index.vue

@@ -249,10 +249,10 @@
           <span>{{ scope.row.userDepartment != null ? companyName(scope.row.userDepartment) : '' }}</span>
         </template> -->
       </el-table-column>
-      <el-table-column v-if="isExist('管理部门')" label="管理部门" align="center" prop="departmentName">
-        <!-- <template slot-scope="scope">
-          <span>{{ scope.row.department != null ? companyName(scope.row.department) : '' }}</span>
-        </template> -->
+      <el-table-column v-if="isExist('管理部门')" label="管理部门" align="center">
+        <template slot-scope="scope">
+          <span>{{ scope.row.departmentName }}</span>
+        </template>
       </el-table-column>
       <el-table-column label="所在位置" align="center" prop="locationName" width="120">
         <template slot-scope="scope">

+ 45 - 14
ruoyi-ui/src/views/inventory/detail/index.vue

@@ -20,6 +20,16 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item label="盘点结果 " prop="inventoryResult">
+        <el-select v-model="queryParams.inventoryResult" placeholder="请选择盘点结果" clearable>
+          <el-option
+            v-for="dict in dict.type.inventory_detail_inventory_result"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -76,7 +86,7 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="编号" align="center" prop="id" />
       <el-table-column label="资产名称" align="center" prop="assetInfo.name" />
-      <el-table-column label="资产位置" align="center">
+      <el-table-column label="资产位置" align="center" width="140">
         <template slot-scope="props">
           <span>{{(props.row.assetInfo.ancestorLocationName ? props.row.assetInfo.ancestorLocationName + "-" : "") +  (props.row.assetInfo.parentLocationName ?  props.row.assetInfo.parentLocationName + "-" : "") + props.row.assetInfo.locationName}}</span>
         </template>
@@ -102,6 +112,17 @@
           <dict-tag :options="dict.type.inventory_detail_is_update_data" :value="scope.row.inventoryStatus"/>
         </template>
       </el-table-column>
+      <el-table-column label="账面数量" align="center" width="150">
+        <template slot-scope="props">
+          <span>{{ props.row.assetInfo.quantity }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="实点数量" align="center" prop="inventoryQuantity"/>
+      <el-table-column label="盘点结果" align="center" prop="inventoryResult">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.inventory_detail_inventory_result" :value="scope.row.inventoryResult"/>
+        </template>
+      </el-table-column>
       <el-table-column label="备注" align="center" prop="remark"  v-if="columns[3].visible" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
@@ -150,6 +171,19 @@
             ></el-option>
           </el-select>
         </el-form-item>
+        <!-- <el-form-item label="盘点数量" prop="orderNumber">
+          <el-input-number size="small" v-model="form.inventoryQuantity" :min="0"></el-input-number>
+        </el-form-item>
+        <el-form-item label="盘点结果" prop="inventoryResult">
+          <el-select v-model="form.inventoryResult" placeholder="请选择盘点结果">
+            <el-option
+              v-for="dict in dict.type.inventory_detail_inventory_result"
+              :key="dict.value"
+              :label="dict.label"
+              :value="parseInt(dict.value)"
+            ></el-option>
+          </el-select>
+        </el-form-item> -->
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" placeholder="请输入备注" />
         </el-form-item>
@@ -179,20 +213,13 @@ import { listDetail, getDetail, delDetail, addDetail, updateDetail } from "@/api
 
 export default {
   name: "Detail",
-  dicts: ['inventory_detail_is_update_data'],
-  props: {
-    orderNumber: {
-      type: String,
-      default() {
-        return null
-      }
-    }
-  },
+  dicts: ['inventory_detail_is_update_data', 'inventory_detail_inventory_result'],
   components: {
     AssetInfo: () => import("@/components/asset/assetCard.vue"),
   },
   data() {
     return {
+      orderNumber: null,
       // 遮罩层
       loading: true,
       // 选中数组
@@ -216,7 +243,7 @@ export default {
       columns: [
         { key: 0, label: `资产编号`, visible: false },
         { key: 1, label: `创建时间`, visible: false },
-        { key: 2, label: `盘点元数据`, visible: true },
+        { key: 2, label: `盘点元数据`, visible: false },
         { key: 3, label: `备注`, visible: false }
       ],
       // 是否显示弹出层
@@ -227,6 +254,7 @@ export default {
         pageSize: 10,
         orderNumber: null,
         inventoryStatus: null,
+        inventoryResult: null,
       },
       // 表单参数
       form: {},
@@ -245,7 +273,8 @@ export default {
     };
   },
   created() {
-    this.queryParams.orderNumber = this.orderNumber
+    this.orderNumber = this.$route.query.orderNumber
+    this.queryParams.orderNumber = this.$route.query.orderNumber;
     this.getList();
   },
   methods: {
@@ -270,9 +299,11 @@ export default {
     reset() {
       this.form = {
         id: null,
-        orderNumber: null,
+        orderNumber: this.orderNumber,
         inventoryMetadata: null,
         inventoryStatus: null,
+        inventoryResult: null,
+        inventoryQuantity: null,
         remark: null
       };
       this.resetForm("form");
@@ -344,7 +375,7 @@ export default {
     handleExport() {
       this.download('inventory/detail/export', {
         ...this.queryParams
-      }, `detail_${new Date().getTime()}.xlsx`)
+      }, `${this.orderNumber}资产盘点报表_${new Date().getTime()}.xlsx`)
     },
     onSelectOriginalAssetInfo(info) {
       const json = JSON.parse(info);

+ 34 - 40
ruoyi-ui/src/views/inventory/inventory/index.vue

@@ -129,27 +129,32 @@
 
     <el-table ref="elTable" v-loading="loading" :data="inventoryList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="资产盘点记录编号" align="center" prop="id" />
-      <el-table-column label="单据编号" align="center" prop="orderNumber" width="120">
+      <el-table-column label="ID" align="center" prop="id" />
+      <el-table-column label="单据编号" align="center" prop="orderNumber" width="100">
         <template slot-scope="scope">
           <el-tooltip class="item" effect="dark" content="查看明细" placement="left">
             <div class="clickNumber" @click="onOpenDetail(scope.row.orderNumber)">{{scope.row.orderNumber}}</div>
           </el-tooltip>
+          <!-- <router-link :to="`/inventory/inventory/detail/${scope.row.orderNumber}`" class="link-type">
+            <span>{{ scope.row.orderNumber }}</span>
+          </router-link> -->
         </template>
       </el-table-column>
       <el-table-column label="任务名称" align="center" prop="name" width="190"/>
-      <el-table-column label="盘点部门" align="center" prop="deptName" >
-        <!-- <template slot-scope="scope">
-          <span>{{ scope.row.inventoryDepartment != null ? companyName(scope.row.inventoryDepartment) : ""}}</span>
-        </template> -->
+      <el-table-column label="二维码" align="center" prop="orderNumber" width="90">
+        <template slot-scope="scope">
+          <image-preview :src="getCode(scope.row.orderNumber)" :width="80" :height="80" />
+        </template>
+      </el-table-column>
+      <el-table-column label="盘点部门" align="center" prop="inventoryDepartmentName" />
+      <el-table-column label="盘点位置" align="center" prop="inventoryLocationName" width="200">
       </el-table-column>
       <el-table-column label="盘点人" align="center" prop="inventoryBy" />
-      <el-table-column label="盘点日期" align="center" prop="inventoryDate" width="180">
+      <el-table-column label="盘点日期" align="center" prop="inventoryDate" width="100">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.inventoryDate, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="盘点位置" align="center" prop="inventoryLocationName" width="200"/>
       <el-table-column label="盘点状态 " align="center" prop="inventoryStatus">
         <template slot-scope="scope">
           <dict-tag :options="dict.type.inventory_status" :value="scope.row.inventoryStatus"/>
@@ -231,22 +236,17 @@
           </el-date-picker>
         </el-form-item>
         <el-form-item label="盘点位置" prop="inventoryLocation">
-          <div v-if="!isUpdate">
-            <treeselect
-            v-model="form.inventoryLocation" 
-            :multiple="true"
-            :clearable="true"
-            :searchable="true"
-            :open-on-click="true"
-            :clear-on-select="true"
-            :sort-value-by="'INDEX'"
-            :options="locationOption"
-            :limit="3" 
-            placeholder="选择位置" />
-          </div>
-          <div v-else>
-            {{form.inventoryLocationName}}
-          </div>
+          <treeselect
+          v-model="form.inventoryLocation" 
+          :multiple="true"
+          :clearable="true"
+          :searchable="true"
+          :open-on-click="true"
+          :clear-on-select="true"
+          :sort-value-by="'INDEX'"
+          :options="locationOption"
+          :limit="3" 
+          placeholder="选择位置" />
         </el-form-item>
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" placeholder="请输入备注" />
@@ -266,20 +266,15 @@
     <el-dialog :visible.sync="openUserSearch">
       <UserSearch @submit="onSelectUser" @cancel="() => {openUserSearch = false}" v-if="openUserSearch"></UserSearch>
     </el-dialog>
-
-    <el-dialog :visible.sync="openDetail" width="900px">
-      <InventoryDetaile :orderNumber="inventoryNumber" v-if="openDetail"></InventoryDetaile>
-    </el-dialog>
   </div>
 </template>
 
 <script>
 import { deptTreeSelect } from '@/api/system/user.js'
-import { listInventory, getInventory, delInventory, addInventory, updateInventory, listInventoryDTO } from "@/api/inventory/inventory";
+import { listInventory, getInventory, delInventory, addInventory, updateInventory,selectQrCode } from "@/api/inventory/inventory";
 import { treeSelect } from "@/api/asset/location";
 import { listDept } from "@/api/system/dept";
 import UserSearch from '@/components/SysUserSearch/index.vue'
-import InventoryDetaile from '@/views/inventory/detail/index.vue'
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 export default {
@@ -287,14 +282,11 @@ export default {
   dicts: ['inventory_result', 'asset_record_status', 'inventory_status'],
   components : {
     UserSearch,
-    InventoryDetaile,
     Treeselect
   },
   data() {
     return {
       openUserSearch: false,
-      // 是否显示明细
-      openDetail: false,
       // 盘点单号
       inventoryNumber: '',
       // 遮罩层
@@ -319,7 +311,6 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
-      isUpdate: false,
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -364,9 +355,13 @@ export default {
     this.getDeptTree()
   },
   methods: {
+    getCode(number) {
+      return selectQrCode(number, Math.random())
+    },
     onOpenDetail(number) {
-      this.inventoryNumber = number
-      this.openDetail = true
+      this.$router.push({
+        path: `/inventory/detail?orderNumber=${number}`
+      })
     },
     /** 查询部门下拉树结构 */
     getDeptTree() {
@@ -380,7 +375,7 @@ export default {
     },
     tenantIdnormalizer(node) {
       return {
-        id: node.number,
+        id: node.id,
         label: node.label,
         children: node.children
       }
@@ -392,7 +387,7 @@ export default {
       listDept().then((response) => {
         this.arr = response.data
       });
-      listInventoryDTO(this.queryParams).then(response => {
+      listInventory(this.queryParams).then(response => {
         this.inventoryList = response.rows;
         this.total = response.total;
         this.loading = false;
@@ -416,7 +411,6 @@ export default {
     },
     // 表单重置
     reset() {
-      this.isUpdate = false
       this.form = {
         id: null,
         orderNumber: null,
@@ -474,7 +468,7 @@ export default {
       const id = row.id || this.ids
       getInventory(id).then(response => {
         this.form = response.data;
-        this.isUpdate = true;
+        this.form.inventoryLocation = response.data.inventoryLocation.split(",").map(Number)
         this.open = true;
         this.title = "修改资产盘点记录";
       });