From bbfc6a9a5b3a899c7405d06454d315d8c283e23f Mon Sep 17 00:00:00 2001
From: yb <1113799@qq.com>
Date: 星期四, 04 九月 2025 15:12:46 +0800
Subject: [PATCH] 倍率统计导出

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentMagnificationService.java         |   13 +++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java |   48 ++++++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMagnificationMapper.java            |    4 +
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentMagnificationDto.java                  |   27 +++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMagnificationMapper.xml         |   25 ++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentMagnificationController.java    |   24 ++++++-
 6 files changed, 135 insertions(+), 6 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentMagnificationController.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentMagnificationController.java
index b1703bc..58091ab 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentMagnificationController.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/controller/MdcEquipmentMagnificationController.java
@@ -10,15 +10,16 @@
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification;
+import org.jeecg.modules.mdc.entity.MdcProcessQuantity;
 import org.jeecg.modules.mdc.service.IMdcEquipmentMagnificationService;
 import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo;
+import org.jeecg.modules.mdc.vo.MdcProcessQuantityVo;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 @Slf4j
 @Api(tags = "鍊嶇巼缁熻")
@@ -48,4 +49,19 @@
         IPage<MdcEquipmentMagnification> pageList = service.pageList(userId,magnificationVo,pageNo, pageSize, req);
         return Result.OK(pageList);
     }
+
+
+
+    /**
+     * 瀵煎嚭excel
+     *
+     * @param request
+     * @param magnificationVo
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, MdcEquipmentMagnificationVo magnificationVo) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = user.getId();
+        return service.exportXls(userId, magnificationVo);
+    }
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentMagnificationDto.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentMagnificationDto.java
new file mode 100644
index 0000000..9523e34
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentMagnificationDto.java
@@ -0,0 +1,27 @@
+package org.jeecg.modules.mdc.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+
+@Data
+public class MdcEquipmentMagnificationDto {
+
+    @Excel(name = "璁惧缂栧彿", width = 15)
+    private String equipmentId;
+    //  涓昏酱鍊嶇巼骞冲潎鍊�
+    @Excel(name = "涓昏酱鍊嶇巼骞冲潎鍊�", width = 15)
+    private BigDecimal spindlebeilv = new BigDecimal(0);
+    //杩涚粰鍊嶇巼骞冲潎鍊�
+    @Excel(name = "杩涚粰鍊嶇巼骞冲潎鍊�", width = 15)
+    private BigDecimal feedbeilv = new BigDecimal(0);
+    //鏈夋晥鏃ユ湡
+    @ApiModelProperty(value = "鏃ユ湡")
+    @Excel(name = "鏃ユ湡", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private String theDate;
+
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMagnificationMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMagnificationMapper.java
index b2be2d3..9604bc3 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMagnificationMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentMagnificationMapper.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto;
 import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification;
 import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo;
 
@@ -24,4 +25,7 @@
 
     IPage<MdcEquipmentMagnification> pageList(IPage<MdcEquipmentMagnification> pageData, @Param("magnificationVo") MdcEquipmentMagnificationVo magnificationVo);
 
+
+    List<MdcEquipmentMagnificationDto> list(@Param("magnificationVo") MdcEquipmentMagnificationVo magnificationVo);
+
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMagnificationMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMagnificationMapper.xml
index 871dcd8..7034af5 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMagnificationMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentMagnificationMapper.xml
@@ -30,4 +30,29 @@
         ORDER BY t1.the_date ASC
     </select>
 
+
+    <!--鍒嗛〉鍒楄〃鏌ヨ-->
+    <select id="list" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto">
+        SELECT
+        *
+        FROM
+        mdc_equipment_magnification t1
+        WHERE 1=1
+        <if test="magnificationVo.equipmentId != null and magnificationVo.equipmentId != ''">
+            AND t1.equipment_id = #{ magnificationVo.equipmentId }
+        </if>
+        <if test="magnificationVo.startTime != null and magnificationVo.startTime != ''">
+            AND t1.the_date &gt;= #{ magnificationVo.startTime }
+        </if>
+        <if test="magnificationVo.endTime != null and magnificationVo.endTime != ''">
+            AND t1.the_date &lt;= #{ magnificationVo.endTime }
+        </if>
+        <if test="magnificationVo.equipmentIdList != null and magnificationVo.equipmentIdList.size() > 0 ">
+            AND t1.equipment_id IN
+            <foreach collection="magnificationVo.equipmentIdList" item="id" index="index" open="(" close=")" separator=",">
+                #{ id }
+            </foreach>
+        </if>
+        ORDER BY t1.the_date ASC
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentMagnificationService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentMagnificationService.java
index 527052b..2d06f20 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentMagnificationService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentMagnificationService.java
@@ -3,9 +3,8 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.mdc.entity.MdcEquipmentMagnification;
-import org.jeecg.modules.mdc.vo.MdcDeviceCalendarQueryVo;
-import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
 import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo;
+import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -17,4 +16,14 @@
 
 
     IPage<MdcEquipmentMagnification> pageList(String userId, MdcEquipmentMagnificationVo magnificationVo, Integer pageNo, Integer pageSize, HttpServletRequest req);
+
+
+    /**
+     * 瀵煎嚭
+     *
+     * @param userId
+     * @param magnificationVo
+     * @return
+     */
+    ModelAndView exportXls(String userId, MdcEquipmentMagnificationVo magnificationVo);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
index 9237246..a2ade91 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentMagnificationServiceImpl.java
@@ -4,13 +4,20 @@
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.mdc.dto.MdcEquipmentMagnificationDto;
 import org.jeecg.modules.mdc.entity.*;
 import org.jeecg.modules.mdc.mapper.MdcEquipmentMagnificationMapper;
 import org.jeecg.modules.mdc.service.*;
 import org.jeecg.modules.mdc.util.DateUtils;
 import org.jeecg.modules.mdc.vo.MdcDeviceCalendarVo;
 import org.jeecg.modules.mdc.vo.MdcEquipmentMagnificationVo;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.stereotype.Service;
