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

1.修改型号update-bug
2.统计图表默认值
3.阈值告警修改

lengfaqiang 2 лет назад
Родитель
Сommit
25ad99ec3b
19 измененных файлов с 372 добавлено и 98 удалено
  1. 22 0
      slope-common/slope-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java
  2. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttCallbackHandler.java
  3. 2 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsDeviceMapper.java
  4. 7 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/mysql/KwsThresholdMapper.java
  5. 3 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsDeviceModel.java
  6. 3 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProject.java
  7. 2 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ThresholdBean.java
  8. 1 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ThresholdSelectDTO.java
  9. 3 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/ThresholdQuery.java
  10. 15 11
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceModelService.java
  11. 15 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java
  12. 81 17
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java
  13. 147 59
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java
  14. 7 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/KwsDeviceModelRepository.java
  15. 7 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/KwsProjectRepository.java
  16. 17 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/impl/KwsDeviceModelImpl.java
  17. 17 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/impl/KwsProjectImpl.java
  18. 7 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsDeviceMapper.xml
  19. 15 0
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsThresholdMapper.xml

+ 22 - 0
slope-common/slope-common-excel/src/main/java/com/sckw/excel/utils/DateUtil.java

@@ -1095,6 +1095,28 @@ public class DateUtil {
     }
 
 
+    /**
+     * 获取当前时间的前${amount}时间的每个小时(包含当前的小时)
+     *
+     * @param date   当前时间
+     * @param amount 当前时间的前多少小时
+     * @return
+     */
+    public static String getDateTimeEndToHour(Date date, int amount) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:59:59.999");
+        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即为一周]
      *

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/MqttCallbackHandler.java

@@ -43,7 +43,7 @@ import java.util.stream.Collectors;
  * @date 2023-10-26 08:10:45
  */
 @Slf4j
-@Service("system/iot/deviceDataSlopeDemo")
+@Service("system/iot/device_data_slope")
 public class MqttCallbackHandler extends AbstractHandler {
 
     @Value("${sms.url}")

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

@@ -5,12 +5,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
 import com.sckw.slope.detection.model.dto.DeviceDataDTO;
 import com.sckw.slope.detection.model.dto.ThresholdSelectDTO;
+import com.sckw.slope.detection.model.param.DeviceQuery;
 import com.sckw.slope.detection.model.vo.AffiliationDeviceVO;
+import com.sckw.slope.detection.model.vo.DeviceVo;
 import com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
-import com.sckw.slope.detection.model.vo.DeviceVo;
-import com.sckw.slope.detection.model.param.DeviceQuery;
 
 import java.util.List;
 import java.util.Map;

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

@@ -3,7 +3,12 @@ package com.sckw.slope.detection.dao.mysql;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsThreshold;
+import com.sckw.slope.detection.model.dto.HeaderData;
+import com.sckw.slope.detection.model.param.ThresholdQuery;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 @Mapper
 @DS("mysql")
@@ -17,4 +22,6 @@ public interface KwsThresholdMapper extends BaseMapper<KwsThreshold> {
     int updateByPrimaryKeySelective(KwsThreshold record);
 
     int updateByPrimaryKey(KwsThreshold record);
+
+    List<KwsThreshold> selectListAll(@Param("thresholdQuery") ThresholdQuery thresholdQuery, @Param("headerData") HeaderData headerData, @Param("status") List<Integer> status);
 }

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

@@ -1,12 +1,12 @@
 package com.sckw.slope.detection.model.dos.mysql;
 
-import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 
 import java.io.Serializable;
 import java.time.LocalDateTime;
-import java.util.Date;
 
 /**
  * @author lfdc
@@ -53,6 +53,7 @@ public class KwsDeviceModel implements Serializable {
     /**
      * 备注
      */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private String remark;
 
     /**

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsProject.java

@@ -1,5 +1,7 @@
 package com.sckw.slope.detection.model.dos.mysql;
 
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
@@ -80,6 +82,7 @@ public class KwsProject implements Serializable {
     /**
      * 备注
      */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private String remark;
 
     /**

+ 2 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ThresholdBean.java

@@ -18,6 +18,6 @@ public class ThresholdBean implements Serializable {
      */
 
     private int level;
-    private String max;
-    private String min;
+    private long max;
+    private long min;
 }

+ 1 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dto/ThresholdSelectDTO.java

