Эх сурвалжийг харах

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

lengfaqiang 2 жил өмнө
parent
commit
eb6c007edf

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

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

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

@@ -24,10 +24,12 @@ public interface KwsProjectMapper extends BaseMapper<KwsProject> {
      */
     List<ProjectVo> selectByProjectParam(@Param("projectQueryDto") ProjectQuery projectQueryDto, @Param("companyId") String companyId);
 
-    List<ProjectDeviceVO> selectDeviceByProjectId(@Param("mountainId") String mountainId, @Param("projectId") Long projectId, @Param("deviceId") Long deviceId);
+    List<ProjectDeviceVO> selectDeviceByProjectId(@Param("mountainId") String mountainId, @Param("projectId") Long projectId,
+                                                  @Param("deviceId") Long deviceId, @Param("type") String type);
 
     List<ProjectDeviceVO> selectDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery);
 
     List<ProjectDeviceVO> selectDeviceNotBindList(@Param("deviceQuery") DeviceQuery deviceQuery);
+
     List<ProjectDeviceVO> selectNotBindDeviceList(@Param("deviceQuery") DeviceQuery deviceQuery);
 }

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

@@ -22,7 +22,7 @@ public class KwsIntegration implements Serializable {
     /**
      * 企业id
      */
-    private String companyId;
+    private String mountainId;
 
     /**
      * 要素名称字符串

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

@@ -0,0 +1,18 @@
+package com.sckw.slope.detection.model.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author lfdc
+ * @description 分页查询项目dto
+ * @date 2023-10-30 13:10:38
+ */
+@Data
+public class ProjectLogQuery implements Serializable {
+
+    private int page;
+
+    private int pageSize;
+}

+ 4 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/vo/ProjectCatLogVO.java

@@ -41,4 +41,8 @@ public class ProjectCatLogVO implements Serializable {
      */
     private List<Map<String, Object>> monitor;
 
+    /**
+     * 要素类型
+     */
+    private String type;
 }

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

@@ -284,7 +284,7 @@ public class DeviceService {
                 headerData.getMountainId(), status, Long.parseLong(deviceId));
 
 
-        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(headerData.getMountainId(), Long.parseLong(projectId), Long.parseLong(deviceId));
+        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(headerData.getMountainId(), Long.parseLong(projectId), Long.parseLong(deviceId),null);
         List<String> deviceIds = new ArrayList<>();
         if (!CollectionUtils.isEmpty(projectDeviceList)) {
             deviceIds = projectDeviceList.stream().map(ProjectDeviceVO::getId).distinct().collect(Collectors.toList());

+ 32 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/LogService.java

@@ -0,0 +1,32 @@
+package com.sckw.slope.detection.service;
+
+import com.github.pagehelper.PageHelper;
+import com.sckw.core.model.page.PageRes;
+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 jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author lfdc
+ * @description 日志service
+ * @date 2023-11-09 14:11:21
+ */
+@Slf4j
+@Service
+public class LogService {
+
+    @Autowired
+    KwsLogMapper logMapper;
+
+    public PageRes select(ProjectLogQuery query, HttpServletRequest request) {
+        PageHelper.startPage(query.getPage(), query.getPageSize());
+        List<KwsLog> kwsLogs = logMapper.selectList(null);
+        return null;
+    }
+}

+ 224 - 80
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -38,7 +38,6 @@ 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.time.ZoneOffset;
 import java.time.format.DateTimeFormatter;
@@ -410,6 +409,7 @@ public class ProjectService {
         HeaderData headerData = commonService.getHeaderData(request);
         String latitude = param.getLatitude();
         String projectId = param.getProjectId();
+        String type = param.getType();
         if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
             String deviceId = param.getDeviceId();
             String mountainId = headerData.getMountainId();
@@ -421,14 +421,25 @@ public class ProjectService {
             if (kwsDevice == null) {
                 return HttpResult.ok();
             }
-            //当前设备下的所有基本要素
             List<Map<String, ProjectCatLogVO>> returnList = new ArrayList<>();
-            basicItem(mountainId, projectId, deviceId, kwsDevice, returnList);
-
-            //集成要素 折线图
-            //集成要素-测量值计算
-            integrationItem(headerData, deviceId, kwsDevice, returnList);
-            LocalDateTime localDateTime = DateUtil.localDateToLocalDateTimeStart(LocalDate.now());
+            Map<String, SystemDict> dictByDictCode = new HashMap<>();
+            if (Objects.nonNull(type)) {
+                dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+                if (dictByDictCode.get(type) != null) {
+                    //当前设备下的所有基本要素
+                    basicItem(mountainId, projectId, deviceId, kwsDevice, returnList, type);
+                } else {
+                    //集成要素 折线图
+                    //集成要素-测量值计算
+                    integrationItem(headerData, deviceId, kwsDevice, returnList, type);
+                }
+            } else {
+                //当前设备下的所有基本要素
+                basicItem(mountainId, projectId, deviceId, kwsDevice, returnList, type);
+                //集成要素 折线图
+                //集成要素-测量值计算
+                integrationItem(headerData, deviceId, kwsDevice, returnList, type);
+            }
             return HttpResult.ok(returnList);
         } else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
             String deviceId = param.getDeviceId();
@@ -441,36 +452,159 @@ public class ProjectService {
             if (kwsDevice == null) {
                 return HttpResult.ok();
             }
-//            List<String> dateTimeDay = DateUtil.getDateTimeDay(LocalDateTime.now(), 7, new ArrayList<String>());
-            List<Date> dateTimeDay = DateUtil.getDateTimeDayToDate(LocalDateTime.now(), 7, new ArrayList<Date>());
-            for (Date dateTime : dateTimeDay) {
+            List<Map<String, ProjectCatLogVO>> returnList = new ArrayList<>();
+            Map<String, SystemDict> dictByDictCode = new HashMap<>();
+            if (Objects.nonNull(type)) {
+                dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+                if (dictByDictCode.get(type) != null) {
+                    List<Date> dateTimeDay = DateUtil.getDateTimeDayToDate(LocalDateTime.now(), 7, new ArrayList<>());
+                    //当前设备下的所有基本要素
+                    basicItemByWeek(mountainId, projectId, deviceId, kwsDevice, returnList, dateTimeDay, type);
+                } else {
+                    //集成要素-测量值计算
+                    integrationItemWeek(headerData, deviceId, kwsDevice, returnList, type);
+                }
+            } else {
+                List<Date> dateTimeDay = DateUtil.getDateTimeDayToDate(LocalDateTime.now(), 7, new ArrayList<>());
                 //当前设备下的所有基本要素
-                List<ProjectCatLogVO> returnList = new ArrayList<>();
-                basicItemByWeek(mountainId, projectId, deviceId, kwsDevice, returnList, dateTime);
+                basicItemByWeek(mountainId, projectId, deviceId, kwsDevice, returnList, dateTimeDay, type);
+                integrationItemWeek(headerData, deviceId, kwsDevice, returnList, type);
             }
-            /**下面是查询当天每小时数据总量的代码示例:
-
-             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;*/
-
+            return HttpResult.ok(returnList);
         } else if (String.valueOf(NumberConstant.TWO).equals(latitude)) {
         } else if (String.valueOf(NumberConstant.ONE).equals(latitude)) {
         } else {
             throw new BusinessException("数据传输异常");
         }
-        return null;
+        return HttpResult.ok();
+    }
+
+    private void integrationItemWeek(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
+        List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
+                .eq(KwsDeviceIntegration::getMountainId, headerData.getMountainId())
+                .eq(KwsDeviceIntegration::getDeviceId, deviceId)
+        );
+        List<Long> longList = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(deviceIntegrations)) {
+            longList = deviceIntegrations.stream().map(KwsDeviceIntegration::getIntegrationId).collect(Collectors.toList());
+        }
+        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));
+            if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
+                kwsIntegrations.forEach(integration -> {
+                    Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
+                    ProjectCatLogVO projectCatLogVO = new ProjectCatLogVO();
+                    String integrationName = integration.getIntegrationName();
+                    String partNames = integration.getPartNames();
+                    List<KwsDeviceReference> referenceList = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
+                            .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
+                            .eq(KwsDeviceReference::getDeviceId, Long.parseLong(deviceId))
+                            .eq(KwsDeviceReference::getItem, integrationName)
+                            .eq(KwsDeviceReference::getDelFlag, 0)
+                            .eq(KwsDeviceReference::getType, 2)
+                    );
+                    //当前基准值
+                    projectCatLogVO.setReference(CollectionUtils.isEmpty(referenceList) ? null :
+                            (referenceList.get(0).getCurrentValue() == null ? null : referenceList.get(0).getCurrentValue()));
+                    //当前要素阈值
+                    List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
+                            .eq(KwsThreshold::getDelFlag, 0)
+                            .eq(KwsThreshold::getItemName, integrationName)
+                            .eq(KwsThreshold::getMountainId, headerData.getMountainId())
+                            .eq(KwsThreshold::getDeviceId, deviceId)
+                    );
+                    Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
+                    if (!CollectionUtils.isEmpty(kwsThresholds)) {
+                        listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
+                    }
+                    //阈值等级map
+//                Map<String, Map<String, String>> thresholdMap = new HashMap<>();
+//                Map<String, String> map = new HashMap<>();
+                    ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
+                    String thresholdMax = "";
+                    String thresholdMin = "";
+                    if (listMap.get(1) != null) {
+                        KwsThreshold kwsThreshold = listMap.get(1).get(0);
+                        thresholdMax = kwsThreshold.getMax();
+                        thresholdMin = kwsThreshold.getMin();
+                        thresholdLevelVO.setThresholdMax(thresholdMax);
+                        thresholdLevelVO.setThresholdMin(thresholdMin);
+//                    map.put("thresholdMax", thresholdMax);
+//                    map.put("thresholdMin", thresholdMin);
+                    }
+//                thresholdMap.put("oneLevelAlarm", map);
+                    projectCatLogVO.setOneLevelAlarm(thresholdLevelVO);
+                    if (listMap.get(2) != null) {
+                        KwsThreshold kwsThreshold = listMap.get(2).get(0);
+                        thresholdMax = kwsThreshold.getMax();
+                        thresholdMin = kwsThreshold.getMin();
+                        thresholdLevelVO.setThresholdMax(thresholdMax);
+                        thresholdLevelVO.setThresholdMin(thresholdMin);
+//                    map.put("thresholdMax", thresholdMax);
+//                    map.put("thresholdMin", thresholdMin);
+                    }
+//                thresholdMap.put("twoLevelAlarm", map);
+                    projectCatLogVO.setTwoLevelAlarm(thresholdLevelVO);
+
+                    if (listMap.get(3) != null) {
+                        KwsThreshold kwsThreshold = listMap.get(3).get(0);
+                        thresholdMax = kwsThreshold.getMax();
+                        thresholdMin = kwsThreshold.getMin();
+                        thresholdLevelVO.setThresholdMax(thresholdMax);
+                        thresholdLevelVO.setThresholdMin(thresholdMin);
+//                    map.put("thresholdMax", thresholdMax);
+//                    map.put("thresholdMin", thresholdMin);
+                    }
+//                thresholdMap.put("threeLevelAlarm", map);
+                    projectCatLogVO.setThreeLevelAlarm(thresholdLevelVO);
+
+                    //当前测量值-TD获取
+                    String formula = integration.getFormula();
+                    List<String> stringList = StringUtils.splitStrToList(partNames, String.class);
+                    if (!CollectionUtils.isEmpty(stringList)) {
+                        for (String item : stringList) {
+                            //当前仅有加速度
+                            BigDecimal decimal = new BigDecimal("0.00");
+                            Date date = new Date();
+                            String dateStart = DateUtil.getDateTimeToHour(date, 24);
+                            String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
+                            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();
+                                    }
+                                    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);
+                        }
+                    }
+                });
+            }
+        }
     }
 
     /**
@@ -481,14 +615,17 @@ public class ProjectService {
      * @param deviceId   所属设备
      * @param kwsDevice  设备信息
      * @param returnList 返回数据
-     * @param date       时间范围
+     * @param dateList   时间范围
      */
