Kaynağa Gözat

1.阈值设置查询
2.阈值配置
3.模板配置
4.边坡详情查看

lengfaqiang 2 yıl önce
ebeveyn
işleme
8c1ec71790
38 değiştirilmiş dosya ile 1166 ekleme ve 281 silme
  1. 1 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/DeviceEnum.java
  2. 36 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/DictItemEnum.java
  3. 88 18
      slope-common/slope-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java
  4. 6 0
      slope-modules/slope-detection/pom.xml
  5. 8 9
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java
  6. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/HttpDemoController.java
  7. 20 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ProjectController.java
  8. 9 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java
  9. 0 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceRelationMapper.java
  10. 1 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectMapper.java
  11. 4 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java
  12. 6 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDevice.java
  13. 14 5
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceReference.java
  14. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceRelation.java
  15. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsThreshold.java
  16. 4 4
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/tdengine/SlopeData.java
  17. 21 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeleteThresholdDTO.java
  18. 27 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeviceDeleteDTO.java
  19. 60 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ProjectChartLogParam.java
  20. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/StatementQuery.java
  21. 15 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectDeviceVO.java
  22. 85 11
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java
  23. 295 26
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java
  24. 2 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ReportService.java
  25. 2 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/TdengineDemoService.java
  26. 94 14
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  27. 3 1
      slope-modules/slope-detection/src/main/resources/bootstrap-lfdc.yml
  28. 1 1
      slope-modules/slope-detection/src/main/resources/bootstrap.yml
  29. 4 2
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceIntegrationMapper.xml
  30. 13 10
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml
  31. 1 1
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceModelPartMapper.xml
  32. 6 13
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceReferenceMapper.xml
  33. 137 139
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceRelationMapper.xml
  34. 50 4
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml
  35. 1 1
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsReportTemplateMapper.xml
  36. 1 3
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsThresholdMapper.xml
  37. 126 0
      slope-modules/slope-detection/src/main/resources/mapper/tdengine/DeviceMapper.xml
  38. 21 2
      slope-modules/slope-detection/src/main/resources/mapper/tdengine/SlopeDataMapper.xml

+ 1 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/DeviceEnum.java

