Quellcode durchsuchen

优化资产盘点报表

LinWuTai vor 1 Jahr
Ursprung
Commit
6a95353410

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

@@ -3,6 +3,7 @@ package com.ruoyi.inventory.controller;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
@@ -11,6 +12,8 @@ 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.inventory.domain.enums.InventoryPlanResult;
+import com.ruoyi.inventory.domain.enums.InventoryPlanStatus;
 import com.ruoyi.system.service.ISysDeptService;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -72,6 +75,17 @@ public class TbAssetInventoryController extends BaseController
     public void export(HttpServletResponse response, TbAssetInventory tbAssetInventory)
     {
         List<TbAssetInventory> list = tbAssetInventoryService.selectTbAssetInventoryList(tbAssetInventory);
+        for (TbAssetInventory assetInventory : list) {
+            Integer inventoryStatus = assetInventory.getInventoryStatus();
+            assetInventory.setInventoryStatusName(InventoryPlanStatus.getName(inventoryStatus));
+
+            Integer inventoryResult = assetInventory.getInventoryResult();
+            assetInventory.setInventoryResultName(InventoryPlanResult.getName(inventoryResult));
+
+            Integer recordStatus = assetInventory.getRecordStatus();
+            String recordStatusName = recordStatus > 0 ? "已提交" : "未提交";
+            assetInventory.setRecordStatusName(recordStatusName);
+        }
         ExcelUtil<TbAssetInventory> util = new ExcelUtil<TbAssetInventory>(TbAssetInventory.class);
         util.exportExcel(response, list, "资产盘点记录数据");
     }

+ 35 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbInventoryDetailController.java

@@ -3,6 +3,8 @@ package com.ruoyi.inventory.controller;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.date.DateUtil;
@@ -86,6 +88,30 @@ public class TbInventoryDetailController extends BaseController
     }
 
     /**
+     * 导出资产盘点记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('inventory:inventory:export')")
+    @Log(title = "资产盘点报表", businessType = BusinessType.EXPORT)
+    @PostMapping("/export/detail")
+    public void exportDetail(HttpServletResponse response, TbAssetInventory tbAssetInventory)
+    {
+        List<TbAssetInventory> tbAssetInventoryList = tbAssetInventoryMapper.selectTbAssetInventoryList(tbAssetInventory);
+        List<AssetInventoryStatement> assetInventoryStatements = new ArrayList<>();
+
+        for (TbAssetInventory assetInventory : tbAssetInventoryList) {
+            String orderNumber = assetInventory.getOrderNumber();
+
+            List<TbInventoryDetail> tbInventoryDetails = tbInventoryDetailService.selectTbInventoryDetailByOrderNumber(orderNumber);
+            List<AssetInventoryStatement> assetInventoryStatementList = getInventoryStatement(assetInventory, tbInventoryDetails);
+            assetInventoryStatements.addAll(assetInventoryStatementList);
+        }
+
+        ExcelUtil<AssetInventoryStatement> util = new ExcelUtil<>(AssetInventoryStatement.class);
+
+        util.exportExcel(response, assetInventoryStatements, "资产盘点报表");
+    }
+
+    /**
      * 获取盘点报表
      *
      * @param tbAssetInventory 盘点计划信息
@@ -97,6 +123,12 @@ public class TbInventoryDetailController extends BaseController
 
         for (TbInventoryDetail inventoryDetail : list) {
             AssetInventoryStatement assetInventoryStatement = new AssetInventoryStatement();
+            // 设置盘点编码
+            assetInventoryStatement.setOrderNumber(tbAssetInventory.getOrderNumber());
+
+            // 设置计划名称
+            assetInventoryStatement.setOrderName(tbAssetInventory.getName());
+
             // 设置盘点部门
             assetInventoryStatement.setInventoryDepartmentName(tbAssetInventory.getInventoryDepartmentName());
 
@@ -144,6 +176,9 @@ public class TbInventoryDetailController extends BaseController
             String inventoryResultName = InventoryResult.getName(inventoryResult);
             assetInventoryStatement.setInventoryResult(inventoryResultName);
 
+            // 设置盘点位置
+            assetInventoryStatement.setInventoryLocation(tbAssetInventory.getInventoryLocationName());
+
             // 设置盘点时间
             assetInventoryStatement.setInventoryDate(tbAssetInventory.getInventoryDate());
 

+ 9 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/domain/TbAssetInventory.java

@@ -58,14 +58,23 @@ public class TbAssetInventory extends BaseEntity
     @Excel(name = "盘点状态,0:盘点编制,1:盘点执行,2:盘点完毕,3:盘点暂停")
     private Integer inventoryStatus;
 
+    @Excel(name = "盘点状态名称(导出)")
+    private String inventoryStatusName;
+
     /** 盘点结果,0:未开始,1:盘盈,2:盘亏,3:正常 */
     @Excel(name = "盘点结果,0:未开始,1:盘盈,2:盘亏,3:正常")
     private Integer inventoryResult;
 
