dongjh 1 rok temu
rodzic
commit
1c9e2e4d1d
26 zmienionych plików z 1392 dodań i 181 usunięć
  1. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java
  2. 32 14
      jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml
  3. 7 0
      module-guan/pom.xml
  4. 285 0
      module-guan/src/main/java/org/jeecg/modules/MysqlBinLogClient.java
  5. 28 0
      module-guan/src/main/java/org/jeecg/modules/common/GuanCommonConstant.java
  6. 3 4
      module-guan/src/main/java/org/jeecg/modules/webaccess/controller/WebAccessController.java
  7. 37 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/dto/CurveDTO.java
  8. 36 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/dto/CurveSubDTO.java
  9. 1 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanAlarm.java
  10. 54 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanAnachglog.java
  11. 11 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanRAlarm.java
  12. 44 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/job/DashboardJob.java
  13. 23 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/job/WACacheJob.java
  14. 28 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/job/WACurveMsgJob.java
  15. 9 1
      module-guan/src/main/java/org/jeecg/modules/webaccess/job/WAMsgJob.java
  16. 9 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/GuanAlarmMapper.java
  17. 13 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/GuanAnachglogMapper.java
  18. 8 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/GuanRAlarmMapper.java
  19. 28 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanAlarmMapper.xml
  20. 23 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanAnachglogMapper.xml
  21. 6 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanRAlarmMapper.xml
  22. 14 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/service/IGuanAnachglogService.java
  23. 9 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/service/IGuanRAlarmService.java
  24. 602 161
      module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java
  25. 45 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/service/impl/GuanAnachglogServiceImpl.java
  26. 36 0
      module-guan/src/main/java/org/jeecg/modules/webaccess/service/impl/GuanRAlarmServiceImpl.java

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/message/websocket/WebSocket.java

@@ -93,7 +93,7 @@ public class WebSocket {
                     log.error(e.getMessage(), e);
                 }
             }
-            log.info("【系统 WebSocket】群发消息:" + message);
+//            log.info("【系统 WebSocket】群发消息:" + message);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }

+ 32 - 14
jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml

@@ -2,13 +2,14 @@ server:
   port: 8866
 
   # 打包时修改该配置 放开ssl证书配置
-  # ssl:
-    #   enabled: true
-    # SSL 证书路径,classpath 必不可少
-    #   key-store: classpath:server.jks
-    # SSL 证书密码
-    #   key-store-password: admin123
-  #   key-store-type: JKS
+  # 同时将jks文件回滚
+#  ssl:
+#      enabled: true
+#    # SSL 证书路径,classpath 必不可少
+#      key-store: classpath:server.jks
+#    # SSL 证书密码
+#      key-store-password: admin123
+#      key-store-type: JKS
 
   tomcat:
     max-swallow-size: -1
@@ -51,8 +52,8 @@ spring:
     initialize-schema: embedded
     #定时任务启动开关,true-开  false-关
     auto-startup: true
-    #延迟1秒启动定时任务
-    startup-delay: 1s
+    #延迟1秒启动定时任务(改成10秒,为binlog缓存数据留出足够的时间)
+    startup-delay: 10s
     #启动时更新己存在的Job
     overwrite-existing-jobs: true
     properties:
@@ -70,7 +71,7 @@ spring:
             clusterCheckinInterval: 15000
           threadPool:
             class: org.quartz.simpl.SimpleThreadPool
-            threadCount: 10
+            threadCount: 20
             threadPriority: 5
             threadsInheritContextClassLoaderOfInitializingThread: true
   #json 时间戳统一转换
@@ -154,12 +155,20 @@ spring:
           #driver-class-name: com.mysql.cj.jdbc.Driver
   #redis 配置
   redis:
+    # 地址
+    host: 119.3.168.55
+    # 端口,默认为6379
+    port: 6380
+    # 数据库索引
     database: 0
-    # 打包时修改该配置
+#    # 密码
+#    password: 123qx
+#    database: 0
+##    # 打包时修改该配置
 #    host: 127.0.0.1
-    host: 152.136.206.27
-    port: 6379
-    password: ''
+##    host: 152.136.206.27
+#    port: 6379
+#    password: ''
 #mybatis plus 设置
 mybatis-plus:
   mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
@@ -311,3 +320,12 @@ third-app:
       # appSecret
       client-secret: ??
       agent-id: ??
+
+binarylog:
+  # 打包时修改该配置
+  # host: 127.0.0.1
+  host: 152.136.206.27
+  port: 3306
+  schema: guan_rl
+  username: itdm-boot
+  password: itdm-boot@2023

+ 7 - 0
module-guan/pom.xml

@@ -22,6 +22,13 @@
             <groupId>org.jeecgframework.boot</groupId>
             <artifactId>jeecg-boot-base-core</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.zendesk</groupId>
+            <artifactId>mysql-binlog-connector-java</artifactId>
+            <version>0.27.1</version> <!--2022.09.17版的-->
+        </dependency>
+
     </dependencies>
 
 

+ 285 - 0
module-guan/src/main/java/org/jeecg/modules/MysqlBinLogClient.java

