From f69452a6d1afcb710880b6ad172663316e3b3610 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期二, 14 一月 2025 11:50:15 +0800
Subject: [PATCH] update

---
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentMapper.java                              |   13 ++----
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml         |    5 ++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalInfoMapper.java            |    2 +
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java         |    9 ++++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java         |   41 ++++++++++++++++----
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java |    5 ++
 lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml          |    1 
 7 files changed, 60 insertions(+), 16 deletions(-)

diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentMapper.java
index 2268dc4..e15c85a 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/EquipmentMapper.java
@@ -1,10 +1,7 @@
 package org.jeecg.modules.mdc.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Delete;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 import org.jeecg.modules.mdc.entity.Equipment;
 import org.jeecg.modules.mdc.vo.WsEquipmentStatus;
 import org.jeecg.modules.mdc.vo.WsEquipmentUtilizationRate;
@@ -23,16 +20,16 @@
     @Select(" SELECT name FROM SysObjects Where XType='U' AND name = '${saveTableName}' ")
     String checkTableExists(@Param("saveTableName") String saveTableName);
 
-    @Select(" SELECT COUNT(CollectTime) num FROM [${saveTableName}] WHERE CollectTime < '${day}' ")
+    @Select(" SELECT COUNT(CollectTime) num FROM ${saveTableName} WHERE CollectTime < '${day}' ")
     Integer checkTableDataNum(@Param("saveTableName") String saveTableName, @Param("day") String day);
 
-    @Insert(" INSERT INTO [${tableName}] SELECT * FROM [${lastTableName}]  WHERE CollectTime < '${date}' ")
+    @Insert(" INSERT INTO ${tableName} SELECT * FROM ${lastTableName}  WHERE CollectTime < '${date}' ")
     void insertTableData(@Param("tableName") String tableName, @Param("lastTableName") String lastTableName, @Param("date") String date);
 
-    @Delete(" delete from [${tableName}] where CollectTime < '${day}' ")
+    @Delete(" delete from ${tableName} where CollectTime < '${day}' ")
     void deleteTableData(@Param("tableName") String saveTableName, @Param("day") String day);
 
-    @Insert(" SELECT * INTO [${tableName}] FROM [${lastTableName}] WHERE CollectTime < '${date}' ")
+    @Insert(" SELECT * INTO ${tableName} FROM ${lastTableName} WHERE CollectTime < '${date}' ")
     void insertNoTableData(@Param("tableName") String tableName, @Param("lastTableName") String lastTableName, @Param("date") String date);
 
     List<WsEquipmentStatus> selectEquipmentStatus();
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalInfoMapper.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalInfoMapper.java
index c542e18..930d4e6 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalInfoMapper.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/MdcEquipmentStatisticalInfoMapper.java
@@ -16,4 +16,6 @@
      * 鑾峰彇璁惧鏈�鏂版棩鏈熺殑杩愯鏁版嵁
      */
     MdcEquipmentStatisticalInfo getMaxStaticsData(@Param("equipmentId") String equipmentId);
+
+    MdcEquipmentStatisticalInfo findMdcEquipmentStatisticalInfo(@Param("equipmentId") String equipmentId, @Param("data") String data);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
index a2b6082..fdd58e4 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentRunningSectionMapper.xml
@@ -38,6 +38,7 @@
             mdc_equipment_running_section
         WHERE
             equipment_id = #{ equipmentId }
+            AND status <![CDATA[ <> ]]> '22'
             AND  (start_long &lt;= #{ endLong } AND end_long &gt;= #{ startLong })
         ORDER BY
             start_time
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
index 77c17f3..d28c88b 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/mapper/xml/MdcEquipmentStatisticalInfoMapper.xml
@@ -7,4 +7,9 @@
     <select id="getMaxStaticsData" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
         SELECT TOP 1 * FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} ORDER BY the_date DESC
     </select>
+
+
+    <select id="findMdcEquipmentStatisticalInfo" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
+        SELECT TOP 1 * FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} AND the_date = #{data}
+    </select>
 </mapper>
\ No newline at end of file
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
index 51473ea..24581d9 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/IMdcEquipmentStatisticalInfoService.java
@@ -17,4 +17,13 @@
      * @param dateTime
      */
     void runningAllEquipmentStatisticalProcess(String dateTime);
+
+    /**
+     * 鏍规嵁璁惧缂栧彿鍜屾棩鏈熸煡璇㈣繍琛屾暟鎹�
+     *
+     * @param equipmentId
+     * @param date
+     * @return
+     */
+    MdcEquipmentStatisticalInfo findMdcEquipmentStatisticalInfo(String equipmentId, String date);
 }
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
index f981ce3..f6a2e6d 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
@@ -54,6 +54,9 @@
     @Resource
     private IMdcEquipmentRunningSectionService mdcEquipmentRunningSectionService;
 