-    private void basicItemByWeek(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<ProjectCatLogVO> returnList, Date date) {
-        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
+    private void basicItemByWeek(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, List<Date> dateList, String type) {
+        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId), type);
         if (!CollectionUtils.isEmpty(projectDeviceList)) {
             for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
+                Map<String, ProjectCatLogVO> returnMap = new HashMap<>();
                 ProjectCatLogVO returnVO = new ProjectCatLogVO();
                 String partName = projectDeviceVO.getPartName();
+                Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+                String itemName = dictByDictCode.get(partName) == null ? partName : dictByDictCode.get(partName).getLabel();
                 //设置过阈值的基本要素
                 List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
                         .eq(KwsDeviceReference::getDeviceId, deviceId)
@@ -516,25 +653,24 @@ public class ProjectService {
                 ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
                 String thresholdMax = "";
                 String thresholdMin = "";
-                if (listMap.get("1") != null) {
-                    KwsThreshold kwsThreshold = listMap.get("1").get(0);
+                if (listMap.get(1) != null) {
+                    KwsThreshold kwsThreshold = listMap.get(1).get(0);
                     thresholdMax = kwsThreshold.getMax();
                     thresholdMin = kwsThreshold.getMin();
                     thresholdLevelVO.setThresholdMax(thresholdMax);
                     thresholdLevelVO.setThresholdMin(thresholdMin);
                 }
                 returnVO.setOneLevelAlarm(thresholdLevelVO);
-                if (listMap.get("2") != null) {
-                    KwsThreshold kwsThreshold = listMap.get("2").get(0);
+                if (listMap.get(2) != null) {
+                    KwsThreshold kwsThreshold = listMap.get(2).get(0);
                     thresholdMax = kwsThreshold.getMax();
                     thresholdMin = kwsThreshold.getMin();
                     thresholdLevelVO.setThresholdMax(thresholdMax);
                     thresholdLevelVO.setThresholdMin(thresholdMin);
                 }
                 returnVO.setTwoLevelAlarm(thresholdLevelVO);
-
-                if (listMap.get("3") != null) {
-                    KwsThreshold kwsThreshold = listMap.get("3").get(0);
+                if (listMap.get(3) != null) {
+                    KwsThreshold kwsThreshold = listMap.get(3).get(0);
                     thresholdMax = kwsThreshold.getMax();
                     thresholdMin = kwsThreshold.getMin();
                     thresholdLevelVO.setThresholdMax(thresholdMax);
@@ -548,52 +684,56 @@ public class ProjectService {
                     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) {
-                            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"));
-                            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(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));
+                    for (int i = 0; i < dateList.size(); i++) {
+                        String dateStart = DateUtil.getDateTimeToHour(dateList.get(i), 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) {
+                                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"));
+                                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(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));
+                                        }
                                     }
                                 }
-                            }
-                            itemList.add(DictItemEnum.LATITUDE_Y.getValue());
-                            if (itemList.contains(partName)) {
-                                if (Objects.nonNull(currentValue)) {
-                                    if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
-                                        offsetValue = new BigDecimal(line).subtract(currentValue);
+                                itemList.add(DictItemEnum.LATITUDE_Y.getValue());
+                                if (itemList.contains(partName)) {
+                                    if (Objects.nonNull(currentValue)) {
+                                        if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
+                                            offsetValue = new BigDecimal(line).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(line)) {
-                                        offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
+                                itemList.clear();
+                                itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
+                                if (itemList.contains(partName)) {
+                                    if (Objects.nonNull(currentValue)) {
+                                        if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
+                                            offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
+                                        }
                                     }
                                 }
+                                datemap.put(key, offsetValue);
+                                mapList.add(datemap);
                             }
-                            datemap.put(key, offsetValue);
-                            mapList.add(datemap);
                         }
                     }
                 }
+                returnVO.setType(partName);
                 returnVO.setMonitor(mapList);
-                returnList.add(returnVO);
+                returnMap.put(itemName, returnVO);
+                returnList.add(returnMap);
             }
         }
     }
