Quellcode durchsuchen

1.数据详情
2.项目日志接口编写
3.数据总览接口编写
4.项目报表接口编写
5.告警通知查询接口编写

lengfaqiang vor 2 Jahren
Ursprung
Commit
f146edcfdf
31 geänderte Dateien mit 840 neuen und 246 gelöschten Zeilen
  1. 38 24
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/MessageLogEnum.java
  2. 26 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/AlarmController.java
  3. 8 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/LogController.java
  4. 18 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ProjectController.java
  5. 11 3
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportController.java
  6. 18 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportTemplateController.java
  7. 2 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceMapper.java
  8. 7 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsReportDataMapper.java
  9. 2 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java
  10. 14 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsAlarm.java
  11. 18 170
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsReportData.java
  12. 1 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/tdengine/SlopeData.java
  13. 31 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmLogThresholdQuery.java
  14. 4 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/StatementQuery.java
  15. 50 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/AlarmLogThresholdVO.java
  16. 42 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/DataScreeningVO.java
  17. 95 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/KwsAlarmVO.java
  18. 9 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ReportStatementVO.java
  19. 6 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/SlopeDataVo.java
  20. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/CommonService.java
  21. 107 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java
  22. 21 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/LogService.java
  23. 53 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java
  24. 39 27
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportService.java
  25. 57 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java
  26. 60 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/Task/ReportTemplateTaskService.java
  27. 24 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  28. 4 1
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsAlarmMapper.xml
  29. 16 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml
  30. 33 1
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportDataMapper.xml
  31. 25 1
      slope-modules/slope-detection/src/main/resources/mapper/tdengine/SlopeDataMapper.xml

+ 38 - 24
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/MessageLogEnum.java

@@ -20,75 +20,75 @@ public enum MessageLogEnum {
     /**
      * 新增边坡项目
      */
-    ADD_PROJECT("slope_manage", "PROJECT_LOG", "新增边坡项目",
-            "边坡【${projectName}】已新增,所属矿山:${mountainName}",  "新增边坡项目"),
+    ADD_PROJECT("slope_manage", "PROJECT_LOG", "新增边坡项目", "1",
+            "边坡【${projectName}】已新增,所属矿山:${mountainName}", "新增边坡项目"),
     /**
      * 修改边坡项目
      */
-    UPDATE_PROJECT("slope_manage", "PROJECT_LOG", "修改边坡项目",
+    UPDATE_PROJECT("slope_manage", "PROJECT_LOG", "修改边坡项目", "2",
             "边坡【${projectName}】已修改,所属矿山:${mountainName}", "修改边坡项目"),
     /**
      * 删除边坡项目
      */
-    DELETE_PROJECT("slope_manage", "PROJECT_LOG", "删除边坡项目",
+    DELETE_PROJECT("slope_manage", "PROJECT_LOG", "删除边坡项目", "3",
             "边坡【${projectName}】已删除,所属矿山:${mountainName}", "删除边坡项目"),
 
     /**
      * 新增组网设备
      */
-    ADD_NETWORKING_DEVICE("slope_manage", "PROJECT_LOG", "新增组网设备",
-            "设备【${deviceName}】已关联组网,所属边坡【${projectName}】",  "新增组网设备"),
+    ADD_NETWORKING_DEVICE("slope_manage", "PROJECT_LOG", "新增组网设备", "4",
+            "设备【${deviceName}】已关联组网,所属边坡【${projectName}】", "新增组网设备"),
     /**
      * 删除组网设备
      */
-    DELETE_NETWORKING_DEVICE("slope_manage", "PROJECT_LOG", "删除组网设备",
-            "设备【${deviceName}】已取消组网,所属边坡【${projectName}】",  "删除组网设备"),
+    DELETE_NETWORKING_DEVICE("slope_manage", "PROJECT_LOG", "删除组网设备", "5",
+            "设备【${deviceName}】已取消组网,所属边坡【${projectName}】", "删除组网设备"),
     /**
      * 调整设备布设
      */
-    UPDATE_DEVICE_LAY("slope_manage", "PROJECT_LOG", "调整设备布设",
-            "设备【${deviceName}】已调整项目位置,所属边坡【${projectName}】",  "调整设备布设"),
+    UPDATE_DEVICE_LAY("slope_manage", "PROJECT_LOG", "调整设备布设", "6",
+            "设备【${deviceName}】已调整项目位置,所属边坡【${projectName}】", "调整设备布设"),
     /**
      * 新增报表模版
      */
-    ADD_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "新增报表模版",
-            "报表模版【${templateName}】已新增,所属边坡【${projectName}】",  "新增报表模版"),
+    ADD_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "新增报表模版", "7",
+            "报表模版【${templateName}】已新增,所属边坡【${projectName}】", "新增报表模版"),
 
     /**
      * 修改报表模版
      */
-    UPDATE_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "修改报表模版",
-                                "报表模版【${templateName}】已修改,所属边坡【${projectName}】",  "修改报表模版"),
+    UPDATE_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "修改报表模版", "8",
+            "报表模版【${templateName}】已修改,所属边坡【${projectName}】", "修改报表模版"),
 
     /**
      * 删除报表模版
      */
-    DELETE_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "删除报表模版",
-                                "报表模版【${templateName}】已删除,所属边坡【${projectName}】",  "删除报表模版"),
+    DELETE_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "删除报表模版", "9",
+            "报表模版【${templateName}】已删除,所属边坡【${projectName}】", "删除报表模版"),
 
     /**
      * 禁用报表模版
      */
-    FORBIDDEN_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "禁用报表模版",
-            "报表模版【${templateName}】已禁用,所属边坡【${projectName}】",  "禁用报表模版"),
+    FORBIDDEN_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "禁用报表模版", "10",
+            "报表模版【${templateName}】已禁用,所属边坡【${projectName}】", "禁用报表模版"),
 
     /**
      * 启用报表模版
      */
-    ENABLE_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "启用报表模版",
-            "报表模版【${templateName}】已启用,所属边坡【${projectName}】",  "启用报表模版"),
+    ENABLE_REPORT_TEMPLATE("slope_manage", "PROJECT_LOG", "启用报表模版", "11",
+            "报表模版【${templateName}】已启用,所属边坡【${projectName}】", "启用报表模版"),
 
     /**
      * 设置设备阈值
      */
-    SETTINGS_DEVICE_THRESHOLD("slope_manage", "PROJECT_LOG", "设置设备阈值",
-            "设备【${deviceName}】已设置了【${element}】监测要素阈值,所属边坡【${projectName}】",  "设置设备阈值"),
+    SETTINGS_DEVICE_THRESHOLD("slope_manage", "PROJECT_LOG", "设置设备阈值", "12",
+            "设备【${deviceName}】已设置了【${element}】监测要素阈值,所属边坡【${projectName}】", "设置设备阈值"),
 
     /**
      * 删除设备阈值
      */
