Просмотр исходного кода

1.项目边坡详情,折线图接口修改
2.项目日志接口查询

lengfaqiang 2 лет назад
Родитель
Сommit
27a625bbe7

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

@@ -33,4 +33,15 @@ public class LogController {
         log.info("日志查询-分页 select param:{}", JSONObject.toJSONString(projectLogQuery));
         return HttpResult.ok(logService.select(projectLogQuery, request));
     }
+
+    /**
+     * 获取操作类型
+     * @param request
+     * @return
+     */
+    @Log(description = "日志查询-操作类型")
+    @RequestMapping(name = "日志查询-操作类型", value = "/selectType", method = RequestMethod.GET)
+    public HttpResult selectType( HttpServletRequest request) {
+        return logService.selectType(request);
+    }
 }

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

@@ -1,10 +1,11 @@
 package com.sckw.slope.detection.model.dos.mysql;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDateTime;
 
 /**
  * @author lfdc
@@ -43,7 +44,8 @@ public class KwsLog implements Serializable {
     /**
      * 操作时间
      */
-    private Date createTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private LocalDateTime createTime;
 
     private static final long serialVersionUID = 1L;
 }

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

@@ -1,10 +1,11 @@
 package com.sckw.slope.detection.model.dos.tdengine;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.time.LocalDateTime;
