Browse Source

更改dashboard数据源返回的数据格式

丁治程 8 months ago
parent
commit
fb32b24dbf

+ 2 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockSummaryHistoryMapper.java

@@ -44,6 +44,8 @@ public interface InterlockSummaryHistoryMapper extends BaseMapper<InterlockSumma
     */
     List<InterlockCountDay> getLoopHealthLevelByTagTime(@Param("yesterday") String yesterday);
 
+    List<InterlockCountDay> getLoopHealthLevelByTagTimeFromDay(@Param("yesterday") String yesterday);
+
 
     /**
      *   author: dzc

+ 25 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockSummaryHistoryMapper.xml

@@ -78,6 +78,31 @@
             h.interlock_system_id
     </select>
 
+
+    <select id="getLoopHealthLevelByTagTimeFromDay" resultType="org.jeecg.modules.interlockCountDay.entity.InterlockCountDay">
+        SELECT
+            h.interlock_system_id as interlock_system_id,
+            b.pid as device_id,
+            b.interlock_name as interlock_name,
+            h.loop_health_level as count_name,
+            COUNT( h.* ) AS count_num,
+            '0' as count_type,
+            #{yesterday} as time
+        FROM
+            interlock_summary_day h
+            left join interlock_base b
+        on h.interlock_system_id = b.id
+        WHERE
+            h.tag_time LIKE TO_CHAR(#{yesterday}::timestamp, 'YYYY-MM-DD') || '%'
+        GROUP BY
+            h.interlock_system_id,
+            b.pid,
+            b.interlock_name,
+            h.loop_health_level
+        ORDER BY
+            h.interlock_system_id
+    </select>
+
     <!-- 按日统计 投用状态(投用率) -->
     <select id="getInterlockStatusByTagTime" resultType="org.jeecg.modules.interlockCountDay.entity.InterlockCountDay">
         SELECT

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockSummaryHistoryService.java

@@ -23,6 +23,8 @@ public interface IInterlockSummaryHistoryService extends IService<InterlockSumma
     */
     List<InterlockCountDay> getLoopHealthLevelByTagTime(String yesterday);
 
+    List<InterlockCountDay> getLoopHealthLevelByTagTimeFromDay(String yesterday);
+
     /**
     *   author: dzc
     *   version: 1.0
@@ -38,4 +40,5 @@ public interface IInterlockSummaryHistoryService extends IService<InterlockSumma
     *   date: 2024/6/18
     */
     List<InterlockCountDay> getYbStatusListByTagTime(String yesterday);
+
 }

+ 6 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockSummaryHistoryServiceImpl.java

@@ -36,6 +36,12 @@ public class InterlockSummaryHistoryServiceImpl extends ServiceImpl<InterlockSum
         return mapper.getLoopHealthLevelByTagTime(yesterday);
     }
 
+
+    @Override
+    public List<InterlockCountDay> getLoopHealthLevelByTagTimeFromDay(String yesterday) {
+        return mapper.getLoopHealthLevelByTagTimeFromDay(yesterday);
+    }
+
     /**
      *   author: dzc
      *   version: 1.0

+ 5 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockjob/DayStatisticsJob.java

@@ -69,7 +69,11 @@ public class DayStatisticsJob implements Job {
         //String yesterday = "2024-06-28 00:00:00"; // 测试模拟的昨天日期
 
         // 统计健康等级 count_type = 0
-        List<InterlockCountDay> loopHealthLevelList = summaryHistoryService.getLoopHealthLevelByTagTime(yesterday);
+        /** 从历史数据中获取 */
+        //List<InterlockCountDay> loopHealthLevelList = summaryHistoryService.getLoopHealthLevelByTagTime(yesterday);
+
+        /** 从每天第一次导出的日报表数据中获取 */
+        List<InterlockCountDay> loopHealthLevelList = summaryHistoryService.getLoopHealthLevelByTagTimeFromDay(yesterday);
 
         HashMap<String, List<InterlockCountDay>> loopHealthLevelMap = new HashMap<>();
         for (InterlockCountDay item:loopHealthLevelList) {

+ 32 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/interlockjob/TruncateIotedgeCollectDataJob.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.interlockjob;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.iotedgeCollectData.service.IIotedgeCollectDataService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author dzc
+ * @date 2024/9/29 9:26
+ * @package org.jeecg.modules.interlockjob
+ * @project interlock_server
+ * @des 定时清空采集表中的数据
+ */
+@Component
+@Slf4j
+public class TruncateIotedgeCollectDataJob implements Job {
+
+    @Autowired
+    @SuppressWarnings("all")
+    private IIotedgeCollectDataService iotedgeCollectDataService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        log.info("开始清空表中存储的IoTEdge采集数据");
+        iotedgeCollectDataService.truncateTable();
+        log.info("清空完成!");
+    }
+}

+ 5 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/mapper/IotedgeCollectDataMapper.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.iotedgeCollectData.mapper;
 import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.iotedgeCollectData.entity.IotedgeCollectData;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -15,4 +16,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 public interface IotedgeCollectDataMapper extends BaseMapper<IotedgeCollectData> {
 
     IotedgeCollectData getOneInfo(@Param("deviceId") String deviceId,@Param("moduleName") String moduleName,@Param("tagName") String tagName,@Param("beginDate") String beginDate);
+
+    @Select("truncate table iotedge_collect_data")
+    void truncateTable();
+
 }

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/IIotedgeCollectDataService.java

@@ -34,4 +34,7 @@ public interface IIotedgeCollectDataService extends IService<IotedgeCollectData>
     Map<String, Object> getAllGroup(String eiToken);
 
     String addIoTedgeUser(String userName,String ssoRole,String userId, String elToken);
+
+    void truncateTable();
+
 }

+ 5 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/iotedgeCollectData/service/impl/IotedgeCollectDataServiceImpl.java

@@ -368,4 +368,9 @@ public class IotedgeCollectDataServiceImpl extends ServiceImpl<IotedgeCollectDat
 
         return result;
     }
+
+    @Override
+    public void truncateTable() {
+        mapper.truncateTable();
+    }
 }