-    DELETE_DEVICE_THRESHOLD("slope_manage", "PROJECT_LOG", "删除设备阈值",
-            "设备【${deviceName}】已删除了【${element}】监测要素阈值,所属边坡【${projectName}】",  "删除设备阈值"),
+    DELETE_DEVICE_THRESHOLD("slope_manage", "PROJECT_LOG", "删除设备阈值", "13",
+            "设备【${deviceName}】已删除了【${element}】监测要素阈值,所属边坡【${projectName}】", "删除设备阈值"),
 
     ;
 
@@ -108,6 +108,11 @@ public enum MessageLogEnum {
      */
     private final String title;
 
+    /**
+     * code值
+     */
+    private final String code;
+
     /**
      * 消息内容
      */
@@ -172,4 +177,13 @@ public enum MessageLogEnum {
         }
         return null;
     }
+
+    public static String getEnumTitleByCode(String code) {
+        for (MessageLogEnum e : MessageLogEnum.values()) {
+            if (e.getCode().equals(code)) {
+                return e.title;
+            }
+        }
+        return null;
+    }
 }

+ 26 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/AlarmController.java

@@ -1,7 +1,17 @@
 package com.sckw.slope.detection.controller;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.sckw.core.annotation.Log;
+import com.sckw.core.web.response.HttpResult;
+import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
+import com.sckw.slope.detection.service.KwsAlarmService;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -14,4 +24,20 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/alarm")
 public class AlarmController {
 
+    @Autowired
+    KwsAlarmService kwsAlarmService;
+
+    @Log(description = "告警日志-系统日志")
+    @RequestMapping(name = "告警日志-系统日志", value = "/logSelectAll", method = RequestMethod.POST)
+    public HttpResult logSelectAll(@Valid @RequestBody AlarmLogThresholdQuery query) {
+        log.info("告警日志-系统日志 logSelectAll param {}", JSONObject.toJSONString(query));
+       return HttpResult.ok(kwsAlarmService.logSelectAll(query));
+    }
+
+    @Log(description = "告警查询-分页")
+    @RequestMapping(name = "告警查询-分页", value = "/select", method = RequestMethod.POST)
+    public HttpResult select(@Valid @RequestBody AlarmLogThresholdQuery query, HttpServletRequest request) {
+        log.info("告警查询-分页 select param {}", JSONObject.toJSONString(query));
+        return HttpResult.ok(kwsAlarmService.select(query,request));
+    }
 }

+ 8 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/LogController.java

@@ -9,10 +9,7 @@ import jakarta.servlet.http.HttpServletRequest;
 import jakarta.validation.Valid;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @author lfdc
@@ -44,4 +41,11 @@ public class LogController {
     public HttpResult selectType( HttpServletRequest request) {
         return logService.selectType(request);
     }
+
+
+    @Log(description = "日志查询-元数据日志")
+    @RequestMapping(name = "日志查询-元数据日志", value = "/selectMetadata", method = RequestMethod.GET)
+    public HttpResult selectMetadata(@RequestParam(("page")) Integer page , @RequestParam("pageSize") Integer pageSize, HttpServletRequest request) {
+        return logService.selectMetadata(page,pageSize,request);
+    }
 }

+ 18 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ProjectController.java

@@ -82,9 +82,9 @@ public class ProjectController {
     @Log(description = "设备组网查询")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备组网查询", value = "/selectDevice", method = RequestMethod.POST)
-    public HttpResult selectDevice(@RequestBody @Valid  DeviceQuery deviceQuery,HttpServletRequest request) {
+    public HttpResult selectDevice(@RequestBody @Valid DeviceQuery deviceQuery, HttpServletRequest request) {
         log.info("设备组网查询 select param:{}", JSONObject.toJSONString(deviceQuery));
-        return HttpResult.ok(projectService.selectDevice(deviceQuery,request));
+        return HttpResult.ok(projectService.selectDevice(deviceQuery, request));
     }
 
     @Log(description = "新增组网设备-关联设备-查询")
@@ -122,8 +122,22 @@ public class ProjectController {
     @Log(description = "项目详情-图表查询")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "项目详情-图表查询", value = "/chartLog", method = RequestMethod.POST)
-    public HttpResult chartLog(@Valid @RequestBody ProjectChartLogParam param, HttpServletRequest response) {
+    public HttpResult chartLog(@Valid @RequestBody ProjectChartLogParam param, HttpServletRequest request) {
         log.info("项目详情-图表查询 chartLog param:{}", JSONObject.toJSONString(param));
-        return projectService.chartLog(param, response);
+        return projectService.chartLog(param, request);
+    }
+
+    @Log(description = "查询所有项目")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "查询所有项目", value = "/selectAll", method = RequestMethod.GET)
+    public HttpResult selectAll(HttpServletRequest request) {
+        return projectService.selectAll();
+    }
+
+    @Log(description = "数据总览")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "数据总览", value = "/dataScreening", method = RequestMethod.GET)
+    public HttpResult dataScreening(@RequestParam("projectId") String projectId ,HttpServletRequest request) {
+        return projectService.dataScreening(projectId);
     }
 }

+ 11 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportController.java

@@ -44,8 +44,16 @@ public class ReportController {
     @Log(description = "报表删除")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "报表删除", value = "/dels", method = RequestMethod.GET)
-    public HttpResult dels(@RequestParam("id") @NotBlank(message = "id不能为空") String id, HttpServletRequest request) {
-        log.info("报表删除 dels param:{}", id);
-        return reportService.dels(id, request);
+    public HttpResult dels(@RequestParam("ids") @NotBlank(message = "id不能为空") String ids, HttpServletRequest request) {
+        log.info("报表删除 dels param:{}", ids);
+        return reportService.dels(ids, request);
+    }
+
+    @Log(description = "报表导出")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "报表导出", value = "/export", method = RequestMethod.GET)
+    public HttpResult export(@RequestParam("ids") @NotBlank(message = "id不能为空") String ids, HttpServletRequest request) {
+        log.info("报表导出 export param:{}", ids);
+        return reportService.export(ids, request);
     }
 }

+ 18 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ReportTemplateController.java

@@ -6,9 +6,11 @@ import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.model.dto.IsEnableDTO;
 import com.sckw.slope.detection.model.dto.ReportTemplateAddDTO;
 import com.sckw.slope.detection.model.dto.ReportTemplateUpdateDTO;