@@ -19,7 +19,7 @@ public class ThresholdSelectDTO implements Serializable {
     private String deviceAlias;
 
     /**
-     * 项目主键ID
+     * 阈值主键ID
      */
     private String id;
 

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

@@ -15,7 +15,9 @@ public class ThresholdQuery implements Serializable {
     private String projectId;
 
     private int page;
-
+    private String alarmLevel;
+    private String alarmInfo;
+    private int status;
     private int pageSize;
 
     /**

+ 15 - 11
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceModelService.java

@@ -24,6 +24,7 @@ import com.sckw.slope.detection.model.param.DeviceModelQuery;
 import com.sckw.slope.detection.model.vo.DeviceModelVo;
 import com.sckw.slope.detection.model.vo.DevicePartModelVo;
 import com.sckw.slope.detection.model.vo.IntegrationItemVO;
+import com.sckw.slope.detection.service.repository.KwsDeviceModelRepository;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -60,7 +61,7 @@ public class DeviceModelService {
      * 项目管理分页查询
      *
      * @param deviceModelQuery 请求分页
-     * @param response        http流
+     * @param response         http流
      * @return 返回值
      */
     public PageRes select(DeviceModelQuery deviceModelQuery, HttpServletRequest response) {
@@ -79,7 +80,7 @@ public class DeviceModelService {
 
         for (DeviceModelVo vo : list) {
             vo.setStatusText(DeviceEnum.getName(vo.getStatus()));
-            for(SystemDict value : dictList.values()) {
+            for (SystemDict value : dictList.values()) {
                 if (vo.getDeviceType().equals(value.getValue())) {
                     vo.setDeviceType(value.getLabel());
                 }
@@ -93,7 +94,7 @@ public class DeviceModelService {
      * 设备型号新增
      *
      * @param deviceModelAdd 请求参数
-     * @param request       http流
+     * @param request        http流
      * @return 返回值
      */
     @Transactional
@@ -124,7 +125,7 @@ public class DeviceModelService {
         BeanUtils.copyProperties(device, vo);
         vo.setStatusText(DeviceEnum.getName(vo.getStatus()));
         //获取要数
-        List<DevicePartModelVo> deviceModelPart= kwsDeviceModelPartMapper.selectByModelId(vo.getId());
+        List<DevicePartModelVo> deviceModelPart = kwsDeviceModelPartMapper.selectByModelId(vo.getId());
         //获取字典
         Map<String, SystemDict> dictList = commonService.getDictList(null, new HashMap<String, String>() {{
             put("code", DictEnum.MODEL_PART.getCodeType());
@@ -136,13 +137,13 @@ public class DeviceModelService {
         //Map<String,IntegrationItemVO> map = new HashMap<>();
         List<IntegrationItemVO> dataList = new ArrayList<>();
         for (DevicePartModelVo part : deviceModelPart) {
-            for(SystemDict value : dictList.values()){
-                if(part.getPartName().equals(value.getValue())){
+            for (SystemDict value : dictList.values()) {
+                if (part.getPartName().equals(value.getValue())) {
                     partData.add(value.getLabel());
                     //查询对应的集成要素
                     List<IntegrationItemVO> integrationItemVO = kwsIntegrationMapper.getDataByFindInSet(value.getValue());
                     for (IntegrationItemVO intvo : integrationItemVO) {
-                        if(!intList.contains(intvo.getId())){//判断是否存在
+                        if (!intList.contains(intvo.getId())) {//判断是否存在
                             intList.add(intvo.getId());
                             dataList.add(intvo);
                         }
@@ -152,7 +153,7 @@ public class DeviceModelService {
         }
         //获取集成要素-end
         List<SystemDict> systemDict = new ArrayList<>();
-        for(SystemDict value : dictList.values()){
+        for (SystemDict value : dictList.values()) {
             systemDict.add((value));
         }
         //获取设备型号名称
@@ -162,7 +163,7 @@ public class DeviceModelService {
         }});
 
 
-        for(SystemDict value : deviceTypeList.values()) {
+        for (SystemDict value : deviceTypeList.values()) {
             if (vo.getDeviceType().equals(value.getValue())) {
                 vo.setDeviceTypeName(value.getLabel());
             }
@@ -174,6 +175,8 @@ public class DeviceModelService {
     }
 
 
+    @Autowired
+    KwsDeviceModelRepository deviceModelRepository;
 
     @Transactional
     public HttpResult update(DeviceModelAdd deviceAdd, HttpServletRequest response) {
@@ -183,7 +186,7 @@ public class DeviceModelService {
         LocalDateTime now = LocalDateTime.now();
         device.setUpdateBy(Long.parseLong(commonService.getHeaderData(response).getUpdateBy()));
         device.setUpdateTime(now);
-        kwsDeviceModelMapper.updateById(device);
+        deviceModelRepository.updateById(device);
         //新增log
         HeaderData headerData = commonService.getHeaderData(response);
         Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
@@ -220,10 +223,11 @@ public class DeviceModelService {
 
     /**
      * 查询设备型号数据
+     *
      * @param request
      * @return
      */
-    public HttpResult findModelList( HttpServletRequest request) {
+    public HttpResult findModelList(HttpServletRequest request) {
         List<KwsDeviceModel> kwsDeviceModels = kwsDeviceModelMapper.selectList(new LambdaQueryWrapper<KwsDeviceModel>()
                 .eq(KwsDeviceModel::getDelFlag, NumberConstant.ZERO)
                 .orderByDesc(KwsDeviceModel::getCreateTime)

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

@@ -44,6 +44,7 @@ import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -121,7 +122,6 @@ public class KwsAlarmService {
     public PageRes select(AlarmLogThresholdQuery query, HttpServletRequest request) {
         HeaderData headerData = commonService.getHeaderData(request);
         PageHelper.startPage(query.getPage(), query.getPageSize());
-
         LambdaQueryWrapper<KwsAlarm> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(StringUtils.isNotBlank(headerData.getMountainId()), KwsAlarm::getMountainId, headerData.getMountainId())
                 .eq(KwsAlarm::getStatus, query.getStatus())
@@ -130,6 +130,15 @@ public class KwsAlarmService {
         if (StringUtils.isNotBlank(query.getProjectId())) {
             wrapper.eq(KwsAlarm::getProjectId, Long.parseLong(query.getProjectId()));
         }
+        if (Objects.nonNull(query.getAlarmLevel())) {
+            wrapper.eq(KwsAlarm::getLevel, query.getAlarmLevel());
+        }
+        if (StringUtils.isNotBlank(query.getAlarmInfo())) {
+            wrapper.eq(KwsAlarm::getTitle, query.getAlarmInfo());
+        }
+        if (StringUtils.isNotBlank(query.getDeviceId())){
+            wrapper.like(KwsAlarm::getDeviceId, query.getDeviceId());
+        }
         wrapper.orderByDesc(KwsAlarm::getCreateTime);
         List<KwsAlarm> list = alarmMapper.selectList(wrapper);
         List<KwsAlarmVO> alarmVOS = new ArrayList<>();
@@ -348,7 +357,11 @@ public class KwsAlarmService {
             vo.setAlarmLevel(kwsAlarm.getTitle() == null ? null : (alarmDetailType.get(kwsAlarm.getTitle()).getLabel()));
             vo.setStartTime(kwsAlarm.getCreateTime());
             vo.setEndTime(kwsAlarm.getUpdateTime());
-//            Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, kwsAlarm.getId()));
+            LocalDateTime now = LocalDateTime.now();
+            System.out.println(now);
+            Long count = alarmDetailMapper.selectCount(new LambdaQueryWrapper<KwsAlarmDetail>().eq(KwsAlarmDetail::getAlarmId, kwsAlarm.getId()));
+            LocalDateTime now1 = LocalDateTime.now();
+            System.out.println(now1);
             //todo 不使用缓存  使用新字段处理
             /**结合到mqtt阈值触发数据存储*/
 //            if (AlarmTypeEnum.ALARM_ONE.getStatus().equals(String.valueOf(kwsAlarm.getType()))) {

+ 81 - 17
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -31,6 +31,7 @@ import com.sckw.slope.detection.model.param.ProjectQuery;
 import com.sckw.slope.detection.model.vo.*;
 import com.sckw.slope.detection.service.repository.KwsDeviceRelationRepository;
 import com.sckw.slope.detection.service.repository.KwsProjectDeviceRepository;
+import com.sckw.slope.detection.service.repository.KwsProjectRepository;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -65,6 +66,9 @@ public class ProjectService {
     @Autowired
     KwsProjectMapper projectMapper;
 
+    @Autowired
+    KwsProjectRepository projectRepository;
+
     @Autowired
     KwsProjectAreaMapper projectAreaMapper;
 
@@ -204,8 +208,8 @@ public class ProjectService {
         LocalDateTime now = LocalDateTime.now();
         project.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
         project.setUpdateTime(now);
-        project.setRemark(org.apache.commons.lang3.StringUtils.isNotBlank(projectAddDto.getRemark()) ? projectAddDto.getRemark() : null);
-        projectMapper.updateById(project);
+        project.setRemark(org.apache.commons.lang3.StringUtils.isBlank(projectAddDto.getRemark()) ? null : projectAddDto.getRemark());
+        projectRepository.updateById(project);
         String fence = projectAddDto.getFence();
         projectAreaMapper.update(null, new LambdaUpdateWrapper<KwsProjectArea>()
                 .eq(KwsProjectArea::getProjectId, projectAddDto.getId())
@@ -446,6 +450,25 @@ public class ProjectService {
         String latitude = param.getLatitude();
         String projectId = param.getProjectId();
         String type = param.getType();
+        String startTime = "";
+        String endTime = "";
+        if ("4".equals(latitude)) {
+            startTime = cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 00:00:00";
+            endTime = cn.hutool.core.date.DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd") + " 23:59:59";
+        } else if ("3".equals(latitude)) {
+            List<String> weekMondayAndSunday = com.sckw.excel.utils.DateUtil.getWeekMondayAndSunday();
+            startTime = weekMondayAndSunday.get(0);
+            endTime = weekMondayAndSunday.get(1);
+        } else if ("2".equals(latitude)) {
+            LocalDate firstDayOfMonth = com.sckw.excel.utils.DateUtil.getFirstDayOfMonth();
+            startTime = com.sckw.excel.utils.DateUtil.dateToStr(firstDayOfMonth, "yyyy-MM-dd") /*+ " 00:00:00"*/;
+            LocalDate lastDayOfMonth = com.sckw.excel.utils.DateUtil.getLastDayOfMonth();
+            endTime = com.sckw.excel.utils.DateUtil.dateToStr(lastDayOfMonth, "yyyy-MM-dd")/* + " 23:59:59"*/;
+        } else if ("1".equals(latitude)) {
+            //查询全年每个月
+            startTime = com.sckw.excel.utils.DateUtil.getYearFirstMonth() + "-01";
+            endTime = com.sckw.excel.utils.DateUtil.getYearLastMonth() + "-31";
+        }
         if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
             String deviceId = param.getDeviceId();
             String mountainId = headerData.getMountainId();
@@ -463,18 +486,18 @@ public class ProjectService {
                 dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
                 if (dictByDictCode.get(type) != null) {
                     //当前设备下的所有基本要素
-                    basicItem(mountainId, projectId, deviceId, kwsDevice, returnList, type);
+                    basicItem(mountainId, projectId, deviceId, kwsDevice, startTime, endTime, returnList, type);
                 } else {
                     //集成要素 折线图
                     //集成要素-测量值计算
-                    integrationItem(headerData, deviceId, kwsDevice, returnList, type);
+                    integrationItem(headerData, deviceId, kwsDevice, startTime, endTime, returnList, type);
                 }
             } else {
                 //当前设备下的所有基本要素
-                basicItem(mountainId, projectId, deviceId, kwsDevice, returnList, type);
+                basicItem(mountainId, projectId, deviceId, kwsDevice, startTime, endTime, returnList, type);
                 //集成要素 折线图
                 //集成要素-测量值计算
-                integrationItem(headerData, deviceId, kwsDevice, returnList, type);
+                integrationItem(headerData, deviceId, kwsDevice, startTime, endTime, returnList, type);
             }
             returnList = returnList.stream().distinct().collect(Collectors.toList());
             return HttpResult.ok(returnList);
@@ -605,7 +628,7 @@ public class ProjectService {
                             //当前仅有加速度
                             BigDecimal decimal = new BigDecimal("0.00");
                             Date date = new Date();
-                            String dateStart = DateUtil.getDateTimeToHour(date, 24);
+                            String dateStart = DateUtil.getDateTimeToHour(date, 23);
                             String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
                             List<SlopeData> selected = null;
                             try {
@@ -643,6 +666,14 @@ public class ProjectService {
                                     map.setDataValue(decimal.toString());
                                     mapList.add(map);
                                 }
+                            } else {
+                                List<String> dateTimeHour = DateUtil.getDateTimeHour(date, 23, new ArrayList<String>());
+                                for (String s : dateTimeHour) {
+                                    DevicesAlarmLogVO datemap = new DevicesAlarmLogVO();
+                                    datemap.setDateTime(s);
+                                    datemap.setDataValue("0");
+                                    mapList.add(datemap);
+                                }
                             }
                             projectCatLogVO.setType(integrationName);
                             projectCatLogVO.setMonitor(mapList);
@@ -730,8 +761,9 @@ public class ProjectService {
                 if (currentValue != null) {
 //                    Date date = new Date();
                     for (int i = 0; i < dateList.size(); i++) {
-                        String dateStart = DateUtil.getDateTimeToHour(dateList.get(i), 24);
+                        String dateStart = DateUtil.getDateTimeToHour(dateList.get(i), 23);
                         String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
+//                        String dateEnd = DateUtil.getDateTimeEndToHour(dateList.get(i), 23);
                         List<SlopeData> selected = null;
                         try {
                             selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
@@ -786,6 +818,14 @@ public class ProjectService {
                                 datemap.setDataValue(offsetValue.toString());
                                 mapList.add(datemap);
                             }
+                        } else {
+                            List<String> dateTimeHour = DateUtil.getDateTimeHour(dateList.get(i), 23, new ArrayList<String>());
+                            for (String s : dateTimeHour) {
+                                DevicesAlarmLogVO datemap = new DevicesAlarmLogVO();
+                                datemap.setDateTime(s);
+                                datemap.setDataValue("0");
+                                mapList.add(datemap);
+                            }
                         }
                     }
                 }
@@ -800,7 +840,7 @@ public class ProjectService {
     /**
      * 集成要素折线图计算
      */
-    private void integrationItem(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
+    private void integrationItem(HeaderData headerData, String deviceId, KwsDevice kwsDevice, String startTime, String endTime, List<Map<String, ProjectCatLogVO>> returnList, String type) {
         List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
                 .eq(KwsDeviceIntegration::getMountainId, headerData.getMountainId())
                 .eq(KwsDeviceIntegration::getDeviceId, deviceId)
@@ -844,8 +884,8 @@ public class ProjectService {
 //                Map<String, Map<String, String>> thresholdMap = new HashMap<>();
 //                Map<String, String> map = new HashMap<>();
                     ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
-                    String thresholdMax = "";
-                    String thresholdMin = "";
+                    String thresholdMax = "0";
+                    String thresholdMin = "0";
                     if (listMap.get(1) != null) {
                         KwsThreshold kwsThreshold = listMap.get(1).get(0);
                         thresholdMax = kwsThreshold.getMax();
@@ -889,7 +929,7 @@ public class ProjectService {
                             //当前仅有加速度
                             BigDecimal decimal = new BigDecimal("0.00");
                             Date date = new Date();
-                            String dateStart = DateUtil.getDateTimeToHour(date, 24);
+                            String dateStart = DateUtil.getDateTimeToHour(date, 23);
                             String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
                             String snCode = kwsDevice.getSnCode();
                             try {
@@ -955,6 +995,14 @@ public class ProjectService {
                                 projectCatLogVO.setMonitor(mapList);
                                 returnMap.put(integrationName, projectCatLogVO);
                                 returnList.add(returnMap);
+                            } else {
+                                List<String> dateTimeHour = DateUtil.getDateTimeHour(date, 23, new ArrayList<String>());
+                                dateTimeHour.forEach(dateTime -> {
+                                    DevicesAlarmLogVO map = new DevicesAlarmLogVO();
+                                    map.setDataValue("0");
+                                    map.setDateTime(dateTime);
+                                    mapList.add(map);
+                                });
                             }
                         }
                     }
@@ -966,7 +1014,7 @@ public class ProjectService {
     /**
      * 折线图 基本要素
      */
-    private void basicItem(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<Map<String, ProjectCatLogVO>> returnList, String type) {
+    private void basicItem(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, String startTime, String endTime, 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) {
@@ -1004,8 +1052,8 @@ public class ProjectService {
 //                Map<String, Map<String, String>> thresholdMap = new HashMap<>();
 //                Map<String, String> map = new HashMap<>();
                 ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
-                String thresholdMax = "";
-                String thresholdMin = "";
+                String thresholdMax = "0";
+                String thresholdMin = "0";
                 if (listMap.get(1) != null) {
                     KwsThreshold kwsThreshold = listMap.get(1).get(0);
                     thresholdMax = kwsThreshold.getMax();
@@ -1042,12 +1090,12 @@ public class ProjectService {
                 returnVO.setThreeLevelAlarm(thresholdLevelVO);
                 //时间统计轴(当前数据检测值)
                 List<DevicesAlarmLogVO> mapList = new ArrayList<>();
+                Date date = new Date();
                 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 dateStart = DateUtil.getDateTimeToHour(date, 23);
                     String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
                     List<SlopeData> selected = null;
                     try {
@@ -1103,6 +1151,22 @@ public class ProjectService {
                             datemap.setDataValue(offsetValue.toString());
                             mapList.add(datemap);
                         }
+                    } else {
+                        List<String> dateTimeHour = DateUtil.getDateTimeHour(date, 23, new ArrayList<String>());
+                        for (String s : dateTimeHour) {
+                            DevicesAlarmLogVO datemap = new DevicesAlarmLogVO();
+                            datemap.setDateTime(s);
+                            datemap.setDataValue("0");
+                            mapList.add(datemap);
+                        }
+                    }
+                } else {
+                    List<String> dateTimeHour = DateUtil.getDateTimeHour(date, 23, new ArrayList<String>());
+                    for (String s : dateTimeHour) {
+                        DevicesAlarmLogVO datemap = new DevicesAlarmLogVO();
+                        datemap.setDateTime(s);
+                        datemap.setDataValue("0");
+                        mapList.add(datemap);
                     }
                 }
                 returnVO.setType(partName);

+ 147 - 59
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -78,6 +78,93 @@ public class ThresholdService {
     @Autowired
     KwsDeviceReferenceMapper deviceReferenceMapper;
 
+    public PageRes newSelect(ThresholdQuery thresholdQuery, HttpServletRequest request) {
+        PageHelper.startPage(thresholdQuery.getPage(), thresholdQuery.getPageSize());
+        HeaderData headerData = commonService.getHeaderData(request);
+        List<Integer> status = new ArrayList<>();
+        status.add(DeviceEnum.ALREADY_REFERRED_TO.getCode());
+        List<KwsThreshold> list = thresholdMapper.selectListAll(thresholdQuery, headerData, status);
+        List<ThresholdSelectDTO> dtoList = deviceMapper.selectDeviceAllByProjectAndMountainId(thresholdQuery.getProjectId(), headerData.getMountainId(), status);
+        PageInfo<ThresholdSelectDTO> info = new PageInfo<>(dtoList);
+        if (CollectionUtils.isEmpty(dtoList)) {
+            return PageRes.build(info, dtoList);
+        }
+        for (ThresholdSelectDTO dto : dtoList) {
+            Long deviceId = dto.getDeviceId();
+            //基本要素
+            List<DeviceElementDTO> basiclElementList = deviceModelPartMapper.selectElementList(thresholdQuery.getProjectId(),
+                    headerData.getMountainId(), status, deviceId);
+            List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
+                    .eq(KwsThreshold::getDeviceId, deviceId)
+                    .eq(KwsThreshold::getMountainId, headerData.getMountainId())
+                    .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
+                    .orderByDesc(KwsThreshold::getCreateTime)
+            );
+            String setting = ThresholdEnum.IS_NOT_SET.getStatus();
+            String statusName = ThresholdEnum.IS_NOT_SET.getDestination();
+            if (!CollectionUtils.isEmpty(kwsThresholds)) {
+                setting = kwsThresholds.get(0).getSetting();
+                if (ThresholdEnum.PARTIAL_SETTING.getStatus().equals(setting)) {
+                    statusName = ThresholdEnum.PARTIAL_SETTING.getDestination();
+                } else {
+                    setting = ThresholdEnum.HAVE_SET.getStatus();
+                    statusName = ThresholdEnum.HAVE_SET.getDestination();
+                }
+            }
+            dto.setId(thresholdQuery.getProjectId());
+            StringBuilder phones = new StringBuilder();
+            if (!CollectionUtils.isEmpty(kwsThresholds)) {
+                for (int i = 0; i < kwsThresholds.size(); i++) {
+                    if (i != (kwsThresholds.size() - 1)) {
+                        phones.append(kwsThresholds.get(i).getPhones()).append(",");
+                    } else {
+                        phones.append(kwsThresholds.get(i).getPhones());
+                    }
+                }
+            }
+            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());
+            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();
+            }
+            dto.setDeviceSetTotal(deviceSetTotal);
+            dto.setDeviceName(dto.getDeviceName());
+            dto.setStatus(setting);
+            dto.setStatusName(statusName);
+            dto.setPhones(phones.toString());
+            dto.setUpdateByName(CollectionUtils.isEmpty(kwsThresholds) ? null : kwsThresholds.get(0).getCreateBy().toString());
+            dto.setUpdateTime(CollectionUtils.isEmpty(kwsThresholds) ? null : kwsThresholds.get(0).getCreateTime());
+        }
+        return PageRes.build(info, dtoList);
+    }
+
     public PageRes select(ThresholdQuery thresholdQuery, HttpServletRequest request) {
         PageHelper.startPage(thresholdQuery.getPage(), thresholdQuery.getPageSize());
         HeaderData headerData = commonService.getHeaderData(request);
@@ -213,6 +300,7 @@ public class ThresholdService {
                 .eq(KwsDeviceReference::getDeviceId, deviceId)
                 .eq(KwsDeviceReference::getType, 1)
                 .eq(KwsDeviceReference::getItem, itemName)
+                .eq(KwsDeviceReference::getDelFlag, 0)
         );
         ThresholdDetailVO vo = new ThresholdDetailVO();
         if (!CollectionUtils.isEmpty(kwsThreshold)) {
@@ -226,8 +314,8 @@ public class ThresholdService {
             for (KwsThreshold threshold : kwsThreshold) {
                 ThresholdBean bean = new ThresholdBean();
                 bean.setLevel(threshold.getLevel());
-                bean.setMax(threshold.getMax());
-                bean.setMin(threshold.getMin());
+                bean.setMax(Integer.valueOf(threshold.getMax()));
+                bean.setMin(Integer.valueOf(threshold.getMin()));
                 beanList.add(bean);
             }
             vo.setThreshold(beanList);
@@ -260,7 +348,7 @@ public class ThresholdService {
         for (ThresholdBean thresholdBean : threshold) {
             //验证数据库层面阈值数据存储值
             int level = thresholdBean.getLevel();
-            checkDatabaseThresholdLevel(level, thresholdBean, headerData, deviceId, itemName);
+//            checkDatabaseThresholdLevel(level, thresholdBean, headerData, deviceId, itemName);
             KwsThreshold selected = thresholdMapper.selectOne(new LambdaQueryWrapper<KwsThreshold>()
                     .eq(KwsThreshold::getMountainId, headerData.getMountainId())
                     .eq(KwsThreshold::getDeviceId, deviceId)
@@ -278,8 +366,8 @@ public class ThresholdService {
                 String setting = checkAndSettings(configurationDTO, headerData);
                 kwsThreshold.setSetting(setting);
                 kwsThreshold.setLevel(Integer.valueOf(thresholdBean.getLevel()));
-                kwsThreshold.setMax(thresholdBean.getMax());
-                kwsThreshold.setMin(thresholdBean.getMin());
+                kwsThreshold.setMax(String.valueOf(thresholdBean.getMax()));
+                kwsThreshold.setMin(String.valueOf(thresholdBean.getMin()));
                 kwsThreshold.setPhones(phones);
                 kwsThreshold.setStatus(0);
                 kwsThreshold.setCreateBy(headerData.getCreateBy() == null ? null : Long.parseLong(headerData.getCreateBy()));
@@ -292,8 +380,8 @@ public class ThresholdService {
                 //计算设置状态  便于select
                 String setting = checkAndSettings(configurationDTO, headerData);
                 selected.setSetting(setting);
-                selected.setMax(thresholdBean.getMax());
-                selected.setMin(thresholdBean.getMin());
+                selected.setMax(String.valueOf(thresholdBean.getMax()));
+                selected.setMin(String.valueOf(thresholdBean.getMin()));
                 selected.setPhones(phones);
                 selected.setStatus(0);
                 selected.setUpdateBy(headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
@@ -332,24 +420,24 @@ public class ThresholdService {
                 String min = twoKwsThreshold.getMin();
                 if (min.contains("-")) {
 //                    min = StringUtils.deleteCharString(min, "-");
-                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) < thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("一级最小值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) > thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("一级最小值阈值设置数据填写错误");
                     }
                 }
                 String max = twoKwsThreshold.getMax();
                 if (max.contains("-")) {
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("一级最大值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("一级最大值阈值设置数据填写错误");
                     }
@@ -358,24 +446,24 @@ public class ThresholdService {
             if (threeKwsThreshold != null) {
                 String min = threeKwsThreshold.getMin();
                 if (min.contains("-")) {
-                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) < thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("一级最小值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) < thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("一级最小值阈值设置数据填写错误");
                     }
                 }
                 String max = threeKwsThreshold.getMax();
                 if (max.contains("-")) {
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("一级最大值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("一级最大值阈值设置数据填写错误");
                     }
@@ -388,12 +476,12 @@ public class ThresholdService {
                 String min = oneKwsThreshold.getMin();
                 if (min.contains("-")) {
 //                    min = StringUtils.deleteCharString(min, "-");
-                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) > thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("二级最小值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) > thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("阈值设置数据填写错误");
                     }
@@ -401,12 +489,12 @@ public class ThresholdService {
                 String max = oneKwsThreshold.getMax();
                 if (max.contains("-")) {
 //                    min = StringUtils.deleteCharString(min, "-");
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) < thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("阈值设置数据填写错误");
                     }
@@ -415,24 +503,24 @@ public class ThresholdService {
             if (threeKwsThreshold != null) {
                 String min = threeKwsThreshold.getMin();
                 if (min.contains("-")) {
-                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) < thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("二级最小级阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) < thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("二级最小级阈值设置数据填写错误");
                     }
                 }
                 String max = threeKwsThreshold.getMax();
                 if (max.contains("-")) {
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("二级最大值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(max) > Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) > thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在三级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("二级最大值阈值设置数据填写错误");
                     }
@@ -444,24 +532,24 @@ public class ThresholdService {
             if (oneKwsThreshold != null) {
                 String min = oneKwsThreshold.getMin();
                 if (min.contains("-")) {
-                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) > thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("三级最小值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(min) < Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) < thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("三级最小值阈值设置数据填写错误");
                     }
                 }
                 String max = oneKwsThreshold.getMax();
                 if (max.contains("-")) {
-                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) < thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("三级最大值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) < thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在一级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("三级最大值阈值设置数据填写错误");
                     }
@@ -470,24 +558,24 @@ public class ThresholdService {
             if (twoKwsThreshold != null) {
                 String min = twoKwsThreshold.getMin();
                 if (min.contains("-")) {
-                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) > thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("三级最小值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(min) > Long.parseLong(thresholdBean.getMin())) {
+                    if (Long.parseLong(min) > thresholdBean.getMin()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMin(), min);
                         throw new BusinessException("三级最小值阈值设置数据填写错误");
                     }
                 }
                 String max = twoKwsThreshold.getMax();
                 if (max.contains("-")) {
-                    if (Long.parseLong(thresholdBean.getMax()) > Long.parseLong(max)) {
+                    if (thresholdBean.getMax() > Long.parseLong(max)) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("三级最大值阈值设置数据填写错误");
                     }
                 } else {
-                    if (Long.parseLong(max) < Long.parseLong(thresholdBean.getMax())) {
+                    if (Long.parseLong(max) < thresholdBean.getMax()) {
                         log.error("当前等级:{},当前设置阈值:{},存在二级阈值:{}", level, thresholdBean.getMax(), max);
                         throw new BusinessException("三级最大值阈值设置数据填写错误");
                     }
@@ -514,32 +602,32 @@ public class ThresholdService {
         ThresholdBean thresholdBeanTwo = maps.get(2);
         ThresholdBean thresholdBeanThree = maps.get(3);
         if (thresholdBeanTwo != null) {
-            String min = thresholdBeanTwo.getMin();//10
-            String max = thresholdBeanTwo.getMax();//90
+            String min = String.valueOf(thresholdBeanTwo.getMin());//10
+            String max = String.valueOf(thresholdBeanTwo.getMax());//90
             if (thresholdBeanThree != null) {
-                String minThree = thresholdBeanThree.getMin();//8
+                long minThree = thresholdBeanThree.getMin();//8
 //                if (minThree.contains("-")) {
 //                    minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");//-8
 //                }
-                String maxThree = thresholdBeanThree.getMax();//80
-                if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
+                long maxThree = thresholdBeanThree.getMax();//80
+                if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(maxThree)) < 0) {
                     throw new BusinessException("阈值填写错误");
                 }
                 if (min.contains("-")) {
 //                min = com.sckw.core.utils.StringUtils.deleteCharString(min, "-");//-10
-                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(minThree)) > 0) {
                         throw new BusinessException("阈值填写错误");
                     }
                 } else {
-                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                    if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(minThree)) > 0) {
                         throw new BusinessException("阈值填写错误");
                     }
                 }
 
             }
             if (thresholdBeanOne != null) {
-                String minOne = thresholdBeanOne.getMin(); //15
-                String maxThree = thresholdBeanOne.getMax();//100
+                String minOne = String.valueOf(thresholdBeanOne.getMin()); //15
+                String maxThree = String.valueOf(thresholdBeanOne.getMax());//100
                 if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) > 0) {
                     throw new BusinessException("阈值填写错误");
                 }
@@ -556,21 +644,21 @@ public class ThresholdService {
             }
         }
         if (thresholdBeanThree != null) {
-            String minThree = thresholdBeanThree.getMin();//8
-            String maxThree = thresholdBeanThree.getMax();//80
+            String minThree = String.valueOf(thresholdBeanThree.getMin());//8
+            String maxThree = String.valueOf(thresholdBeanThree.getMax());//80
             if (thresholdBeanTwo != null) {
-                String twoMax = thresholdBeanTwo.getMax();//90
-                String twoMin = thresholdBeanTwo.getMin();//-10
-                if (BigDecimal.valueOf(Long.parseLong(twoMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
+                long twoMax = thresholdBeanTwo.getMax();//90
+                long twoMin = thresholdBeanTwo.getMin();//-10
+                if (BigDecimal.valueOf(twoMax).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
                     throw new BusinessException("阈值填写错误");
                 }
                 if (minThree.contains("-")) {
 //                    minThree = com.sckw.core.utils.StringUtils.deleteCharString(minThree, "-");//-8
-                    if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                    if (BigDecimal.valueOf(twoMin).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
                         throw new BusinessException("阈值填写错误");
                     }
                 } else {
-                    if (BigDecimal.valueOf(Long.parseLong(twoMin)).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
+                    if (BigDecimal.valueOf(twoMin).compareTo(BigDecimal.valueOf(Long.parseLong(minThree))) > 0) {
                         throw new BusinessException("阈值填写错误");
                     }
                 }
@@ -580,8 +668,8 @@ public class ThresholdService {
 
             }
             if (thresholdBeanOne != null) {
-                String oneMax = thresholdBeanOne.getMax();//100
-                String oneMin = thresholdBeanOne.getMin();//-15
+                String oneMax = String.valueOf(thresholdBeanOne.getMax());//100
+                String oneMin = String.valueOf(thresholdBeanOne.getMin());//-15
                 if (BigDecimal.valueOf(Long.parseLong(oneMax)).compareTo(BigDecimal.valueOf(Long.parseLong(maxThree))) < 0) {
                     throw new BusinessException("阈值填写错误");
                 }
@@ -607,18 +695,18 @@ public class ThresholdService {
             for (int i = maxLevel; i > 0; i--) {
                 ThresholdBean thresholdBean = maps.get(maxLevel);
                 if (thresholdBean != null) {
-                    String thresholdBeanMin = thresholdBean.getMin();
+                    String thresholdBeanMin = String.valueOf(thresholdBean.getMin());
                     if (thresholdBeanMin.contains("-")) {
                         thresholdBeanMin = com.sckw.core.utils.StringUtils.deleteCharString(thresholdBeanMin, "-");
                     }
                     ThresholdBean thresholdBean1 = maps.get(i);
                     if (thresholdBean1 != null) {
-                        String max = thresholdBean1.getMax();
-                        String min = thresholdBean1.getMin();
+                        String max = String.valueOf(thresholdBean1.getMax());
+                        String min = String.valueOf(thresholdBean1.getMin());
                         if (min.contains("-")) {
                             min = com.sckw.core.utils.StringUtils.deleteCharString(min, "-");
                         }
-                        if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(Long.parseLong(thresholdBean.getMax()))) > 0) {
+                        if (BigDecimal.valueOf(Long.parseLong(max)).compareTo(BigDecimal.valueOf(thresholdBean.getMax())) > 0) {
                             throw new BusinessException("阈值填写错误");
                         }
                         if (BigDecimal.valueOf(Long.parseLong(min)).compareTo(BigDecimal.valueOf(Long.parseLong(thresholdBeanMin))) < 0) {
@@ -633,8 +721,8 @@ public class ThresholdService {
                     int levelMax = level + 1;
                     int levelMin = level - 1;
                     if (maps.get(levelMax) != null) {
-                        String min = value.getMin();
-                        String max = value.getMax();
+                        long min = value.getMin();
+                        long max = value.getMax();
                     }
                     if (maps.get(levelMin) != null) {
 
@@ -834,7 +922,7 @@ public class ThresholdService {
         //100 全部  0未设置 1 部分设置 2 已设置
         String type = param.getType();
         if ("100".equals(type)) {
-            return getDeviceAll(projectId, headerData,param);
+            return getDeviceAll(projectId, headerData, param);
         } else {
             List<ProjectThresholdSettingVO> returnList = new ArrayList<>();
             List<KwsProjectDevice> selectList = projectDeviceMapper.selectList(new LambdaQueryWrapper<KwsProjectDevice>()
@@ -938,14 +1026,14 @@ public class ThresholdService {
                     returnList.add(vo);
                 }
             }
-            if (!CollectionUtils.isEmpty(returnList)){
+            if (!CollectionUtils.isEmpty(returnList)) {
                 returnList = returnList.stream().skip((param.getPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
             }
             return HttpResult.ok(returnList);
         }
     }
 
-    private HttpResult getDeviceAll(String projectId, HeaderData headerData,ProjectThresholdSettingParam param) {
+    private HttpResult getDeviceAll(String projectId, HeaderData headerData, ProjectThresholdSettingParam param) {
         List<ProjectThresholdSettingVO> returnList = new ArrayList<>();
         List<KwsProjectDevice> selectList = projectDeviceMapper.selectList(new LambdaQueryWrapper<KwsProjectDevice>()
                 .eq(KwsProjectDevice::getDelFlag, 0)
@@ -1029,7 +1117,7 @@ public class ThresholdService {
             returnData.setPhones(phoneList == null ? null : phoneList.toString());
             returnList.add(returnData);
         }
-        if (!CollectionUtils.isEmpty(returnList)){
+        if (!CollectionUtils.isEmpty(returnList)) {
             returnList = returnList.stream().skip((param.getPage() - 1) * param.getPageSize()).limit(param.getPageSize()).collect(Collectors.toList());
         }
         return HttpResult.ok(returnList);

+ 7 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/KwsDeviceModelRepository.java

@@ -0,0 +1,7 @@
+package com.sckw.slope.detection.service.repository;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.sckw.slope.detection.model.dos.mysql.KwsDeviceModel;
+
+public interface KwsDeviceModelRepository extends IService<KwsDeviceModel> {
+}

+ 7 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/KwsProjectRepository.java

@@ -0,0 +1,7 @@
+package com.sckw.slope.detection.service.repository;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.sckw.slope.detection.model.dos.mysql.KwsProject;
+
+public interface KwsProjectRepository extends IService<KwsProject> {
+}

+ 17 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/impl/KwsDeviceModelImpl.java

@@ -0,0 +1,17 @@
+package com.sckw.slope.detection.service.repository.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sckw.slope.detection.dao.mysql.KwsDeviceModelMapper;
+import com.sckw.slope.detection.model.dos.mysql.KwsDeviceModel;
+import com.sckw.slope.detection.service.repository.KwsDeviceModelRepository;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-30 17:11:03
+ */
+@Service
+public class KwsDeviceModelImpl extends ServiceImpl<KwsDeviceModelMapper,KwsDeviceModel> implements KwsDeviceModelRepository {
+
+}

+ 17 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/repository/impl/KwsProjectImpl.java

@@ -0,0 +1,17 @@
+package com.sckw.slope.detection.service.repository.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.sckw.slope.detection.dao.mysql.KwsProjectMapper;
+import com.sckw.slope.detection.model.dos.mysql.KwsProject;
+import com.sckw.slope.detection.service.repository.KwsProjectRepository;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-11-30 09:11:35
+ */
+@Service
+public class KwsProjectImpl extends ServiceImpl<KwsProjectMapper,KwsProject> implements KwsProjectRepository {
+
+}

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

@@ -385,4 +385,11 @@
   <select id="getDataByDeviceIdAndProjectId" resultType="com.sckw.slope.detection.model.vo.excel.KwsAlarmExportVO">
 
     </select>
+
+  <select id="selectAlarmAndDeviceAll" resultType="com.sckw.slope.detection.model.dto.ThresholdSelectDTO">
+      SELECT b.id     AS deviceId,
+             b.alias  AS deviceAlias,
+             b.`name` AS deviceName
+          a.id as ,
+  </select>
 </mapper>

+ 15 - 0
slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsThresholdMapper.xml

@@ -202,4 +202,19 @@
             del_flag    = #{delFlag,jdbcType=TINYINT}
         where id = #{id,jdbcType=BIGINT}
     </update>
+
+    <select id="selectListAll" resultMap="BaseResultMap">
+
+        <where>
+            <if test="thresholdQuery.alarmInfo != null and thresholdQuery.alarmInfo !=''">
+                and title = #{thresholdQuery.alarmInfo}
+            </if>
+            <if test="thresholdQuery.alarmLevel != null and thresholdQuery.alarmLevel !=''">
+                and level = #{thresholdQuery.alarmLevel}
+            </if>
+            <if test="thresholdQuery.alarmLevel != null and thresholdQuery.alarmLevel !=''">
+                and level = #{thresholdQuery.alarmLevel}
+            </if>
+        </where>
+    </select>
 </mapper>