@@ -0,0 +1,285 @@
+package org.jeecg.modules;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.github.shyiko.mysql.binlog.BinaryLogClient;
+import com.github.shyiko.mysql.binlog.event.*;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+import org.apache.commons.lang3.ObjectUtils;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.webaccess.dto.CirculateDTO;
+import org.jeecg.modules.webaccess.dto.CurveDTO;
+import org.jeecg.modules.webaccess.entity.GuanAnachglog;
+import org.jeecg.modules.webaccess.entity.GuanRAlarm;
+import org.jeecg.modules.webaccess.service.IGuanAnachglogService;
+import org.jeecg.modules.webaccess.service.IGuanRAlarmService;
+import org.jeecg.modules.webaccess.service.WebAccessService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.core.annotation.Order;
+import org.springframework.data.redis.core.BoundHashOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+import org.jeecg.modules.common.GuanCommonConstant;
+import org.jeecg.common.util.RedisUtil;
+
+/**
+ * 监控MySQL库数据的增删改
+ * 在SpringBoot中,提供了一个接口:ApplicationRunner。
+ * 该接口中,只有一个run方法,他执行的时机是:spring容器启动完成之后,就会紧接着执行这个接口实现类的run方法。
+ */
+@Order
+@Component
+@Slf4j
+public class MysqlBinLogClient implements ApplicationRunner {
+
+    @Value("${binarylog.host}")
+    private String host;
+    @Value("${binarylog.port}")
+    private Integer port;
+    @Value("${binarylog.schema}")
+    private String schema;
+    @Value("${binarylog.username}")
+    private String username;
+    @Value("${binarylog.password}")
+    private String password;
+
+    //@Autowired
+    //private RyTask ryTask;
+
+    @Autowired
+    private IGuanRAlarmService alarmService;
+
+    @Autowired
+    private IGuanAnachglogService anachglogService;
+
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private WebAccessService webAccessService;
+
+    @Autowired
+    private WebSocket webSocket;
+
+    // 不知道正式库是否是这个值
+    private Long guanralarmid = 1228L; // 报警信息
+    private Long guananachglogid = 1030L; // 设备状态
+    private Long bwanalogtableid = 1030L; // 实时数据信息
+
+
+    @Async
+    @Override
+    @Order
+    public void run(ApplicationArguments args) throws Exception {
+        initRedisCache();
+
+        //项目启动完成连接bin-log
+        new Thread(() -> {
+            connectMysqlBinLog();
+        }).start();
+    }
+
+    /**
+     * 程序启动时,将需要的信息提前放置到redis中
+     */
+    public void initRedisCache() {
+        webAccessService.loadCacheData(true);
+    }
+
+    /**
+     * 连接mysqlBinLog
+     */
+    public void connectMysqlBinLog() {
+        log.info("监控BinLog服务已启动");
+
+        //自己MySQL的信息。host,port,username,password
+        BinaryLogClient client = new BinaryLogClient(host, port, schema, username, password);
+        // 设置连接时间为20秒
+        client.setConnectTimeout(20 * 1000);
+
+        /**因为binlog不是以数据库为单位划分的,所以监控binglog不是监控的单个的数据库,而是整个     当前所设置连接的MySQL,
+         *其中任何一个库发生数据增删改,这里都能检测到,
+         *所以不用设置所监控的数据库的名字(我也不知道怎么设置,没发现有包含这个形参的构造函数)
+         *如果需要只监控指定的数据库,可以看后面代码,可以获取到当前发生变更的数据库名称。可以根据名称来决定是否监控
+         **/
+
+        client.setServerId(47); //和自己之前设置的server-id保持一致,但是我不知道为什么不一致也能成功
+        //下面直接照抄就行
+        client.registerEventListener(event -> {
+            EventData data = event.getData();
+            if (data instanceof TableMapEventData) {
+                //只要连接的MySQL发生的增删改的操作,则都会进入这里,无论哪个数据库
+                TableMapEventData tableMapEventData = (TableMapEventData) data;
+                if (schema.equals(tableMapEventData.getDatabase())) {
+                    if ("guan_ralarm".equals(tableMapEventData.getTable())) {
+                        guanralarmid = tableMapEventData.getTableId();
+                    } else if ("bwanalogtable".equals(tableMapEventData.getTable())) {
+                        bwanalogtableid = tableMapEventData.getTableId();
+                    } else if ("guan_anachglog".equals(tableMapEventData.getTable())) {
+                        guananachglogid = tableMapEventData.getTableId();
+                    }
+                }
+            }
+
+
+            // 增加数据(监控:报警信息、设备状态、实时值)
+            if (data instanceof WriteRowsEventData) {
+                long currTableId = ((WriteRowsEventData) data).getTableId();
+
+                // 1、报警信息
+                if (guanralarmid == currTableId) {
+                    System.out.println("guan_ralarm Insert:" + data.toString());
+                    Object[] obj = Arrays.stream(((WriteRowsEventData) data).getRows().get(0)).toArray();
+                    GuanRAlarm rAlarm = new GuanRAlarm();
+                    rAlarm.setId((Integer) obj[0]);
+                    rAlarm.setTagname(obj[1].toString());
+                    rAlarm.setDescription(obj[2].toString());
+                    rAlarm.setLogtime((Date) obj[3]);
+                    rAlarm.setPriority(obj[4].toString());
+                    rAlarm.setAction(obj[5].toString());
+                    rAlarm.setUsername(obj[6].toString());
+                    rAlarm.setNodename(obj[7].toString());
+                    rAlarm.setNodeip(obj[8].toString());
+                    rAlarm.setAlmgroup(obj[9].toString());
+                    rAlarm.setAlarmvalue((Double) obj[10]);
+                    rAlarm.setAlarmlimit((Double) obj[11]);
+                    rAlarm.setAlarmid((Integer) obj[12]);
+
+                    // websocket推送
+                    List<GuanRAlarm> alarmList = alarmService.selectAlarm24h(false);
+                    alarmList.add(0, rAlarm);
+                    redisUtil.set(GuanCommonConstant.GUAN_ALARMS_24H, alarmList);
+
+                    JSONObject jsonObject = new JSONObject();
+                    // 最近24H报警信息
+                    jsonObject.put("最近24H报警信息", alarmList.toString());
+
+                    webSocket.pushMessage(jsonObject.toString());
+                }
+
+                // 2、设备状态
+                if (guananachglogid == currTableId) {
+                    System.out.println("guan_anachglog Insert:" + data.toString());
+                    Object[] obj = Arrays.stream(((WriteRowsEventData) data).getRows().get(0)).toArray();
+                    GuanAnachglog anachglog = new GuanAnachglog();
+                    anachglog.setId((Integer) obj[0]);
+                    anachglog.setProjnodeid((Integer) obj[1]);
+                    anachglog.setTagname(obj[2].toString());
+                    anachglog.setLogdate(obj[3].toString());
+                    anachglog.setLogtime(obj[4].toString());
+                    anachglog.setLogmillisecond((Integer) obj[5]);
+                    anachglog.setLogvalue((Double) obj[6]);
+                    anachglog.setAlarm((Integer) obj[7]);
+
+                    // 缓存设备状态
+                    if (redisUtil.hasKey(GuanCommonConstant.GUAN_EQUIPMENT_STATUS)) {
+                        redisUtil.del(GuanCommonConstant.GUAN_EQUIPMENT_STATUS);
+                    }
+                    redisUtil.set(GuanCommonConstant.GUAN_EQUIPMENT_STATUS, anachglog);
+
+                    // 如果设备状态的LogValue=1,代表设备开始运行,则更新曲线信息
+                    if (anachglog.getLogvalue() == 1) {
+                        // 更新预制曲线
+                        List<String> duans = new ArrayList<>();
+                        List<CirculateDTO> yzqxList = webAccessService.getYzcx(duans);
+
+                        // 缓存中,存在则删除,并重新设置
+                        if (redisUtil.hasKey(GuanCommonConstant.GUAN_PREPARE_CURVE)) {
+                            redisUtil.del(GuanCommonConstant.GUAN_PREPARE_CURVE);
+                        }
+                        redisUtil.set(GuanCommonConstant.GUAN_PREPARE_CURVE, yzqxList);
+
+                        if (redisUtil.hasKey(GuanCommonConstant.GUAN_PREPARE_CURVE_SECTION)) {
+                            redisUtil.del(GuanCommonConstant.GUAN_PREPARE_CURVE_SECTION);
+                        }
+                        redisUtil.set(GuanCommonConstant.GUAN_PREPARE_CURVE_SECTION, duans);
+
+                        // 更新全程曲线
+                        List<CurveDTO> wholeCrveList = webAccessService.getWholeCurve(null);
+
+                        // 缓存中,存在则删除,并重新设置
+                        if (redisUtil.hasKey(GuanCommonConstant.GUAN_WHOLE_CURE)) {
+                            redisUtil.del(GuanCommonConstant.GUAN_WHOLE_CURE);
+                        }
+                        redisUtil.set(GuanCommonConstant.GUAN_WHOLE_CURE, wholeCrveList);
+
+                        // 更新实时曲线
+                        List<CurveDTO> realtimeCrveList = webAccessService.getRealtimeCurve(null);
+
+                        // 缓存中,存在则删除,并重新设置
+                        if (redisUtil.hasKey(GuanCommonConstant.GUAN_REALTIME_CURVE)) {
+                            redisUtil.del(GuanCommonConstant.GUAN_REALTIME_CURVE);
+                        }
+                        redisUtil.set(GuanCommonConstant.GUAN_REALTIME_CURVE, realtimeCrveList);
+
+                        // websocket推送
+                        JSONObject jsonObject = new JSONObject();
+
+                        jsonObject.put("全程曲线", wholeCrveList);
+                        jsonObject.put("实时曲线", realtimeCrveList);
+                        // 预制曲线
+                        jsonObject.put("预制曲线", yzqxList);
+                        jsonObject.put("预制曲线线段", duans);
+
+                        webSocket.pushMessage(jsonObject.toString());
+                    }
+                }
+            }
+            // 修改数据
+            else if (data instanceof UpdateRowsEventData) {
+                long currTableId = ((UpdateRowsEventData) data).getTableId();
+            }
+            // 删除数据
+            else if (data instanceof DeleteRowsEventData) {
+                long currTableId = ((DeleteRowsEventData) data).getTableId();
+
+                // 1、报警信息
+                if (guanralarmid == currTableId) {
+                    System.out.println("guan_ralarm Update:" + data.toString());
+                    Object[] obj = Arrays.stream(((DeleteRowsEventData) data).getRows().get(0)).toArray();
+                    Integer id = (Integer) obj[0];
+
+                    // websocket推送
+                    List<GuanRAlarm> alarmList = alarmService.selectAlarm24h(false);
+                    if (alarmList != null && alarmList.size() > 0) {
+                        for (int i = 0; i < alarmList.size(); i++) {
+                            if (alarmList.get(i).getId().equals(id)) {
+                                alarmList.remove(i);
+                                break;
+                            }
+                        }
+                    }
+                    redisUtil.set(GuanCommonConstant.GUAN_ALARMS_24H, alarmList);
+                    JSONObject jsonObject = new JSONObject();
+                    // 最近24H报警信息
+                    jsonObject.put("最近24H报警信息", alarmList.toString());
+                    webSocket.pushMessage(jsonObject.toString());
+                }
+            }
+        });
+        try {
+            client.connect();
+        } catch (
+                IOException e) {
+            e.printStackTrace();
+        }
+    }
+}
+

+ 28 - 0
module-guan/src/main/java/org/jeecg/modules/common/GuanCommonConstant.java

@@ -0,0 +1,28 @@
+package org.jeecg.modules.common;
+
+/**
+ * @Description: 通用常量
+ * @author: jeecg-boot
+ */
+public interface GuanCommonConstant {
+
+
+    /**报警信息(24小时内)*/
+    String GUAN_ALARMS_24H = "guan_alarms_24h";
+
+    /**预制曲线*/
+    String GUAN_PREPARE_CURVE = "guan_prepare_curve";
+
+    /**预制曲线-段*/
+    String GUAN_PREPARE_CURVE_SECTION = "guan_prepare_curve_section";
+
+    /**实时曲线*/
+    String GUAN_REALTIME_CURVE = "guan_realtime_curve";
+
+    /**全程曲线*/
+    String GUAN_WHOLE_CURE = "guan_whole_curve";
+
+    /**设备状态*/
+    String GUAN_EQUIPMENT_STATUS = "guan_equipment_status";
+
+}

+ 3 - 4
module-guan/src/main/java/org/jeecg/modules/webaccess/controller/WebAccessController.java