+import com.sckw.slope.detection.model.param.StatementQuery;
 import com.sckw.slope.detection.service.ReportTemplateService;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,14 @@ public class ReportTemplateController {
     @Autowired
     ReportTemplateService reportTemplateService;
 
+    @Log(description = "模板查询")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "模板查询", value = "/select", method = RequestMethod.POST)
+    public HttpResult select(@RequestBody @Valid StatementQuery query, HttpServletRequest request) {
+        log.info("模板查询 select param:{}", JSONObject.toJSONString(query));
+        return HttpResult.ok(reportTemplateService.select(query, request));
+    }
+
     @Log(description = "模版新增")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "模版新增", value = "/add", method = RequestMethod.POST)
@@ -58,4 +68,12 @@ public class ReportTemplateController {
         return reportTemplateService.enable(isEnable, request);
     }
 
+    @Log(description = "模版删除")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "模版删除", value = "/dels", method = RequestMethod.GET)
+    public HttpResult dels(@RequestParam("ids") @NotBlank(message = "id不能为空") String ids, HttpServletRequest request) {
+        log.info("模版删除 dels param:{}", ids);
+        return reportTemplateService.dels(ids, request);
+    }
+
 }

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

@@ -35,4 +35,6 @@ public interface KwsDeviceMapper extends BaseMapper<KwsDevice> {
     List<AffiliationDeviceVO> selectDeviceAllAndProjectData(@Param("projectId") String projectId);
 
     List<ThresholdSelectDTO> selectDeviceAllByProjectAndMountainId(@Param("projectId") String projectId, @Param("mountainId") String mountainId, @Param("status") List<Integer> status);
+
+    int selectCountByProject(@Param("projectId") String projectId);
 }

+ 7 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsReportDataMapper.java

@@ -3,7 +3,12 @@ package com.sckw.slope.detection.dao.mysql;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
+import com.sckw.slope.detection.model.param.StatementQuery;
+import com.sckw.slope.detection.model.vo.ReportStatementVO;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 @DS("mysql")
@@ -19,4 +24,6 @@ public interface KwsReportDataMapper extends BaseMapper<KwsReportData> {
     int updateByPrimaryKeySelective(KwsReportData record);
 
     int updateByPrimaryKey(KwsReportData record);
+
+    List<ReportStatementVO> selectListByReportNameAndProjectId(@Param("query") StatementQuery query, @Param("mountainId") String mountainId);
 }

+ 2 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java

@@ -33,4 +33,6 @@ public interface SlopeDataMapper extends BaseMapper<SlopeData> {
     int insertData(@Param("slopeData") SlopeData slopeData);
 
     List<SlopeData> selectListByLineOrderByCreateTime(@Param("snCode") String snCode, @Param("item") String item);
+
+    List<SlopeDataVo> selectListByMaster(@Param("page") Integer page, @Param("pageSize") Integer pageSize);
 }

+ 14 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsAlarm.java

@@ -1,10 +1,11 @@
 package com.sckw.slope.detection.model.dos.mysql;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDateTime;
 
 /**
  * @author lfdc
@@ -26,6 +27,10 @@ public class KwsAlarm implements Serializable {
      */
     private String companyId;
 
+    private String mountainId;
+
+
+    private String projectId;
     /**
      * 告警标题
      */
@@ -69,7 +74,14 @@ public class KwsAlarm implements Serializable {
     /**
      * 创建时间
      */
-    private Date createTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private LocalDateTime createTime;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private LocalDateTime updateTime;
 
     /**
      * 触发次数

+ 18 - 170
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsReportData.java

@@ -1,10 +1,12 @@
 package com.sckw.slope.detection.model.dos.mysql;
 
+import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
 
 
 /**
@@ -112,183 +114,29 @@ public class KwsReportData implements Serializable {
      */
     private String items;
 
+    /**
+     * 文件大小
+     */
+    private BigDecimal fileSize;
+
+    private String fileUrl;
+
     /**
      * 告警时间
      */
-    private Date alarmTime;
+    private LocalDateTime alarmTime;
 
     /**
      * 创建时间
      */
-    private Date createTime;
-
-    private static final long serialVersionUID = 1L;
-
-    public Long getId() {
-        return id;
-    }
-
-    public void setId(Long id) {
-        this.id = id;
-    }
-
-    public Long getTemplateId() {
-        return templateId;
-    }
-
-    public void setTemplateId(Long templateId) {
-        this.templateId = templateId;
-    }
-
-    public Long getProjectId() {
-        return projectId;
-    }
-
-    public void setProjectId(Long projectId) {
-        this.projectId = projectId;
-    }
-
-    public String getProjectName() {
-        return projectName;
-    }
-
-    public void setProjectName(String projectName) {
-        this.projectName = projectName;
-    }
-
-    public Long getDeviceId() {
-        return deviceId;
-    }
-
-    public void setDeviceId(Long deviceId) {
-        this.deviceId = deviceId;
-    }
-
-    public String getDeviceName() {
-        return deviceName;
-    }
-
-    public void setDeviceName(String deviceName) {
-        this.deviceName = deviceName;
-    }
-
-    public String getSnCode() {
-        return snCode;
-    }
-
-    public void setSnCode(String snCode) {
-        this.snCode = snCode;
-    }
-
-    public String getAlias() {
-        return alias;
-    }
-
-    public void setAlias(String alias) {
-        this.alias = alias;
-    }
-
-    public Long getModelId() {
-        return modelId;
-    }
-
-    public void setModelId(Long modelId) {
-        this.modelId = modelId;
-    }
+    private LocalDateTime createTime;
 
-    public String getModelName() {
-        return modelName;
-    }
-
-    public void setModelName(String modelName) {
-        this.modelName = modelName;
-    }
-
-    public String getDeviceType() {
-        return deviceType;
-    }
-
-    public void setDeviceType(String deviceType) {
-        this.deviceType = deviceType;
-    }
-
-    public String getDeviceLabel() {
-        return deviceLabel;
-    }
-
-    public void setDeviceLabel(String deviceLabel) {
-        this.deviceLabel = deviceLabel;
-    }
-
-    public String getLat() {
-        return lat;
-    }
-
-    public void setLat(String lat) {
-        this.lat = lat;
-    }
-
-    public String getLng() {
-        return lng;
-    }
-
-    public void setLng(String lng) {
-        this.lng = lng;
-    }
-
-    public String getAlt() {
-        return alt;
-    }
-
-    public void setAlt(String alt) {
-        this.alt = alt;
-    }
-
-    public Integer getAlarmType() {
-        return alarmType;
-    }
-
-    public void setAlarmType(Integer alarmType) {
-        this.alarmType = alarmType;
-    }
-
-    public String getAlarmTitle() {
-        return alarmTitle;
-    }
-
-    public void setAlarmTitle(String alarmTitle) {
-        this.alarmTitle = alarmTitle;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public String getItems() {
-        return items;
-    }
-
-    public void setItems(String items) {
-        this.items = items;
-    }
-
-    public Date getAlarmTime() {
-        return alarmTime;
-    }
-
-    public void setAlarmTime(Date alarmTime) {
-        this.alarmTime = alarmTime;
-    }
+    /**
+     * 删除标识
+     */
+    @TableLogic(value = "0")
+    private int delFlag;
 
-    public Date getCreateTime() {
-        return createTime;
-    }
+    private static final long serialVersionUID = 1L;
 
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
-    }
 }

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/tdengine/SlopeData.java

