From 0d978c2fcf7ce97c90ee25297f9ebf37079bc18a Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期四, 18 四月 2024 10:05:53 +0800
Subject: [PATCH] 首页利用率排序

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcHomeMapper.java                 |    3 ++-
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalInfoDto.java   |   13 +++++++++++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java        |    9 +++------
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcHomeMapper.xml              |   10 ++++++----
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentServiceImpl.java |    6 +++++-
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentDayUtilizationVo.java         |    4 ++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java     |    9 +++++++--
 7 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalInfoDto.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalInfoDto.java
new file mode 100644
index 0000000..981c87a
--- /dev/null
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/dto/MdcEquipmentStatisticalInfoDto.java
@@ -0,0 +1,13 @@
+package org.jeecg.modules.mdc.dto;
+
+import lombok.Data;
+import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo;
+
+/**
+ * @author Lius
+ * @date 2024/4/18 9:38
+ */
+@Data
+public class MdcEquipmentStatisticalInfoDto extends MdcEquipmentStatisticalInfo {
+    private String equipmentName;
+}
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java
index ebf871a..dee9373 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/job/RunningMonitoringSpeedJob.java
@@ -82,13 +82,10 @@
             for (MdcEquipment mdcEquipment : mdcEquipmentList) {
                 String saveTableName = mdcEquipment.getSaveTableName();
                 MdcEquipmentDto mdcEquipmentDto = new MdcEquipmentDto();
-                try {
-                    //鏌ヨ鍗曡〃鏁版嵁
-                    mdcEquipmentDto = mdcEquipmentService.getWorkLineLast(saveTableName);
 
-                } catch (Exception e) {
-                    log.error("鏌ヨ鍗曡〃鏁版嵁澶辫触!", e);
-                }
+                //鏌ヨ鍗曡〃鏁版嵁
+                mdcEquipmentDto = mdcEquipmentService.getWorkLineLast(saveTableName);
+
                 if (mdcEquipmentDto != null && StringUtils.isNotBlank(mdcEquipmentDto.getSpindlespeed()) && StringUtils.isNotBlank(mdcEquipmentDto.getActualspindlespeed())) {
                     MessageDTO messageDTO = new MessageDTO();
                     messageDTO.setTitle("璁惧杩愯杞�熸姤璀︼紒");
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcHomeMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcHomeMapper.java
index 233a763..856217d 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcHomeMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcHomeMapper.java
@@ -2,6 +2,7 @@
 
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalInfoDto;
 import org.jeecg.modules.mdc.entity.MdcEquipment;
 import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo;
 import org.jeecg.modules.mdc.entity.MdcOverallEquipmentEfficiency;
@@ -86,7 +87,7 @@
     /**
      * 鏌ヨ鍓嶄竷澶╁埄鐢ㄧ巼
      */
-    List<MdcEquipmentStatisticalInfo> getEquipmentSevenUtilizationStatistics(@Param("equipmentIdList") List<String> equipmentIdList, @Param("start") String start, @Param("end") String end);
+    List<MdcEquipmentStatisticalInfoDto> getEquipmentSevenUtilizationStatistics(@Param("equipmentIdList") List<String> equipmentIdList, @Param("start") String start, @Param("end") String end);
 
     List<MdcEquipment> getEquipmentList(@Param("productionId") String productionId);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcHomeMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcHomeMapper.xml
index b809b98..28cc1a9 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcHomeMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcHomeMapper.xml
@@ -123,13 +123,15 @@
             the_date
     </select>
 
-    <select id="getEquipmentSevenUtilizationStatistics" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
+    <select id="getEquipmentSevenUtilizationStatistics" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalInfoDto">
         SELECT
-            equipment_id,
+            t1.equipment_id,
+            t2.equipment_name,
             SUM ( process_long ) processLong,
             SUM ( open_long ) openLong
         FROM
-            mdc_equipment_statistical_info
+            mdc_equipment_statistical_info t1
+            LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id
         <where>
             AND the_date BETWEEN #{start} AND #{end}
             <if test="equipmentIdList != null and equipmentIdList.size() > 0 ">
@@ -140,7 +142,7 @@
             </if>
         </where>
         GROUP BY
-            equipment_id
+            t1.equipment_id,t2.equipment_name
     </select>
 
 
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java
index dc7a99f..2198c50 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/IMdcHomeServiceImpl.java
@@ -1,6 +1,7 @@
 package org.jeecg.modules.mdc.service.impl;
 
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalInfoDto;
 import org.jeecg.modules.mdc.entity.EquipmentLog;
 import org.jeecg.modules.mdc.entity.MdcEquipment;
 import org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo;
@@ -144,6 +145,9 @@
                 result.add(mdcCommonVo);
             }
         }