@@ -6,12 +6,11 @@ import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.webaccess.dto.CurveDTO;
 import org.jeecg.modules.webaccess.dto.WaLogDTO;
 import org.jeecg.modules.webaccess.entity.GuanTest;
 import org.jeecg.modules.webaccess.service.WebAccessService;
 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.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -137,7 +136,7 @@ public class WebAccessController {
     @ApiOperation(value = "获取大屏展示数据", notes = "获取大屏展示数据")
     @RequestMapping(value = "/getDashBoardData", method = RequestMethod.GET)
     public Result getDashBoardData() {
-        String rtn = webAccessService.organizeDashData();
+        String rtn = webAccessService.firstLoadData();
 
         return Result.OK("获取成功", rtn);
     }
@@ -170,7 +169,7 @@ public class WebAccessController {
     @ApiOperation(value = "获取全程曲线", notes = "获取全程曲线")
     @RequestMapping(value = "/getQcqx", method = RequestMethod.GET)
     public Result getQcqx(GuanTest guanTest) {
-        JSONArray rtn = webAccessService.getDashboardDataLog(guanTest.getStarttime());
+        List<CurveDTO> rtn = webAccessService.getWholeCurve(guanTest.getStarttime());
 
         return Result.OK("获取成功", rtn);
     }

+ 37 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/dto/CurveDTO.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.webaccess.dto;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 曲线实体
+ */
+@Data
+public class CurveDTO {
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 类型
+     */
+    private String type;
+
+    /**
+     * 曲线列表
+     */
+    private List<CurveSubDTO> subList;
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("{");
+        sb.append("name='").append(name).append('\'');
+        sb.append(", type='").append(type).append('\'');
+        sb.append(", subList=").append(subList);
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 36 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/dto/CurveSubDTO.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.webaccess.dto;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.StringJoiner;
+
+/**
+ * 曲线实体-单条记录
+ */
+@Data
+public class CurveSubDTO {
+    /**
+     * 真实时间(将来用于排序使用)
+     */
+    private Date logtime;
+
+    /**
+     * 转换时间
+     */
+    private String transtime;
+
+    /**
+     * 值
+     */
+    private String tagvalue;
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder("{");
+        sb.append("transtime='").append(transtime).append('\'');
+        sb.append(", tagvalue='").append(tagvalue).append('\'');
+        sb.append('}');
+        return sb.toString();
+    }
+}

+ 1 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanAlarm.java

@@ -8,6 +8,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
+import java.util.StringJoiner;
 
 @Data
 @TableName("guan_alarm")

+ 54 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanAnachglog.java

@@ -0,0 +1,54 @@
+package org.jeecg.modules.webaccess.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+@Data
+@TableName("guan_anachglog")
+public class GuanAnachglog {
+    /**主键*/
+    @ApiModelProperty(value = "主键")
+    private Integer id;
+
+    /**所属工程*/
+    @Excel(name = "所属工程")
+    @ApiModelProperty(value = "所属工程")
+    private Integer projnodeid;
+
+    /**点名称*/
+    @Excel(name = "点名称", width = 32)
+    @ApiModelProperty(value = "点名称")
+    private String tagname;
+
+
+    /**日期*/
+    @Excel(name = "日期", width = 12)
+    @ApiModelProperty(value = "日期")
+    private String logdate;
+
+
+    /**时间*/
+    @Excel(name = "时间", width = 12)
+    @ApiModelProperty(value = "时间")
+    private String logtime;
+
+
+    /**毫秒*/
+    @Excel(name = "毫秒")
+    @ApiModelProperty(value = "毫秒")
+    private Integer logmillisecond;
+
+
+    /**点位值*/
+    @Excel(name = "点位值")
+    @ApiModelProperty(value = "点位值")
+    private Double logvalue;
+
+
+    /**报警*/
+    @Excel(name = "报警")
+    @ApiModelProperty(value = "报警")
+    private Integer alarm;
+}

+ 11 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/entity/GuanRAlarm.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 
 @Data
@@ -75,4 +76,14 @@ public class GuanRAlarm {
     /**报警信息主键*/
     @ApiModelProperty(value = "报警信息主键")
     private Integer alarmid;
+
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("{");
+        sb.append("tagname='").append(tagname).append('\'');
+        sb.append(", logtime='").append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(logtime)).append("'");
+        sb.append('}');
+        return sb.toString();
+    }
 }

+ 44 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/job/DashboardJob.java

@@ -0,0 +1,44 @@
+package org.jeecg.modules.webaccess.job;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.webaccess.service.WebAccessService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 实时值获取、推送
+ */
+@Slf4j
+@Component("waMsgJob")
+public class DashboardJob {
+
+    @Autowired
+    private WebAccessService webAccessService;
+
+    @Autowired
+    private WebSocket webSocket;
+
+    /**
+     * 实时数据获取、推送
+     */
+    public void realtimeData() {
+        String rtn = webAccessService.loadRealtimeData();
+        webSocket.pushMessage(rtn);
+    }
+
+    /**
+     * 曲线信息获取、推送
+     */
+    public void curveData() {
+        String rtn = webAccessService.loadIncrementCurveData();
+        webSocket.pushMessage(rtn);
+    }
+
+    /**
+     * 刷新缓存信息
+     */
+    public void cacheData() {
+        webAccessService.loadCacheData(false);
+    }
+}

+ 23 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/job/WACacheJob.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.webaccess.job;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.webaccess.service.WebAccessService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 刷新缓存信息
+ */
+@Slf4j
+public class WACacheJob implements Job {
+
+    @Autowired
+    private WebAccessService webAccessService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        webAccessService.loadCacheData(false);
+    }
+}

+ 28 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/job/WACurveMsgJob.java

@@ -0,0 +1,28 @@
+package org.jeecg.modules.webaccess.job;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.webaccess.service.WebAccessService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * 曲线信息获取、推送
+ */
+@Slf4j
+public class WACurveMsgJob implements Job {
+
+    @Autowired
+    private WebAccessService webAccessService;
+
+    @Autowired
+    private WebSocket webSocket;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        String rtn = webAccessService.loadIncrementCurveData();
+        webSocket.pushMessage(rtn);
+    }
+}

+ 9 - 1
module-guan/src/main/java/org/jeecg/modules/webaccess/job/WAMsgJob.java

@@ -20,7 +20,15 @@ public class WAMsgJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        String rtn = webAccessService.organizeDashData();
+        // 实时数据
+        String rtn = webAccessService.loadRealtimeData();
         webSocket.pushMessage(rtn);
+
+        // 曲线数据
+        String curve = webAccessService.loadIncrementCurveData();
+        webSocket.pushMessage(curve);
+
+        // 刷新缓存
+        webAccessService.loadCacheData(false);
     }
 }

+ 9 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/GuanAlarmMapper.java

@@ -2,6 +2,15 @@ package org.jeecg.modules.webaccess.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.webaccess.entity.GuanAlarm;
+import org.jeecg.modules.webaccess.entity.GuanRAlarm;
+
+import java.util.List;
 
 public interface GuanAlarmMapper extends BaseMapper<GuanAlarm> {
+
+    /**
+     * 获取最近24小时报警信息
+     * @return
+     */
+    public List<GuanRAlarm> selectAlarm24h();
 }

+ 13 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/GuanAnachglogMapper.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.webaccess.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.webaccess.entity.GuanAnachglog;
+import org.jeecg.modules.webaccess.entity.GuanTest;
+
+public interface GuanAnachglogMapper extends BaseMapper<GuanAnachglog> {
+    /**
+     * 获取最新一条信息
+     * @return
+     */
+    public GuanAnachglog selectTop1Anachglog();
+}

+ 8 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/GuanRAlarmMapper.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.webaccess.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.webaccess.entity.GuanRAlarm;
 
+import java.util.List;
+
 public interface GuanRAlarmMapper extends BaseMapper<GuanRAlarm> {
 
     /**
@@ -10,4 +12,10 @@ public interface GuanRAlarmMapper extends BaseMapper<GuanRAlarm> {
      * @return
      */
     public GuanRAlarm selectTop1Alarm();
+
+    /**
+     * 获取最近24小时报警信息
+     * @return
+     */
+    public List<GuanRAlarm> selectAlarm24h();
 }

+ 28 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanAlarmMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.webaccess.mapper.GuanAlarmMapper">
+
+    <resultMap type="org.jeecg.modules.webaccess.entity.GuanAlarm" id="GuanAlarmResult">
+        <result property="id"    column="id"    />
+        <result property="tagname"    column="tagname"    />
+        <result property="description"    column="description"    />
+        <result property="logtime"    column="logtime"    />
+        <result property="priority"    column="priority"    />
+        <result property="action"    column="action"    />
+        <result property="username"    column="username"    />
+        <result property="nodename"    column="nodename"    />
+        <result property="nodeip"    column="nodeip"    />
+        <result property="almgroup"    column="almgroup"    />
+        <result property="alarmvalue"    column="alarmvalue"    />
+        <result property="alarmlimit"    column="alarmlimit"    />
+        <result property="restoretime"    column="restoretime"    />
+    </resultMap>
+
+
+    <select id="selectAlarm24h" resultMap="GuanAlarmResult">
+        select * from guan_alarm
+        where logtime &gt;= DATE_ADD(now(), INTERVAL -1 DAY)
+        order by id desc
+    </select>
+
+</mapper>