@@ -26,6 +26,7 @@ public class SlopeData implements Serializable {
     private String line;
     private String val;
     private String msgId;
+    private String jsonText;
     private String name;
     private String vin;
     private String serialNumber;

+ 31 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/AlarmLogThresholdQuery.java

@@ -0,0 +1,31 @@
+package com.sckw.slope.detection.model.param;
+
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 告警数据查询
+ * @date 2023-11-01 16:11:48
+ */
+@Data
+public class AlarmLogThresholdQuery implements Serializable {
+
+    /**
+     * 项目id
+     */
+    private String projectId;
+
+    @NotNull(message = "当前页不能为空")
+    private int page;
+
+    @NotNull(message = "每页条数不能为空")
+    private int pageSize;
+
+    /**
+     * 设备id
+     */
+    private String deviceId;
+}

+ 4 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/StatementQuery.java

@@ -39,14 +39,14 @@ public class StatementQuery {
     /**
      * 开始时间
      */
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private String startTime;
 
     /**
      * 结束时间
      */
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
-    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private String endTime;
 }

+ 50 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/AlarmLogThresholdVO.java

@@ -0,0 +1,50 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author lfdc
+ * @description 数据分析-系统日志-告警日志vo
+ * @date 2023-11-10 15:11:34
+ */
+@Data
+public class AlarmLogThresholdVO implements Serializable {
+    private Long id;
+
+    private String mountainId;
+
+    private String projectId;
+    private String projectName;
+
+    /**
+     * 告警标题
+     */
+    private String title;
+
+    /**
+     * 告警触发数值
+     */
+    private String val;
+
+    /**
+     * 告警内容
+     */
+    private String content;
+
+    /**
+     * 告警等级
+     */
+    private Integer level;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    private static final long serialVersionUID = 1L;
+}

+ 42 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/DataScreeningVO.java

@@ -0,0 +1,42 @@
+package com.sckw.slope.detection.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 数据总览
+ * @date 2023-11-10 14:11:38
+ */
+@Data
+public class DataScreeningVO implements Serializable {
+    /**
+     * 监测项目总数
+     */
+    private Long projectTotal;
+    /**
+     * 关联设备总数
+     */
+    private int deviceTotal;
+    /**
+     * 设备在线率
+     */
+    private double deviceOnlineRate;
+    /**
+     * 告警总数
+     */
+    private int alarmTotal;
+    /**
+     * 未读告警总数
+     */
+    private int unreadAlarmTotal;
+    /**
+     * 一级告警数量
+     */
+    private int oneAlarmTotal;
+    /**
+     * 今日告警总数
+     */
+    private int todayAlarmTotal;
+}

+ 95 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/KwsAlarmVO.java

@@ -0,0 +1,95 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author lfdc
+ * @description 告警vo
+ * @date 2023-11-10 17:11:35
+ */
+@Data
+public class KwsAlarmVO implements Serializable {
+    private Long id;
+
+    /**
+     * 触发的id(阈值id或者设备id)
+     */
+    private Long pid;
+
+    /**
+     * 企业id
+     */
+    private String companyId;
+
+    private String mountainId;
+
+
+    private String projectId;
+    /**
+     * 告警标题
+     */
+    private String title;
+
+    /**
+     * 告警触发数值
+     */
+    private String val;
+
+    /**
+     * 告警内容
+     */
+    private String content;
+
+    /**
+     * 告警等级
+     */
+    private Integer level;
+
+    /**
+     * 1数据告警  2设备告警
+     */
+    private Integer type;
+
+    /**
+     * 纬度
+     */
+    private String lat;
+
+    /**
+     * 经度
+     */
+    private String lng;
+
+    /**
+     * 海拔
+     */
+    private String alt;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private LocalDateTime createTime;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private LocalDateTime updateTime;
+
+    /**
+     * 触发次数
+     */
+    private Integer triggerTimes;
+
+    /**
+     * 状态
+     */
+    private Byte status;
+
+    private static final long serialVersionUID = 1L;
+}

+ 9 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ReportStatementVO.java

@@ -5,6 +5,7 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 
 /**
@@ -17,7 +18,7 @@ import java.time.LocalDateTime;
 public class ReportStatementVO implements Serializable {
 
     /**
-     * 项目主键ID
+     * 报表id
      */
     private String id;
     /**
@@ -45,6 +46,12 @@ public class ReportStatementVO implements Serializable {
      */
     private String projectId;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    /**
+     * 文件大小
+     */
+    private BigDecimal fileSize;
+
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime createTime;
 }

+ 6 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/SlopeDataVo.java

