Quellcode durchsuchen

优化盘点的部门查询

LinWuTai vor 1 Jahr
Ursprung
Commit
6f311c8cd1

+ 19 - 9
ruoyi-admin/src/main/java/com/ruoyi/inventory/controller/TbInventoryDetailController.java

@@ -5,6 +5,7 @@ import java.util.Date;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
 import com.ruoyi.asset.domain.TbAssetInformation;
@@ -69,7 +70,6 @@ public class TbInventoryDetailController extends BaseController
     public void export(HttpServletResponse response, TbInventoryDetail tbInventoryDetail)
     {
         List<TbInventoryDetail> list = tbInventoryDetailService.selectTbInventoryDetailList(tbInventoryDetail);
-        List<AssetInventoryStatement> assetInventoryStatements = new ArrayList<>();
 
         String orderNumber = tbInventoryDetail.getOrderNumber();
         if (StrUtil.isBlank(orderNumber)) {
@@ -78,14 +78,25 @@ public class TbInventoryDetailController extends BaseController
 
         TbAssetInventory tbAssetInventory = tbAssetInventoryMapper.selectTbAssetInventoryByNumber(orderNumber);
 
-        for (TbInventoryDetail inventoryDetail : list) {
-            AssetInventoryStatement assetInventoryStatement = new AssetInventoryStatement();
-            // 设置计划编码
-            assetInventoryStatement.setOrderNumber(inventoryDetail.getOrderNumber());
+        List<AssetInventoryStatement> assetInventoryStatements = getInventoryStatement(tbAssetInventory, list);
 
-            // 设置盘点名称
-            assetInventoryStatement.setInventoryName(tbAssetInventory.getName());
+        ExcelUtil<AssetInventoryStatement> util = new ExcelUtil<>(AssetInventoryStatement.class);
 
+        util.exportExcel(response, assetInventoryStatements, DateUtil.format(tbAssetInventory.getInventoryDate(), "yyyy年MM月dd日"), tbAssetInventory.getName());
+    }
+
+    /**
+     * 获取盘点报表
+     *
+     * @param tbAssetInventory 盘点计划信息
+     * @param list 盘点详细列表
+     * @return 盘点报表列表
+     */
+    private List<AssetInventoryStatement> getInventoryStatement(TbAssetInventory tbAssetInventory, List<TbInventoryDetail> list) {
+        List<AssetInventoryStatement> assetInventoryStatements = new ArrayList<>();
+
+        for (TbInventoryDetail inventoryDetail : list) {
+            AssetInventoryStatement assetInventoryStatement = new AssetInventoryStatement();
             // 设置盘点部门
             assetInventoryStatement.setInventoryDepartmentName(tbAssetInventory.getInventoryDepartmentName());
 
@@ -142,8 +153,7 @@ public class TbInventoryDetailController extends BaseController
             assetInventoryStatements.add(assetInventoryStatement);
         }
 
-        ExcelUtil<AssetInventoryStatement> util = new ExcelUtil<>(AssetInventoryStatement.class);
-        util.exportExcel(response, assetInventoryStatements, "资产盘点报表");
+        return assetInventoryStatements;
     }
 
     /**

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

@@ -55,14 +55,6 @@ public class AssetInventoryStatement {
     @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;

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

@@ -6,7 +6,8 @@ spring:
         druid:
             # 主库数据源
             master:
-                #url: jdbc:mysql://139.9.50.163:3306/rfid-hotel-manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+#                url: jdbc:mysql://139.9.50.163:3306/rfid_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+#                password: ydl@123456
                 url: jdbc:mysql://127.0.0.1:3306/rfid-hotel-manager?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
                 password: mysql@123456
                 username: root

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

@@ -49,7 +49,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>  
             <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="inventoryDepartment != null  and inventoryDepartment != ''"> and a.inventory_department = #{inventoryDepartment} OR a.inventory_department in (
+                SELECT DISTINCTROW dept_id from sys_dept WHERE ancestors like concat('%', #{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>

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

@@ -124,6 +124,16 @@
           v-hasPermi="['inventory:inventory:export']"
         >导出</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['inventory:inventory:export']"
+        >导出报表</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -232,7 +242,8 @@
             v-model="form.inventoryDate"
             type="date"
             value-format="yyyy-MM-dd"
-            placeholder="请选择盘点日期">
+            placeholder="请选择盘点日期"
+            :picker-options="pickerOptions">
           </el-date-picker>
         </el-form-item>
         <el-form-item label="盘点位置" prop="inventoryLocation">
@@ -325,6 +336,11 @@ export default {
         inventoryResult: null,
         recordStatus: null,
       },
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < Date.now() - 8.64e7;
+        }
+      },
       // 表单参数
       form: {},
       // 表单校验