+ 23 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanAnachglogMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.webaccess.mapper.GuanAnachglogMapper">
+
+    <resultMap type="org.jeecg.modules.webaccess.entity.GuanAnachglog" id="GuanAnachglogResult">
+        <result property="id"    column="id"    />
+        <result property="projnodeid"    column="projnodeid"    />
+        <result property="tagname"    column="tagname"    />
+        <result property="logdate"    column="logdate"    />
+        <result property="logtime"    column="logtime"    />
+        <result property="logmillisecond"    column="logmillisecond"    />
+        <result property="logvalue"    column="logvalue"    />
+        <result property="alarm"    column="alarm"    />
+    </resultMap>
+
+
+    <select id="selectTop1Anachglog" resultMap="GuanAnachglogResult">
+        select * from guan_anachglog
+        order by id desc
+        limit 1
+    </select>
+
+</mapper>

+ 6 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/mapper/xml/GuanRAlarmMapper.xml

@@ -25,4 +25,10 @@
         limit 1
     </select>
 
+    <select id="selectAlarm24h" resultMap="GuanRAlarmResult">
+        select * from guan_ralarm
+        where logtime &gt;= DATE_ADD(now(), INTERVAL -1 DAY)
+        order by id desc
+    </select>
+
 </mapper>

+ 14 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/IGuanAnachglogService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.webaccess.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.webaccess.entity.GuanAnachglog;
+
+public interface IGuanAnachglogService extends IService<GuanAnachglog> {
+
+    /**
+     * 获取最新一条报警信息
+     * @param ifRefresh 是否强制刷新
+     * @return
+     */
+    public GuanAnachglog selectTop1Anachglog(Boolean ifRefresh);
+}

+ 9 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/IGuanRAlarmService.java

@@ -3,6 +3,8 @@ package org.jeecg.modules.webaccess.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.webaccess.entity.GuanRAlarm;
 
+import java.util.List;
+
 public interface IGuanRAlarmService extends IService<GuanRAlarm> {
 
     /**
@@ -10,4 +12,11 @@ public interface IGuanRAlarmService extends IService<GuanRAlarm> {
      * @return
      */
     public GuanRAlarm selectTop1Alarm();
+
+    /**
+     * 获取最新一条报警信息
+     * @param ifRefresh 是否强制刷新
+     * @return
+     */
+    public List<GuanRAlarm> selectAlarm24h(Boolean ifRefresh);
 }

+ 602 - 161
module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java

@@ -6,11 +6,12 @@ import net.sf.json.JSONObject;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.collections.map.HashedMap;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.common.util.RedisUtil;
+import org.jeecg.modules.common.GuanCommonConstant;
 import org.jeecg.modules.system.entity.SysDictItem;
 import org.jeecg.modules.system.service.ISysDictItemService;
-import org.jeecg.modules.webaccess.dto.CirculateDTO;
-import org.jeecg.modules.webaccess.dto.SectionDTO;
-import org.jeecg.modules.webaccess.dto.WaLogDTO;
+import org.jeecg.modules.webaccess.dto.*;
+import org.jeecg.modules.webaccess.entity.GuanAnachglog;
 import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
 import org.jeecg.modules.webaccess.entity.GuanRAlarm;
 import org.jeecg.modules.webaccess.entity.GuanTest;
@@ -34,6 +35,7 @@ import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.jar.JarEntry;
+import java.util.stream.Collectors;
 
 /**
  * 调用webaccess的接口
@@ -54,7 +56,13 @@ public class WebAccessService {
     private GuanTestMapper guanTestMapper;
 
     @Autowired
-    private GuanRAlarmMapper guanRAlarmMapper;
+    private IGuanRAlarmService guanRAlarmService;
+
+    @Autowired
+    private RedisUtil redisUtil;
+
+    @Autowired
+    private IGuanAnachglogService anachglogService;
 
 
     //region <<字典获取webaccess信息>>
@@ -425,7 +433,7 @@ public class WebAccessService {
 
     //region <<根据大屏参数设置,获取实时点位值>>
     /**
-     * 取得测点(Tag)的量测
+     * 获取实时点位
      *
      * @return
      */
@@ -607,181 +615,371 @@ public class WebAccessService {
     }
     //endregion
 
-    //region <<根据大屏参数设定,取得历史记录>>
+    //region <<根据大屏参数设置,获取实时曲线、全程曲线>>
+
     /**
-     * 取得历史记录
-     *
+     * 获取实时曲线
+     * @param startTime 开始时间
      * @return
      */
-    public JSONArray getDashboardDataLog(Date startTime) {
+    public List<CurveDTO> getRealtimeCurve(Date startTime) {
         // 获取大屏参数设置
         GuanDashboardParam paramat = new GuanDashboardParam();
         paramat.setStatus("1"); // 状态为启用
         paramat.setIflog("Y"); // 需要获取历史记录
         List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+        if (dashboardParamList == null || dashboardParamList.size() < 1) {
+            return null;
+        }
 
         // 组合参数信息
-        JSONArray list = new JSONArray();
-        if (dashboardParamList != null && dashboardParamList.size() > 0) {
-            Integer ssIntervals = null; // 实时曲线的 每笔数据之间隔时间
-            Integer qcIntervals = null; // 全程曲线的 每笔数据之间隔时间
-
-            Integer ssRecord = null; // 实时曲线的 获取记录条数
-            Integer qcRecord = null; // 全程曲线的 获取记录条数
-
-            Integer ssDuration = null; // 实时曲线的 获取历史记录时长
-
-            Date now = new Date();
-
-            // 获取试验运行时间
-//            List<WaLogDTO> tags = new ArrayList<>();
-//            WaLogDTO waLogDTO = new WaLogDTO("试验运行时间");
-//            tags.add(waLogDTO);
-//            JSONObject waparams = generateGetObject(tags);
-//            Integer syyxsj = Integer.parseInt(getTagNameValues(waparams)); // 获取试验运行时间
-//
-//            // 防止试验运行时间太长,导致查询不到数据(3个月*30天*24小时*60分钟*60秒 = 7,776,000)
-//            syyxsj = syyxsj < 7776000 ? syyxsj : 7776000;
-//
-//            // 开始时间
-            Calendar calendar = Calendar.getInstance();
-            calendar.setTime(now); // 设置当前的时间戳
-//            calendar.add(Calendar.SECOND, -syyxsj);
-//            Date startTime = calendar.getTime(); // 试验开始时间(也是 全程曲线开始时间)
-            GuanTest guanTest = guanTestMapper.selectTop1Test();
-            startTime = startTime == null ? guanTest.getStarttime() : startTime; // 试验开始时间(也是 全程曲线开始时间)
-            Integer syyxsj = Integer.parseInt(((now.getTime() - startTime.getTime()) / 1000) + "");
-            Date realityTime = null; // 实时曲线开始时间
+        List<CurveDTO> curveList = new ArrayList<CurveDTO>();
+        Integer ssIntervals = null; // 实时曲线的 每笔数据之间隔时间
+        Integer ssRecord = null; // 实时曲线的 获取记录条数
+        Integer ssDuration = null; // 实时曲线的 获取历史记录时长
+        Date now = new Date();
 
-            for (GuanDashboardParam param : dashboardParamList) {
-                if (param.getTagName() != null && !"".equals(param.getTagName())) {
-                    JSONObject jo = null;
-
-                    // 1 获取 实时曲线 参数
-                    if (param.getParamName().equals("辐射强度值-实时") || param.getParamName().equals("湿度实值-实时") ||
-                            param.getParamName().equals("温度实值-实时")) {
-                        // 1.1 每笔数据之间隔时间
-                        if (ssIntervals == null) {
-                            ssIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
-                        }
-
-                        // 1.2 开始时间(实验运行时间>历史时长,则用历史时长计算开始时间,否则用实际运行时间计算开始时间)
-                        if (ssDuration == null) {
-                            ssDuration = param.getDuration() == null || param.getDuration() == 0 ? 4 : param.getDuration();
-                        }
-                        if (realityTime == null) {
-                            calendar.setTime(now); // 设置当前的时间戳
-                            if (syyxsj > param.getDuration() * 3600) {
-                                calendar.add(Calendar.HOUR, -ssDuration);
-                            }
-                            else {
-                                calendar.add(Calendar.SECOND, -syyxsj);
-                            }
-                            realityTime = calendar.getTime();
-                        }
-
-                        // 1.3 计算 获取记录条数
-                        if (ssRecord == null) {
-                            ssRecord = Integer.parseInt((ChronoUnit.MINUTES.between(
-                                    LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(realityTime).replace(" ", "T")),
-                                    LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now).replace(" ", "T"))
-                                ) / ssIntervals) + "");
-                        }
-
-                        // 组合参数
-                        jo = generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(realityTime),
-                                param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
-                                ssIntervals,
-                                ssRecord,
-                                param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
-                                param.getTagName());
-                    }
+        // 开始时间
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(now); // 设置当前的时间戳
+        // calendar.add(Calendar.SECOND, -syyxsj);
+        // Date startTime = calendar.getTime(); // 试验开始时间(也是 全程曲线开始时间)
+        GuanTest guanTest = guanTestMapper.selectTop1Test();
+        startTime = startTime == null ? guanTest.getStarttime() : startTime; // 试验开始时间(也是 全程曲线开始时间)
+        Integer syyxsj = Integer.parseInt(((now.getTime() - startTime.getTime()) / 1000) + "");
+        Date realityTime = null; // 实时曲线开始时间
+
+        for (GuanDashboardParam param : dashboardParamList) {
+            // 没有点位名
+            if (param.getTagName() == null || "".equals(param.getTagName())) {
+                continue;
+            }
+            // 不是实时曲线设置
+            if (!param.getParamName().equals("辐射强度值-实时") && !param.getParamName().equals("湿度实值-实时") &&
+                !param.getParamName().equals("温度实值-实时")) {
+                continue;
+            }
+            JSONObject jo = null;
+            CurveDTO curve = new CurveDTO();
 
-                    // 2 获取 全程曲线 参数
-                    if (param.getParamName().equals("辐射强度值-全程") || param.getParamName().equals("湿度实值-全程") ||
-                            param.getParamName().equals("温度实值-全程")) {
-                        // 2.1 计算每笔数据之间隔时间(设x = 参数定义的间隔时间,y = 间隔天数,计算公式:x + x * y)
-                        qcIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
-                        LocalDate startLocalDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
-                        LocalDate endLocalDate = now.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
-                        Long day = ChronoUnit.DAYS.between(startLocalDate, endLocalDate);
-                        qcIntervals = qcIntervals + qcIntervals * (Integer.parseInt(day.toString()));
-
-                        // 2.2 获取记录条数
-                        if (qcRecord == null) {
-                            qcRecord = Integer.parseInt((ChronoUnit.MINUTES.between(
-                                    LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime).replace(" ", "T")),
-                                    LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now).replace(" ", "T"))
-                                ) / qcIntervals) + "");
-                        }
-
-                        // 2.3 组合参数
-                        jo = generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime),
-                                param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
-                                qcIntervals,
-                                qcRecord,
-                                param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
-                                param.getTagName());
-                    }
+            curve.setType("实时");
+            // 1.1 每笔数据之间隔时间
+            if (ssIntervals == null) {
+                ssIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
+            }
 