@@ -1,5 +1,6 @@
 package com.sckw.slope.detection.model.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -12,13 +13,17 @@ import java.util.Date;
  */
 @Data
 public class SlopeDataVo implements Serializable {
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date ts;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date rawId;
     private int tslverId;
     private String guid;
+    private String jsonText;
     private String line;
     private String val;
-//    private String msgId;
+    //    private String msgId;
 //    private String name;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 }

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/CommonService.java

@@ -106,7 +106,7 @@ public class CommonService {
         String content = com.sckw.core.utils.StringUtils.replaceTextVar(messageLogEnum.getContent(), logMap);
         KwsLog log = new KwsLog();
         log.setId(new IdWorker(NumberConstant.ONE).nextId());
-        log.setType(messageLogEnum.getType());
+        log.setType(messageLogEnum.getCode());
         log.setCompanyId(headerData.getCompanyId());
         log.setMountainId(headerData.getMountainId());
         log.setContent(content);

+ 107 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -0,0 +1,107 @@
+package com.sckw.slope.detection.service;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.model.page.PageRes;
+import com.sckw.slope.detection.dao.mysql.KwsAlarmMapper;
+import com.sckw.slope.detection.dao.mysql.KwsDeviceMapper;
+import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
+import com.sckw.slope.detection.model.dos.mysql.KwsAlarm;
+import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
+import com.sckw.slope.detection.model.dos.mysql.KwsProject;
+import com.sckw.slope.detection.model.dto.HeaderData;
+import com.sckw.slope.detection.model.param.AlarmLogThresholdQuery;
+import com.sckw.slope.detection.model.vo.AlarmLogThresholdVO;
+import com.sckw.slope.detection.model.vo.KwsAlarmVO;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author lfdc
+ * @description 告警service
+ * @date 2023-11-10 15:11:29
+ */
+@Slf4j
+@Service
+public class KwsAlarmService {
+
+    @Autowired
+    CommonService commonService;
+
+    @Autowired
+    KwsDeviceMapper deviceMapper;
+
+    @Autowired
+    KwsProjectMapper projectMapper;
+
+    @Autowired
+    KwsAlarmMapper alarmMapper;
+
+    public PageRes logSelectAll(AlarmLogThresholdQuery query) {
+        PageHelper.startPage(query.getPage(), query.getPageSize());
+        List<KwsAlarm> kwsAlarms = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
+                .eq(KwsAlarm::getStatus, 0)
+                .orderByDesc(KwsAlarm::getCreateTime));
+        PageInfo<AlarmLogThresholdVO> info = new PageInfo<AlarmLogThresholdVO>();
+        List<AlarmLogThresholdVO> list = new ArrayList<>();
+        if (CollectionUtils.isEmpty(kwsAlarms)) {
+            return PageRes.build(info, kwsAlarms);
+        }
+        if (!CollectionUtils.isEmpty(kwsAlarms)) {
+            kwsAlarms.forEach(KwsAlarm -> {
+                AlarmLogThresholdVO vo = new AlarmLogThresholdVO();
+                vo.setId(KwsAlarm.getId());
+                vo.setMountainId(KwsAlarm.getMountainId());
+                vo.setTitle(KwsAlarm.getTitle());
+                KwsProject project = projectMapper.selectById(Long.parseLong(KwsAlarm.getProjectId()));
+                vo.setProjectId(KwsAlarm.getProjectId());
+                vo.setProjectName(project == null ? null : project.getName());
+                vo.setContent(KwsAlarm.getContent());
+                vo.setLevel(KwsAlarm.getLevel());
+                vo.setCreateTime(KwsAlarm.getCreateTime());
+                list.add(vo);
+            });
+        }
+        return PageRes.build(info, list);
+    }
+
+    public PageRes select(AlarmLogThresholdQuery query, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
+        PageHelper.startPage(query.getPage(), query.getPageSize());
+        List<KwsAlarm> list = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
+                .eq(StringUtils.isNotBlank(headerData.getMountainId()), KwsAlarm::getMountainId, headerData.getMountainId()));
+        PageInfo<KwsAlarm> info = new PageInfo<KwsAlarm>();
+        if (CollectionUtils.isEmpty(list)) {
+            return PageRes.build(info, list);
+        }
+        Map<Integer, List<KwsAlarm>> listMap = list.stream().collect(Collectors.groupingBy(KwsAlarm::getType));
+        List<KwsAlarm> kwsAlarms = new ArrayList<>();
+        List<KwsAlarmVO> alarmVOS = new ArrayList<>();
+        if (listMap.get(1) != null) {
+            kwsAlarms = listMap.get(1);
+            for (KwsAlarm kwsAlarm : kwsAlarms) {
+                Long deviceId = kwsAlarm.getPid();
+                KwsDevice kwsDevice = deviceMapper.selectById(deviceId);
+                KwsProject project = projectMapper.selectById(Long.parseLong(kwsAlarm.getProjectId()));
+
+            }
+        }
+        if (listMap.get(2) != null) {
+            kwsAlarms = listMap.get(2);
+        }
+        if (!CollectionUtils.isEmpty(kwsAlarms) && kwsAlarms.size() > 0) {
+
+        }
+        return null;
+    }
+}

+ 21 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/LogService.java

@@ -3,12 +3,15 @@ package com.sckw.slope.detection.service;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.sckw.core.model.enums.MessageLogEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.KwsLogMapper;
+import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsLog;
 import com.sckw.slope.detection.model.param.ProjectLogQuery;
 import com.sckw.slope.detection.model.vo.LogSelectVO;
+import com.sckw.slope.detection.model.vo.SlopeDataVo;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -18,7 +21,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -33,6 +38,9 @@ public class LogService {
     @Autowired
     KwsLogMapper logMapper;
 
+    @Autowired
+    SlopeDataMapper slopeDataMapper;
+
     public PageRes select(ProjectLogQuery query, HttpServletRequest request) {
         PageHelper.startPage(query.getPage(), query.getPageSize());
         List<KwsLog> kwsLogs = logMapper.selectList(new LambdaQueryWrapper<KwsLog>()
@@ -59,6 +67,18 @@ public class LogService {
         if (!CollectionUtils.isEmpty(kwsLogs)) {
             typeList = kwsLogs.stream().map(KwsLog::getType).distinct().collect(Collectors.toList());
         }
-        return HttpResult.ok(typeList);
+        List<Map<String, String>> returnList = new ArrayList<>();
+        for (String s : typeList) {
+            Map<String, String> map = new HashMap<>();
+            map.put(s, MessageLogEnum.getEnumTitleByCode(s));
+            returnList.add(map);
+        }
+        return HttpResult.ok(returnList);
+    }
+
+    public HttpResult selectMetadata(Integer page, Integer pageSize, HttpServletRequest request) {
+        page = (page - 1) * pageSize;
+        List<SlopeDataVo> list = slopeDataMapper.selectListByMaster(page, pageSize);
+        return HttpResult.ok(list);
     }
 }

+ 53 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -41,6 +41,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -1143,4 +1144,56 @@ public class ProjectService {
         }
         return HttpResult.ok("删除关联设备成功!");
     }
+
+    public HttpResult selectAll() {
+        List<KwsProject> kwsProjects = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getDelFlag, 0));
+        Map<Long, String> projectMap = new HashMap<>();
+        if (!CollectionUtils.isEmpty(kwsProjects)) {
+            projectMap = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
+        }
+        return HttpResult.ok(projectMap);
+    }
+
+    @Autowired
+    KwsAlarmMapper alarmMapper;
+
+    public HttpResult dataScreening(String projectId) {
+        DataScreeningVO vo = new DataScreeningVO();
+        long count = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>()
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(projectId), KwsProject::getId, Long.parseLong(projectId))).stream().count();
+        vo.setProjectTotal(count);
+        int deviceCount = deviceMapper.selectCountByProject(projectId);
+        vo.setDeviceTotal(deviceCount);
+        vo.setDeviceOnlineRate(0);
+        LocalDateTime localDateTimeEnd = DateUtil.localDateToLocalDateTimeEnd(LocalDate.now());
+        LocalDateTime localDateTimeStart = DateUtil.localDateToLocalDateTimeStart(LocalDate.now());
+        KwsProject project = new KwsProject();
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(projectId)) {
+            project = projectMapper.selectById(projectId);
+        }
+        String mountainId = "";
+        if (Objects.nonNull(project)) {
+            mountainId = project.getMountainId();
+        }
+        List<KwsAlarm> kwsAlarmsCount = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
+        );
+        vo.setAlarmTotal(CollectionUtils.isEmpty(kwsAlarmsCount) ? 0 : kwsAlarmsCount.size());
+        List<KwsAlarm> unreadKwsAlarms = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
+                .eq(KwsAlarm::getStatus, 0)
+        );
+        vo.setUnreadAlarmTotal(CollectionUtils.isEmpty(unreadKwsAlarms) ? 0 : unreadKwsAlarms.size());
+        List<KwsAlarm> oneThresholdAlarm = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
+                .eq(KwsAlarm::getLevel, NumberConstant.ONE)
+        );
+        vo.setOneAlarmTotal(CollectionUtils.isEmpty(oneThresholdAlarm) ? 0 : oneThresholdAlarm.size());
+        List<KwsAlarm> kwsAlarms = alarmMapper.selectList(new LambdaQueryWrapper<KwsAlarm>()
+                .eq(org.apache.commons.lang3.StringUtils.isNotBlank(mountainId), KwsAlarm::getMountainId, mountainId)
+                .gt(KwsAlarm::getCreateTime, localDateTimeStart).lt(KwsAlarm::getCreateTime, localDateTimeEnd)
+        );
+        vo.setTodayAlarmTotal(CollectionUtils.isEmpty(kwsAlarms) ? 0 : kwsAlarms.size());
+        return HttpResult.ok("查询成功", vo);
+    }
 }