@@ -601,7 +741,7 @@ public class ProjectService {
     /**
      * 集成要素折线图计算
      */
-    private void integrationItem(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList) {
+    private void integrationItem(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
         List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
                 .eq(KwsDeviceIntegration::getMountainId, headerData.getMountainId())
                 .eq(KwsDeviceIntegration::getDeviceId, deviceId)
@@ -611,7 +751,9 @@ public class ProjectService {
             longList = deviceIntegrations.stream().map(KwsDeviceIntegration::getIntegrationId).collect(Collectors.toList());
         }
         if (!CollectionUtils.isEmpty(longList)) {
-            List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>().in(KwsIntegration::getId, longList));
+            List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
+                    .in(KwsIntegration::getId, longList)
+                    .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);
@@ -716,6 +858,7 @@ public class ProjectService {
                                     mapList.add(map);
                                 }
                             }
+                            projectCatLogVO.setType(integrationName);
                             projectCatLogVO.setMonitor(mapList);
                             returnMap.put(integrationName, projectCatLogVO);
                             returnList.add(returnMap);
@@ -729,8 +872,8 @@ public class ProjectService {
     /**
      * 折线图 基本要素
      */
-    private void basicItem(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList) {
-        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
+    private void basicItem(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
+        List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId), type);
         if (!CollectionUtils.isEmpty(projectDeviceList)) {
             for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
                 Map<String, ProjectCatLogVO> returnMap = new HashMap<>();
@@ -854,6 +997,7 @@ public class ProjectService {
                         }
                     }
                 }
+                returnVO.setType(partName);
                 returnVO.setMonitor(mapList);
                 returnMap.put(itemName, returnVO);
                 returnList.add(returnMap);

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

@@ -12,7 +12,7 @@
     <result column="remark" jdbcType="VARCHAR" property="remark" />
     <result column="status" jdbcType="TINYINT" property="status" />
     <result column="create_by" jdbcType="BIGINT" property="createBy" />
-      <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
+    <result column="mountain_id" jdbcType="VARCHAR" property="mountainId" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_by" jdbcType="BIGINT" property="updateBy" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />

+ 3 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsProjectMapper.xml

@@ -91,6 +91,9 @@
         <if test="deviceId != null and deviceId != ''">
             AND c.id = #{deviceId}
         </if>
+        <if test="type != null and type != ''">
+           and  e.part_name  = #{type}
+        </if>
     </select>
 
     <select id="selectDeviceList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">