-                    // 获取信息
-                    JSONObject dataLog = GetDataLog(jo);
-                    JSONObject logObj = new JSONObject();
-                    logObj.put("Name", param.getParamName());
-                    if (dataLog.getJSONArray("DataLog").size() > 0) {
-                        logObj.put("Values", dataLog.getJSONArray("DataLog").getJSONObject(0).getJSONArray("Values"));
+            // 1.2 开始时间(实验运行时间>历史时长,则用历史时长计算开始时间,否则用实际运行时间计算开始时间)
+            if (ssDuration == null) {
+                ssDuration = param.getDuration() == null || param.getDuration() == 0 ? 4 : param.getDuration();
+            }
+            if (realityTime == null) {
+                calendar.setTime(now); // 设置当前的时间戳
+                if (syyxsj > param.getDuration() * 3600) {
+                    calendar.add(Calendar.HOUR, -ssDuration);
+                }
+                else {
+                    calendar.add(Calendar.SECOND, -syyxsj);
+                }
+                realityTime = calendar.getTime();
+            }
+
+            // 1.3 计算 获取记录条数
+            if (ssRecord == null) {
+                ssRecord = Integer.parseInt((ChronoUnit.MINUTES.between(
+                        LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(realityTime).replace(" ", "T")),
+                        LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now).replace(" ", "T"))
+                    ) / ssIntervals) + "");
+            }
+
+            // 组合参数
+            jo = generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(realityTime),
+                    param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
+                    ssIntervals,
+                    ssRecord,
+                    param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
+                    param.getTagName());
+
+            // 获取信息
+            JSONObject dataLog = GetDataLog(jo);
+            curve.setName(param.getParamName());
+            if (dataLog.getJSONArray("DataLog").size() > 0) {
+                List<String> values = dataLog.getJSONArray("DataLog").getJSONObject(0).getJSONArray("Values");
+                List<CurveSubDTO> subList = new ArrayList<>();
+                if (values != null && values.size() > 0) {
+                    for (String value : values) {
+                        CurveSubDTO sub = new CurveSubDTO();
+                        sub.setTagvalue(value);
+                        subList.add(sub);
                     }
-                    else {
-                        logObj.put("Values", null);
+                }
+                curve.setSubList(subList);
+            }
+            else {
+                curve.setSubList(null);
+            }
+            curveList.add(curve);
+        }
+        // 设置实时曲线时间分布
+        genTime(realityTime, now, ssIntervals, "HH:mm", curveList, "实时");
+
+        return curveList;
+    }
+
+    /**
+     * 获取全程曲线
+     * @param startTime 开始时间
+     * @return
+     */
+    public List<CurveDTO> getWholeCurve(Date startTime) {
+        // 获取大屏参数设置
+        GuanDashboardParam paramat = new GuanDashboardParam();
+        paramat.setStatus("1"); // 状态为启用
+        paramat.setIflog("Y"); // 需要获取历史记录
+        List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+        if (dashboardParamList == null || dashboardParamList.size() < 1) {
+            return null;
+        }
+
+        // 组合参数信息
+        List<CurveDTO> curveList = new ArrayList<CurveDTO>();
+        Integer qcIntervals = null; // 全程曲线的 每笔数据之间隔时间
+        Integer qcRecord = null; // 全程曲线的 获取记录条数
+        Date now = new Date();
+
+        // 获取试验运行时间
+        // List<WaLogDTO> tags = new ArrayList<>();
+        // WaLogDTO waLogDTO = new WaLogDTO("试验运行时间");
+        // tags.add(waLogDTO);
+        // JSONObject waparams = generateGetObject(tags);
+        // Integer syyxsj = Integer.parseInt(getTagNameValues(waparams)); // 获取试验运行时间
+        // 防止试验运行时间太长,导致查询不到数据(3个月*30天*24小时*60分钟*60秒 = 7,776,000)
+        // syyxsj = syyxsj < 7776000 ? syyxsj : 7776000;
+
+        // 开始时间
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(now); // 设置当前的时间戳
+        // calendar.add(Calendar.SECOND, -syyxsj);
+        // Date startTime = calendar.getTime(); // 试验开始时间(也是 全程曲线开始时间)
+        GuanTest guanTest = guanTestMapper.selectTop1Test();
+        startTime = startTime == null ? guanTest.getStarttime() : startTime; // 试验开始时间(也是 全程曲线开始时间)
+        Integer syyxsj = Integer.parseInt(((now.getTime() - startTime.getTime()) / 1000) + "");
+        Date realityTime = null; // 实时曲线开始时间
+
+        for (GuanDashboardParam param : dashboardParamList) {
+            // 没有点位名
+            if (param.getTagName() == null || "".equals(param.getTagName())) {
+                continue;
+            }
+            if (!param.getParamName().equals("辐射强度值-全程") && !param.getParamName().equals("湿度实值-全程") &&
+                !param.getParamName().equals("温度实值-全程")) {
+                continue;
+            }
+            JSONObject jo = null;
+            CurveDTO curve = new CurveDTO();
+
+            // 2 获取 全程曲线 参数
+            curve.setType("全程");
+            // 2.1 计算每笔数据之间隔时间(设x = 参数定义的间隔时间,y = 间隔天数,计算公式:x + x * y)
+            qcIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
+            LocalDate startLocalDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate endLocalDate = now.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            Long day = ChronoUnit.DAYS.between(startLocalDate, endLocalDate);
+            qcIntervals = qcIntervals + qcIntervals * (Integer.parseInt(day.toString()));
+
+            // 2.2 获取记录条数
+            if (qcRecord == null) {
+                qcRecord = Integer.parseInt((ChronoUnit.MINUTES.between(
+                        LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime).replace(" ", "T")),
+                        LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now).replace(" ", "T"))
+                ) / qcIntervals) + "");
+            }
+
+            // 2.3 组合参数
+            jo = generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime),
+                    param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
+                    qcIntervals,
+                    qcRecord,
+                    param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
+                    param.getTagName());
+
+            // 获取信息
+            JSONObject dataLog = GetDataLog(jo);
+            curve.setName(param.getParamName());
+            if (dataLog.getJSONArray("DataLog").size() > 0) {
+                List<String> values = dataLog.getJSONArray("DataLog").getJSONObject(0).getJSONArray("Values");
+                List<CurveSubDTO> subList = new ArrayList<>();
+                if (values != null && values.size() > 0) {
+                    for (String value : values) {
+                        CurveSubDTO sub = new CurveSubDTO();
+                        sub.setTagvalue(value);
+                        subList.add(sub);
                     }
-                    list.add(logObj);
                 }
+                curve.setSubList(subList);
+            }
+            else {
+                curve.setSubList(null);
             }