+ 39 - 27
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportService.java

@@ -4,18 +4,15 @@ 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.NumberConstant;
-import com.sckw.core.model.enums.MessageLogEnum;
-import com.sckw.core.model.enums.ReportEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
 import com.sckw.slope.detection.dao.mysql.KwsReportDataMapper;
 import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsProject;
-import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
+import com.sckw.slope.detection.model.dos.mysql.KwsReportData;
 import com.sckw.slope.detection.model.dto.HeaderData;
 import com.sckw.slope.detection.model.param.StatementQuery;
 import com.sckw.slope.detection.model.vo.ReportDetailVO;
@@ -26,10 +23,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.time.LocalDateTime;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author lfdc
@@ -54,13 +52,20 @@ public class ReportService {
     public PageRes select(StatementQuery query, HttpServletRequest request) {
         PageHelper.startPage(query.getPage(), query.getPageSize());
         String mountainId = commonService.getHeaderData(request).getMountainId();
-        List<ReportStatementVO> list = reportTemplateMapper.selectListByReportNameAndProjectIdAndCompany(query, mountainId);
+        List<ReportStatementVO> list = reportDataMapper.selectListByReportNameAndProjectId(query, mountainId);
         PageInfo<ReportStatementVO> info = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(info, list);
         }
+        List<String> collect = list.stream().map(ReportStatementVO::getProjectId).collect(Collectors.toList());
+        List<KwsProject> kwsProjects = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>()
+                .in(KwsProject::getId, collect)
+                .eq(KwsProject::getDelFlag, 0));
+        Map<Long, String> map = new HashMap<>();
+        if (!CollectionUtils.isEmpty(kwsProjects)) {
+            map = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
+        }
         for (ReportStatementVO reportStatementVO : list) {
-            reportStatementVO.setStatus(ReportEnum.getDescription(reportStatementVO.getStatus()));
             reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
         }
         return PageRes.build(info, list);
@@ -74,27 +79,34 @@ public class ReportService {
         return HttpResult.ok(vo);
     }
 
-    public HttpResult dels(String id, HttpServletRequest request) {
+    public HttpResult dels(String ids, HttpServletRequest request) {
+        List<Long> list = StringUtils.splitStrToList(ids, Long.class);
         HeaderData headerData = commonService.getHeaderData(request);
-        KwsReportTemplate template = reportTemplateMapper.selectOne(new LambdaQueryWrapper<KwsReportTemplate>().eq(KwsReportTemplate::getDelFlag, 0)
-                .eq(KwsReportTemplate::getId, Long.parseLong(id)));
-        if (template == null) {
-            throw new BusinessException("模板删除失败,参数错误");
+        if (!CollectionUtils.isEmpty(list)) {
+            list.forEach(id -> {
+                reportDataMapper.update(null, new LambdaUpdateWrapper<KwsReportData>()
+                        .eq(KwsReportData::getId, id)
+                        .eq(KwsReportData::getDelFlag, 0)
+                        .set(KwsReportData::getDelFlag, 1));
+            });
         }
-        reportTemplateMapper.update(null, new LambdaUpdateWrapper<KwsReportTemplate>()
-                .eq(KwsReportTemplate::getId, Long.parseLong(id))
-                .set(KwsReportTemplate::getUpdateTime, LocalDateTime.now())
-                .set(KwsReportTemplate::getUpdateBy, (headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy())))
-                .set(KwsReportTemplate::getStatus, NumberConstant.ONE)
-        );
-        KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
-                .eq(KwsProject::getId, Long.parseLong(template.getProjectId())));
-        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
-        logMap.put("projectName", project.getName());
-        logMap.put("templateName", template.getName());
-        commonService.insertLog(MessageLogEnum.DELETE_REPORT_TEMPLATE, headerData, logMap, headerData.getUpdateBy() == null ?
-                null : Long.parseLong(headerData.getUpdateBy()));
+        return HttpResult.ok();
+    }
 
-        return HttpResult.ok("删除成功");
+    /**
+     * @param ids
+     * @param request
+     * @return
+     */
+    public HttpResult export(String ids, HttpServletRequest request) {
+        List<Long> list = StringUtils.splitStrToList(ids, Long.class);
+        List<KwsReportData> kwsReportData = reportDataMapper.selectList(new LambdaQueryWrapper<KwsReportData>()
+                .eq(KwsReportData::getDelFlag, 0)
+                .in(KwsReportData::getId, list));
+        List<String> fileUrls = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(kwsReportData)) {
+            fileUrls = kwsReportData.stream().map(KwsReportData::getFileUrl).collect(Collectors.toList());
+        }
+        return HttpResult.ok(fileUrls);
     }
 }