+        if (!result.isEmpty()) {
+            result.sort(Comparator.comparing(MdcCommonVo::getValue).reversed());
+        }
         return result;
     }
 
@@ -249,12 +253,13 @@
         String end = DateUtils.format(DateUtils.toDate(LocalDate.now().plusDays(-1).toString(), DateUtils.STR_DATE), DateUtils.STRDATE);
         if (equipmentIdList != null && !equipmentIdList.isEmpty()) {
             result.put("equipmentIdList", equipmentIdList);
-            List<MdcEquipmentStatisticalInfo> mdcEquipmentStatisticalInfoList = mdcHomeMapper.getEquipmentSevenUtilizationStatistics(equipmentIdList, start, end);
+            List<MdcEquipmentStatisticalInfoDto> mdcEquipmentStatisticalInfoList = mdcHomeMapper.getEquipmentSevenUtilizationStatistics(equipmentIdList, start, end);
             List<EquipmentDayUtilizationVo> dataList = new ArrayList<>();
             if (mdcEquipmentStatisticalInfoList != null && !mdcEquipmentStatisticalInfoList.isEmpty()) {
-                for (MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfoList) {
+                for (MdcEquipmentStatisticalInfoDto mdcEquipmentStatisticalInfo : mdcEquipmentStatisticalInfoList) {
                     EquipmentDayUtilizationVo equipmentDayUtilizationVo = new EquipmentDayUtilizationVo();
                     equipmentDayUtilizationVo.setEquipmentId(mdcEquipmentStatisticalInfo.getEquipmentId());
+                    equipmentDayUtilizationVo.setEquipmentName(mdcEquipmentStatisticalInfo.getEquipmentName());
                     equipmentDayUtilizationVo.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("864"), 4, RoundingMode.HALF_UP).divide(new BigDecimal(mdcEquipmentStatisticalInfoList.size()), 4, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP));
                     if (BigDecimal.ZERO.compareTo(mdcEquipmentStatisticalInfo.getOpenLong()) == -1) {
                         equipmentDayUtilizationVo.setOpenRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(mdcEquipmentStatisticalInfo.getOpenLong(), 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP));
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 33e6449..588b583 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
@@ -846,7 +846,11 @@
      */
     @Override
     public MdcEquipmentDto getWorkLineLast(String tableName) {
-        return this.baseMapper.findWorkLineLast(tableName);
+        try {
+            return this.baseMapper.findWorkLineLast(tableName);
+        } catch (Exception e) {
+            return null;
+        }
     }
 
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentDayUtilizationVo.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentDayUtilizationVo.java
index c634d10..9f9510e 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentDayUtilizationVo.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/vo/EquipmentDayUtilizationVo.java
@@ -15,6 +15,10 @@
      */
     private String equipmentId;
     /**
+     * 璁惧鍚嶇О
+     */
+    private String equipmentName;
+    /**
      * 鍒╃敤鐜�
      */
     private BigDecimal utilizationRate = BigDecimal.ZERO;

--
Gitblit v1.9.3