+            curveList.add(curve);
+        }
+        // 设置全程曲线时间分布
+        genTime(startTime, now, qcIntervals, "MM-dd HH:mm", curveList, "全程");
+
+        return curveList;
+    }
+
+    /**
+     * 获取实时曲线-当前
+     * @return
+     */
+    public List<CurveDTO> getIncrementRealtimeCurve() {
+        // 获取大屏参数设置
+        GuanDashboardParam paramat = new GuanDashboardParam();
+        paramat.setStatus("1"); // 状态为启用
+        paramat.setIflog("Y"); // 需要获取历史记录
+        List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+        if (dashboardParamList == null || dashboardParamList.size() < 1) {
+            return null;
+        }
 
-            // 获取实时曲线时间分布
-            List<String> stimes = genTime(realityTime, now, ssIntervals, "HH:mm");
-            JSONObject stimeObject = new JSONObject();
-            stimeObject.put("Name", "实时曲线-时间分布");
-            stimeObject.put("Values", stimes);
-            list.add(stimeObject);
-
-            // 获取全程曲线时间分布
-            List<String> qtimes = genTime(startTime, now, qcIntervals, "MM-dd HH:mm");
-            JSONObject qtimeObject = new JSONObject();
-            qtimeObject.put("Name", "全程曲线-时间分布");
-            qtimeObject.put("Values", qtimes);
-            list.add(qtimeObject);
+        // 组合参数信息
+        List<WaLogDTO> tags = new ArrayList<>();
+        for (GuanDashboardParam param : dashboardParamList) {
+            // 没有点位名
+            if (param.getTagName() == null || "".equals(param.getTagName())) {
+                continue;
+            }
+            // 不是实时曲线设置
+            if (!param.getParamName().equals("辐射强度值-实时") && !param.getParamName().equals("湿度实值-实时") &&
+                    !param.getParamName().equals("温度实值-实时")) {
+                continue;
+            }
+            WaLogDTO tag = new WaLogDTO(param.getTagName());
+            tags.add(tag);
         }
-        else {
+
+        JSONObject waparams = generateGetObject(tags);
+        JSONObject jsonObject = getTagNameValuesNoAnalysis(waparams);
+        JSONArray resArray = jsonObject.getJSONArray("Values");
+        List<CurveDTO> curveList = new ArrayList<>();
+        if (resArray != null && resArray.size() > 0) {
+            for (Integer i = 0; i < resArray.size(); i++) {
+                JSONObject res = resArray.getJSONObject(i);
+                CurveDTO curve = new CurveDTO();
+                curve.setType("实时");
+                curve.setName(res.get("Name").toString());
+
+                List<CurveSubDTO> subList = new ArrayList<>();
+                CurveSubDTO sub = new CurveSubDTO();
+                sub.setLogtime(new Date());
+
+                sub.setTranstime(new SimpleDateFormat("HH:mm").format(new Date()));
+                sub.setTagvalue(res.get("Value").toString());
+                subList.add(sub);
+
+                curve.setSubList(subList);
+                curveList.add(curve);
+            }
+        }
+
+        return curveList;
+    }
+
+    /**
+     * 获取全程曲线-当前
+     * @return
+     */
+    public List<CurveDTO> getIncrementWholeCurve() {
+        // 获取大屏参数设置
+        GuanDashboardParam paramat = new GuanDashboardParam();
+        paramat.setStatus("1"); // 状态为启用
+        paramat.setIflog("Y"); // 需要获取历史记录
+        List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+        if (dashboardParamList == null || dashboardParamList.size() < 1) {
             return null;
         }
-        return list;
+
+        // 组合参数信息
+        List<WaLogDTO> tags = new ArrayList<>();
+        for (GuanDashboardParam param : dashboardParamList) {
+            // 没有点位名
+            if (param.getTagName() == null || "".equals(param.getTagName())) {
+                continue;
+            }
+            // 不是实时曲线设置
+            if (!param.getParamName().equals("辐射强度值-全程") && !param.getParamName().equals("湿度实值-全程") &&
+                    !param.getParamName().equals("温度实值-全程")) {
+                continue;
+            }
+            WaLogDTO tag = new WaLogDTO(param.getTagName());
+            tags.add(tag);
+        }
+
+        JSONObject waparams = generateGetObject(tags);
+        JSONObject jsonObject = getTagNameValuesNoAnalysis(waparams);
+        JSONArray resArray = jsonObject.getJSONArray("Values");
+        List<CurveDTO> curveList = new ArrayList<>();
+        if (resArray != null && resArray.size() > 0) {
+            for (Integer i = 0; i < resArray.size(); i++) {
+                JSONObject res = resArray.getJSONObject(i);
+                CurveDTO curve = new CurveDTO();
+                curve.setType("实时");
+                curve.setName(res.get("Name").toString());
+
+                List<CurveSubDTO> subList = new ArrayList<>();
+                CurveSubDTO sub = new CurveSubDTO();
+                sub.setLogtime(new Date());
+
+                sub.setTranstime(new SimpleDateFormat("HH:mm").format(new Date()));
+                sub.setTagvalue(res.get("Value").toString());
+                subList.add(sub);
+
+                curve.setSubList(subList);
+                curveList.add(curve);
+            }
+        }
+
+        return curveList;
     }
 
     /**
-     * 生成实时曲线需要的时间
+     * 生成曲线的时间
+     *
      * @param startTime 开始时间
+     * @param endTime 结束时间
      * @param intervals 间隔频率(分钟)
+     * @param dateformat 时间格式
+     * @param curveList 曲线信息
+     * @param type 曲线类型
+     * @return
      */
-    private List<String> genTime(Date startTime, Date endTime, Integer intervals, String dateformat) {
+    private void genTime(Date startTime, Date endTime, Integer intervals,
+                                 String dateformat, List<CurveDTO> curveList, String type) {
         List<String> times = new ArrayList<>();
-
         // 循环获取时间
         Calendar calendar = Calendar.getInstance();
-        while (startTime.before(endTime)) {
-//            times.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime));
-            times.add(new SimpleDateFormat(dateformat).format(startTime));
-            // 设置当前的时间戳
-            calendar.setTime(startTime);
-            calendar.add(Calendar.MINUTE, intervals);
-            startTime = calendar.getTime();
-        }
 
-        return times;
+        if (curveList != null && curveList.size() > 0) {
+            for (int i = 0; i < curveList.size(); i++) {
+                if (!type.equals(curveList.get(i).getType())) {
+                    continue;
+                }
+                Date beginTime = (Date) startTime.clone();
+
+                for (int j = 0; j < curveList.get(i).getSubList().size(); j++) {
+                    curveList.get(i).getSubList().get(j).setLogtime(beginTime);
+                    curveList.get(i).getSubList().get(j).setTranstime(new SimpleDateFormat(dateformat).format(beginTime));
+                    // 设置当前的时间戳
+                    calendar.setTime(beginTime);
+                    calendar.add(Calendar.MINUTE, intervals);
+                    beginTime = calendar.getTime();
+                }
+            }
+        }
     }
     //endregion
 
-    // region <<获取预制曲线>>
+    // region <<根据大屏参数设置,获取预制曲线>>
     /**
      * 获取预制曲线
      * @return
@@ -1116,11 +1314,21 @@ public class WebAccessService {
 
     // region <<获取报警信息>>
     /**
+     * 获取24小时内报警信息
+     * @return
+     */
+    public List<GuanRAlarm> getAlarm24h() {
+        List<GuanRAlarm> alarmList = guanRAlarmService.selectAlarm24h(false);
+
+        return alarmList;
+    }
+
+    /**
      * 获取最新一条报警信息
      * @return
      */
     public GuanRAlarm getLastAlarm() {
-        GuanRAlarm rAlarm = guanRAlarmMapper.selectTop1Alarm();
+        GuanRAlarm rAlarm = guanRAlarmService.selectTop1Alarm();
 
         return rAlarm;
     }
@@ -1169,12 +1377,12 @@ public class WebAccessService {
     //region <<组合获取到的大屏展示数据>>
 
     /**
-     * 组合获取到的大屏展示数据
+     * 获取设备实时数据
      * @return
      */
-    public String organizeDashData() {
+    public String loadRealtimeData() {
 
-        log.info(String.format(" 获取设备实时值! 时间:" + DateUtils.getTimestamp()));
+        log.info(String.format(" 获取设备实时信息! 开始时间 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
 
         JSONObject jsonObject = new JSONObject();
 
@@ -1182,19 +1390,252 @@ public class WebAccessService {
         JSONArray tagArray = getDashboardTagNameValues();
         jsonObject.put("设备实时值", tagArray);
 
-        // 设备历史值
-        JSONArray logArray = getDashboardDataLog(null);
-        jsonObject.put("设备历史值", logArray);
+        log.info(String.format(" 获取设备实时信息! 结束时间 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
+
+        return jsonObject.toString();
+    }
+
+    /**
+     * 获取曲线数据
+     * @return
+     */
+    public String loadCurveData() {
+
+        log.info(String.format(" 获取设备曲线信息! 开始时间 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
+
+        JSONObject jsonObject = new JSONObject();
+
+        // 实时曲线在缓存中不存在,则获取实时曲线并存入缓存中,否则做增量添加
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_REALTIME_CURVE)) {
+            List<CurveDTO> realtimeCrveList = getRealtimeCurve(null);
+            jsonObject.put("实时曲线", realtimeCrveList.toString());
+            redisUtil.set(GuanCommonConstant.GUAN_REALTIME_CURVE, realtimeCrveList);
+        }
+        // 增量添加
+        else {
+            List<CurveDTO> incrementRealtimeCurveList = getIncrementRealtimeCurve();
+            List<CurveDTO> realtimeCrveList = (List<CurveDTO>) redisUtil.get(GuanCommonConstant.GUAN_REALTIME_CURVE);
+            // 将获取的增加数据增加到实时曲线的列表中
+            if (realtimeCrveList != null && realtimeCrveList.size() > 0) {
+                for (int i = 0; i < realtimeCrveList.size(); i++) {
+                    String name = realtimeCrveList.get(i).getName();
+                    List<CurveDTO> subCurveList = incrementRealtimeCurveList.stream()
+                            .filter(p -> p.getName().equals(name)).collect(Collectors.toList());
+                    if (subCurveList != null && subCurveList.size() > 0 &&
+                            subCurveList.get(0).getSubList() != null && subCurveList.get(0).getSubList().size() > 0) {
+                        realtimeCrveList.get(i).getSubList().add(subCurveList.get(0).getSubList().get(0));
+                    }
+                }
+            }
+            else {
+                Collections.copy(incrementRealtimeCurveList, realtimeCrveList);
+            }
+            jsonObject.put("实时曲线", realtimeCrveList.toString());
+            // 重新缓存实时曲线
+            redisUtil.set(GuanCommonConstant.GUAN_REALTIME_CURVE, realtimeCrveList);
+        }
+
+        // 全程曲线在缓存中不存在,则获取全程曲线并存入缓存中,否则做增量添加
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_WHOLE_CURE)) {
+            List<CurveDTO> wholeCrveList = getWholeCurve(null);
+            jsonObject.put("全程曲线", wholeCrveList.toString());
+            redisUtil.set(GuanCommonConstant.GUAN_WHOLE_CURE, wholeCrveList);
+        }
+        // 增量添加
+        else {
+            List<CurveDTO> incrementWholeCurveList = getIncrementWholeCurve();
+            List<CurveDTO> wholeCrveList = (List<CurveDTO>) redisUtil.get(GuanCommonConstant.GUAN_WHOLE_CURE);
+            // 将获取的增加数据增加到全程曲线的列表中
+            if (wholeCrveList != null && wholeCrveList.size() > 0) {
+                for (int i = 0; i < wholeCrveList.size(); i++) {
+                    String name = wholeCrveList.get(i).getName();
+                    List<CurveDTO> subCurveList = incrementWholeCurveList.stream()
+                            .filter(p -> p.getName().equals(name)).collect(Collectors.toList());
+                    if (subCurveList != null && subCurveList.size() > 0 &&
+                            subCurveList.get(0).getSubList() != null && subCurveList.get(0).getSubList().size() > 0) {
+                        wholeCrveList.get(i).getSubList().add(subCurveList.get(0).getSubList().get(0));
+                    }
+                }
+            }
+            else {
+                Collections.copy(incrementWholeCurveList, wholeCrveList);
+            }
+            jsonObject.put("全程曲线", wholeCrveList.toString());
+            // 重新缓存全程曲线
+            redisUtil.set(GuanCommonConstant.GUAN_WHOLE_CURE, wholeCrveList);
+        }
+
+        // 预制曲线在缓存中不存在,则获取预制曲线并存入缓存中,否则不做处理
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_PREPARE_CURVE)) {
+            List<String> duans = new ArrayList<>();
+            List<CirculateDTO> yzqxList = getYzcx(duans);
+            jsonObject.put("预制曲线", yzqxList);
+            jsonObject.put("预制曲线线段", duans);
+            redisUtil.set(GuanCommonConstant.GUAN_PREPARE_CURVE, yzqxList);
+            redisUtil.set(GuanCommonConstant.GUAN_PREPARE_CURVE_SECTION, duans);
+        }
+
+        // 最近24H报警信息在缓存中不存在,则获取信息并存入缓存中,否则不做处理
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_ALARMS_24H)) {
+            List<GuanRAlarm> alarmList = getAlarm24h();
+            jsonObject.put("最近24H报警信息", alarmList.toString());
+            redisUtil.set(GuanCommonConstant.GUAN_ALARMS_24H, alarmList);
+        }
+
+        log.info(String.format(" 获取设备曲线信息! 结束时间 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
+
+        return jsonObject.toString();
+    }
+
+    /**
+     * 获取曲线数据 增量
+     * @return
+     */
+    public String loadIncrementCurveData() {
+
+        log.info(String.format(" 获取设备曲线信息(增量)! 开始时间 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
+
+        JSONObject jsonObject = new JSONObject();
+
+        // 实时曲线
+        List<CurveDTO> incrementRealtimeCurveList = getIncrementRealtimeCurve();
+        List<CurveDTO> realtimeCrveList = null;
+        if (redisUtil.hasKey(GuanCommonConstant.GUAN_REALTIME_CURVE)) {
+            realtimeCrveList = (List<CurveDTO>) redisUtil.get(GuanCommonConstant.GUAN_REALTIME_CURVE);
+        }
+        // 将获取的增加数据增加到实时曲线的列表中
+        if (realtimeCrveList != null && realtimeCrveList.size() > 0) {
+            for (int i = 0; i < realtimeCrveList.size(); i++) {
+                String name = realtimeCrveList.get(i).getName();
+                List<CurveDTO> subCurveList = incrementRealtimeCurveList.stream()
+                        .filter(p -> p.getName().equals(name)).collect(Collectors.toList());
+                if (subCurveList != null && subCurveList.size() > 0 &&
+                        subCurveList.get(0).getSubList() != null && subCurveList.get(0).getSubList().size() > 0) {
+                    realtimeCrveList.get(i).getSubList().add(subCurveList.get(0).getSubList().get(0));
+                }
+            }
+        }
+        else {
+            Collections.copy(incrementRealtimeCurveList, realtimeCrveList);
+        }
+        // 重新缓存实时曲线
+        redisUtil.set(GuanCommonConstant.GUAN_REALTIME_CURVE, realtimeCrveList);
+        // 返回增量信息
+        jsonObject.put("实时曲线", incrementRealtimeCurveList.toString());
+
+        // 全程曲线
+        List<CurveDTO> incrementWholeCurveList = getIncrementWholeCurve();
+        List<CurveDTO> wholeCrveList = null;
+        if (redisUtil.hasKey(GuanCommonConstant.GUAN_WHOLE_CURE)) {
+            wholeCrveList = (List<CurveDTO>) redisUtil.get(GuanCommonConstant.GUAN_WHOLE_CURE);
+        }
+        // 将获取的增加数据增加到全程曲线的列表中
+        if (wholeCrveList != null && wholeCrveList.size() > 0) {
+            for (int i = 0; i < wholeCrveList.size(); i++) {
+                String name = wholeCrveList.get(i).getName();
+                List<CurveDTO> subCurveList = incrementWholeCurveList.stream()
+                        .filter(p -> p.getName().equals(name)).collect(Collectors.toList());
+                if (subCurveList != null && subCurveList.size() > 0 &&
+                        subCurveList.get(0).getSubList() != null && subCurveList.get(0).getSubList().size() > 0) {
+                    wholeCrveList.get(i).getSubList().add(subCurveList.get(0).getSubList().get(0));
+                }
+            }
+        }
+        else {
+            Collections.copy(incrementWholeCurveList, wholeCrveList);
+        }
+        // 返回增量信息
+        redisUtil.set(GuanCommonConstant.GUAN_WHOLE_CURE, wholeCrveList);
+        jsonObject.put("全程曲线", wholeCrveList.toString());
+
+        log.info(String.format(" 获取设备曲线信息(增量)! 结束时间 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
+
+        return jsonObject.toString();
+    }
+
+    /**
+     * 缓存数据
+     * @param isRefresh 是否强制刷新
+     * @return
+     */
+    public void loadCacheData(Boolean isRefresh) {
+
+        log.info(String.format("缓存信息! 开始时间 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
 
-        // 最新一条报警信息
-        GuanRAlarm rAlarm = getLastAlarm();
-        jsonObject.put("最新一条报警信息", rAlarm);
+        // 1 获取设备状态
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_EQUIPMENT_STATUS) || isRefresh) {
+            GuanAnachglog anachglog = anachglogService.selectTop1Anachglog(true);
+            redisUtil.set(GuanCommonConstant.GUAN_EQUIPMENT_STATUS, anachglog);
+        }
+
+        // 重新获取预制曲线
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_PREPARE_CURVE) || isRefresh) {
+            List<String> duans = new ArrayList<>();
+            List<CirculateDTO> yzqxList = getYzcx(duans);
+            redisUtil.set(GuanCommonConstant.GUAN_PREPARE_CURVE, yzqxList);
+            redisUtil.set(GuanCommonConstant.GUAN_PREPARE_CURVE_SECTION, duans);
+        }
+
+        // 重新获取实时曲线
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_REALTIME_CURVE) || isRefresh) {
+            List<CurveDTO> realtimeCrveList = getRealtimeCurve(null);
+            redisUtil.set(GuanCommonConstant.GUAN_REALTIME_CURVE, realtimeCrveList);
+        }
+
+        // 重新获取全程曲线
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_WHOLE_CURE) || isRefresh) {
+            List<CurveDTO> wholeCrveList = getWholeCurve(null);
+            redisUtil.set(GuanCommonConstant.GUAN_WHOLE_CURE, wholeCrveList);
+        }
+
+        // 重新获取当前时间之前24小时的报警信息
+        if (!redisUtil.hasKey(GuanCommonConstant.GUAN_ALARMS_24H) || isRefresh) {
+            List<GuanRAlarm> alarmList = getAlarm24h();
+            redisUtil.set(GuanCommonConstant.GUAN_ALARMS_24H, alarmList);
+        }
+
+        log.info(String.format("缓存信息! 结束时间 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
+    }
+
+    /**
+     * 前端页面首次加载,获取大屏展示数据
+     * 只获取报警信息、预制曲线、全程曲线、实时曲线,其它信息不获取
+     *
+     * @return
+     */
+    public String firstLoadData() {
+
+        log.info(String.format(" 前端首次加载值! 开始时间 ↓↓↓↓↓↓↓↓↓↓:" + DateUtils.getTimestamp()));
+
+        JSONObject jsonObject = new JSONObject();
+
+        // 实时曲线 从redis中获取
+        if (redisUtil.hasKey(GuanCommonConstant.GUAN_REALTIME_CURVE)) {
+            List<CurveDTO> realtimeCrveList = (List<CurveDTO>) redisUtil.get(GuanCommonConstant.GUAN_REALTIME_CURVE);
+            jsonObject.put("实时曲线", realtimeCrveList.toString());
+        }
+
+        // 全程曲线 从redis中获取
+        if (redisUtil.hasKey(GuanCommonConstant.GUAN_WHOLE_CURE)) {
+            List<CurveDTO> wholeCrveList = (List<CurveDTO>) redisUtil.get(GuanCommonConstant.GUAN_WHOLE_CURE);
+            jsonObject.put("全程曲线", wholeCrveList.toString());
+        }
+
+        // 预制曲线 从redis中获取
+        if (redisUtil.hasKey(GuanCommonConstant.GUAN_PREPARE_CURVE)) {
+            List<String> duans = (List<String>) redisUtil.get(GuanCommonConstant.GUAN_PREPARE_CURVE);
+            List<CirculateDTO> yzqxList = (List<CirculateDTO>) redisUtil.get(GuanCommonConstant.GUAN_PREPARE_CURVE_SECTION);
+            jsonObject.put("预制曲线", yzqxList);
+            jsonObject.put("预制曲线线段", duans);
+        }
+
+        // 最近24H报警信息 从redis中获取
+        if (redisUtil.hasKey(GuanCommonConstant.GUAN_ALARMS_24H)) {
+            List<GuanRAlarm> alarmList = (List<GuanRAlarm>) redisUtil.get(GuanCommonConstant.GUAN_ALARMS_24H);
+            jsonObject.put("最近24H报警信息", alarmList.toString());
+        }
 
-        // 预制曲线
-        List<String> duans = new ArrayList<>();
-        List<CirculateDTO> yzqxList = getYzcx(duans);
-        jsonObject.put("预制曲线", yzqxList);
-        jsonObject.put("预制曲线线段", duans);
+        log.info(String.format(" 前端首次加载值! 结束时间 ↑↑↑↑↑↑↑↑↑↑:" + DateUtils.getTimestamp()));
 
         return jsonObject.toString();
     }

+ 45 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/impl/GuanAnachglogServiceImpl.java

@@ -0,0 +1,45 @@
+package org.jeecg.modules.webaccess.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.RedisUtil;
+import org.jeecg.modules.common.GuanCommonConstant;
+import org.jeecg.modules.webaccess.entity.GuanAnachglog;
+import org.jeecg.modules.webaccess.mapper.GuanAnachglogMapper;
+import org.jeecg.modules.webaccess.service.IGuanAnachglogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+@Service
+public class GuanAnachglogServiceImpl extends ServiceImpl<GuanAnachglogMapper, GuanAnachglog> implements IGuanAnachglogService {
+
+    @Autowired
+    private GuanAnachglogMapper guanAnachglogMapper;
+
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+
+    /**
+     * 获取最新一条信息
+     * @param ifRefresh 是否强制刷新
+     * @return
+     */
+    @Override
+    public GuanAnachglog selectTop1Anachglog(Boolean ifRefresh) {
+        GuanAnachglog guanAnachglog = null;
+
+        // 不是强制刷新且存在缓存中存在设备状态
+        if (!ifRefresh && redisTemplate.hasKey(GuanCommonConstant.GUAN_EQUIPMENT_STATUS)) {
+            guanAnachglog = (GuanAnachglog) redisTemplate.opsForValue().get(GuanCommonConstant.GUAN_EQUIPMENT_STATUS);
+        }
+        else {
+            guanAnachglog = guanAnachglogMapper.selectTop1Anachglog();
+            redisTemplate.delete(GuanCommonConstant.GUAN_EQUIPMENT_STATUS);
+            redisTemplate.opsForValue().set(GuanCommonConstant.GUAN_EQUIPMENT_STATUS, guanAnachglog);
+        }
+
+        return guanAnachglog;
+    }
+}

+ 36 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/service/impl/GuanRAlarmServiceImpl.java

@@ -1,23 +1,59 @@
 package org.jeecg.modules.webaccess.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.common.GuanCommonConstant;
+import org.jeecg.modules.webaccess.entity.GuanAnachglog;
 import org.jeecg.modules.webaccess.entity.GuanRAlarm;
 import org.jeecg.modules.webaccess.mapper.GuanRAlarmMapper;
 import org.jeecg.modules.webaccess.service.IGuanRAlarmService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
 @Service
 public class GuanRAlarmServiceImpl extends ServiceImpl<GuanRAlarmMapper, GuanRAlarm> implements IGuanRAlarmService {
     @Autowired
     private GuanRAlarmMapper guanRAlarmMapper;
 
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+
 
     /**
      * 获取最新一条报警信息
      * @return
      */
+    @Override
     public GuanRAlarm selectTop1Alarm() {
         return guanRAlarmMapper.selectTop1Alarm();
     }
+
+    /**
+     * 获取最新一条报警信息
+     * @param ifRefresh 是否强制刷新
+     * @return
+     */
+    @Override
+    public List<GuanRAlarm> selectAlarm24h(Boolean ifRefresh) {
+        List<GuanRAlarm> alarmList = null;
+
+        // 不是强制刷新且存在缓存中存在设备状态
+        if (!ifRefresh && redisTemplate.hasKey(GuanCommonConstant.GUAN_ALARMS_24H)) {
+            alarmList = (List<GuanRAlarm>) redisTemplate.opsForValue().get(GuanCommonConstant.GUAN_ALARMS_24H);
+        }
+        else {
+            alarmList = guanRAlarmMapper.selectAlarm24h();
+            if (alarmList == null) {
+                alarmList = new ArrayList<>();
+            }
+            redisTemplate.delete(GuanCommonConstant.GUAN_ALARMS_24H);
+            redisTemplate.opsForValue().set(GuanCommonConstant.GUAN_ALARMS_24H, alarmList);
+        }
+
+        return alarmList;
+    }
 }