+import org.springframework.web.servlet.ModelAndView;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -130,6 +137,47 @@
         return this.baseMapper.pageList(pageData, magnificationVo);
     }
 
+    @Override
+    public ModelAndView exportXls(String userId, MdcEquipmentMagnificationVo magnificationVo) {
+        List<String> equipmentIds = new ArrayList<>();
+        if (StringUtils.isNotEmpty(magnificationVo.getParentId()) && StringUtils.isEmpty(magnificationVo.getEquipmentId())) {
+            if ("2".equals(magnificationVo.getTypeTree())) {
+                // 閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, magnificationVo.getParentId());
+            } else {
+                // 浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, magnificationVo.getParentId());
+            }
+        } else if (StringUtils.isNotEmpty(magnificationVo.getEquipmentId())) {
+            // 鍗曞彴璁惧淇℃伅
+            magnificationVo.setEquipmentIdList(Collections.singletonList(magnificationVo.getEquipmentId()));
+        } else {
+            // 鏌ヨ鐢ㄦ埛鎷ユ湁鐨勬墍鏈夎澶囦俊鎭�
+            if ("2".equals(magnificationVo.getTypeTree())) {
+                //閮ㄩ棬灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null);
+            } else {
+                //浜х嚎灞傜骇
+                equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null);
+            }
+        }
+        if (magnificationVo.getEquipmentIdList() == null || magnificationVo.getEquipmentIdList().isEmpty()) {
+            magnificationVo.setEquipmentIdList(equipmentIds);
+        }
+        if (magnificationVo.getEquipmentIdList() == null || magnificationVo.getEquipmentIdList().isEmpty()) {
+            return null;
+        }
+        List<MdcEquipmentMagnificationDto> magnificationDtos = super.baseMapper.list(magnificationVo);
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        // 瀵煎嚭鏂囦欢鍚嶇О
+        mv.addObject(NormalExcelConstants.FILE_NAME, "鍊嶇巼鎶ヨ〃");
+        mv.addObject(NormalExcelConstants.CLASS, MdcDownTime.class);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("鍊嶇巼鎶ヨ〃", "瀵煎嚭浜�:" + user.getRealname(), "鍊嶇巼鎶ヨ〃"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, magnificationDtos);
+        return mv;
+    }
+
     private MdcEquipmentMagnification selectMagnification(String equipmentId,String date,String drivetype,List<MdcDriveTypeParamConfig> list) {
         Date startTime = DateUtils.plusTime(DateUtils.getShortDate(date), 0);
         Date endTime = DateUtils.plusTime(DateUtils.getShortDate(date), 1);

--
Gitblit v1.9.3