+    @Excel(name = "盘点结果名称(导出)")
+    private String inventoryResultName;
+
     /** 记录状态,0:未提交,1:已提交 */
     @Excel(name = "记录状态,0:未提交,1:已提交")
     private Integer recordStatus;
 
+    @Excel(name = "记录状态名称(导出)")
+    private String recordStatusName;
+
     /** 记录创建时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "记录创建时间", width = 30, dateFormat = "yyyy-MM-dd")

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

@@ -14,6 +14,12 @@ import java.util.Date;
  */
 @Data
 public class AssetInventoryStatement {
+    @Excel(name = "计划编码")
+    private String orderNumber;
+
+    @Excel(name = "计划名称")
+    private String orderName;
+
     /** 资产编码 */
     @Excel(name = "资产编码")
     private String assetNumber;

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/ITbInventoryDetailService.java

@@ -2,6 +2,7 @@ package com.ruoyi.inventory.service;
 
 import java.util.List;
 import com.ruoyi.inventory.domain.TbInventoryDetail;
+import com.ruoyi.inventory.domain.dto.AssetInventoryStatement;
 
 /**
  * 资产盘点明细Service接口
@@ -19,6 +20,8 @@ public interface ITbInventoryDetailService
      */
     public TbInventoryDetail selectTbInventoryDetailById(Long id);
 
+    public List<TbInventoryDetail> selectTbInventoryDetailByOrderNumber(String orderNumber);
+
     /**
      * 查询资产盘点明细列表
      * 

+ 5 - 0
ruoyi-admin/src/main/java/com/ruoyi/inventory/service/impl/TbInventoryDetailServiceImpl.java

@@ -51,6 +51,11 @@ public class TbInventoryDetailServiceImpl implements ITbInventoryDetailService
         return tbInventoryDetailMapper.selectTbInventoryDetailById(id);
     }
 
+    @Override
+    public List<TbInventoryDetail> selectTbInventoryDetailByOrderNumber(String orderNumber) {
+        return tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
+    }
+
 
     /**
      * 查询资产盘点明细列表

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

@@ -130,7 +130,7 @@
           plain
           icon="el-icon-download"
           size="mini"
-          @click="handleExport"
+          @click="onOpenExportDetail"
           v-hasPermi="['inventory:inventory:export']"
         >导出报表</el-button>
       </el-col>
@@ -277,6 +277,34 @@
     <el-dialog :visible.sync="openUserSearch">
       <UserSearch @submit="onSelectUser" @cancel="() => {openUserSearch = false}" v-if="openUserSearch"></UserSearch>
     </el-dialog>
+
+    <el-dialog title="导出报表" :visible.sync="openExport" width="360px">
+      <el-form ref="form" :model="exportParams" label-width="80px">
+        <el-form-item label="盘点部门" prop="inventoryDepartment">
+          <treeselect
+              v-model="exportParams.inventoryDepartment"
+              :options="deptOptions"
+              placeholder="选择盘点部门"
+              @keyup.enter.native="handleQuery"
+            />
+        </el-form-item>
+        <el-form-item label="盘点地点" prop="inventoryLocation">
+          <treeselect v-model="exportParams.inventoryLocation" :options="locationOption" :normalizer="tenantIdnormalizer" placeholder="选择位置" @keyup.enter.native="handleQuery" />
+        </el-form-item>
+        <el-form-item label="盘点日期" prop="inventoryDate">
+          <el-date-picker clearable
+            v-model="exportParams.inventoryDate"
+            type="date"
+            value-format="yyyy-MM-dd"
+            placeholder="请选择盘点日期">
+          </el-date-picker>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitExport">确 定</el-button>
+        <el-button @click="openExport=false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -336,6 +364,13 @@ export default {
         inventoryResult: null,
         recordStatus: null,
       },
+      openExport: false,
+      exportParams: {
+        inventoryDepartment: null,
+        inventoryDate: null,
+        inventoryLocation: null,
+        recordStatus: 1,
+      },
       pickerOptions: {
         disabledDate(time) {
           return time.getTime() < Date.now() - 8.64e7;
@@ -379,6 +414,22 @@ export default {
         path: `/inventory/detail?orderNumber=${number}`
       })
     },
+    onOpenExportDetail() {
+      const queryParams = this.queryParams
+      this.exportParams = {
+        inventoryDepartment: queryParams.inventoryDepartment,
+        inventoryDate: queryParams.inventoryDate,
+        inventoryLocation: queryParams.inventoryLocation,
+        recordStatus: 1,
+      }
+      this.openExport = true
+    },
+    submitExport() {
+      this.download('inventory/detail/export/detail', {
+        ...this.exportParams
+      }, `资产盘点报表_${new Date().getTime()}.xlsx`)
+      this.openExport = false
+    },
     /** 查询部门下拉树结构 */
     getDeptTree() {
       deptTreeSelect().then((response) => {