+    @Resource
+    private IMdcEquipmentStatisticalInfoService mdcEquipmentStatisticalInfoService;
+
     /**
      * 鍒╃敤鐜囨姤琛�
      *
@@ -1702,10 +1705,11 @@
 
                     List<MdcUtilizationResultDto> list = new ArrayList<>();
                     for (String date : dateList) {
-                        Date startTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL);
-                        Date endTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL);
-                        endTime = DateUtils.addDays(endTime, 1);
-                        list.add(this.utilizationRate(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList));
+//                        Date startTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL);
+//                        Date endTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL);
+//                        endTime = DateUtils.addDays(endTime, 1);
+//                        list.add(this.utilizationRate(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList));
+                        list.add(this.utilizationRateTrend(mdcEquDepDto.getEquipmentId(), mdcEquDepDto.getEquipmentName(), mdcEquDepDto.getEquipmentType(), date, mdcUtilizationRateList));
                     }
                     mdcEfficiencyListDto.setDataList(list);
                     listDtos.add(mdcEfficiencyListDto);
@@ -1722,10 +1726,7 @@
                     mdcEfficiencyListDto.setEquipmentType(mdcEquProDto.getEquipmentType());
                     List<MdcUtilizationResultDto> list = new ArrayList<>();
                     for (String date : dateList) {
-                        Date startTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL);
-                        Date endTime = DateUtils.toDate(date + " 00:00:00", DateUtils.STR_DATE_TIME_SMALL);
-                        endTime = DateUtils.addDays(endTime, 1);
-                        list.add(this.utilizationRate(mdcEquProDto.getEquipmentId(), mdcEquProDto.getEquipmentName(), mdcEquProDto.getEquipmentType(), startTime, endTime, date, mdcUtilizationRateList));
+                        list.add(this.utilizationRateTrend(mdcEquProDto.getEquipmentId(), mdcEquProDto.getEquipmentName(), mdcEquProDto.getEquipmentType(), date, mdcUtilizationRateList));
                     }
                     mdcEfficiencyListDto.setDataList(list);
                     listDtos.add(mdcEfficiencyListDto);
@@ -1737,6 +1738,30 @@
         return result;
     }
 
+    private MdcUtilizationResultDto utilizationRateTrend(String equipmentId, String equipmentName, String equipmentType, String date, List<MdcUtilizationRate> mdcUtilizationRateList) {
+        MdcUtilizationResultDto dto = new MdcUtilizationResultDto();
+        dto.setEquipmentId(equipmentId);
+        dto.setEquipmentName(equipmentName);
+        dto.setEquipmentType(equipmentType);
+        dto.setTheDate(date);
+        MdcEquipmentStatisticalInfo mdcEquipmentStatisticalInfo = mdcEquipmentStatisticalInfoService.findMdcEquipmentStatisticalInfo(equipmentId, date);
+        if (mdcEquipmentStatisticalInfo != null) {
+            dto.setUtilizationRate(mdcEquipmentStatisticalInfo.getProcessLong().divide(new BigDecimal("86400"), 6, RoundingMode.HALF_UP));
+        } else {
+            dto.setUtilizationRate(new BigDecimal("0"));
+        }
+        long rate = dto.getUtilizationRate().multiply(new BigDecimal("100")).longValue();
+        for (MdcUtilizationRate mdcUtilizationRate : mdcUtilizationRateList) {
+            if (rate >= mdcUtilizationRate.getMinimumRange() && rate < mdcUtilizationRate.getMaximumRange()) {
+                dto.setColor(mdcUtilizationRate.getRateParameterColor());
+            }
+        }
+        if (StringUtils.isBlank(dto.getColor())) {
+            dto.setColor(mdcUtilizationRateList.get(mdcUtilizationRateList.size() - 1).getRateParameterColor());
+        }
+        return dto;
+    }
+
     @Override
     public List<BigDecimal> getEfficiencyRate(String equipmentId, String date) {
         return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date);
diff --git a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
index 5f89d3e..d63b055 100644
--- a/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
+++ b/lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEquipmentStatisticalInfoServiceImpl.java
@@ -75,6 +75,11 @@
         }
     }
 
+    @Override
+    public MdcEquipmentStatisticalInfo findMdcEquipmentStatisticalInfo(String equipmentId, String date) {
+        return this.baseMapper.findMdcEquipmentStatisticalInfo(equipmentId, date.replaceAll("-", ""));
+    }
+
     private List<EquipmentStatisticalInfo> dataHandle(List<MdcEquipmentStatisticalInfo> list) {
         List<EquipmentStatisticalInfo> result = new ArrayList<>();
         list.forEach(item -> {

--
Gitblit v1.9.3