+ 57 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportTemplateService.java

@@ -2,10 +2,14 @@ package com.sckw.slope.detection.service;
 
 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.NumberConstant;
 import com.sckw.core.model.enums.MessageLogEnum;
+import com.sckw.core.model.enums.ReportEnum;
 import com.sckw.core.model.enums.ReportTypeEnum;
+import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
@@ -16,17 +20,22 @@ import com.sckw.slope.detection.model.dto.HeaderData;
 import com.sckw.slope.detection.model.dto.IsEnableDTO;
 import com.sckw.slope.detection.model.dto.ReportTemplateAddDTO;
 import com.sckw.slope.detection.model.dto.ReportTemplateUpdateDTO;
+import com.sckw.slope.detection.model.param.StatementQuery;
 import com.sckw.slope.detection.model.vo.KwsReportTemplateVO;
+import com.sckw.slope.detection.model.vo.ReportStatementVO;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.time.LocalDateTime;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author lfdc
@@ -168,4 +177,52 @@ public class ReportTemplateService {
                 null : Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok("修改成功");
     }
+
+    public PageRes select(StatementQuery query, HttpServletRequest request) {
+        PageHelper.startPage(query.getPage(), query.getPageSize());
+        String mountainId = commonService.getHeaderData(request).getMountainId();
+        List<ReportStatementVO> list = reportTemplateMapper.selectListByReportNameAndProjectIdAndCompany(query, mountainId);
+        PageInfo<ReportStatementVO> info = new PageInfo<>(list);
+        if (CollectionUtils.isEmpty(list)) {
+            return PageRes.build(info, list);
+        }
+        List<String> collect = list.stream().map(ReportStatementVO::getProjectId).collect(Collectors.toList());
+        List<KwsProject> kwsProjects = projectMapper.selectList(new LambdaQueryWrapper<KwsProject>()
+                .in(KwsProject::getId, collect)
+                .eq(KwsProject::getDelFlag, 0));
+        Map<Long, String> map = new HashMap<>();
+        if (!CollectionUtils.isEmpty(kwsProjects)) {
+            map = kwsProjects.stream().collect(Collectors.toMap(KwsProject::getId, KwsProject::getName));
+        }
+        for (ReportStatementVO reportStatementVO : list) {
+            reportStatementVO.setStatus(ReportEnum.getDescription(reportStatementVO.getStatus()));
+            reportStatementVO.setReportType(ReportTypeEnum.getDescription(reportStatementVO.getReportType()));
+            reportStatementVO.setProjectName(map.get(Long.parseLong(reportStatementVO.getProjectId())));
+        }
+        return PageRes.build(info, list);
+    }
+
+    public HttpResult dels(String id, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
+        KwsReportTemplate template = reportTemplateMapper.selectOne(new LambdaQueryWrapper<KwsReportTemplate>().eq(KwsReportTemplate::getDelFlag, 0)
+                .eq(KwsReportTemplate::getId, Long.parseLong(id)));
+        if (template == null) {
+            throw new BusinessException("模板删除失败,参数错误");
+        }
+        reportTemplateMapper.update(null, new LambdaUpdateWrapper<KwsReportTemplate>()
+                .eq(KwsReportTemplate::getId, Long.parseLong(id))
+                .set(KwsReportTemplate::getUpdateTime, LocalDateTime.now())
+                .set(KwsReportTemplate::getUpdateBy, (headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy())))
+                .set(KwsReportTemplate::getStatus, NumberConstant.ONE)
+        );
+        KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
+                .eq(KwsProject::getId, Long.parseLong(template.getProjectId())));
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("projectName", project.getName());
+        logMap.put("templateName", template.getName());
+        commonService.insertLog(MessageLogEnum.DELETE_REPORT_TEMPLATE, headerData, logMap, headerData.getUpdateBy() == null ?
+                null : Long.parseLong(headerData.getUpdateBy()));
+
+        return HttpResult.ok("删除成功");
+    }
 }

+ 60 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/Task/ReportTemplateTaskService.java

@@ -0,0 +1,60 @@
+package com.sckw.slope.detection.service.Task;
+
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.sckw.core.model.enums.ReportTypeEnum;
+import com.sckw.slope.detection.dao.mysql.KwsReportTemplateMapper;
+import com.sckw.slope.detection.model.dos.mysql.KwsReportTemplate;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * @author lfdc
+ * @description 报表任务
+ * @date 2023-11-10 11:11:25
+ */
+
+@Slf4j
+@Component
+@EnableScheduling
+public class ReportTemplateTaskService {
+
+    @Resource
+    KwsReportTemplateMapper reportTemplateMapper;
+
+    /**
+     * 报表生成定时任务
+     */
+    //    @Scheduled(cron = "0 0 0 ? * *")
+    public void templateTask() {
+        List<KwsReportTemplate> kwsReportTemplates = reportTemplateMapper.selectList(new LambdaQueryWrapper<KwsReportTemplate>()
+                .eq(KwsReportTemplate::getStatus, 0)
+                .eq(KwsReportTemplate::getDelFlag, 0));
+        if (!CollectionUtils.isEmpty(kwsReportTemplates)) {
+            for (KwsReportTemplate kwsReportTemplate : kwsReportTemplates) {
+                Integer type = kwsReportTemplate.getType();
+                if (ReportTypeEnum.DAY.getCode() == type) {
+                    LocalDateTime localDateTime = LocalDateTime.now().minusDays(1);
+                    LocalDateTime dateEnd = com.sckw.excel.utils.DateUtil.localDateToLocalDateTimeEnd(localDateTime.toLocalDate());
+                    LocalDateTime dateStart = com.sckw.excel.utils.DateUtil.localDateToLocalDateTimeStart(localDateTime.toLocalDate());
+
+                }
+                if (ReportTypeEnum.WEEK.getCode() == type) {
+                    if (2 != DateUtil.thisDayOfWeekEnum().getValue()) {
+                        continue;
+                    }
+                }
+                if (ReportTypeEnum.MONTH.getCode() == type) {
+
+                }
+            }
+        }
+
+    }
+}

+ 24 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -621,6 +621,30 @@ public class ThresholdService {
                 thresholdRepository.updateById(threshold);
             });
         }
