From 8aa4ffc8a81a0a8d98bc89b969707c90a5c1fc53 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期三, 31 一月 2024 14:37:53 +0800
Subject: [PATCH] 设备管理按照车间筛选和导出

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java                  |    8 ++-
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml         |   32 +++++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java    |   18 +++++----
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java |   11 +++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java            |    7 +++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java         |    6 +++
 6 files changed, 70 insertions(+), 12 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
index c76195d..9ff87ae 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentController.java
@@ -1,6 +1,5 @@
 package org.jeecg.modules.mdc.controller;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -13,9 +12,7 @@
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.mdc.dto.MdcEquipmentDto;
 import org.jeecg.modules.mdc.entity.MdcEquipment;
 import org.jeecg.modules.mdc.entity.MdcEquipmentMonitor;
@@ -431,14 +428,19 @@
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, MdcEquipment mdcEquipment) {
         // Step.1 缁勮鏌ヨ鏉′欢
-        QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap());
+        //QueryWrapper<MdcEquipment> queryWrapper = QueryGenerator.initQueryWrapper(mdcEquipment, request.getParameterMap());
         //Step.2 AutoPoi 瀵煎嚭Excel
         ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
-        String selections = request.getParameter("selections");
-        if (!oConvertUtils.isEmpty(selections)) {
-            queryWrapper.in("id", selections.split(","));
+        List<MdcEquipment> pageList = mdcEquipmentService.exportXlsList(mdcEquipment);
+        List<String> equipmentIds = pageList.stream().map(MdcEquipment::getId).collect(Collectors.toList());
+        if (!equipmentIds.isEmpty()) {
+            Map<String, String> equDepNames = mdcEquipmentService.getDepNamesByEquipmentIds(equipmentIds);
+            Map<String, String> equProNames = mdcEquipmentService.getProNamesByEquipmentIds(equipmentIds);
+            pageList.forEach(item -> {
+                item.setOrgCodeTxt(equDepNames.get(item.getId()));
+                item.setProductionName(equProNames.get(item.getId()));
+            });
         }
-        List<MdcEquipment> pageList = mdcEquipmentService.list(queryWrapper);
         mv.addObject(NormalExcelConstants.FILE_NAME, "璁惧鍒楄〃");
         mv.addObject(NormalExcelConstants.CLASS, MdcEquipment.class);
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java
index 787e61d..cc47df4 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/MdcEquipment.java
@@ -47,13 +47,13 @@
     /**
      * 鎶ヨ鍙�
      */
-    @Excel(name = "鎶ヨ鍙�", width = 15)
+    //@Excel(name = "鎶ヨ鍙�", width = 15)
     @ApiModelProperty(value = "鎶ヨ鍙�")
     private String alarm;
     /**
      * 閲囬泦鏃堕棿
      */
-    @Excel(name = "閲囬泦鏃堕棿", width = 15)
+    //@Excel(name = "閲囬泦鏃堕棿", width = 15)
     @ApiModelProperty(value = "閲囬泦鏃堕棿")
     private String collectTime;
     /**
@@ -65,7 +65,7 @@
     /**
      * 璁惧瀹炴椂鐘舵��
      */
-    @Excel(name = "璁惧瀹炴椂鐘舵��", width = 15)
+    //@Excel(name = "璁惧瀹炴椂鐘舵��", width = 15)
     @ApiModelProperty(value = "璁惧瀹炴椂鐘舵��")
     private Integer oporation;
     /**
@@ -132,9 +132,11 @@
     private Integer equipmentStatus;
 
     /**閮ㄩ棬鍚嶇О*/
+    @Excel(name = "閮ㄩ棬鍚嶇О", width = 15)
     private transient String orgCodeTxt;
 
     /**浜х嚎鍚嶇О*/
+    @Excel(name = "杞﹂棿鍚嶇О", width = 15)
     private transient String productionName;
 
     @TableField(exist = false)
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
index 0f32435..4cab5f9 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMapper.java
@@ -98,4 +98,11 @@
 
     @InterceptorIgnore(tenantLine = "1")
     MdcEquipmentDto getWorkLineLast(@Param("tableName") String saveTableName);
+
+    /**
+     * 瀵煎嚭list
+     * @param mdcEquipment
+     * @return
+     */
+    List<MdcEquipment> exportXlsList(@Param("mdcEquipment") MdcEquipment mdcEquipment);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
index 298d26e..492e4b3 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMapper.xml
@@ -239,7 +239,7 @@
                 AND t1.drive_type = #{mdcEquipment.driveType}
             </if>
             <if test="mdcEquipment.productionName != null and mdcEquipment.productionName != '' ">
-                AND t3.production_name LIKE CONCAT(CONCAT('%',#{mdcEquipment.productionName}),'%')
+                AND t3.id = #{ mdcEquipment.productionName } OR t3.parent_id = #{ mdcEquipment.productionName }
             </if>
         </where>
         order by t1.sort_no
@@ -250,4 +250,34 @@
         select top 1 spindlespeed, actualspindlespeed from [${tableName}] order by CollectTime  desc
     </select>
 
+    <select id="exportXlsList" resultType="org.jeecg.modules.mdc.entity.MdcEquipment">
+        SELECT
+            t1.*
+        FROM
+            mdc_equipment t1
+            LEFT JOIN mdc_production_equipment t2 ON t1.id = t2.equipment_id
+            LEFT JOIN mdc_production t3 ON t2.production_id = t3.id
+        <where>
+            <if test="mdcEquipment.equipmentId != null and mdcEquipment.equipmentId != '' ">
+                AND t1.equipment_id LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentId}),'%')
+            </if>
+            <if test="mdcEquipment.equipmentName != null and mdcEquipment.equipmentName != '' ">
+                AND t1.equipment_name LIKE CONCAT(CONCAT('%',#{mdcEquipment.equipmentName}),'%')
+            </if>
+            <if test="mdcEquipment.equipmentModel != null and mdcEquipment.equipmentModel != '' ">
+                AND t1.equipment_name = #{mdcEquipment.equipmentModel}
+            </if>
+            <if test="mdcEquipment.equipmentType != null and mdcEquipment.equipmentType != '' ">
+                AND t1.equipmentType = #{mdcEquipment.equipmentType}
+            </if>
+            <if test="mdcEquipment.driveType != null and mdcEquipment.driveType != '' ">
+                AND t1.drive_type = #{mdcEquipment.driveType}
+            </if>
+            <if test="mdcEquipment.productionName != null and mdcEquipment.productionName != '' ">
+                AND t3.id = #{ mdcEquipment.productionName } OR t3.parent_id = #{ mdcEquipment.productionName }
+            </if>
+        </where>
+        order by t1.sort_no
+    </select>
+
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
index 4ea1405..1880efa 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentService.java
@@ -182,5 +182,11 @@
      */
     void monitoringSpeedProcess();
 
+    /**
+     * 瀵煎嚭List
+     * @param mdcEquipment
+     * @return
+     */
+    List<MdcEquipment> exportXlsList(MdcEquipment mdcEquipment);
 
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
index a0fb120..5eb7085 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java
@@ -766,4 +766,15 @@
 
     }
 
+    /**
+     * 瀵煎嚭list
+     *
+     * @param mdcEquipment
+     * @return
+     */
+    @Override
+    public List<MdcEquipment> exportXlsList(MdcEquipment mdcEquipment) {
+        return this.baseMapper.exportXlsList(mdcEquipment);
+    }
+
 }

--
Gitblit v1.9.3