+import java.util.Date;
 
 /**
  * @author lfdc
@@ -16,8 +17,10 @@ import java.time.LocalDateTime;
 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 LocalDateTime ts;
-    private LocalDateTime rawId;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date ts;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date rawId;
     private int tslverId;
     private String guid;
     private String line;
@@ -28,5 +31,6 @@ public class SlopeData implements Serializable {
     private String serialNumber;
     private String tagsTitle;
     private String tags;
-    private LocalDateTime createTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
 }

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

@@ -12,6 +12,10 @@ import java.io.Serializable;
 @Data
 public class ProjectLogQuery implements Serializable {
 
+    private String content;
+
+    private String type;
+
     private int page;
 
     private int pageSize;

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

@@ -0,0 +1,50 @@
+package com.sckw.slope.detection.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-09 15:11:50
+ */
+@Data
+public class LogSelectVO implements Serializable {
+    private Long id;
+
+    /**
+     * 操作类型
+     */
+    private String type;
+
+    /**
+     * 操作类型
+     */
+    private String typeName;
+
+    /**
+     * 矿山id
+     */
+    private String mountainId;
+
+    /**
+     * 操作内容
+     */
+    private String content;
+
+    /**
+     * 创建人
+     */
+    private String createByName;
+
+    /**
+     * 操作时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private LocalDateTime createTime;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
 import java.util.*;
 
 /**
@@ -110,7 +111,7 @@ public class CommonService {
         log.setMountainId(headerData.getMountainId());
         log.setContent(content);
         log.setCreateBy(operationBy);
-        log.setCreateTime(new Date());
+        log.setCreateTime(LocalDateTime.now());
         return logMapper.insert(log);
     }
 }

+ 14 - 8
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -41,7 +41,6 @@ import org.springframework.util.CollectionUtils;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.time.ZoneOffset;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -370,7 +369,7 @@ public class DeviceService {
                 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));
+                        offsetValue = new BigDecimal(val).divide(new BigDecimal(1000),12,BigDecimal.ROUND_HALF_UP);
                     }
 //                    currentMeasurement.put(itemName, offsetValue);
                     vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
@@ -418,22 +417,29 @@ public class DeviceService {
                     String currentMeasurementTime = "";
                     if (!CollectionUtils.isEmpty(stringList)) {
                         for (int i = 0; i < stringList.size(); i++) {
-                            List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(integrationName, stringList.get(i));
+                            String snCode = kwsDevice.getSnCode();
+                            InsTables insTables = insTablesMapper.selectTableIsExit("slope_data_" + snCode);
+                            if (insTables == null) {
+                                insTablesMapper.createTable("slope_data_" + snCode);
+                            }
+                            List<SlopeData> selected = slopeDataMapper.selectListByLineOrderByCreateTime(snCode, stringList.get(i));
                             if (!CollectionUtils.isEmpty(selected)) {
                                 if (selected.size() == 2) {
                                     SlopeData currSlopeData = selected.get(0);
                                     SlopeData lastSlopeData = selected.get(1);
-                                    LocalDateTime date = currSlopeData.getTs();
+                                    Date date = currSlopeData.getTs();
                                     if (date != null) {
                                         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
                                         currentMeasurementTime = simpleDateFormat.format(date);
                                     }
-                                    LocalDateTime date1 = lastSlopeData.getTs();
-                                    long epochMilli = date.toInstant(ZoneOffset.of("+8")).toEpochMilli();
-                                    long epochMilli1 = date1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                    Date date1 = lastSlopeData.getTs();
+//                                    long epochMilli = date.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                    long epochMilli = date.getTime();
+                                    long epochMilli1 = date1.getTime();
+//                                    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))));
+                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))),12,BigDecimal.ROUND_HALF_UP);
                                 }
                             }
                         }

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

@@ -1,16 +1,25 @@
 package com.sckw.slope.detection.service;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.sckw.core.model.page.PageRes;
+import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.KwsLogMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsLog;
 import com.sckw.slope.detection.model.param.ProjectLogQuery;
+import com.sckw.slope.detection.model.vo.LogSelectVO;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author lfdc
@@ -26,7 +35,30 @@ public class LogService {
 
     public PageRes select(ProjectLogQuery query, HttpServletRequest request) {
         PageHelper.startPage(query.getPage(), query.getPageSize());
+        List<KwsLog> kwsLogs = logMapper.selectList(new LambdaQueryWrapper<KwsLog>()
+                .eq(StringUtils.isNotBlank(query.getType()), KwsLog::getType, query.getType())
+                .like(StringUtils.isNotBlank(query.getContent()), KwsLog::getContent, query.getContent()));
+        PageInfo<KwsLog> info = new PageInfo<>(kwsLogs);
+        if (CollectionUtils.isEmpty(kwsLogs)) {
+            return PageRes.build(info, kwsLogs);
+        }
+        List<LogSelectVO> list = new ArrayList<>();
+        kwsLogs.forEach(projectLog -> {
+            LogSelectVO vo = new LogSelectVO();
+            BeanUtils.copyProperties(projectLog, vo);
+            vo.setTypeName(projectLog.getType());
+            vo.setCreateByName(projectLog.getCreateBy() == null ? null : projectLog.getCreateBy().toString());
+            list.add(vo);
+        });
+        return PageRes.build(info, list);
+    }
+
+    public HttpResult selectType(HttpServletRequest request) {
         List<KwsLog> kwsLogs = logMapper.selectList(null);
-        return null;
+        List<String> typeList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(kwsLogs)) {
+            typeList = kwsLogs.stream().map(KwsLog::getType).distinct().collect(Collectors.toList());
+        }
+        return HttpResult.ok(typeList);
     }
 }

+ 82 - 42
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -19,8 +19,10 @@ 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.InsTablesMapper;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
+import com.sckw.slope.detection.model.dos.tdengine.InsTables;
 import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import com.sckw.slope.detection.model.dto.*;
 import com.sckw.slope.detection.model.param.DeviceQuery;
@@ -38,9 +40,8 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.time.ZoneOffset;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -76,6 +77,9 @@ public class ProjectService {
     @Autowired
     SlopeDataMapper slopeDataMapper;
 
+    @Autowired
+    InsTablesMapper insTablesMapper;
+
     @Autowired
     KwsProjectDeviceMapper projectDeviceMapper;
 
@@ -440,6 +444,7 @@ public class ProjectService {
                 //集成要素-测量值计算
                 integrationItem(headerData, deviceId, kwsDevice, returnList, type);
             }
+            returnList = returnList.stream().distinct().collect(Collectors.toList());
             return HttpResult.ok(returnList);
         } else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
             String deviceId = param.getDeviceId();
@@ -491,7 +496,7 @@ public class ProjectService {
         if (!CollectionUtils.isEmpty(longList)) {
             List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
                     .in(KwsIntegration::getId, longList)
-                    .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type),KwsIntegration::getIntegrationName,type));
+                    .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type), KwsIntegration::getIntegrationName, type));
             if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
                 kwsIntegrations.forEach(integration -> {
                     Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
@@ -576,22 +581,27 @@ public class ProjectService {
                                 for (int i = 0; i < selected.size(); i++) {
                                     Map<String, Object> map = new HashMap<>();
                                     SlopeData currSlopeData = selected.get(i);
-                                    String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+//                                    String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+                                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+                                    String key = simpleDateFormat.format(currSlopeData.getTs());
                                     SlopeData lastSlopeData = selected.get(i + 1);
-                                    LocalDateTime localDateTime = currSlopeData.getTs();
+                                    Date localDateTime = currSlopeData.getTs();
                                     long epochMilli1 = 0L;
                                     String val2 = "0";
-                                    LocalDateTime localDateTime1 = lastSlopeData.getTs();
+                                    Date localDateTime1 = lastSlopeData.getTs();
                                     if (lastSlopeData != null) {
-                                        epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+//                                        epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                        epochMilli1 = localDateTime1.getTime();
                                         val2 = lastSlopeData.getVal();
                                     }
-                                    long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
-                                    epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+//                                    long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                    long epochMilli = localDateTime.getTime();
+//                                    epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                    epochMilli1 = localDateTime1.getTime();
                                     String val1 = currSlopeData.getVal();
                                     long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
                                     long val = Long.parseLong(val1) - Long.parseLong(val2);
-                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
+                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
                                     map.put(key, decimal);
                                     mapList.add(map);
                                 }
@@ -692,8 +702,10 @@ public class ProjectService {
                             for (SlopeData message : selected) {
                                 BigDecimal offsetValue = new BigDecimal("0.00");
                                 Map<String, Object> datemap = new HashMap<>(NumberConstant.SIXTEEN);
-                                LocalDateTime createTime = message.getCreateTime();
-                                String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+                                Date createTime = message.getTs();
+//                                String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
+                                String key = simpleDateFormat.format(createTime);
                                 String line = message.getLine();
                                 String val1 = message.getVal();
                                 if (itemList.contains(partName)) {
@@ -702,7 +714,7 @@ public class ProjectService {
                                         double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
                                         double cosValue = Math.cos(angleInRadians);
                                         if (org.apache.commons.lang3.StringUtils.isNotBlank(val1)) {
-                                            double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
+                                            double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
                                             offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
                                         }
                                     }
@@ -720,7 +732,7 @@ public class ProjectService {
                                 if (itemList.contains(partName)) {
                                     if (Objects.nonNull(currentValue)) {
                                         if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
-                                            offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
+                                            offsetValue = new BigDecimal(line).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
                                         }
                                     }
                                 }
@@ -753,7 +765,7 @@ public class ProjectService {
         if (!CollectionUtils.isEmpty(longList)) {
             List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
                     .in(KwsIntegration::getId, longList)
-                    .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type),KwsIntegration::getIntegrationName,type));
+                    .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type), KwsIntegration::getIntegrationName, type));
             if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
                 kwsIntegrations.forEach(integration -> {
                     Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
@@ -832,36 +844,59 @@ public class ProjectService {
                             Date date = new Date();
                             String dateStart = DateUtil.getDateTimeToHour(date, 24);
                             String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
+                            String snCode = kwsDevice.getSnCode();
+                            InsTables insTables = insTablesMapper.selectTableIsExit("slope_data_" + snCode);
+                            if (insTables == null) {
+                                insTablesMapper.createTable("slope_data_" + snCode);
+                            }
                             List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), item, dateStart, dateEnd);
                             List<Map<String, Object>> mapList = new ArrayList<>();
                             if (!CollectionUtils.isEmpty(selected)) {
                                 for (int i = 0; i < selected.size(); i++) {
                                     Map<String, Object> map = new HashMap<>();
                                     SlopeData currSlopeData = selected.get(i);
-                                    String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
-                                    SlopeData lastSlopeData = selected.get(i + 1);
-                                    LocalDateTime localDateTime = currSlopeData.getTs();
-                                    long epochMilli1 = 0L;
-                                    String val2 = "0";
-                                    LocalDateTime localDateTime1 = lastSlopeData.getTs();
-                                    if (lastSlopeData != null) {
-                                        epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
-                                        val2 = lastSlopeData.getVal();
+//                                    String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+                                    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+                                    String key = simpleDateFormat.format(currSlopeData.getTs());
+                                    if (i == selected.size() - 1) {
+//                                        Date localDateTime = currSlopeData.getTs();
+//                                        long epochMilli1 = 0L;
+//                                        String val2 = "0";
+//                                        long epochMilli = localDateTime.getTime();
+//                                        String val1 = currSlopeData.getVal();
+//                                        long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
+//                                        long val = Long.parseLong(val1) - Long.parseLong(val2);
+//                                        decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
+                                        map.put(key, decimal);
+                                        mapList.add(map);
+                                    } else {
+                                        SlopeData lastSlopeData = selected.get(i + 1);
+                                        Date localDateTime = currSlopeData.getTs();
+                                        long epochMilli1 = 0L;
+                                        String val2 = "0";
+                                        Date localDateTime1 = lastSlopeData.getTs();
+                                        if (lastSlopeData != null) {
+//                                        epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                            epochMilli1 = localDateTime1.getTime();
+                                            val2 = lastSlopeData.getVal();
+                                        }
+//                                    long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                        long epochMilli = localDateTime.getTime();
+//                                    epochMilli1= localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
+                                        epochMilli1 = localDateTime1.getTime();
+                                        String val1 = currSlopeData.getVal();
+                                        long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
+                                        long val = Long.parseLong(val1) - Long.parseLong(val2);
+                                        decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
+                                        map.put(key, decimal);
+                                        mapList.add(map);
                                     }
-                                    long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
-                                    epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
-                                    String val1 = currSlopeData.getVal();
-                                    long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
-                                    long val = Long.parseLong(val1) - Long.parseLong(val2);
-                                    decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
-                                    map.put(key, decimal);
-                                    mapList.add(map);
                                 }
+                                projectCatLogVO.setType(integrationName);
+                                projectCatLogVO.setMonitor(mapList);
+                                returnMap.put(integrationName, projectCatLogVO);
+                                returnList.add(returnMap);
                             }
-                            projectCatLogVO.setType(integrationName);
-                            projectCatLogVO.setMonitor(mapList);
-                            returnMap.put(integrationName, projectCatLogVO);
-                            returnList.add(returnMap);
                         }
                     }
                 });
@@ -960,18 +995,23 @@ public class ProjectService {
                         for (SlopeData message : selected) {
                             BigDecimal offsetValue = new BigDecimal("0.00");
                             Map<String, Object> datemap = new HashMap<>(NumberConstant.SIXTEEN);
-                            LocalDateTime createTime = message.getCreateTime();
-                            String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+                            Date createTime = message.getTs();
+//                            String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
+                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
+                            String key = format.format(createTime);
                             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 angleInRadians = Math.toRadians(selected == null ? 0L : (selectListByLine == null ? 0L : Double.parseDouble(selectListByLine.getVal())));
                                     double cosValue = Math.cos(angleInRadians);
                                     if (org.apache.commons.lang3.StringUtils.isNotBlank(val1)) {
-                                        double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
-                                        offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
+                                        BigDecimal subtract = new BigDecimal(val1).subtract(currentValue);
+                                        if (subtract.compareTo(new BigDecimal("0.00")) != 0) {
+                                            double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
+                                            offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
+                                        }
                                     }
                                 }
                             }
@@ -988,7 +1028,7 @@ public class ProjectService {
                             if (itemList.contains(partName)) {
                                 if (Objects.nonNull(currentValue)) {
                                     if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
-                                        offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
+                                        offsetValue = new BigDecimal(line).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
                                     }
                                 }
                             }

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

@@ -9,7 +9,7 @@ import com.sckw.slope.detection.model.vo.SlopeDataVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.time.LocalDateTime;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -31,7 +31,7 @@ public class TdengineDemoService {
         List<SlopeDataVo> list1 = slopeDataMapper.selectList();
         System.out.println(JSONObject.toJSONString(list1));
         SlopeData data = new SlopeData();
-        LocalDateTime now = LocalDateTime.now();
+        Date now = new Date();
         data.setTs(now);
         data.setRawId(now);
         data.setTslverId(1);
@@ -43,14 +43,14 @@ public class TdengineDemoService {
         data.setSerialNumber("7");
         data.setTagsTitle("name");
         data.setTags("sss");
-        data.setCreateTime(now);
+        data.setCreateTime(new Date());
         int insert = slopeDataMapper.insertData(data);
     }
 
     public void getTable() {
         String tableName = "slope_data_6_7";
         InsTables insTables = insTablesMapper.selectTableIsExit(tableName);
-        if (insTables != null){
+        if (insTables != null) {
         }
     }
 

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

@@ -5,7 +5,7 @@
     <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
         <!--@mbg.generated-->
         <!--@Table slope_data-->
-        <id column="ts" jdbcType="TIMESTAMP" property="tslverId"/>
+        <id column="ts" jdbcType="TIMESTAMP" property="ts"/>
         <result column="rawId" jdbcType="TIMESTAMP" property="rawId"/>
         <result column="tslverId" jdbcType="TINYINT" property="tslverId"/>
         <result column="guid" jdbcType="VARCHAR" property="guid"/>
@@ -67,7 +67,7 @@
         <!--        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 id="selectLineList" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
         SELECT
         <include refid="Base_List">
         </include>