Explorar o código

1.修改mqtt订阅逻辑
2.修改导出优化逻辑
3.修改图表查询统计接口

lengfaqiang %!s(int64=2) %!d(string=hai) anos
pai
achega
ce4bf74527
Modificáronse 15 ficheiros con 452 adicións e 67 borrados
  1. 3 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/constant/Global.java
  2. 38 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/AlarmTitleEnum.java
  3. 8 5
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/AlarmTypeEnum.java
  4. 4 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/vo/BaseList.java
  5. 64 7
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttDeviceCallbackHandler.java
  6. 10 5
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/AlarmController.java
  7. 11 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/HttpDemoController.java
  8. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceMapper.java
  9. 60 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmLogThresholdExport.java
  10. 6 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmLogThresholdQuery.java
  11. 22 14
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/excel/KwsAlarmExportVO.java
  12. 54 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/excel/ThresholdRecordDetailExportVO.java
  13. 154 30
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java
  14. 11 5
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java
  15. 4 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml

+ 3 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/constant/Global.java

@@ -113,6 +113,9 @@ public class Global {
     public static final String REDIS_SYS_DICT_PREFIX = "dictInfo:dict:";
     public static final String REDIS_SYS_DICT_GROUP_PREFIX = "dictInfo:group:";
 
+    /**告警触发次数*/
+    public static final String REDIS_SYS_ALARM_PREFIX = "dictInfo:alarm:";
+
     /**redis用户车辆gps信息*/
     public static final String REDIS_CACHE_GPS_CAR_PREFIX = "cacheGpsCar:";
 

+ 38 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/AlarmTitleEnum.java

@@ -0,0 +1,38 @@
+package com.sckw.core.model.enums;
+
+import lombok.Getter;
+
+/**
+ * @author czh
+ * @desc 告警明细
+ * @date 2023/6/15
+ */
+@Getter
+public enum AlarmTitleEnum {
+
+    //离线时长超1天
+    ALARM_TITLE_ONE(1, "1", "离线时长超1天"),
+    //数值超阈值
+    ALARM_TITLE_TWO(2, "2", "数值超阈值");
+
+    private final int code;
+
+    private final String status;
+
+    private final String name;
+
+    AlarmTitleEnum(int code, String status, String name) {
+        this.code = code;
+        this.status = status;
+        this.name = name;
+    }
+
+    public static AlarmTitleEnum getName(int code) {
+        for (AlarmTitleEnum entryTypeEnum : values()) {
+            if (entryTypeEnum.getCode() == code) {
+                return entryTypeEnum;
+            }
+        }
+        return null;
+    }
+}

+ 8 - 5
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/AlarmTypeEnum.java

@@ -10,17 +10,20 @@ import lombok.Getter;
 @Getter
 public enum AlarmTypeEnum {
 
-    //自主入驻
-    ALARM_ONE(1, "数据告警"),
-    //平台接入
-    ALARM_TWO(2, "设备告警");
+    //数据告警
+    ALARM_ONE(1, "1", "数据告警"),
+    //设备告警
+    ALARM_TWO(2, "2", "设备告警");
 
     private final int code;
 
+    private final String status;
+
     private final String name;
 
-    AlarmTypeEnum(int code, String name){
+    AlarmTypeEnum(int code, String status, String name) {
         this.code = code;
+        this.status = status;
         this.name = name;
     }
 

+ 4 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/vo/BaseList.java

@@ -11,6 +11,10 @@ import org.hibernate.validator.constraints.Length;
  */
 @Data
 public class BaseList {
+    /**
+     * 父级id
+     */
+    private String parentId;
     /**
      * 数据id 逗号隔开
      */

+ 64 - 7
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttDeviceCallbackHandler.java

@@ -4,13 +4,17 @@ import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.NumberConstant;
+import com.sckw.core.model.enums.AlarmTitleEnum;
+import com.sckw.core.model.enums.AlarmTypeEnum;
 import com.sckw.core.model.enums.DictEnum;
 import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.utils.CollectionUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.log.TraceLog.TraceLog;
+import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.slope.detection.dao.mysql.*;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
@@ -23,6 +27,7 @@ import com.sckw.slope.detection.service.CommonService;
 import com.sckw.slope.detection.service.TdengineService;
 import com.sckw.slope.detection.service.api.DetectionApiService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.common.utils.MD5Utils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -123,7 +128,20 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
                         Long level = Long.valueOf(map.get("level"));
                         Long thresholdId = Long.valueOf(map.get("thresholdId"));
                         //阈值表以及明细表存储
-                        insertAlarmAndDetail(level, device, thresholdId, itemValue, ts);
+                        long id = insertAlarmAndDetail(level, device, thresholdId, itemValue, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
+                        /**阈值次数存redis*/
+                        String key = Global.REDIS_SYS_ALARM_PREFIX + Global.POUND + String.valueOf(id) + Global.POUND+ AlarmTypeEnum.ALARM_ONE.getStatus()
+                                + Global.POUND + AlarmTitleEnum.ALARM_TITLE_TWO.getStatus();
+                        String number = RedissonUtils.getString(key);
+                        Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>()
+                                .eq(KwsAlarmDetail::getAlarmId, id)
+                                .eq(KwsAlarmDetail::getStatus, 0)
+                        );
+                        if (StringUtils.isBlank(number)) {
+                            RedissonUtils.putString(key, "1", Global.COMMON_EXPIRE);
+                        } else {
+                            RedissonUtils.putString(key, count.toString(), Global.COMMON_EXPIRE);
+                        }
                         /*【露天矿山边坡监测系统】尊敬的管理员,2023-10-01 12:23:34监测到一级告警。
                             设备名称:位移监测设备-gnss一号机,监测数值:55。123456789N,请尽快处理问题。*/
                         Map<String, Object> messageMap = new HashMap<>();
@@ -187,7 +205,20 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
                 long diff = Math.abs(date.getTime() - deviceTime.getTime());
                 long diffHours = diff / (60 * 60 * 1000) % 24;
                 if (diffHours > 24) {
-                    insertAlarmAndDetail(1L, device, device.getId(), itemValue, ts);
+                    long id = insertAlarmAndDetail(1L, device, device.getId(), itemValue, ts, AlarmTitleEnum.ALARM_TITLE_ONE.getStatus(), AlarmTypeEnum.ALARM_TWO.getCode());
+                    /**阈值次数存redis*/
+                    String key = Global.REDIS_SYS_ALARM_PREFIX + Global.POUND + String.valueOf(id) + Global.POUND+ AlarmTypeEnum.ALARM_TWO.getStatus()
+                            + Global.POUND + AlarmTitleEnum.ALARM_TITLE_ONE.getStatus();
+                    String number = RedissonUtils.getString(key);
+                    Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>()
+                            .eq(KwsAlarmDetail::getAlarmId, id)
+                            .eq(KwsAlarmDetail::getStatus, 0)
+                    );
+                    if (StringUtils.isBlank(number)) {
+                        RedissonUtils.putString(key, "1", Global.COMMON_EXPIRE);
+                    } else {
+                        RedissonUtils.putString(key, count.toString(), Global.COMMON_EXPIRE);
+                    }
                     // todo 暂未设备告警电话,设备告警不推送短信
                     device.setOnline(1);
                     deviceMapper.updateById(device);
@@ -384,8 +415,13 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
      * @param thresholdId 阈值id/设备id
      * @param itemValue   td数据当时检测值
      * @param ts          td时间
+     * @param alarmTitle  设备类型明细
+     * @param type        设备类型
      */
-    private void insertAlarmAndDetail(Long level, KwsDevice device, Long thresholdId, String itemValue, Long ts) {
+    private long insertAlarmAndDetail(Long level, KwsDevice device, Long thresholdId,
+                                      String itemValue, Long ts,
+                                      String alarmTitle, Integer type
+    ) {
         Long deviceId = device.getId();
         KwsProjectDevice projectDevice = projectDeviceMapper.selectOne(new LambdaQueryWrapper<KwsProjectDevice>()
                 .eq(KwsProjectDevice::getDeviceId, deviceId)
@@ -405,10 +441,10 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
                 wrapper.eq(KwsAlarm::getCompanyId, projectDevice.getCompanyId());
             }
         }
+        long alarmId = new IdWorker(NumberConstant.ONE).nextId();
         List<KwsAlarm> alarms = alarmMapper.selectList(wrapper);
         if (CollectionUtils.isEmpty(alarms)) {
             KwsAlarm alarm = new KwsAlarm();
-            long alarmId = new IdWorker(NumberConstant.ONE).nextId();
             String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
             String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
             String projectId = projectDevice == null ? null :
@@ -418,9 +454,9 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
             alarm.setMountainId(mountainId);
             alarm.setProjectId(projectId);
             alarm.setDeviceId(deviceId);
-            alarm.setTitle("2");
+            alarm.setTitle(alarmTitle);
             alarm.setLevel(level.intValue());
-            alarm.setType(2);
+            alarm.setType(type);
             LocalDateTime localDateTime = Instant.ofEpochSecond(ts).atZone(ZoneId.systemDefault()).toLocalDateTime();
 //            LocalDateTime localDateTime = new Date(ts).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
             alarm.setCreateTime(localDateTime);
@@ -435,19 +471,40 @@ public class MqttDeviceCallbackHandler extends AbstractHandler {
             alarmDetail.setPid(thresholdId);
             alarmDetail.setVal(itemValue);
             alarmDetail.setLat(device.getLogicLat());
-            alarmDetail.setLng(device.getLogicAlt());
+            alarmDetail.setLng(device.getLogicLng());
             alarmDetail.setAlt(device.getLogicAlt());
             alarmDetail.setCreateTime(localDateTime);
             alarmDetail.setUpdateTime(localDateTime);
             alarmDetail.setStatus(0);
             alarmDetailMapper.insert(alarmDetail);
         } else {
+            alarmId = alarms.get(0).getId();
             KwsAlarm alarm = alarms.get(0);
             LocalDateTime localDateTime = Instant.ofEpochSecond(ts).atZone(ZoneId.systemDefault()).toLocalDateTime();
 //            LocalDateTime localDateTime = new Date(ts).toInstant().atOffset(ZoneOffset.of("+8")).toLocalDateTime();
             alarm.setUpdateTime(localDateTime);
+            alarm.setStatus(0);
             alarmMapper.updateById(alarm);
+            String mountainId = projectDevice == null ? null : projectDevice.getMountainId();
+            String companyId = projectDevice == null ? null : projectDevice.getCompanyId();
+            String projectId = projectDevice == null ? null :
+                    (projectDevice.getProjectId() == null ? null : projectDevice.getProjectId().toString());
+            KwsAlarmDetail alarmDetail = new KwsAlarmDetail();
+            alarmDetail.setId(new IdWorker(NumberConstant.TWO).nextId());
+            alarmDetail.setMountainId(mountainId);
+            alarmDetail.setCompanyId(companyId);
+            alarmDetail.setAlarmId(alarm.getId());
+            alarmDetail.setPid(thresholdId);
+            alarmDetail.setVal(itemValue);
+            alarmDetail.setLat(device.getLogicLat());
+            alarmDetail.setLng(device.getLogicLng());
+            alarmDetail.setAlt(device.getLogicAlt());
+            alarmDetail.setCreateTime(localDateTime);
+            alarmDetail.setUpdateTime(localDateTime);
+            alarmDetail.setStatus(0);
+            alarmDetailMapper.insert(alarmDetail);
         }
+        return alarmId;
     }
 
     /**

+ 10 - 5
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/AlarmController.java

@@ -8,11 +8,13 @@ import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.annotation.ExcelContext;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.log.TraceLog.TraceLog;
+import com.sckw.slope.detection.model.param.AlarmLogThresholdExport;
 import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
 import com.sckw.slope.detection.model.param.AlarmStatisticsQuery;
 import com.sckw.slope.detection.model.vo.ThresholdLogDetailVO;
-import com.sckw.slope.detection.model.vo.ThresholdRecordDetailVO;
 import com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO;
+import com.sckw.slope.detection.model.vo.excel.ThresholdRecordDetailExportVO;
 import com.sckw.slope.detection.service.KwsAlarmService;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
@@ -60,9 +62,11 @@ public class AlarmController {
         return kwsAlarmService.read(baseList, request);
     }
 
+
+    @TraceLog(description = "告警导出")
     @Log(description = "告警导出")
     @RequestMapping(name = "告警导出", value = "/export", method = RequestMethod.POST)
-    public HttpResult export(@Valid @RequestBody AlarmLogThresholdQuery query, HttpServletRequest request, HttpServletResponse response) throws IOException {
+    public HttpResult export(@Valid @RequestBody AlarmLogThresholdExport query, HttpServletRequest request, HttpServletResponse response) throws IOException {
         log.info("告警导出 export param {}", JSONObject.toJSONString(query));
         List<KwsAlarmExportVO> export = kwsAlarmService.export(query, request, response);
         if (org.springframework.util.CollectionUtils.isEmpty(export)) {
@@ -82,16 +86,17 @@ public class AlarmController {
         return HttpResult.ok(kwsAlarmService.thresholdDetail(baseList, request));
     }
 
+    @TraceLog(description = "告警记录-导出详情明细")
     @Log(description = "告警记录-导出详情明细")
     @RequestMapping(name = "告警记录-导出详情明细", value = "/exportDetail", method = RequestMethod.POST)
-    public HttpResult exportDetail(@Valid @RequestBody PublicBaseList baseList, HttpServletRequest request, HttpServletResponse response) throws IOException {
+    public HttpResult exportDetail(@Valid @RequestBody BaseList baseList, HttpServletRequest request, HttpServletResponse response) throws IOException {
         log.info("告警记录-导出详情明细 exportDetail param {}", baseList);
-        List<ThresholdRecordDetailVO> list = kwsAlarmService.exportDetail(baseList, request);
+        List<ThresholdRecordDetailExportVO> list = kwsAlarmService.exportDetail(baseList, request);
         if (org.springframework.util.CollectionUtils.isEmpty(list)) {
             return HttpResult.ok(HttpStatus.SUCCESS_CODE, "暂无数据,请确认");
         }
         ExcelContext excelContext = KwsAlarmExportVO.class.getAnnotation(ExcelContext.class);
-        String filePath = ExcelUtil.exportByExcelUploadingToOss(response, list, excelContext.fileName() + ".xlsx", KwsAlarmExportVO.class);
+        String filePath = ExcelUtil.exportByExcelUploadingToOss(response, list, excelContext.fileName() + ".xlsx", ThresholdRecordDetailExportVO.class);
         Map<String, String> filePathMap = new HashMap<>();
         filePathMap.put("filePath", filePath);
         return HttpResult.ok(filePathMap);

+ 11 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/HttpDemoController.java

@@ -1,10 +1,12 @@
 package com.sckw.slope.detection.controller;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DictEnum;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.core.web.response.PhpResult;
+import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.slope.detection.model.dto.SystemDict;
 import com.sckw.slope.detection.service.api.DetectionApiService;
 import jakarta.servlet.http.HttpServletResponse;
@@ -26,6 +28,8 @@ import java.util.List;
 @RestController
 @RequestMapping("/http")
 public class HttpDemoController {
+//    @Autowired
+//    RedisLockUtil redisLockUtil;
 
     @Autowired
     DetectionApiService detectionApiService;
@@ -37,6 +41,13 @@ public class HttpDemoController {
         System.out.println(saasGetDemo);
     }
 
+    @RequestMapping(value = "/getRedis", method = RequestMethod.GET)
+    public void getRedis(HttpServletResponse response) {
+        String key = Global.REDIS_SYS_DICT_PREFIX + "type" + Global.POUND + "value";
+        String dictCache = RedissonUtils.getString(key);
+        RedissonUtils.putString(key, "1", Global.COMMON_EXPIRE);
+    }
+
 
     @RequestMapping(value = "/toSaasPostDemo", method = RequestMethod.GET)
     public void httpToSaasPostDemo() {

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceMapper.java

@@ -6,6 +6,7 @@ import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
 import com.sckw.slope.detection.model.dto.DeviceDataDTO;
 import com.sckw.slope.detection.model.dto.ThresholdSelectDTO;
 import com.sckw.slope.detection.model.vo.AffiliationDeviceVO;
+import com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import com.sckw.slope.detection.model.vo.DeviceVo;
@@ -52,4 +53,6 @@ public interface KwsDeviceMapper extends BaseMapper<KwsDevice> {
     int selectDeviceOnlineRateCountByProject(@Param("projectId") String projectId);
 
     List<Map<String, String>> selectListByModelType(@Param("modelType") String modelType);
+
+    KwsAlarmExportVO getDataByDeviceIdAndProjectId(@Param("deviceId") Long deviceId, @Param("projectId") String projectId);
 }

+ 60 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmLogThresholdExport.java

@@ -0,0 +1,60 @@
+package com.sckw.slope.detection.model.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-27 09:11:59
+ */
+@Data
+public class AlarmLogThresholdExport implements Serializable{
+
+        /**
+         * 导出需要的id/all全导出
+         */
+        private String ids;
+
+        /**
+         * 项目id
+         */
+        private String projectId;
+
+        /**
+         * 项目名称
+         */
+        private String projectName;
+
+//        @NotNull(message = "当前页不能为空")
+        private int page;
+
+//        @NotNull(message = "每页条数不能为空")
+        private int pageSize;
+
+        /**
+         * 告警级别
+         */
+        private int alarmLevel;
+
+        /**
+         * 告警明细
+         */
+        private String alarmInfo;
+
+        /**
+         * 设备id
+         */
+        private String deviceId;
+
+        /**
+         * 设备名称
+         */
+        private String deviceName;
+
+        /**
+         * 状态(告警类型(1:当前,2历史))
+         */
+        private int status;
+    }

+ 6 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmLogThresholdQuery.java

@@ -13,6 +13,11 @@ import java.io.Serializable;
 @Data
 public class AlarmLogThresholdQuery implements Serializable {
 
+    /**
+     * 导出需要的id
+     */
+    private String ids;
+
     /**
      * 项目id
      */
@@ -50,7 +55,7 @@ public class AlarmLogThresholdQuery implements Serializable {
     private String deviceName;
 
     /**
-     * 状态(告警类型(1:当前,2历史))
+     * 状态(告警类型(0:当前,1历史))
      */
     private int status;
 }

+ 22 - 14
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/excel/KwsAlarmExportVO.java

@@ -1,5 +1,6 @@
 package com.sckw.slope.detection.model.vo.excel;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.sckw.excel.annotation.ExcelContext;
@@ -19,16 +20,17 @@ public class KwsAlarmExportVO implements Serializable {
     /**
      * 触发的id(阈值id或者设备id)
      */
-    @ExcelProperty("id")
+    @ExcelIgnore
     private Long id;
 
     /**
      * 企业id
      */
+    @ExcelIgnore
     private String companyId;
-
+    @ExcelIgnore
     private String mountainId;
-
+    @ExcelIgnore
     private String projectId;
 //    /**
 //     * 告警标题
@@ -38,82 +40,88 @@ public class KwsAlarmExportVO implements Serializable {
     /**
      * 告警触发数值
      */
-    @ExcelProperty("告警触发数值")
+//    @ExcelProperty("告警触发数值")
+    @ExcelIgnore
     private String val;
 
     /**
      * 告警内容
      */
-    @ExcelProperty("告警内容")
+//    @ExcelProperty("告警内容")
+    @ExcelIgnore
     private String content;
 
     /**
      * 告警等级
      */
-    @ExcelProperty("告警等级")
+    @ExcelProperty(value = "告警等级", index = 3)
     private String level;
 
     /**
      * 1数据告警  2设备告警
      */
-    @ExcelProperty("告警类型")
+    @ExcelProperty(value = "告警类型", index = 4)
     private String type;
 
     /**
      * 纬度
      */
+    @ExcelIgnore
     private String lat;
 
     /**
      * 经度
      */
+    @ExcelIgnore
     private String lng;
 
     /**
      * 海拔
      */
+    @ExcelIgnore
     private String alt;
 
     /**
      * 触发次数
      */
-    @ExcelProperty("触发次数")
-    private Integer triggerTimes;
+    @ExcelProperty(value = "触发次数", index = 6)
+    private String triggerTimes;
 
     /**
      * 状态
      */
+    @ExcelIgnore
     private int status;
 
     /**
      * 设备名称
      */
-    @ExcelProperty("设备名称")
+    @ExcelProperty(value = "设备名称", index = 1)
     private String deviceName;
 
     /**
      * 项目名称
      */
-    @ExcelProperty("项目名称")
+    @ExcelProperty(value = "所属检测项目", index = 2)
     private String projectName;
 
     /**
      * 告警类型
      */
-    @ExcelProperty("告警类型")
+    @ExcelProperty(value = "类型明细", index = 5)
     private String alarmLevel;
 
     /**
      * 开始时间
      */
-    @ExcelProperty("开始时间")
+    @ExcelProperty(value = "首次时间", index = 7)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime startTime;
 
     /**
      * 结束时间
      */
-    @ExcelProperty("结束时间")
+    @ExcelProperty(value = "末次时间", index = 8)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime endTime;
 

+ 54 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/excel/ThresholdRecordDetailExportVO.java

@@ -0,0 +1,54 @@
+package com.sckw.slope.detection.model.vo.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author lfdc
+ * @description 告警记录明细数据
+ * @date 2023-11-14 14:11:06
+ */
+@Data
+public class ThresholdRecordDetailExportVO implements Serializable {
+    /**
+     * ID
+     */
+    private Long id;
+    /**
+     * 告警类型
+     */
+    @ExcelProperty("告警类型")
+    private String alarmLevel;
+    /**
+     * 监测类型
+     */
+    private String type;
+    /**
+     * 当前测量值
+     */
+    @ExcelProperty("当前测量值")
+    private String value;
+    @ExcelProperty("监测要素")
+    private String itemName;
+    /**
+     * 通知短信
+     */
+    @ExcelProperty("通知短信")
+    private String phone;
+    /**
+     * 告警地点
+     */
+    @ExcelProperty("告警地点")
+    private String location;
+    /**
+     * 告警产生时间
+     */
+    @ExcelProperty("产生时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+}

+ 154 - 30
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -1,23 +1,29 @@
 package com.sckw.slope.detection.service;
 
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.excel.util.DateUtils;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.enums.AlarmTitleEnum;
+import com.sckw.core.model.enums.AlarmTypeEnum;
 import com.sckw.core.model.enums.DictEnum;
 import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.model.vo.BaseList;
 import com.sckw.core.model.vo.PublicBaseList;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.redis.utils.RedissonUtils;
 import com.sckw.slope.detection.dao.mysql.*;
 import com.sckw.slope.detection.dao.tdengine.DevicesMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
 import com.sckw.slope.detection.model.dto.HeaderData;
 import com.sckw.slope.detection.model.dto.SystemDict;
+import com.sckw.slope.detection.model.param.AlarmLogThresholdExport;
 import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
 import com.sckw.slope.detection.model.param.AlarmStatisticsQuery;
 import com.sckw.slope.detection.model.vo.AlarmLogThresholdVO;
@@ -25,6 +31,7 @@ import com.sckw.slope.detection.model.vo.KwsAlarmVO;
 import com.sckw.slope.detection.model.vo.ThresholdLogDetailVO;
 import com.sckw.slope.detection.model.vo.ThresholdRecordDetailVO;
 import com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO;
+import com.sckw.slope.detection.model.vo.excel.ThresholdRecordDetailExportVO;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
@@ -38,8 +45,10 @@ import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author lfdc
@@ -123,6 +132,7 @@ public class KwsAlarmService {
         if (StringUtils.isNotBlank(query.getProjectId())) {
             wrapper.eq(KwsAlarm::getProjectId, Long.parseLong(query.getProjectId()));
         }
+        wrapper.orderByDesc(KwsAlarm::getCreateTime);
         List<KwsAlarm> list = alarmMapper.selectList(wrapper);
         List<KwsAlarmVO> alarmVOS = new ArrayList<>();
         PageInfo<KwsAlarm> info = new PageInfo<KwsAlarm>(list);
@@ -169,18 +179,31 @@ public class KwsAlarmService {
                     .set(KwsAlarm::getStatus, 1)
                     .eq(KwsAlarm::getId, id)
             );
+            alarmDetailMapper.update(null, new LambdaUpdateWrapper<KwsAlarmDetail>()
+                    .set(KwsAlarmDetail::getStatus, 1)
+                    .eq(KwsAlarmDetail::getAlarmId, id)
+            );
         });
         return HttpResult.ok("消息已读");
     }
 
-    public List<KwsAlarmExportVO> export(AlarmLogThresholdQuery query, HttpServletRequest request, HttpServletResponse response) {
+    public List<KwsAlarmExportVO> export(AlarmLogThresholdExport query, HttpServletRequest request, HttpServletResponse response) {
+        List<Long> idsList = null;
+        String ids = query.getIds();
+        if (StringUtils.isNotBlank(ids) && (!"all".equals(ids))) {
+            idsList = com.sckw.core.utils.StringUtils.splitStrToList(ids, Long.class);
+        }
         HeaderData headerData = commonService.getHeaderData(request);
         LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(StringUtils.isNotBlank(headerData.getMountainId()), KwsAlarm::getMountainId, headerData.getMountainId())
-                .eq(KwsAlarm::getStatus, query.getStatus());
+                .eq(KwsAlarm::getStatus, query.getStatus()).orderByDesc(KwsAlarm::getCreateTime)
+        ;
         if (StringUtils.isNotBlank(query.getProjectId())) {
             wrapper.eq(KwsAlarm::getProjectId, Long.parseLong(query.getProjectId()));
         }
+        if (!CollectionUtils.isEmpty(idsList) && idsList.size() > 0) {
+            wrapper.in(KwsAlarm::getId, idsList);
+        }
         List<KwsAlarm> list = alarmMapper.selectList(wrapper);
         List<KwsAlarmExportVO> alarmVOS = new ArrayList<>();
         if (CollectionUtils.isEmpty(list)) {
@@ -189,30 +212,80 @@ public class KwsAlarmService {
         Map<String, SystemDict> thresholdLevel = commonService.getDictByDictCode(DictEnum.THRESHOLD_LEVEL);
         Map<String, SystemDict> alarmType = commonService.getDictByDictCode(DictEnum.ALARM_TYPE);
         Map<String, SystemDict> alarmDetailType = commonService.getDictByDictCode(DictEnum.ALARM_DETAIL_TYPE);
+        String now = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+        System.out.println("数据翻译开始时间" + now);
+        int i = 1;
+        List<KwsProject> projectList = projectMapper.selectList(null);
+        Map<Long, String> projectMap = projectList.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
+        List<KwsDevice> deviceList = deviceMapper.selectList(null);
+        Map<Long, String> deviceMap = deviceList.stream().collect(Collectors.toMap(KwsDevice::getId, KwsDevice::getName));
         for (KwsAlarm kwsAlarm : list) {
-            KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
-                    .eq(StringUtils.isNotBlank(headerData.getMountainId()), KwsDevice::getMountainId, headerData.getMountainId())
-                    .eq(KwsDevice::getId, kwsAlarm.getDeviceId()));
-            KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
-                    .eq(KwsProject::getId, Long.parseLong(kwsAlarm.getProjectId()))
-                    .eq(StringUtils.isNotBlank(headerData.getMountainId()), KwsProject::getMountainId, headerData.getMountainId())
-            );
+            i++;
+            System.out.println("数据翻译开始时间" + i + "次数" + now);
             KwsAlarmExportVO vo = new KwsAlarmExportVO();
             BeanUtils.copyProperties(kwsAlarm, vo);
-            vo.setLevel(kwsAlarm.getLevel() == null ? null :
-                    (thresholdLevel == null ? String.valueOf(kwsAlarm.getLevel()) : thresholdLevel.get(String.valueOf(kwsAlarm.getLevel())).getLabel()));
-            vo.setType(kwsAlarm.getType() == null ? null :
-                    (alarmType == null ? String.valueOf(kwsAlarm.getType()) : alarmType.get(String.valueOf(kwsAlarm.getType())).getLabel()));
-            vo.setDeviceName(kwsDevice == null ? kwsAlarm.getDeviceId().toString() : kwsDevice.getName());
-            vo.setProjectName(project == null ? kwsAlarm.getProjectId() : project.getName());
-            vo.setAlarmLevel(kwsAlarm.getTitle() == null ? null :
-                    (alarmDetailType == null ? kwsAlarm.getTitle() : alarmDetailType.get(kwsAlarm.getTitle()).getLabel()));
+
+            String levelTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译等级开始时间" + i + "次数" + levelTime);
+            vo.setLevel(kwsAlarm.getLevel() == null ? null : (thresholdLevel.get(String.valueOf(kwsAlarm.getLevel())).getLabel()));
+            String levelEndTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译等级结束时间" + i + "次数" + levelEndTime);
+
+            String typeTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译类型开始时间" + i + "次数" + typeTime);
+            vo.setType(kwsAlarm.getType() == null ? null : (alarmType.get(String.valueOf(kwsAlarm.getType())).getLabel()));
+            String typeEndTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译类型结束时间" + i + "次数" + typeEndTime);
+
+
+            String deviceTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译设备名称开始时间" + i + "次数" + deviceTime);
+            vo.setDeviceName(deviceMap == null ? kwsAlarm.getDeviceId().toString() : deviceMap.get(kwsAlarm.getDeviceId()));
+            String deviceEndTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译设备名称结束时间" + i + "次数" + deviceEndTime);
+
+            String projectTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译项目名称开始时间" + i + "次数" + projectTime);
+            vo.setProjectName(projectMap == null ? kwsAlarm.getProjectId() : projectMap.get(Long.parseLong(kwsAlarm.getProjectId())));
+            String projectEndTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译项目名称结束时间" + i + "次数" + projectEndTime);
+
+            String alarmTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译告警等级开始时间" + i + "次数" + alarmTime);
+            vo.setAlarmLevel(kwsAlarm.getTitle() == null ? null : (alarmDetailType.get(kwsAlarm.getTitle()).getLabel()));
+            String alarmEndTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译告警等级结束时间" + i + "次数" + alarmEndTime);
+
             vo.setStartTime(kwsAlarm.getCreateTime());
             vo.setEndTime(kwsAlarm.getUpdateTime());
-            Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, kwsAlarm.getId()));
-            vo.setTriggerTimes(count.intValue());
+
+            String countTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译统计开始时间" + i + "次数" + countTime);
+//            Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, kwsAlarm.getId()));
+            /**结合到mqtt阈值触发数据存储*/
+            String count = null;
+            Long id = kwsAlarm.getId();
+            if (AlarmTypeEnum.ALARM_ONE.getStatus().equals(String.valueOf(kwsAlarm.getType()))) {
+                /**阈值次数存redis*/
+                String key = Global.REDIS_SYS_ALARM_PREFIX + Global.POUND + String.valueOf(id) + Global.POUND + AlarmTypeEnum.ALARM_ONE.getStatus()
+                        + Global.POUND + AlarmTitleEnum.ALARM_TITLE_TWO.getStatus();
+                count = RedissonUtils.getString(key);
+            } else {
+                /**阈值次数存redis*/
+                String key = Global.REDIS_SYS_ALARM_PREFIX + Global.POUND + String.valueOf(id) + Global.POUND + AlarmTypeEnum.ALARM_TWO.getStatus()
+                        + Global.POUND + AlarmTitleEnum.ALARM_TITLE_ONE.getStatus();
+                count = RedissonUtils.getString(key);
+            }
+            vo.setTriggerTimes(count);
+            String countEndTime = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译统计结束时间" + i + "次数" + countEndTime);
+
             alarmVOS.add(vo);
+            String format = DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS");
+            System.out.println("数据翻译结束时间" + i + "次数" + format);
         }
+        System.out.println("数据翻译开始时间" + now);
+        System.out.println("数据翻译结束时间" + DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
         return alarmVOS;
     }
 
@@ -224,7 +297,9 @@ public class KwsAlarmService {
         KwsAlarm kwsAlarm = alarmMapper.selectById(id);
         PageHelper.startPage(baseList.getPage(), baseList.getPageSize());
         List<KwsAlarmDetail> detailList = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
-                .eq(KwsAlarmDetail::getAlarmId, Long.parseLong(id)));
+                .eq(KwsAlarmDetail::getAlarmId, Long.parseLong(id))
+                .eq(KwsAlarmDetail::getStatus, 0)
+        );
         PageInfo<ThresholdRecordDetailVO> info = new PageInfo(detailList);
         if (CollectionUtils.isEmpty(detailList)) {
             return PageRes.build(info, detailList);
@@ -234,7 +309,32 @@ public class KwsAlarmService {
 //        Map<String, SystemDict> alarmType = commonService.getDictByDictCode(DictEnum.ALARM_TYPE);
         Map<String, SystemDict> thresholdLevel = commonService.getDictByDictCode(DictEnum.THRESHOLD_LEVEL);
         if ("1".equals(kwsAlarm.getType())) {
-
+            for (KwsAlarmDetail detail : detailList) {
+                Long pid = detail.getPid();
+                KwsDevice kwsDevice = deviceMapper.selectById(pid);
+                ThresholdRecordDetailVO vo = new ThresholdRecordDetailVO();
+                vo.setId(detail.getId());
+                vo.setAlarmLevel(kwsAlarm.getLevel() == null ? null :
+                        (thresholdLevel == null ? String.valueOf(kwsAlarm.getLevel()) : thresholdLevel.get(String.valueOf(kwsAlarm.getLevel())).getLabel()));
+//                vo.setType(kwsThreshold.getItemName() == null ? null :
+//                        (dictByDictCode == null ? kwsThreshold.getItemName() : dictByDictCode.get(kwsThreshold.getItemName()).getLabel()));
+//                vo.setValue(detail.getVal());
+//                vo.setItemName(kwsThreshold.getItemName());
+                vo.setPhone("");
+                StringBuilder location = new StringBuilder();
+                if (StringUtils.isNotBlank(kwsDevice.getLogicLng())) {
+                    location.append(kwsDevice.getLogicLng()).append(";");
+                }
+                if (StringUtils.isNotBlank(kwsDevice.getLogicLat())) {
+                    location.append(kwsDevice.getLogicLat()).append(";");
+                }
+                if (StringUtils.isNotBlank(kwsDevice.getLogicAlt())) {
+                    location.append(kwsDevice.getLogicAlt()).append(";");
+                }
+                vo.setLocation(location.toString());
+                vo.setCreateTime(detail.getCreateTime());
+                list.add(vo);
+            }
         } else {
             for (KwsAlarmDetail detail : detailList) {
                 Long pid = detail.getPid();
@@ -249,7 +349,18 @@ public class KwsAlarmService {
                 vo.setItemName(kwsThreshold.getItemName());
                 vo.setPhone(kwsThreshold.getPhones());
                 KwsDevice kwsDevice = deviceMapper.selectById(kwsThreshold.getDeviceId());
-                vo.setLocation(kwsDevice == null ? null : kwsDevice.getLogicAlt() + ";" + kwsDevice.getLogicLat() + ";" + kwsDevice.getLogicLng());
+                StringBuilder location = new StringBuilder();
+                if (StringUtils.isNotBlank(kwsDevice.getLogicLng())) {
+                    location.append(kwsDevice.getLogicLng()).append(";");
+                }
+                if (StringUtils.isNotBlank(kwsDevice.getLogicLat())) {
+                    location.append(kwsDevice.getLogicLat()).append(";");
+                }
+                if (StringUtils.isNotBlank(kwsDevice.getLogicAlt())) {
+                    location.append(kwsDevice.getLogicAlt()).append(";");
+                }
+//                vo.setLocation(kwsDevice == null ? null : kwsDevice.getLogicAlt() + ";" + kwsDevice.getLogicLat() + ";" + kwsDevice.getLogicLng());
+                vo.setLocation(location.toString());
                 vo.setCreateTime(detail.getCreateTime());
                 list.add(vo);
             }
@@ -316,8 +427,8 @@ public class KwsAlarmService {
                         vo.setOriginalOffset(computeOriginalOffset);
                     }
                 } else {
-                    vo.setCurrentValue(deviceReference.getCurrentValue());
-                    vo.setOriginalValue(deviceReference.getOriginalValue());
+                    vo.setCurrentValue(deviceReference == null ? null : deviceReference.getCurrentValue());
+                    vo.setOriginalValue(deviceReference == null ? null : deviceReference.getOriginalValue());
                 }
 
             }
@@ -550,12 +661,25 @@ public class KwsAlarmService {
         return HttpResult.ok(returnList);
     }
 
-    public List<ThresholdRecordDetailVO> exportDetail(PublicBaseList baseList, HttpServletRequest request) {
-        String id = baseList.getId();
-        KwsAlarm kwsAlarm = alarmMapper.selectById(id);
+    public List<ThresholdRecordDetailExportVO> exportDetail(BaseList baseList, HttpServletRequest request) {
+        List<ThresholdRecordDetailExportVO> list = new ArrayList<>();
+        String parentId = baseList.getParentId();
+        if (StringUtils.isBlank(parentId)) {
+            return list;
+        }
+        String ids = baseList.getIds();
+        List<Long> idsList = new ArrayList<>();
+        if (StringUtils.isNotBlank(ids) && (!"all".equals(ids))) {
+            idsList = com.sckw.core.utils.StringUtils.splitStrToList(ids, Long.class);
+        }
         List<KwsAlarmDetail> detailList = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
-                .eq(KwsAlarmDetail::getAlarmId, Long.parseLong(id)));
-        List<ThresholdRecordDetailVO> list = new ArrayList<>();
+                .eq(KwsAlarmDetail::getAlarmId, Long.parseLong(parentId))
+                .in(!CollectionUtils.isEmpty(idsList), KwsAlarmDetail::getId, idsList)
+        );
+        if (CollectionUtils.isEmpty(detailList)) {
+            return list;
+        }
+        KwsAlarm kwsAlarm = alarmMapper.selectById(detailList.get(0).getAlarmId());
         Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
         Map<String, SystemDict> alarmType = commonService.getDictByDictCode(DictEnum.ALARM_TYPE);
         if ("1".equals(kwsAlarm.getType())) {
@@ -564,7 +688,7 @@ public class KwsAlarmService {
             for (KwsAlarmDetail detail : detailList) {
                 Long pid = detail.getPid();
                 KwsThreshold kwsThreshold = thresholdMapper.selectById(pid);
-                ThresholdRecordDetailVO vo = new ThresholdRecordDetailVO();
+                ThresholdRecordDetailExportVO vo = new ThresholdRecordDetailExportVO();
                 vo.setId(detail.getId());
                 vo.setAlarmLevel(kwsAlarm.getType() == null ? null :
                         (alarmType == null ? String.valueOf(kwsAlarm.getType()) : alarmType.get(String.valueOf(kwsAlarm.getType())).getLabel()));

+ 11 - 5
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -630,7 +630,8 @@ public class ProjectService {
                                     long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
                                     long val = Long.parseLong(val1) - Long.parseLong(val2);
                                     decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
-                                    map.put(key, decimal);
+                                    map.put("dateTime", key);
+                                    map.put("dateValue", decimal);
                                     mapList.add(map);
                                 }
                             }
@@ -769,7 +770,8 @@ public class ProjectService {
                                         }
                                     }
                                 }
-                                datemap.put(key, offsetValue);
+                                datemap.put("dateTime", key);
+                                datemap.put("dataValue", offsetValue);
                                 mapList.add(datemap);
                             }
                         }
@@ -909,7 +911,8 @@ public class ProjectService {
 //                                        long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
 //                                        long val = Long.parseLong(val1) - Long.parseLong(val2);
 //                                        decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
-                                        map.put(key, decimal);
+                                        map.put("dataTime", key);
+                                        map.put("dataValue", decimal);
                                         mapList.add(map);
                                     } else {
                                         SlopeData lastSlopeData = selected.get(i + 1);
@@ -930,7 +933,9 @@ public class ProjectService {
                                         long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
                                         long val = Long.parseLong(val1) - Long.parseLong(val2);
                                         decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
-                                        map.put(key, decimal);
+//                                        map.put(key, decimal);
+                                        map.put("dataTime", key);
+                                        map.put("dataValue", decimal);
                                         mapList.add(map);
                                     }
                                 }
@@ -1079,7 +1084,8 @@ public class ProjectService {
                                     }
                                 }
                             }
-                            datemap.put(key, offsetValue);
+                            datemap.put("dateTime", key);
+                            datemap.put("dataValue", offsetValue);
                             mapList.add(datemap);
                         }
                     }

+ 4 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml

@@ -381,4 +381,8 @@
           and c.device_type = #{modelType}
       </if>
   </select>
+
+  <select id="getDataByDeviceIdAndProjectId" resultType="com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO">
+
+    </select>
 </mapper>