@@ -24,6 +24,7 @@ public enum DeviceEnum {
      * 校验中
      */
     BE_CHECKING(3, "3", "校验中"),
+
     /**
      * 已基准
      */

+ 36 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/DictItemEnum.java

@@ -0,0 +1,36 @@
+package com.sckw.core.model.enums;
+
+/**
+ * @author lfdc
+ * @description 字段检测要素枚举
+ * @date 2023-11-05 15:11:30
+ */
+
+public enum DictItemEnum {
+
+    LONGITUDE_X("longitude", "1", "经度(X偏移)"),
+    LATITUDE_Y("latitude", "2", "纬度(Y偏移)"),
+    ALTITUDE_Z("altitude", "3", "海拔(z偏移)"),
+    ;
+    private final String codeType;
+    private final String value;
+    private final String name;
+
+    DictItemEnum(String codeType, String value, String name) {
+        this.codeType = codeType;
+        this.value = value;
+        this.name = name;
+    }
+
+    public String getCodeType() {
+        return codeType;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

+ 88 - 18
slope-common/slope-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java

@@ -24,6 +24,7 @@ public class DateUtil {
     public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
     public static final String DEF_DATE_FORMAT = "yyyy-MM-dd";
     public static final DateTimeFormatter YYYY_MM_DD_HH_MM_SS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+    public static final DateTimeFormatter YYYY_MM_DD_HH_MM_SS_SSS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
     public static final DateTimeFormatter YYYYMMDDHHMMSS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
     public static final DateTimeFormatter YYYY_MM_DD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
     public static final DateTimeFormatter HH_MM_SS = DateTimeFormatter.ofPattern("HH:mm:ss");
@@ -476,6 +477,11 @@ public class DateUtil {
         return dateTime.format(YYYY_MM_DD_HH_MM_SS);
     }
 
+    public static String localDateTimeFormat(LocalDateTime dateTime) {
+        return dateTime.format(YYYY_MM_DD_HH_MM_SS_SSS);
+    }
+
+
     public static long millis(LocalDate date) {
         return millis(date.atStartOfDay());
     }
@@ -531,25 +537,14 @@ public class DateUtil {
     }
 
     public static void main(String[] args) throws ParseException {
-//        String lastTwoMonthDate = getLastTwoMonthDateStart();
-//        String lastTwoMonthDateEnd = getLastTwoMonthDateEnd();
-//        String s = "2023-12-12";
-//        Date date = DateUtil.stringPatchingStartToDateTime(s);
-//        Date date1 = DateUtil.stringPatchingEndToDateTime(s);
-//        System.out.println(date);
-//        System.out.println(date1);
-//        String lastWeekDateStart = getLastWeekDateStart();
-//        String lastWeekDateEnd = getLastWeekDateEnd();
-//        System.out.println(lastWeekDateStart);
-//        System.out.println(lastWeekDateEnd);
-//        String beforeWeekDate = DateUtil.getBeforeWeekDate(6) + " 00:00:00";
-//        String beforeWeekDate1 = DateUtil.getBeforeWeekDate(7) + " 23:59:59";
-//        ;
-//        System.out.println(beforeWeekDate);
-//        System.out.println(beforeWeekDate1);
-//        DateTime dateTime = lastMonth();
-//        System.out.println(dateTime);
 
+        String s = localDateTimeFormat(LocalDateTime.now());
+        List<String> dateTimeHour = getDateTimeHour(new Date(), 24, new ArrayList<String>());
+        String dateTimeHour1 = getDateTimeToHour(new Date(), 24);
+        System.out.println(dateTimeHour);
+        List<String> list = new ArrayList<>();
+        List<String> dateTimeSS = getDateTimeDay(LocalDateTime.now(), 7, list);
+        System.out.println(dateTimeSS);
 //        // 获取当前日期
 //        LocalDate currentDate = LocalDate.now();
 //        // 计算一年前的日期
@@ -803,6 +798,81 @@ public class DateUtil {
     }
 
 
+    /**
+     * 当前时间的前一个星期[传递6即为一周]
+     *
+     * @return 2023-09-12 00:00:00
+     */
+    public static LocalDateTime getLastWeekDate(LocalDateTime localDate, long amount) {
+        LocalDateTime localDateTime = localDate.minusDays(amount);
+        return localDateTime;
+    }
+
+    /**
+     * 获取当前时间的前${amount}时间的每一天
+     *
+     * @param now    当前时间
+     * @param amount 当前时间的前几天
+     * @param list   获取到时间的数组
+     * @return
+     */
+    public static List<String> getDateTimeDay(LocalDateTime now, int amount, List<String> list) {
+        for (int i = 0; i < amount; i++) {
+            LocalDateTime lastWeekDate = DateUtil.getLastWeekDate(now, i);
+            DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            String key = df.format(lastWeekDate);
+            list.add(key);
+        }
+        return list;
+    }
+
+
+    /**
+     * 获取当前时间的前${amount}时间的每个小时(包含当前的小时)
+     *
+     * @param date   当前时间
+     * @param amount 当前时间的前多少小时
+     * @param list   获取到时间的数组
+     * @return
+     */
+    public static List<String> getDateTimeHour(Date date, int amount, List<String> list) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:00:00");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        String time = sdf.format(date);
+        list.add(time);
+        for (int i = 0; i < amount; i++) {
+            calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+            time = sdf.format(calendar.getTime());
+            list.add(time);
+        }
+        return list;
+    }
+
+
+    /**
+     * 获取当前时间的前${amount}时间的每个小时(包含当前的小时)
+     *
+     * @param date   当前时间
+     * @param amount 当前时间的前多少小时
+     * @return
+     */
+    public static String getDateTimeToHour(Date date, int amount) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:00:00.000");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        String time = sdf.format(date);
+        for (int i = 0; i < amount; i++) {
+            calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+            time = sdf.format(calendar.getTime());
+            if (i == (amount - 1)) {
+                return time;
+            }
+        }
+        return null;
+    }
+
+
     /**
      * 当前时间的前一个星期 [传递6即为一周]
      *

+ 6 - 0
slope-modules/slope-detection/pom.xml

@@ -32,6 +32,12 @@
             <version>1.0.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>slope-common-excel</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
         <dependency>
             <groupId>com.sckw</groupId>
             <artifactId>slope-common-remote</artifactId>

+ 8 - 9
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java

@@ -2,7 +2,6 @@ package com.sckw.slope.detection.controller;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.sckw.core.annotation.Log;
-import com.sckw.core.annotation.RepeatSubmit;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.model.dto.LocationDTO;
 import com.sckw.slope.detection.model.param.DeviceAdd;
@@ -49,25 +48,25 @@ public class DeviceController {
     @Log(description = "设备查询-分页")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备查询-分页", value = "/select", method = RequestMethod.POST)
-    public HttpResult select(@Valid @RequestBody DeviceQuery deviceQuery, HttpResponse response) {
+    public HttpResult select(@Valid @RequestBody DeviceQuery deviceQuery, HttpResponse request) {
         log.info("设备查询 select param:{}", JSONObject.toJSONString(deviceQuery));
-        return HttpResult.ok(deviceService.select(deviceQuery, response));
+        return HttpResult.ok(deviceService.select(deviceQuery, request));
     }
 
     @Log(description = "设备新增")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备新增", value = "/add", method = RequestMethod.POST)
-    public HttpResult add(@Valid @RequestBody DeviceAdd deviceAdd, HttpServletRequest response) {
+    public HttpResult add(@Valid @RequestBody DeviceAdd deviceAdd, HttpServletRequest request) {
         log.info("设备新增 add param:{}", JSONObject.toJSONString(deviceAdd));
-        return deviceService.add(deviceAdd, response);
+        return deviceService.add(deviceAdd, request);
     }
 
     @Log(description = "设备详情")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备详情", value = "/detail", method = RequestMethod.GET)
-    public HttpResult detail(@RequestParam("id") @NotNull(message = "数据id不能为空") long id, HttpServletRequest response) {
+    public HttpResult detail(@RequestParam("id") @NotNull(message = "数据id不能为空") long id, HttpServletRequest request) {
         log.info("设备 detail param:{}", id);
-        return deviceService.detail(id, response);
+        return deviceService.detail(id, request);
     }
 
     @Log(description = "设备位置配置")
@@ -95,8 +94,8 @@ public class DeviceController {
     @Log(description = "设备编辑")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备编辑", value = "/update", method = RequestMethod.POST)
-    public HttpResult update(@Valid @RequestBody DeviceAdd deviceAdd, HttpServletRequest response) {
+    public HttpResult update(@Valid @RequestBody DeviceAdd deviceAdd, HttpServletRequest request) {
         log.info("设备编辑 update param:{}", JSONObject.toJSONString(deviceAdd));
-        return deviceService.update(deviceAdd, response);
+        return deviceService.update(deviceAdd, request);
     }
 }

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

@@ -56,7 +56,7 @@ public class HttpDemoController {
                 , mapPara);
         List<SystemDict> systemDictList = new ArrayList<>();
         if (httpResult.isStatus()) {
-            ArrayList list = JSONObject.parseObject(JSONObject.toJSONString(httpResult.getData()), ArrayList.class);
+            List list = JSONObject.parseObject(JSONObject.toJSONString(httpResult.getData()), List.class);
             if (!CollectionUtils.isEmpty(list)) {
                 list.forEach(s -> {
                     SystemDict systemDict = JSONObject.parseObject(s.toString(), SystemDict.class);

+ 20 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ProjectController.java

@@ -4,9 +4,11 @@ import com.alibaba.fastjson2.JSONObject;
 import com.sckw.core.annotation.Log;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.model.dto.BindDevice;
+import com.sckw.slope.detection.model.dto.DeviceDeleteDTO;
 import com.sckw.slope.detection.model.dto.ProjectAddDTO;
 import com.sckw.slope.detection.model.dto.ProjectUpdateDTO;
 import com.sckw.slope.detection.model.param.DeviceQuery;
+import com.sckw.slope.detection.model.param.ProjectChartLogParam;
 import com.sckw.slope.detection.model.param.ProjectQuery;
 import com.sckw.slope.detection.service.ProjectService;
 import jakarta.servlet.http.HttpServletRequest;
@@ -80,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) {
+    public HttpResult selectDevice(@RequestBody @Valid  DeviceQuery deviceQuery,HttpServletRequest request) {
         log.info("设备组网查询 select param:{}", JSONObject.toJSONString(deviceQuery));
-        return HttpResult.ok(projectService.selectDevice(deviceQuery));
+        return HttpResult.ok(projectService.selectDevice(deviceQuery,request));
     }
 
     @Log(description = "新增组网设备-关联设备-查询")
@@ -108,4 +110,20 @@ public class ProjectController {
         log.info("项目设备查询 deviceFind param:{}", JSONObject.toJSONString(deviceQuery));
         return projectService.deviceFind(deviceQuery, request);
     }
+
+    @Log(description = "项目设备删除")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "项目设备删除", value = "/deviceDelete", method = RequestMethod.POST)
+    public HttpResult deviceDelete(@RequestBody @Valid DeviceDeleteDTO deviceDelete, HttpServletRequest request) {
+        log.info("项目设备删除 deviceDelete delete:{}", JSONObject.toJSONString(deviceDelete));
+        return projectService.deviceDelete(deviceDelete, request);
+    }
+
+    @Log(description = "项目详情-图表查询")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "项目详情-图表查询", value = "/chartLog", method = RequestMethod.POST)
+    public HttpResult chartLog(@Valid @RequestBody ProjectChartLogParam param, HttpServletRequest response) {
+        log.info("项目详情-图表查询 chartLog param:{}", JSONObject.toJSONString(param));
+        return projectService.chartLog(param, response);
+    }
 }

+ 9 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/ThresholdController.java

@@ -3,6 +3,7 @@ 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.dto.DeleteThresholdDTO;
 import com.sckw.slope.detection.model.dto.ThresholdConfigurationDTO;
 import com.sckw.slope.detection.model.param.ThresholdDetailQuery;
 import com.sckw.slope.detection.model.param.ThresholdQuery;
@@ -53,4 +54,12 @@ public class ThresholdController {
         return thresholdService.configuration(configurationDTO, request);
     }
 
+    @Log(description = "阈值删除")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "阈值删除", value = "/dels", method = RequestMethod.POST)
+    public HttpResult dels(@Valid @RequestBody DeleteThresholdDTO deleteThreshold, HttpServletRequest request) {
+        log.info("阈值删除 dels param:{}", JSONObject.toJSONString(deleteThreshold));
+        return thresholdService.dels(deleteThreshold, request);
+    }
+
 }

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

@@ -10,8 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
 public interface KwsDeviceRelationMapper extends BaseMapper<KwsDeviceRelation> {
     int deleteByPrimaryKey(Long id);
 
-    int insert(KwsDeviceRelation record);
-
     int insertSelective(KwsDeviceRelation record);
 
     KwsDeviceRelation selectByPrimaryKey(Long id);

+ 1 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsProjectMapper.java

@@ -29,4 +29,5 @@ public interface KwsProjectMapper extends BaseMapper<KwsProject> {
     List<ProjectDeviceVO> selectDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery);
 
     List<ProjectDeviceVO> selectDeviceNotBindList(@Param("deviceQuery") DeviceQuery deviceQuery);
+    List<ProjectDeviceVO> selectNotBindDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery);
 }

+ 4 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java

@@ -26,8 +26,11 @@ public interface SlopeDataMapper extends BaseMapper<SlopeData> {
 
     List<SlopeDataVo> selectList();
 
-    SlopeData selectListByLine(@Param("item") String item);
+    SlopeData selectListByLine(@Param("snCode") String snCode,@Param("item") String item);
+
+    List<SlopeData> selectLineList(@Param("snCode") String snCode, @Param("item") String item, @Param("dateStart") String dateStart, @Param("dateEnd") String dateEnd);
 
     int insertData(@Param("slopeData") SlopeData slopeData);
 
+    List<SlopeData> selectListByLineOrderByCreateTime(@Param("snCode") String snCode, @Param("item") String item);
 }

+ 6 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDevice.java

@@ -1,14 +1,11 @@
 package com.sckw.slope.detection.model.dos.mysql;
 
-import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
-import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
-import java.util.Date;
 
 /**
  * @author lfdc
@@ -48,7 +45,7 @@ public class KwsDevice implements Serializable {
     /**
      * 质保日期
      */
-    private DateTime validTime;
+    private LocalDateTime validTime;
 
     /**
      * 秘钥
@@ -121,6 +118,11 @@ public class KwsDevice implements Serializable {
      */
     private Integer related;
 
+    /**
+     * 是否关联设备(主从设备 0未关联 1 主 2从)
+     */
+    private String relevanceLevel;
+
     private static final long serialVersionUID = 1L;
 
 }

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

@@ -7,7 +7,6 @@ import lombok.Data;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.Date;
 
 /**
  * @author lfdc
@@ -32,9 +31,14 @@ public class KwsDeviceReference implements Serializable {
     private String mountainId;
 
     /**
-    * 基准值
+    * 原始基准值
     */
-    private BigDecimal value;
+    private BigDecimal originalValue;
+
+    /**
+     * 当前基准值
+     */
+    private BigDecimal currentValue;
 
     /**
     * 偏移量
@@ -44,7 +48,7 @@ public class KwsDeviceReference implements Serializable {
     /**
     * 状态
     */
-    private Byte status;
+    private int status;
 
     /**
     * 创建人
@@ -54,7 +58,7 @@ public class KwsDeviceReference implements Serializable {
     /**
     * 创建时间
     */
-    private Date createTime;
+    private LocalDateTime createTime;
 
     /**
     * 修改人
@@ -66,6 +70,11 @@ public class KwsDeviceReference implements Serializable {
     */
     private LocalDateTime updateTime;
 
+    /**
+     * 要素类型 1 基本要素 2 集成要素
+     */
+    private int  type;
+
     /**
     * 删除标识
     */

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceRelation.java

@@ -24,7 +24,7 @@ public class KwsDeviceRelation implements Serializable {
     /**
      * 企业id
      */
-    private String companyId;
+    private String mountainId;
 
     /**
      * 关联的设备id

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsThreshold.java

@@ -30,7 +30,7 @@ public class KwsThreshold implements Serializable {
     /**
      * 企业id
      */
-    private String companyId;
+//    private String companyId;
     private String mountainId;
     private String setting;
 

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

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDateTime;
 
 /**
  * @author lfdc
@@ -16,8 +16,8 @@ import java.util.Date;
 public class SlopeData implements Serializable {
     //ts|raw_id|tslver_id|guid|line|val|create_time|msg_id|name|
 //    SELECT ts, raw_id, tslver_id, guid, line, val, create_time, msg_idmsg_id, name
-    private Date ts;
-    private Date rawId;
+    private LocalDateTime ts;
+    private LocalDateTime rawId;
     private int tslverId;
     private String guid;
     private String line;
@@ -28,5 +28,5 @@ public class SlopeData implements Serializable {
     private String serialNumber;
     private String tagsTitle;
     private String tags;
-    private Date createTime;
+    private LocalDateTime createTime;
 }

+ 21 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeleteThresholdDTO.java

@@ -0,0 +1,21 @@
+package com.sckw.slope.detection.model.dto;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 阈值删除
+ * @date 2023-11-07 10:11:37
+ */
+@Data
+public class DeleteThresholdDTO implements Serializable {
+    @NotBlank(message = "项目id不能能为空")
+    private String projectId;
+    @NotBlank(message = "设备id不能能为空")
+    private String deviceId;
+    @NotBlank(message = "设备要素id不能能为空")
+    private String itemName;
+}

+ 27 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/DeviceDeleteDTO.java

@@ -0,0 +1,27 @@
+package com.sckw.slope.detection.model.dto;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+/**
+ * @author lfdc
+ * @description 关联设备删除
+ * @date 2023-11-06 11:11:33
+ */
+@Data
+public class DeviceDeleteDTO {
+    /**
+     * 设备关联主键id
+     */
+    private String deviceRelationId;
+
+    @NotBlank(message = "项目id不能为空")
+    private String projectId;
+
+    @NotBlank(message = "设备id不能为空")
+    private String deviceId;
+
+//    @NotBlank(message = "主设备id不能为空")
+    private String parentId;
+
+}

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

@@ -0,0 +1,60 @@
+package com.sckw.slope.detection.model.param;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 项目详情-设备列表查询
+ * @date 2023-11-05 10:11:30
+ */
+@Data
+public class ProjectChartLogParam implements Serializable {
+
+    /**
+     * type :
+     * status : 1 已基准、2未调基准
+     * latitude : 维度(年、月)
+     * deviceId : 设备id
+     * startTime : 开始时间
+     * endTime : 结束时间
+     * partName : 检测要素
+     */
+
+    /**
+     * x X轴、y Y轴、z Z轴 检测要素
+     */
+    private String type;
+    /**
+     * 1 已基准、2未调基准
+     */
+    private String status;
+    /**
+     * 维度(1年、2月、3周,4日)
+     */
+    private String latitude;
+    /**
+     * 设备id
+     */
+    @NotBlank(message = "设备id不能为空")
+    private String deviceId;
+    /**
+     * 项目id
+     */
+    @NotBlank(message = "项目id不能为空")
+    private String projectId;
+    /**
+     * 开始时间
+     */
+    private String startTime;
+    /**
+     * 结束时间
+     */
+    private String endTime;
+    /**
+     * 检测要素
+     */
+    private String partName;
+}

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

@@ -24,7 +24,7 @@ public class StatementQuery {
     /**
      * 项目名称
      */
-    @NotBlank(message = "项目名称不能为空")
+//    @NotBlank(message = "项目名称不能为空")
     private String projectName;
 
     /**

+ 15 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectDeviceVO.java

@@ -26,6 +26,16 @@ public class ProjectDeviceVO implements Serializable {
      */
     private String name;
 
+    /**
+     * 关联设备表主键id
+     */
+    private Long deviceRelationId;
+
+//    /**
+//     * 所属主设备id
+//     */
+//    private String deviceParentId;
+
     /**
      * 别名(单元名称)
      */
@@ -76,4 +86,9 @@ public class ProjectDeviceVO implements Serializable {
      * 所属主设备名称
      */
     private String parentName;
+
+    /**
+     * 要素id
+     */
+    private String partName;
 }

+ 85 - 11
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DeviceEnum;
+import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.response.HttpResult;
@@ -31,10 +32,8 @@ import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.time.ZoneOffset;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -46,6 +45,8 @@ import java.util.stream.Collectors;
 @Service
 public class DeviceService {
 
+    private static final Long equatorial_circumference = 40075020000L;
+
     @Autowired
     CommonService commonService;
 
@@ -210,6 +211,10 @@ public class DeviceService {
      */
     public HttpResult outputValue(String projectId, String deviceId, HttpServletRequest request) {
         HeaderData headerData = commonService.getHeaderData(request);
+        KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(Long.parseLong(deviceId));
+        if (kwsDevice == null) {
+            return HttpResult.ok();
+        }
         List<Integer> status = new ArrayList<>();
         status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
         //集成要素
@@ -226,6 +231,7 @@ public class DeviceService {
         List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
                 .eq(KwsDeviceReference::getDeviceId, deviceId)
                 .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
+                .eq(KwsDeviceReference::getType, 1)
                 .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
         );
         List<DeviceOutputValueVO> mapList = new ArrayList<>();
@@ -233,21 +239,59 @@ public class DeviceService {
             references.forEach(re -> {
                 DeviceOutputValueVO vo = new DeviceOutputValueVO();
                 String item = re.getItem();
-                BigDecimal value = re.getValue();
+                BigDecimal originalValue = re.getOriginalValue();
+                BigDecimal currentValue = re.getCurrentValue();
+                BigDecimal offset = re.getOffset();
                 //当前基准值
                 HashMap<String, Object> currentMap = new HashMap<>();
+                currentMap.put(item, currentValue);
                 //原始基准值
                 HashMap<String, Object> primitive = new HashMap<>();
+                primitive.put(item, originalValue);
                 //当前测量值-TD获取
                 HashMap<String, Object> currentMeasurement = new HashMap<>();
-                SlopeData slopeData = slopeDataMapper.selectListByLine(item);
-                primitive.put(item, value);
+                SlopeData slopeData = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), item);
+                String val = slopeData == null ? null : slopeData.getVal();
                 //存在经度纬度海拔等要素 要进行公式计算
-                String itemList = "";
+                /**
+                 * 经度方向的距离 =  L * cos(A) * ( X / 360)
+                 其中:L=40075020000毫米(赤道周长)
+                 A=基准值的纬度
+                 X=测量值经度 - 基准值经度
+                 纬度方向的距离 = Y * 111000000
+                 其中: Y =测量值纬度 - 基准值纬度*/
+                List<String> itemList = new ArrayList<>();
+                itemList.add(DictItemEnum.LONGITUDE_X.getValue());
+                if (itemList.contains(re.getItem())) {
+                    BigDecimal offsetValue = new BigDecimal("0.00");
+                    if (Objects.nonNull(currentValue)) {
+                        SlopeData selected = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
+                        double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selected.getVal()));
+                        double cosValue = Math.cos(angleInRadians);
+                        if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
+                            double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
+                            offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
+                        }
+                    }
+                    currentMeasurement.put(item, offsetValue);
+                }
+                itemList.clear();
+                itemList.add(DictItemEnum.LATITUDE_Y.getValue());
                 if (itemList.contains(re.getItem())) {
-                    currentMap.put(item, value);
-                } else {
-                    currentMap.put(item, value);
+                    BigDecimal offsetValue = new BigDecimal("0.00");
+                    if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
+                        offsetValue = new BigDecimal(val).subtract(currentValue);
+                    }
+                    currentMeasurement.put(item, offsetValue);
+                }
+                itemList.clear();
+                itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
+                if (itemList.contains(re.getItem())) {
+                    BigDecimal offsetValue = new BigDecimal("0.00");
+                    if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
+                        offsetValue = new BigDecimal(val).divide(new BigDecimal(1000));
+                    }
+                    currentMeasurement.put(item, offsetValue);
                 }
                 vo.setCurrentMap(currentMap);
                 vo.setPrimitive(primitive);
@@ -270,13 +314,43 @@ public class DeviceService {
                 kwsIntegrations.forEach(integration -> {
                     String integrationName = integration.getIntegrationName();
                     String partNames = integration.getPartNames();
+                    KwsDeviceReference reference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
+                            .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
+                            .eq(KwsDeviceReference::getDeviceId, Long.parseLong(deviceId))
+                            .eq(KwsDeviceReference::getDelFlag, 0)
+                            .eq(KwsDeviceReference::getType, 2)
+                    );
                     DeviceOutputValueVO vo = new DeviceOutputValueVO();
                     //当前基准值
                     HashMap<String, Object> currentMap = new HashMap<>();
+                    currentMap.put(integrationName, reference == null ? null : reference.getCurrentValue());
                     //原始基准值
                     HashMap<String, Object> primitive = new HashMap<>();
+                    primitive.put(integrationName, reference == null ? null : reference.getOriginalValue());
                     //当前测量值-TD获取
                     HashMap<String, Object> currentMeasurement = new HashMap<>();
+                    String formula = integration.getFormula();
+                    List<String> stringList = StringUtils.splitStrToList(partNames, String.class);
+                    BigDecimal decimal = new BigDecimal("0.00");
+                    if (!CollectionUtils.isEmpty(stringList)) {
+                        for (int i = 0; i < stringList.size(); i++) {
+                            List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(integrationName, stringList.get(i));
+                            if (!CollectionUtils.isEmpty(selected)) {
+                                if (selected.size() == 2) {
+                                    SlopeData currSlopeData = selected.get(0);
+                                    SlopeData lastSlopeData = selected.get(1);
+                                    LocalDateTime date = currSlopeData.getCreateTime();
+                                    LocalDateTime date1 = lastSlopeData.getCreateTime();
+                                    long epochMilli = date.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                    long epochMilli1 = date1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                    long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
+                                    long val = Long.parseLong(currSlopeData.getVal()) - Long.parseLong(lastSlopeData.getVal());
+                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
+                                }
+                            }
+                        }
+                    }
+                    currentMeasurement.put(integrationName, decimal);
                     vo.setCurrentMap(currentMap);
                     vo.setPrimitive(primitive);
                     vo.setCurrentMeasurement(currentMeasurement);

+ 295 - 26
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -8,16 +8,22 @@ import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DeviceEnum;
+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.utils.IdWorker;
 import com.sckw.core.utils.RegularUtils;
 import com.sckw.core.utils.StringUtils;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
+import com.sckw.excel.utils.DateUtil;
 import com.sckw.slope.detection.dao.mysql.*;
+import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
+import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.param.DeviceQuery;
+import com.sckw.slope.detection.model.param.ProjectChartLogParam;
 import com.sckw.slope.detection.model.param.ProjectQuery;
 import com.sckw.slope.detection.model.vo.*;
 import com.sckw.slope.detection.service.repository.KwsDeviceRelationRepository;
@@ -30,9 +36,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author lfdc
@@ -43,6 +51,8 @@ import java.util.List;
 @Service
 public class ProjectService {
 
+    private static final Long equatorial_circumference = 40075020000L;
+
     @Autowired
     CommonService commonService;
 
@@ -52,9 +62,15 @@ public class ProjectService {
     @Autowired
     KwsProjectAreaMapper projectAreaMapper;
 
+    @Autowired
+    KwsDeviceIntegrationMapper deviceIntegrationMapper;
+
     @Autowired
     KwsDeviceMapper deviceMapper;
 
+    @Autowired
+    SlopeDataMapper slopeDataMapper;
+
     @Autowired
     KwsProjectDeviceMapper projectDeviceMapper;
 
@@ -199,7 +215,8 @@ public class ProjectService {
         return HttpResult.ok(jsonObject);
     }
 
-    public PageRes selectDevice(DeviceQuery deviceQuery) {
+    public PageRes selectDevice(DeviceQuery deviceQuery, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
         PageHelper.startPage(deviceQuery.getPage(), deviceQuery.getPageSize());
 //        List<ProjectDeviceVO> list = projectMapper.selectDeviceByProjectId(Long.parseLong(deviceQuery.getProjectId()));
         List<ProjectDeviceVO> list = projectMapper.selectDeviceList(deviceQuery);
@@ -208,9 +225,22 @@ public class ProjectService {
             return PageRes.build(info, list);
         }
 //        后期要数据翻译产品类型
-//        for (ProjectDeviceDTO projectDeviceDTO : list) {
-//
-//        }
+        for (ProjectDeviceVO projectDeviceDTO : list) {
+            Long id = projectDeviceDTO.getDeviceRelationId();
+            KwsDeviceRelation deviceRelation = deviceRelationMapper.selectOne(new LambdaQueryWrapper<KwsDeviceRelation>()
+                    .eq(KwsDeviceRelation::getId, id)
+                    .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
+                    .eq(KwsDeviceRelation::getDelFlag, 0)
+            );
+            if (deviceRelation != null) {
+                projectDeviceDTO.setParentId(deviceRelation.getDeviceId().toString());
+                KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(deviceRelation.getDeviceId());
+                projectDeviceDTO.setParentName(kwsDevice == null ? null : kwsDevice.getName());
+            }
+            if (projectDeviceDTO.getId().equals(projectDeviceDTO.getProjectId())) {
+                projectDeviceDTO.setParentName(null);
+            }
+        }
         return PageRes.build(info, list);
     }
 
@@ -223,31 +253,37 @@ public class ProjectService {
         List<Long> list = StringUtils.splitStrToList(bindDevice.getDeviceIds(), Long.class);
         String bindDeviceId = bindDevice.getBindDeviceId();
         //设备主从绑定
-        if (org.apache.commons.lang3.StringUtils.isNotBlank(bindDeviceId)) {
-            List<KwsDeviceRelation> saveList = new ArrayList<>();
-            list.forEach(id -> {
-                KwsDeviceRelation deviceRelation = new KwsDeviceRelation();
-                deviceRelation.setId(new IdWorker(NumberConstant.ONE).nextId());
-                deviceRelation.setDeviceId(Long.parseLong(bindDeviceId));
-                deviceRelation.setCompanyId(companyId);
-                deviceRelation.setRelateDeviceId(id);
-                deviceRelation.setStatus(NumberConstant.ZERO);
-                deviceRelation.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
-                LocalDateTime now = LocalDateTime.now();
-                deviceRelation.setCreateTime(now);
-                deviceRelation.setUpdateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
-                deviceRelation.setUpdateTime(now);
-                deviceRelation.setDelFlag(NumberConstant.ZERO);
-                saveList.add(deviceRelation);
-            });
-            deviceRelationRepository.saveBatch(saveList);
-        }
+        List<KwsDeviceRelation> saveList = new ArrayList<>();
+        list.forEach(id -> {
+            String deviceId = "";
+            if (bindDeviceId == null) {
+                //当主设备设置关联时,未关联主设备,即当前设备为主设备
+                deviceId = String.valueOf(id);
+            } else {
+                deviceId = bindDeviceId;
+            }
+            KwsDeviceRelation deviceRelation = new KwsDeviceRelation();
+            deviceRelation.setId(new IdWorker(NumberConstant.ONE).nextId());
+            deviceRelation.setDeviceId(Long.parseLong(deviceId));
+            deviceRelation.setMountainId(headerData.getMountainId());
+            deviceRelation.setRelateDeviceId(id);
+            deviceRelation.setStatus(NumberConstant.ZERO);
+            deviceRelation.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
+            LocalDateTime now = LocalDateTime.now();
+            deviceRelation.setCreateTime(now);
+            deviceRelation.setUpdateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
+            deviceRelation.setUpdateTime(now);
+            deviceRelation.setDelFlag(NumberConstant.ZERO);
+            saveList.add(deviceRelation);
+        });
+        deviceRelationRepository.saveBatch(saveList);
         //矿山与设备绑定
         if (!CollectionUtils.isEmpty(list)) {
             list.forEach(id -> {
                 KwsProjectDevice device = new KwsProjectDevice();
                 device.setId(new IdWorker(NumberConstant.ONE).nextId());
                 device.setProjectId(projectId);
+                device.setMountainId(headerData.getMountainId());
                 device.setDeviceId(id);
                 device.setStatus(NumberConstant.ONE);
                 device.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
@@ -262,9 +298,21 @@ public class ProjectService {
         //设备修改状态
         if (!CollectionUtils.isEmpty(list)) {
             list.forEach(id -> {
+                String level = "1";
+                if (bindDeviceId != null) {
+                    KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(Long.parseLong(bindDeviceId));
+                    if (kwsDevice == null) {
+                        throw new BusinessException("所属主设备id错误!");
+                    }
+                    kwsDevice.setRelevanceLevel(level);
+                    kwsDevice.setUpdateTime(LocalDateTime.now());
+                    kwsDevice.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
+                    level = "2";
+                }
                 KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(id);
                 deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
                         .eq(KwsDevice::getId, id)
+                        .set(KwsDevice::getRelevanceLevel, level)
                         .set(KwsDevice::getStatus, DeviceEnum.BE_CHECKING.getCode())
                         .set(KwsDevice::getAlias, bindDevice.getAlias() == null ? kwsDevice.getName() : bindDevice.getAlias())
                         .set(KwsDevice::getUpdateTime, LocalDateTime.now())
@@ -277,7 +325,7 @@ public class ProjectService {
 
     public PageRes deviceBindSelect(DeviceQuery deviceQuery, HttpServletRequest request) {
         PageHelper.startPage(deviceQuery.getPage(), deviceQuery.getPageSize());
-        List<ProjectDeviceVO> list = projectMapper.selectDeviceNotBindList(deviceQuery);
+        List<ProjectDeviceVO> list = projectMapper.selectNotBindDeviceList(deviceQuery);
         PageInfo<ProjectDeviceVO> info = new PageInfo<>(list);
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(info, list);
@@ -304,4 +352,225 @@ public class ProjectService {
         vo.setDeviceList(list);
         return HttpResult.ok(vo);
     }
+
+    /**
+     * 边坡详情-设备要素折线图
+     *
+     * @param param   请求参数
+     * @param request 请求头信息
+     * @return 数据响应
+     */
+    public HttpResult chartLog(ProjectChartLogParam param, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
+        String latitude = param.getLatitude();
+        String projectId = param.getProjectId();
+        if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
+            Map<String, SystemDict> dictList = commonService.getDictList(null, new HashMap<String, String>() {{
+                put("code", DictEnum.MODEL_PART.getCodeType());
+                put("type", "1");
+            }});
+            String deviceId = param.getDeviceId();
+            String mountainId = headerData.getMountainId();
+            KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
+                    .eq(KwsDevice::getId, Long.parseLong(deviceId))
+                    .eq(KwsDevice::getMountainId, mountainId)
+                    .eq(KwsDevice::getDelFlag, NumberConstant.ZERO)
+            );
+            if (kwsDevice == null) {
+                return HttpResult.ok();
+            }
+            //集成要素
+            List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
+                    mountainId, null, Long.parseLong(deviceId));
+            //集成要素
+            List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
+                    .eq(KwsDeviceIntegration::getMountainId, mountainId)
+                    .eq(KwsDeviceIntegration::getDeviceId, deviceId)
+            );
+
+            //当前设备下的所有基本要素
+            List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
+            if (!CollectionUtils.isEmpty(projectDeviceList)) {
+                for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
+                    String partName = projectDeviceVO.getPartName();
+                    //设置过阈值的基本要素
+                    List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
+                            .eq(KwsDeviceReference::getDeviceId, deviceId)
+                            .eq(KwsDeviceReference::getMountainId, mountainId)
+                            .eq(KwsDeviceReference::getType, 1)
+                            .eq(KwsDeviceReference::getItem, partName)
+                            .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
+                    );
+                    KwsDeviceReference deviceReference = new KwsDeviceReference();
+                    if (!CollectionUtils.isEmpty(references)) {
+                        deviceReference = references.get(0);
+                    }
+                    SlopeData slopeData = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), partName);
+                    String val = slopeData == null ? null : slopeData.getVal();
+                    //基准值
+                    BigDecimal currentValue = deviceReference.getCurrentValue();
+                    BigDecimal offsetValue = new BigDecimal("0.00");
+                    if (currentValue != null) {
+                        /**存在经纬度海拔值的需要公式计算*/
+                        List<String> itemList = new ArrayList<>();
+                        itemList.add(DictItemEnum.LONGITUDE_X.getValue());
+                        Date date = new Date();
+                        String dateStart = DateUtil.getDateTimeToHour(date, 24);
+                        String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
+                        List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
+                        if (!CollectionUtils.isEmpty(selected)){
+                            for (SlopeData message : selected) {
+                                String line = message.getLine();
+                                String val1 = message.getVal();
+                                if (itemList.contains(partName)) {
+                                    if (Objects.nonNull(currentValue)) {
+                                        SlopeData selectListByLine = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
+                                        double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
+                                        double cosValue = Math.cos(angleInRadians);
+                                        if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
+                                            double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
+                                            offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
+                                        }
+                                    }
+                                }
+                                itemList.add(DictItemEnum.LATITUDE_Y.getValue());
+                                if (itemList.contains(partName)) {
+                                    if (Objects.nonNull(currentValue)) {
+                                        if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
+                                            offsetValue = new BigDecimal(val).subtract(currentValue);
+                                        }
+                                    }
+                                }
+                                itemList.clear();
+                                itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
+                                if (itemList.contains(partName)) {
+                                    if (Objects.nonNull(currentValue)) {
+                                        if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
+                                            offsetValue = new BigDecimal(val).divide(new BigDecimal(1000));
+                                        }
+                                    }
+                                }
+                            }
+                        }
+
+                    }
+                }
+            }
+
+            LocalDateTime localDateTime = DateUtil.localDateToLocalDateTimeStart(LocalDate.now());
+        } else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
+//            //开始时间
+//            dateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 6);
+//            //结束时间
+//            dateEnd = DateUtil.getLastWeekDateEndToString(0);
+            List<String> dateTimeDay = DateUtil.getDateTimeDay(LocalDateTime.now(), 7, new ArrayList<String>());
+            for (String dateTime : dateTimeDay) {
+
+            }
+            /**下面是查询当天每小时数据总量的代码示例:
+
+             SELECT DATE_FORMAT(timestamp, '%Y-%m-%d %H:00:00') AS hour,
+             COUNT(*) AS count
+             FROM data
+             WHERE DATE(timestamp) = CURDATE()
+             GROUP BY hour;*/
+
+            /** 下面是查询当天每小时某个字段平均值的代码示例:
+
+
+             SELECT DATE_FORMAT(timestamp, '%Y-%m-%d %H:00:00') AS hour,
+             AVG(value) AS average
+             FROM data
+             WHERE DATE(timestamp) = CURDATE()
+             GROUP BY hour;*/
+
+        } else if (String.valueOf(NumberConstant.TWO).equals(latitude)) {
+        } else if (String.valueOf(NumberConstant.ONE).equals(latitude)) {
+        } else {
+            throw new BusinessException("数据传输异常");
+        }
+        return null;
+    }
+
+
+    /**
+     * 项目关联设备删除
+     *
+     * @param deviceDelete 设备id
+     * @param request      请求数据
+     * @return 返回数据
+     */
+    public HttpResult deviceDelete(DeviceDeleteDTO deviceDelete, HttpServletRequest request) {
+        HeaderData headerData = commonService.getHeaderData(request);
+        Long projectId = Long.parseLong(deviceDelete.getProjectId());
+        KwsProject project = projectMapper.selectOne(new LambdaQueryWrapper<KwsProject>().eq(KwsProject::getId, projectId));
+        String deviceId = deviceDelete.getDeviceId();
+        String bindDeviceId = deviceDelete.getDeviceRelationId();
+        String deviceParentId = deviceDelete.getParentId();
+        //设备主从解绑
+        //如果删除主设备  子设备也要删除
+        //id集合
+        List<Long> deleteList = new ArrayList<>();
+        if (deviceId.equals(deviceParentId)) {
+            List<KwsDeviceRelation> deviceRelationList = deviceRelationMapper.selectList(
+                    new LambdaQueryWrapper<KwsDeviceRelation>()
+                            .eq(KwsDeviceRelation::getDeviceId, deviceId)
+                            .eq(KwsDeviceRelation::getDelFlag, 0)
+                            .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
+                            .ne(KwsDeviceRelation::getRelateDeviceId, deviceId)
+            );
+            //主设备数据
+            KwsDeviceRelation deviceRelation = deviceRelationMapper.selectOne(
+                    new LambdaQueryWrapper<KwsDeviceRelation>()
+                            .eq(KwsDeviceRelation::getDeviceId, deviceId)
+                            .eq(KwsDeviceRelation::getDelFlag, 0)
+                            .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
+                            .eq(KwsDeviceRelation::getRelateDeviceId, deviceId)
+            );
+            if (deviceRelation != null) {
+                deleteList.add(deviceRelation.getId());
+            }
+            if (!CollectionUtils.isEmpty(deviceRelationList)) {
+                deleteList = deviceRelationList.stream().map(KwsDeviceRelation::getId).collect(Collectors.toList());
+                deleteList.add(Long.parseLong(bindDeviceId));
+            }
+            deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
+                    .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
+                    .set(KwsDeviceRelation::getDelFlag, 1)
+                    .in(KwsDeviceRelation::getRelateDeviceId, deleteList)
+            );
+        } else {
+            deleteList.add(Long.parseLong(deviceId));
+            deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
+                    .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
+                    .set(KwsDeviceRelation::getDelFlag, 1)
+                    .in(KwsDeviceRelation::getRelateDeviceId, deleteList)
+            );
+        }
+        //矿山与设备解绑
+        if (!CollectionUtils.isEmpty(deleteList)) {
+            projectDeviceMapper.update(null, new LambdaUpdateWrapper<KwsProjectDevice>()
+                    .set(KwsProjectDevice::getDelFlag, 1)
+                    .set(KwsProjectDevice::getUpdateBy, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()))
+                    .set(KwsProjectDevice::getUpdateTime, LocalDateTime.now())
+                    .eq(KwsProjectDevice::getDelFlag, 0)
+                    .eq(KwsProjectDevice::getProjectId, projectId)
+                    .eq(KwsProjectDevice::getMountainId, headerData.getMountainId())
+                    .in(KwsProjectDevice::getDeviceId, deleteList)
+            );
+        }
+        //设备修改状态
+        if (!CollectionUtils.isEmpty(deleteList)) {
+            deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
+                    .in(KwsDevice::getId, deleteList)
+                    .eq(KwsDevice::getMountainId, headerData.getMountainId())
+                    .eq(KwsDevice::getDelFlag, 0)
+                    .set(KwsDevice::getRelevanceLevel, 0)
+                    .set(KwsDevice::getStatus, DeviceEnum.NOT_IN_USE.getCode())
+                    .set(KwsDevice::getUpdateTime, LocalDateTime.now())
+                    .set(KwsDevice::getUpdateBy, headerData.getUpdateBy() == null ? Long.parseLong(headerData.getCreateBy()) : Long.parseLong(headerData.getUpdateBy()))
+            );
+        }
+        return HttpResult.ok("删除关联设备成功!");
+    }
 }

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

@@ -44,8 +44,8 @@ public class ReportService {
 
     public PageRes select(StatementQuery query, HttpServletRequest request) {
         PageHelper.startPage(query.getPage(), query.getPageSize());
-        String companyId = commonService.getHeaderData(request).getCompanyId();
-        List<ReportStatementVO> list = reportTemplateMapper.selectListByReportNameAndProjectIdAndCompany(query, companyId);
+        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);

+ 2 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/TdengineDemoService.java

@@ -7,7 +7,7 @@ import com.sckw.slope.detection.model.vo.SlopeDataVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
+import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -26,7 +26,7 @@ public class TdengineDemoService {
         List<SlopeDataVo> list1 = slopeDataMapper.selectList();
         System.out.println(JSONObject.toJSONString(list1));
         SlopeData data = new SlopeData();
-        java.util.Date now = new Date();
+        LocalDateTime now = LocalDateTime.now();
         data.setTs(now);
         data.setRawId(now);
         data.setTslverId(1);

+ 94 - 14
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -1,11 +1,13 @@
 package com.sckw.slope.detection.service;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.DeviceEnum;
+import com.sckw.core.model.enums.DictEnum;
 import com.sckw.core.model.enums.ThresholdEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
@@ -31,6 +33,7 @@ import org.springframework.util.CollectionUtils;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
@@ -81,9 +84,6 @@ public class ThresholdService {
             //基本要素
             List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(thresholdQuery.getProjectId(),
                     headerData.getMountainId(), status, deviceId);
-            //集成要素
-            List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(thresholdQuery.getProjectId(),
-                    headerData.getMountainId(), status, deviceId);
             List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
                     .eq(KwsThreshold::getDeviceId, deviceId)
                     .eq(KwsThreshold::getMountainId, headerData.getMountainId())
@@ -112,11 +112,34 @@ public class ThresholdService {
                     }
                 }
             }
+            List<String> itemNameList = new ArrayList<>();
             //翻译
             List<String> collect = basiclElementList.stream().map(DeviceElementDTO::getElement).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(collect)) {
+                for (String dict : collect) {
+                    //不查询数据库【kws_device_model_part】 查字典
+                    Map<String, SystemDict> dictList = commonService.getDictList(null,
+                            new HashMap<>() {
+                                {
+                                    put("code", DictEnum.MODEL_PART.getCodeType());
+                                    put("type", "1");
+                                }
+                            }
+                    );
+                    itemNameList.add(dictList == null ? dict : (dictList.get(dict) == null ? dict : dictList.get(dict).getLabel()));
+                }
+            }
+            //集成要素
+            List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(thresholdQuery.getProjectId(),
+                    headerData.getMountainId(), status, deviceId);
             List<String> collect1 = integratedElementList.stream().map(DeviceElementDTO::getIntegrationElement).collect(Collectors.toList());
-            dto.setItemName(collect.toString() + collect1.toString());
-//            dto.setDeviceTotal();
+            if (!CollectionUtils.isEmpty(collect1)) {
+                itemNameList.addAll(collect1);
+            }
+            dto.setItemName(JSONObject.toJSONString(itemNameList));
+            //获取总数和设置阈值数
+            int deviceTotal = getThresholdNumber(thresholdQuery.getProjectId(), headerData, deviceId);
+            dto.setDeviceTotal(String.valueOf(deviceTotal));
             int deviceSetTotal = 0;
             if (!CollectionUtils.isEmpty(kwsThresholds)) {
                 deviceSetTotal = kwsThresholds.stream().map(KwsThreshold::getItemName).distinct().collect(Collectors.toList()).size();
@@ -132,6 +155,39 @@ public class ThresholdService {
         return PageRes.build(info, dtoList);
     }
 
+    private int getThresholdNumber(String projectId, HeaderData headerData, Long deviceId) {
+        List<Integer> status = new ArrayList<>();
+        status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
+        //基本要素
+        List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(projectId,
+                headerData.getMountainId(), status, deviceId);
+        //集成要素
+        List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
+                headerData.getMountainId(), status, deviceId);
+        int count = 0;
+        if (!CollectionUtils.isEmpty(basiclElementList)) {
+            List<String> collect = basiclElementList.stream().map(DeviceElementDTO::getElement).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(collect)) {
+                for (String s : collect) {
+                    List<String> stringList = StringUtils.splitStrToList(s, String.class);
+                    count = count + stringList.size();
+                }
+            }
+
+        }
+        if (!CollectionUtils.isEmpty(integratedElementList)) {
+            List<String> collect = basiclElementList.stream().map(DeviceElementDTO::getIntegrationElement).collect(Collectors.toList());
+            if (!CollectionUtils.isEmpty(collect)) {
+                count = count + collect.size();
+//                for (String s : collect) {
+//                    List<String> stringList = StringUtils.splitStrToList(s, String.class);
+//                    count = count + stringList.size();
+//                }
+            }
+        }
+        return count;
+    }
+
     public HttpResult detail(ThresholdDetailQuery thresholdQuery, HttpServletRequest request) {
         String deviceId = thresholdQuery.getDeviceId();
         String itemName = thresholdQuery.getItemName();
@@ -146,6 +202,7 @@ public class ThresholdService {
         KwsDeviceReference deviceReference = deviceReferenceMapper.selectOne(new LambdaQueryWrapper<KwsDeviceReference>()
                 .eq(KwsDeviceReference::getMountainId, mountainId)
                 .eq(KwsDeviceReference::getDeviceId, deviceId)
+                .eq(KwsDeviceReference::getType, 1)
                 .eq(KwsDeviceReference::getItem, itemName)
         );
         ThresholdDetailVO vo = new ThresholdDetailVO();
@@ -153,7 +210,7 @@ public class ThresholdService {
             vo.setPhones(kwsThreshold.get(0).getPhones());
             vo.setItemName(itemName);
             vo.setDeviceId(deviceId);
-            vo.setItemValue(deviceReference == null ? null : deviceReference.getValue());
+            vo.setItemValue(deviceReference == null ? null : deviceReference.getCurrentValue());
             //查询td获取数据
 //            vo.setVariation();
             List<ThresholdBean> beanList = new ArrayList<>();
@@ -198,7 +255,6 @@ public class ThresholdService {
                     .eq(KwsThreshold::getMountainId, headerData.getMountainId())
                     .eq(KwsThreshold::getDeviceId, deviceId)
                     .eq(KwsThreshold::getItemName, itemName)
-                    .eq(KwsThreshold::getCompanyId, headerData.getMountainId())
                     .eq(KwsThreshold::getLevel, level)
                     .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
             );
@@ -207,7 +263,6 @@ public class ThresholdService {
                 kwsThreshold.setId(new IdWorker(NumberConstant.ONE).nextId());
                 kwsThreshold.setDeviceId(Long.parseLong(deviceId));
                 kwsThreshold.setItemName(itemName);
-                kwsThreshold.setCompanyId(headerData.getCompanyId());
                 kwsThreshold.setMountainId(headerData.getMountainId());
                 //计算设置状态  便于select
                 String setting = checkAndSettings(configurationDTO, headerData);
@@ -346,7 +401,6 @@ public class ThresholdService {
                 .eq(KwsThreshold::getMountainId, headerData.getMountainId())
                 .eq(KwsThreshold::getDeviceId, deviceId)
                 .eq(KwsThreshold::getItemName, itemName)
-                .eq(KwsThreshold::getCompanyId, headerData.getMountainId())
                 .eq(KwsThreshold::getLevel, 2)
                 .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
         );
@@ -463,7 +517,6 @@ public class ThresholdService {
                     .eq(KwsThreshold::getMountainId, headerData.getMountainId())
                     .eq(KwsThreshold::getDeviceId, Long.parseLong(configurationDTO.getDeviceId()))
                     .eq(KwsThreshold::getItemName, configurationDTO.getItemName())
-                    .eq(KwsThreshold::getCompanyId, headerData.getMountainId())
                     .eq(KwsThreshold::getLevel, (maxLevel + 1))
                     .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
             );
@@ -499,10 +552,11 @@ public class ThresholdService {
         if (!CollectionUtils.isEmpty(integratedElementList)) {
             List<String> collect = basiclElementList.stream().map(DeviceElementDTO::getIntegrationElement).collect(Collectors.toList());
             if (!CollectionUtils.isEmpty(collect)) {
-                for (String s : collect) {
-                    List<String> stringList = StringUtils.splitStrToList(s, String.class);
-                    count = count + stringList.size();
-                }
+                count = count + collect.size();
+//                for (String s : collect) {
+//                    List<String> stringList = StringUtils.splitStrToList(s, String.class);
+//                    count = count + stringList.size();
+//                }
             }
         }
         List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
@@ -526,4 +580,30 @@ public class ThresholdService {
         }
         return setting;
     }
+
+    @Transactional
+    public HttpResult dels(DeleteThresholdDTO deleteThreshold, HttpServletRequest request) {
+        String itemName = deleteThreshold.getItemName();
+        String projectId = deleteThreshold.getProjectId();
+        String deviceId = deleteThreshold.getDeviceId();
+        HeaderData headerData = commonService.getHeaderData(request);
+//        List<DeviceElementDTO> list = deviceModelPartMapper.selectElementList(projectId, headerData.getMountainId(), null, Long.parseLong(deviceId));
+        List<KwsThreshold> list = thresholdRepository.list(new LambdaQueryWrapper<KwsThreshold>()
+                .eq(KwsThreshold::getDeviceId, Long.parseLong(deviceId))
+                .eq(KwsThreshold::getMountainId, headerData.getMountainId())
+                .eq(KwsThreshold::getItemName, itemName)
+                .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
+        );
+        if (!CollectionUtils.isEmpty(list)) {
+            list.forEach(threshold -> {
+                threshold.setStatus(NumberConstant.ONE);
+                threshold.setDelFlag(NumberConstant.ONE);
+                threshold.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
+                threshold.setUpdateName(headerData.getUpdateName());
+                threshold.setUpdateTime(LocalDateTime.now());
+                thresholdRepository.updateById(threshold);
+            });
+        }
+        return HttpResult.ok("删除成功");
+    }
 }

+ 3 - 1
slope-modules/slope-detection/src/main/resources/bootstrap-lfdc.yml

@@ -46,4 +46,6 @@ mqtt:
     keepalive: 20
   # 要消费的topic配置
   receive:
-    topic: slopePush/slopePull/test/out,test,slope,sharjeck/ai/test/out
+    topic: slopePush/slopePull/test/out,test,slope,sharjeck/ai/test/out
+OkHttpClit:
+  url: "http://10.10.10.185:9501"

+ 1 - 1
slope-modules/slope-detection/src/main/resources/bootstrap.yml

@@ -7,7 +7,7 @@ spring:
 #    name: slope-detection
   profiles:
 
-    active: sky
+    active: lfdc
     #active: ${DEPLOY_MODE:dev}
   main:
     allow-bean-definition-overriding: true

+ 4 - 2
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceIntegrationMapper.xml

@@ -158,14 +158,16 @@
     </update>
 
     <select id="selectIntegratedElement" resultType="com.sckw.slope.detection.model.dto.DeviceElementDTO">
-        SELECT a.id             as deviceId,
+        SELECT a.id               as deviceId,
                c.`name`,
                c.alias,
-               e.integration_id as element
+               e.integration_id   as element,
+               f.integration_name as integrationElement
         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
                  LEFT JOIN kws_device_integration e ON c.id = e.device_id
+                 LEFT JOIN kws_integration f ON f.id = e.integration_id
         WHERE a.del_flag = 0
           and e.del_flag = 0
           and b.del_flag = 0

+ 13 - 10
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml

@@ -10,10 +10,12 @@
     <result column="alias" jdbcType="VARCHAR" property="alias" />
     <result column="sn_code" jdbcType="VARCHAR" property="snCode" />
     <result column="model_id" jdbcType="BIGINT" property="modelId" />
-      <result column="company_id" jdbcType="VARCHAR" property="companyId" />
+    <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
     <result column="valid_time" jdbcType="TIMESTAMP" property="validTime" />
     <result column="secret_key" jdbcType="VARCHAR" property="secretKey" />
+    <result column="relevance_level" jdbcType="VARCHAR" property="relevanceLevel" />
     <result column="inter_face" jdbcType="VARCHAR" property="interFace" />
+    <result column="related" jdbcType="VARCHAR" property="related" />
     <result column="remark" jdbcType="VARCHAR" property="remark" />
     <result column="status" jdbcType="TINYINT" property="status" />
     <result column="create_by" jdbcType="BIGINT" property="createBy" />
@@ -24,15 +26,16 @@
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, `attribute`, `name`, `alias`, sn_code, model_id, valid_time, secret_key, inter_face,
-    remark, `status`, create_by, create_time, update_by, update_time, del_flag,company_id
+    id, `attribute`, `name`, `alias`, sn_code, model_id, valid_time, secret_key, inter_face,relevance_level,
+    remark, `status`, create_by, create_time, update_by, update_time, del_flag,mountain_id,related
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    <!--@mbg.generated-->
-    select 
-    <include refid="Base_Column_List" />
-    from kws_device
-    where id = #{id,jdbcType=BIGINT}
+      <!--@mbg.generated-->
+      select
+      <include refid="Base_Column_List"/>
+      from kws_device
+      where del_flag = 0
+        and id = #{id,jdbcType=BIGINT}
   </select>
   <select id="selectByDeviceParam" resultType="com.sckw.slope.detection.model.vo.DeviceVo">
       select d.id,
@@ -277,10 +280,10 @@
           AND d.del_flag = 0
           AND c.id NOT in (SELECT DISTINCT a.relate_device_id
                            FROM kws_device_relation a
-                                    LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
+                                    LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id where a.del_flag = 0)
           AND c.id NOT in (SELECT DISTINCT a.device_id
                            FROM kws_device_relation a
-                                    LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
+                                    LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id where a.del_flag = 0)
         <if test="projectId != null and projectId != ''">
             AND a.id = #{projectId}
         </if>

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

@@ -176,7 +176,7 @@
           and a.project_id = #{projectId}
       </if>
       <if test="deviceId != null and deviceId != ''">
-          and b.device_id = #{deviceId}
+          and b.id = #{deviceId}
       </if>
   </select>
 

+ 6 - 13
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceReferenceMapper.xml

@@ -7,9 +7,11 @@
         <id column="id" jdbcType="BIGINT" property="id"/>
         <result column="device_id" jdbcType="BIGINT" property="deviceId"/>
         <result column="item" jdbcType="VARCHAR" property="item"/>
-        <result column="value" jdbcType="DECIMAL" property="value"/>
+        <result column="original_value" jdbcType="DECIMAL" property="originalValue"/>
+        <result column="current_value" jdbcType="DECIMAL" property="originalValue"/>
         <result column="offset" jdbcType="DECIMAL" property="offset"/>
         <result column="status" jdbcType="TINYINT" property="status"/>
+        <result column="type" jdbcType="TINYINT" property="type"/>
         <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
         <result column="create_by" jdbcType="BIGINT" property="createBy"/>
         <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
@@ -23,7 +25,9 @@
         device_id,
         mountain_id,
         item,
-        `value`,
+        type,
+        original_value,
+        current_value,
         `offset`,
         `status`,
         create_by,
@@ -45,17 +49,6 @@
         from kws_device_reference
         where id = #{id,jdbcType=BIGINT}
     </delete>
-    <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference">
-        <!--@mbg.generated-->
-        insert into kws_device_reference (id, device_id, item,
-                                          `value`, `offset`, `status`,
-                                          create_by, create_time, update_by,
-                                          update_time, del_flag)
-        values (#{id,jdbcType=BIGINT}, #{deviceId,jdbcType=BIGINT}, #{item,jdbcType=VARCHAR},
-                #{value,jdbcType=DECIMAL}, #{offset,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT},
-                #{createBy,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=BIGINT},
-                #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=TINYINT})
-    </insert>
     <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference">
         <!--@mbg.generated-->
         insert into kws_device_reference

+ 137 - 139
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceRelationMapper.xml

@@ -1,152 +1,150 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.slope.detection.dao.mysql.KwsDeviceRelationMapper">
-  <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
-    <!--@mbg.generated-->
-    <!--@Table kws_device_relation-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="device_id" jdbcType="BIGINT" property="deviceId" />
-    <result column="relate_device_id" jdbcType="BIGINT" property="relateDeviceId" />
-    <result column="status" jdbcType="TINYINT" property="status" />
-    <result column="create_by" jdbcType="BIGINT" property="createBy" />
-    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
-    <result column="update_by" jdbcType="BIGINT" property="updateBy" />
-      <result column="company_id" jdbcType="VARCHAR" property="companyId" />
-    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
-    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, device_id, relate_device_id, `status`, create_by, create_time, update_by, update_time, 
-    del_flag,company_id
-  </sql>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    <!--@mbg.generated-->
-    select 
-    <include refid="Base_Column_List" />
-    from kws_device_relation
-    where id = #{id,jdbcType=BIGINT}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-    <!--@mbg.generated-->
-    delete from kws_device_relation
-    where id = #{id,jdbcType=BIGINT}
-  </delete>
-  <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
-    <!--@mbg.generated-->
-    insert into kws_device_relation (id, device_id, relate_device_id, 
-      `status`, create_by, create_time, 
-      update_by, update_time, del_flag
-      )
-    values (#{id,jdbcType=BIGINT}, #{deviceId,jdbcType=BIGINT}, #{relateDeviceId,jdbcType=BIGINT}, 
-      #{status,jdbcType=TINYINT}, #{createBy,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, 
-      #{updateBy,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=TINYINT}
-      )
-  </insert>
-  <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
-    <!--@mbg.generated-->
-    insert into kws_device_relation
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
+    <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
+        <!--@mbg.generated-->
+        <!--@Table kws_device_relation-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="device_id" jdbcType="BIGINT" property="deviceId"/>
+        <result column="relate_device_id" jdbcType="BIGINT" property="relateDeviceId"/>
+        <result column="status" jdbcType="TINYINT" property="status"/>
+        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
+        <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
         id,
-      </if>
-      <if test="deviceId != null">
         device_id,
-      </if>
-      <if test="relateDeviceId != null">
         relate_device_id,
-      </if>
-      <if test="status != null">
         `status`,
-      </if>
-      <if test="createBy != null">
         create_by,
-      </if>
-      <if test="createTime != null">
         create_time,
-      </if>
-      <if test="updateBy != null">
         update_by,
-      </if>
-      <if test="updateTime != null">
         update_time,
-      </if>
-      <if test="delFlag != null">
         del_flag,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=BIGINT},
-      </if>
-      <if test="deviceId != null">
-        #{deviceId,jdbcType=BIGINT},
-      </if>
-      <if test="relateDeviceId != null">
-        #{relateDeviceId,jdbcType=BIGINT},
-      </if>
-      <if test="status != null">
-        #{status,jdbcType=TINYINT},
-      </if>
-      <if test="createBy != null">
-        #{createBy,jdbcType=BIGINT},
-      </if>
-      <if test="createTime != null">
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateBy != null">
-        #{updateBy,jdbcType=BIGINT},
-      </if>
-      <if test="updateTime != null">
-        #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="delFlag != null">
-        #{delFlag,jdbcType=TINYINT},
-      </if>
-    </trim>
-  </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
-    <!--@mbg.generated-->
-    update kws_device_relation
-    <set>
-      <if test="deviceId != null">
-        device_id = #{deviceId,jdbcType=BIGINT},
-      </if>
-      <if test="relateDeviceId != null">
-        relate_device_id = #{relateDeviceId,jdbcType=BIGINT},
-      </if>
-      <if test="status != null">
-        `status` = #{status,jdbcType=TINYINT},
-      </if>
-      <if test="createBy != null">
-        create_by = #{createBy,jdbcType=BIGINT},
-      </if>
-      <if test="createTime != null">
-        create_time = #{createTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="updateBy != null">
-        update_by = #{updateBy,jdbcType=BIGINT},
-      </if>
-      <if test="updateTime != null">
-        update_time = #{updateTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="delFlag != null">
-        del_flag = #{delFlag,jdbcType=TINYINT},
-      </if>
-    </set>
-    where id = #{id,jdbcType=BIGINT}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
-    <!--@mbg.generated-->
-    update kws_device_relation
-    set device_id = #{deviceId,jdbcType=BIGINT},
-      relate_device_id = #{relateDeviceId,jdbcType=BIGINT},
-      `status` = #{status,jdbcType=TINYINT},
-      create_by = #{createBy,jdbcType=BIGINT},
-      create_time = #{createTime,jdbcType=TIMESTAMP},
-      update_by = #{updateBy,jdbcType=BIGINT},
-      update_time = #{updateTime,jdbcType=TIMESTAMP},
-      del_flag = #{delFlag,jdbcType=TINYINT}
-    where id = #{id,jdbcType=BIGINT}
-  </update>
+        mountain_id
+    </sql>
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from kws_device_relation
+        where id = #{id,jdbcType=BIGINT}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        <!--@mbg.generated-->
+        delete
+        from kws_device_relation
+        where id = #{id,jdbcType=BIGINT}
+    </delete>
+    <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
+        <!--@mbg.generated-->
+        insert into kws_device_relation
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="deviceId != null">
+                device_id,
+            </if>
+            <if test="relateDeviceId != null">
+                relate_device_id,
+            </if>
+            <if test="status != null">
+                `status`,
+            </if>
+            <if test="createBy != null">
+                create_by,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateBy != null">
+                update_by,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+            <if test="delFlag != null">
+                del_flag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="deviceId != null">
+                #{deviceId,jdbcType=BIGINT},
+            </if>
+            <if test="relateDeviceId != null">
+                #{relateDeviceId,jdbcType=BIGINT},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=TINYINT},
+            </if>
+            <if test="createBy != null">
+                #{createBy,jdbcType=BIGINT},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateBy != null">
+                #{updateBy,jdbcType=BIGINT},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="delFlag != null">
+                #{delFlag,jdbcType=TINYINT},
+            </if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
+        <!--@mbg.generated-->
+        update kws_device_relation
+        <set>
+            <if test="deviceId != null">
+                device_id = #{deviceId,jdbcType=BIGINT},
+            </if>
+            <if test="relateDeviceId != null">
+                relate_device_id = #{relateDeviceId,jdbcType=BIGINT},
+            </if>
+            <if test="status != null">
+                `status` = #{status,jdbcType=TINYINT},
+            </if>
+            <if test="createBy != null">
+                create_by = #{createBy,jdbcType=BIGINT},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateBy != null">
+                update_by = #{updateBy,jdbcType=BIGINT},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="delFlag != null">
+                del_flag = #{delFlag,jdbcType=TINYINT},
+            </if>
+        </set>
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceRelation">
+        <!--@mbg.generated-->
+        update kws_device_relation
+        set device_id        = #{deviceId,jdbcType=BIGINT},
+            relate_device_id = #{relateDeviceId,jdbcType=BIGINT},
+            `status`         = #{status,jdbcType=TINYINT},
+            create_by        = #{createBy,jdbcType=BIGINT},
+            create_time      = #{createTime,jdbcType=TIMESTAMP},
+            update_by        = #{updateBy,jdbcType=BIGINT},
+            update_time      = #{updateTime,jdbcType=TIMESTAMP},
+            del_flag         = #{delFlag,jdbcType=TINYINT}
+        where id = #{id,jdbcType=BIGINT}
+    </update>
 </mapper>

+ 50 - 4
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml

@@ -70,11 +70,14 @@
                d.device_type  AS deviceType,
                d.manufacturer AS manufacturer,
                d.`name`       AS modelName,
-               c.create_time  AS createTime
+               c.create_time  AS createTime,
+               e.part_name    as partName
         FROM kws_project a
-                 LEFT JOIN kws_project_device b ON a.id = b.project_id and a.mountain_id = b.mountain_id
+                 LEFT JOIN kws_project_device b
+                           ON a.id = b.project_id and a.mountain_id = b.mountain_id
                  LEFT JOIN kws_device c ON b.device_id = c.id and c.mountain_id = b.mountain_id
                  LEFT JOIN kws_device_model d ON c.model_id = d.id and d.mountain_id = c.mountain_id
+                 LEFT JOIN kws_device_model_part e ON e.device_model_id = d.id and d.mountain_id = c.mountain_id
         WHERE a.del_flag = 0
           AND b.del_flag = 0
           AND c.del_flag = 0
@@ -99,15 +102,20 @@
                d.device_type  AS deviceType,
                d.manufacturer AS manufacturer,
                d.`name`       AS deviceModelName,
-               c.create_time  AS createTime
+               c.create_time  AS createTime,
+               e.id           AS deviceRelationId,
+               e.device_id    AS parentId
         FROM kws_project a
-                 LEFT JOIN kws_project_device b ON a.id = b.project_id
+                 LEFT JOIN kws_project_device b
+                           ON a.id = b.project_id
                  LEFT JOIN kws_device c ON b.device_id = c.id
                  LEFT JOIN kws_device_model d ON c.model_id = d.id
+                 LEFT JOIN kws_device_relation e ON e.relate_device_id = c.id
         WHERE a.del_flag = 0
           AND b.del_flag = 0
           AND c.del_flag = 0
           AND d.del_flag = 0
+          AND e.del_flag = 0
         <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
             AND a.id = #{deviceQuery.projectId}
         </if>
@@ -141,6 +149,7 @@
         WHERE a.del_flag = 0
           AND c.del_flag = 0
           AND d.del_flag = 0
+          AND c.relevance_level = 0
           AND c.id NOT in (SELECT DISTINCT a.relate_device_id
                            FROM kws_device_relation a
                                     LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
@@ -163,4 +172,41 @@
             and c.name like concat('%', #{deviceQuery.name}, '%')
         </if>
     </select>
+
+    <select id="selectNotBindDeviceList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
+        SELECT a.id           AS id,
+               a.`status`     AS STATUS,
+               a.`name`       AS NAME,
+               a.create_time  AS createTime,
+               d.device_type  AS deviceType,
+               d.manufacturer AS manufacturer,
+               d.`name`       AS deviceModelName
+        FROM kws_device a
+                 LEFT JOIN kws_device_model d ON d.id = a.model_id
+        WHERE a.mountain_id = d.mountain_id
+          and a.del_flag = 0
+          AND a.del_flag = 0
+          AND d.del_flag = 0
+          AND a.relevance_level = 0
+        <if test="deviceQuery.manufacturer != null and deviceQuery.manufacturer != ''">
+            and d.manufacturer like concat('%'
+              , #{deviceQuery.manufacturer}
+              , '%')
+        </if>
+        <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
+            and d.device_type like concat('%'
+              , #{deviceQuery.deviceType}
+              , '%')
+        </if>
+        <if test="deviceQuery.deviceModel != null and deviceQuery.deviceModel != ''">
+            and d.name like concat('%'
+              , #{deviceQuery.deviceModel}
+              , '%')
+        </if>
+        <if test="deviceQuery.name != null and deviceQuery.name != ''">
+            and a.name like concat('%'
+              , #{deviceQuery.name}
+              , '%')
+        </if>
+    </select>
 </mapper>

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

@@ -189,7 +189,7 @@
             and project_id = #{query.projectId}
         </if>
         <if test="companyId != null and companyId != ''">
-            and company_id = #{companyId,jdbcType=VARCHAR}
+            and mountain_id = #{companyId,jdbcType=VARCHAR}
         </if>
     </select>
 

+ 1 - 3
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsThresholdMapper.xml

@@ -8,7 +8,6 @@
         <result column="device_id" jdbcType="BIGINT" property="deviceId"/>
         <result column="item_name" jdbcType="VARCHAR" property="itemName"/>
         <result column="level" jdbcType="INTEGER" property="level"/>
-        <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
         <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
         <result column="setting" jdbcType="VARCHAR" property="setting"/>
         <result column="max" jdbcType="VARCHAR" property="max"/>
@@ -42,8 +41,7 @@
         create_time,
         update_by,
         update_time,
-        del_flag,
-        company_id
+        del_flag
     </sql>
     <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
         <!--@mbg.generated-->

+ 126 - 0
slope-modules/slope-detection/src/main/resources/mapper/tdengine/DeviceMapper.xml

@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sckw.slope.detection.dao.tdengine.DeviceMapper">
+  <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.tdengine.Device">
+    <!--@mbg.generated-->
+    <!--@Table device-->
+    <id column="ts" jdbcType="TIMESTAMP" property="ts" />
+    <result column="guid" jdbcType="VARCHAR" property="guid" />
+    <result column="tslver" jdbcType="VARCHAR" property="tslver" />
+    <result column="key" jdbcType="VARCHAR" property="key" />
+    <result column="cvalue" jdbcType="VARCHAR" property="cvalue" />
+    <result column="json_text" jdbcType="VARCHAR" property="jsonText" />
+    <result column="sn" jdbcType="VARCHAR" property="sn" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    ts, guid, tslver, "key", cvalue, json_text, sn
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.util.Date" resultMap="BaseResultMap">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from device
+    where ts = #{ts,jdbcType=TIMESTAMP}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.util.Date">
+    <!--@mbg.generated-->
+    delete from device
+    where ts = #{ts,jdbcType=TIMESTAMP}
+  </delete>
+  <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.tdengine.Device">
+    <!--@mbg.generated-->
+    insert into device (ts, guid, tslver, 
+      "key", cvalue, json_text, 
+      sn)
+    values (#{ts,jdbcType=TIMESTAMP}, #{guid,jdbcType=VARCHAR}, #{tslver,jdbcType=VARCHAR}, 
+      #{key,jdbcType=VARCHAR}, #{cvalue,jdbcType=VARCHAR}, #{jsonText,jdbcType=VARCHAR}, 
+      #{sn,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.tdengine.Device">
+    <!--@mbg.generated-->
+    insert into device
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="ts != null">
+        ts,
+      </if>
+      <if test="guid != null">
+        guid,
+      </if>
+      <if test="tslver != null">
+        tslver,
+      </if>
+      <if test="key != null">
+        "key",
+      </if>
+      <if test="cvalue != null">
+        cvalue,
+      </if>
+      <if test="jsonText != null">
+        json_text,
+      </if>
+      <if test="sn != null">
+        sn,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="ts != null">
+        #{ts,jdbcType=TIMESTAMP},
+      </if>
+      <if test="guid != null">
+        #{guid,jdbcType=VARCHAR},
+      </if>
+      <if test="tslver != null">
+        #{tslver,jdbcType=VARCHAR},
+      </if>
+      <if test="key != null">
+        #{key,jdbcType=VARCHAR},
+      </if>
+      <if test="cvalue != null">
+        #{cvalue,jdbcType=VARCHAR},
+      </if>
+      <if test="jsonText != null">
+        #{jsonText,jdbcType=VARCHAR},
+      </if>
+      <if test="sn != null">
+        #{sn,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.tdengine.Device">
+    <!--@mbg.generated-->
+    update device
+    <set>
+      <if test="guid != null">
+        guid = #{guid,jdbcType=VARCHAR},
+      </if>
+      <if test="tslver != null">
+        tslver = #{tslver,jdbcType=VARCHAR},
+      </if>
+      <if test="key != null">
+        "key" = #{key,jdbcType=VARCHAR},
+      </if>
+      <if test="cvalue != null">
+        cvalue = #{cvalue,jdbcType=VARCHAR},
+      </if>
+      <if test="jsonText != null">
+        json_text = #{jsonText,jdbcType=VARCHAR},
+      </if>
+      <if test="sn != null">
+        sn = #{sn,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where ts = #{ts,jdbcType=TIMESTAMP}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.tdengine.Device">
+    <!--@mbg.generated-->
+    update device
+    set guid = #{guid,jdbcType=VARCHAR},
+      tslver = #{tslver,jdbcType=VARCHAR},
+      "key" = #{key,jdbcType=VARCHAR},
+      cvalue = #{cvalue,jdbcType=VARCHAR},
+      json_text = #{jsonText,jdbcType=VARCHAR},
+      sn = #{sn,jdbcType=VARCHAR}
+    where ts = #{ts,jdbcType=TIMESTAMP}
+  </update>
+</mapper>

+ 21 - 2
slope-modules/slope-detection/src/main/resources/mapper/tdengine/SlopeDataMapper.xml

@@ -45,16 +45,35 @@
         SELECT
         <include refid="Base_List">
         </include>
-        FROM devices.slope_data_#{vin}_
+        FROM devices.slope_data_#{snCode}
+        where line = #{item}
+        order by create_time desc limit 1
+    </select>
+
+    <select id="selectListByLineOrderByCreateTime" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
+        SELECT
+        <include refid="Base_List">
+        </include>
+        FROM devices.slope_data_#{snCode}
+        where line = #{item}
+        order by create_time desc limit 2
     </select>
 
     <insert id="insertData" parameterType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
         <!--        insert into devices.slope_data_202_2021-->
-        insert into devices.slope_data_#{slopeData.vin}_#{slopeData.serialNumber} using devices.slope_data (#{slopeData.tagsTitle}) tags (#{slopeData.tags})
+        insert into devices.slope_data_#{slopeData.serialNumber} using devices.slope_data (#{slopeData.tagsTitle}) tags (#{slopeData.tags})
             (ts, raw_id, tslver_id, guid, line, val, create_time)
         VALUES (#{slopeData.ts}, #{slopeData.rawId},
         #{slopeData.tslverId}, #{slopeData.guid},
         #{slopeData.line}, #{slopeData.val}, #{slopeData.createTime})
         <!--        VALUES('2023-12-12 00:00:00.100', '2023-12-12 00:00:00.100', 111, '111', '1111', '111', '2023-12-12 00:00:00.100');-->
     </insert>
+
+    <select id="selectLineList" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_List">
+        </include>
+        FROM devices.slope_data_#{snCode}
+        where line = #{item} and create_time &gt;= #{dateStart} and create_time &lt;= #{dateEnd}
+    </select>
 </mapper>