+        List<String> stringList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(list)) {
+            stringList = list.stream().map(KwsThreshold::getItemName).distinct().collect(Collectors.toList());
+        }
+        if (!CollectionUtils.isEmpty(stringList) && stringList.size() > 0) {
+            Map<String, SystemDict> dict = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+            KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>()
+                    .eq(KwsProject::getId, Long.parseLong(projectId)));
+            StringBuilder itemNameList = new StringBuilder();
+            for (int i = 0; i < stringList.size(); i++) {
+                if (i != stringList.size() - 1) {
+                    itemNameList.append(dict == null ? itemName : dict.get(itemName).getLabel()).append(",");
+                } else {
+                    itemNameList.append(dict == null ? itemName : dict.get(itemName).getLabel());
+                }
+            }
+            KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>().eq(KwsDevice::getId, Long.parseLong(deviceId)));
+            Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+            logMap.put("projectName", project.getName());
+            logMap.put("element", itemNameList);
+            logMap.put("deviceName", kwsDevice == null ? null : kwsDevice.getName());
+            commonService.insertLog(MessageLogEnum.DELETE_DEVICE_THRESHOLD, headerData, logMap, headerData.getUpdateBy() == null ?
+                    null : Long.parseLong(headerData.getUpdateBy()));
+        }
         return HttpResult.ok("删除成功");
     }
 }

+ 4 - 1
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsAlarmMapper.xml

@@ -10,19 +10,22 @@
     <result column="val" jdbcType="VARCHAR" property="val" />
     <result column="content" jdbcType="VARCHAR" property="content" />
     <result column="company_id" jdbcType="VARCHAR" property="companyId" />
+    <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
+    <result column="project_id" jdbcType="VARCHAR" property="projectId" />
     <result column="level" jdbcType="INTEGER" property="level" />
     <result column="type" jdbcType="INTEGER" property="type" />
     <result column="lat" jdbcType="VARCHAR" property="lat" />
     <result column="lng" jdbcType="VARCHAR" property="lng" />
     <result column="alt" jdbcType="VARCHAR" property="alt" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
     <result column="trigger_times" jdbcType="INTEGER" property="triggerTimes" />
     <result column="status" jdbcType="TINYINT" property="status" />
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
     id, pid, title, val, content, `level`, `type`, lat, lng, alt, create_time, trigger_times, 
-    `status`,company_id
+    `status`,company_id,mountain_id,project_id,update_time
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->

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

@@ -333,4 +333,20 @@
             </foreach>
         </if>
     </select>
+
+  <select id="selectCountByProject" resultType="int">
+      SELECT count(distinct c.id)
+      FROM kws_project a
+               LEFT JOIN kws_project_device b
+                         ON a.id = b.project_id
+               LEFT JOIN kws_device c ON b.device_id = c.id
+      WHERE a.del_flag = 0
+        AND b.del_flag = 0
+        AND c.del_flag = 0
+        and a.mountain_id = b.mountain_id
+        and b.mountain_id = c.mountain_id
+      <if test="projectId != null and projectId != ''">
+          and a.id=#{projectId}
+      </if>
+  </select>
 </mapper>

+ 33 - 1
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportDataMapper.xml

@@ -24,6 +24,8 @@
     <result column="alarm_title" jdbcType="VARCHAR" property="alarmTitle" />
     <result column="content" jdbcType="VARCHAR" property="content" />
     <result column="items" jdbcType="VARCHAR" property="items" />
+    <result column="file_url" jdbcType="VARCHAR" property="fileUrl" />
+    <result column="file_size"  property="fileSize" />
     <result column="alarm_time" jdbcType="TIMESTAMP" property="alarmTime" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
   </resultMap>
@@ -31,7 +33,7 @@
     <!--@mbg.generated-->
     id, template_id, project_id, project_name, device_id, device_name, sn_code, `alias`, 
     model_id, model_name, device_type, device_label, lat, lng, alt, alarm_type, alarm_title, 
-    content, items, alarm_time, create_time,company_id
+    content, items, alarm_time, create_time,company_id,file_url,file_size
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
@@ -292,4 +294,34 @@
   <select id="selectDataAndTemplate" resultType="com.sckw.slope.detection.model.vo.ReportDetailVO">
 
     </select>
+
+  <select id="selectListByReportNameAndProjectId" resultType="com.sckw.slope.detection.model.vo.ReportStatementVO">
+      SELECT b.`name`       AS reportName,
+             b.type         AS reportType,
+             a.project_name AS projectName,
+             a.file_size    AS fileSize,
+             a.create_time  AS createTime,
+             a.id           as id
+      FROM kws_report_data a
+               LEFT JOIN kws_report_template b ON a.template_id = b.id
+      WHERE a.mountain_id = b.mountain_id
+        AND b.del_flag = 0
+        and a.del_flag = 0
+      <if test="query.projectId != null and query.projectId != ''">
+          and a.project_id = #{query.projectId}
+      </if>
+      <if test="query.reportName != null and query.reportName != ''">
+          and b.name like concat('%', #{query.reportName}
+              , '%')
+      </if>
+      <if test="query.reportName != null and query.reportName != ''">
+          and b.type = #{query.reportType}
+      </if>
+      <if test="query.startTime != null and query.startTime != ''">
+          and a.create_time &gt;= #{query.startTime}
+      </if>
+      <if test="query.endTime != null and query.endTime != ''">
+          and a.create_time &lt;= #{query.endTime}
+      </if>
+  </select>
 </mapper>

+ 25 - 1
slope-modules/slope-detection/src/main/resources/mapper/tdengine/SlopeDataMapper.xml

@@ -26,7 +26,8 @@
                val,
                create_time as createTime,
                msg_id      as msgId,
-               name
+               name,
+               json_text   as jsonText
         FROM devices.slope_data_6_7
     </select>
 
@@ -37,6 +38,7 @@
         guid,
         line,
         val,
+        json_text   as jsonText,
         create_time as createTime
     </sql>
     <select id="selectListByLine" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
@@ -89,4 +91,26 @@
         create_time TIMESTAMP
         )
     </insert>
+
+    <select id="selectListByMaster" resultType="com.sckw.slope.detection.model.vo.SlopeDataVo">
+        SELECT
+        <include refid="Base_List">
+        </include>
+        FROM devices.slope_data
+        <if test="(page != null and page !='') and ( pageSize != null and pageSize != '')">
+            limit #{page},#{pageSize}
+        </if>
+
+<!--        SELECT-->
+<!--        t1.ts,-->
+<!--        t1.raw_id      as rawId,-->
+<!--        t1.tslver_id   as tslverId,-->
+<!--        t1.guid,-->
+<!--        t1.line,-->
+<!--        t1.val,-->
+<!--        t1.create_time as createTime,-->
+<!--        t2.json_text as jsonText-->
+<!--        FROM devices.slope_data AS t1-->
+<!--        LEFT JOIN devices.slope_raw AS t2 ON t1.guid  = t2.guid-->
+    </select>
 </mapper>