15928045575 2 лет назад
Родитель
Сommit
4d83501481
13 измененных файлов с 309 добавлено и 95 удалено
  1. 53 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/IntegrationStatusEnum.java
  2. 65 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/MessageLogEnum.java
  3. 4 0
      slope-common/slope-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java
  4. 2 3
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java
  5. 2 2
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceModelController.java
  6. 19 5
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/backTrackController.java
  7. 5 0
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/DeviceQuery.java
  8. 70 13
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/BackTrackService.java
  9. 30 3
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceModelService.java
  10. 55 64
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java
  11. 0 1
      slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/task/ReportTemplateTaskService.java
  12. 3 3
      slope-modules/slope-detection/src/main/resources/mapper/mysql/KwsAlarmMapper.xml
  13. 1 1
      slope-modules/slope-detection/src/main/resources/mapper/tdengine/SlopeDataMapper.xml

+ 53 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/IntegrationStatusEnum.java

@@ -0,0 +1,53 @@
+package com.sckw.core.model.enums;
+
+/**
+ * @author lfdc
+ * @description 设备状态
+ * @date 2023-11-01 10:07:23
+ */
+public enum IntegrationStatusEnum {
+
+    /**
+     * 识别失败
+     */
+    INTEGRATION_ZERO(0, "0", "未自适应"),
+    /**
+     * 识别中
+     */
+    INTEGRATION_ONE(1, "1", "启用自适应"),
+
+    ;
+
+    public Integer getCode() {
+        return code;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public String getDestination() {
+        return destination;
+    }
+
+    private final Integer code;
+    private final String status;
+    private final String destination;
+
+    IntegrationStatusEnum(Integer code, String status, String destination) {
+        this.code = code;
+        this.status = status;
+        this.destination = destination;
+    }
+    public static String getDestination(Integer code) {
+        for (IntegrationStatusEnum enums : IntegrationStatusEnum.values()) {
+            if (enums.getCode().equals(code)) {
+                return enums.getDestination();
+            }
+        }
+        return null;
+    }
+
+
+
+}

+ 65 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/model/enums/MessageLogEnum.java

@@ -90,6 +90,71 @@ public enum MessageLogEnum {
     DELETE_DEVICE_THRESHOLD("slope_manage", "PROJECT_LOG", "删除设备阈值", "13",
             "设备【${deviceName}】已删除了【${element}】监测要素阈值,所属边坡【${projectName}】", "删除设备阈值"),
 
+    /**
+     * 新增集成分析方案
+     */
+    INTEGRATION_ADD("slope_manage", "PROJECT_LOG", "新增集成分析方案", "14",
+            "集成要素【${name}】已被新增,【${type}】所有设备", "新增集成分析方案"),
+    /**
+     * 修改集成分析方案
+     */
+    INTEGRATION_UPDATE("slope_manage", "PROJECT_LOG", "修改集成分析方案", "15",
+            "集成要素【${name}】已被修改,【${type}】所有设备", "修改集成分析方案"),
+
+    /**
+     * 新增设备型号
+     */
+    MODEL_ADD("slope_manage", "PROJECT_LOG", "新增设备型号", "16",
+            "型号【${name}】已被新增", "新增设备型号"),
+
+    /**
+     * 修改设备型号
+     */
+    MODEL_UPDATE("slope_manage", "PROJECT_LOG", "修改设备型号", "17",
+            "型号【${name}】已被修改", "修改设备型号"),
+
+    /**
+     * 删除设备型号
+     */
+    MODEL_DELETE("slope_manage", "PROJECT_LOG", "删除设备型号", "18",
+            "型号【${name}】已被删除", "删除设备型号"),
+    /**
+     * 新增设备
+     */
+    DEVICE_ADD("slope_manage", "PROJECT_LOG", "新增设备", "19",
+            "设备【${name}】已被新增,所属型号【${type}】", "新增设备"),
+    /**
+     * 修改设备
+     */
+    DEVICE_UPDATE("slope_manage", "PROJECT_LOG", "修改设备", "20",
+            "设备【${name}】已被修改,所属型号【${type}】", "修改设备"),
+    /**
+     * 删除设备
+     */
+    DEVICE_DELETE("slope_manage", "PROJECT_LOG", "删除设备", "21",
+            "设备【${name}】已被删除,所属型号【${type}】", "删除设备"),
+    /**
+     * 禁用设备
+     */
+    DEVICE_DISABLED("slope_manage", "PROJECT_LOG", "禁用设备", "22",
+            "设备【${name}】已被禁用,所属型号【${type}】", "禁用设备"),
+
+    /**
+     * 启用设备
+     */
+    DEVICE_ABLED("slope_manage", "PROJECT_LOG", "启用设备", "23",
+            "设备【${name}】已被启用,所属型号【${type}】", "启用设备"),
+    /**
+     * 设备基准值设置
+     */
+    DEVICE_SETBASE("slope_manage", "PROJECT_LOG", "设备基准值设置", "24",
+            "设备【${name}】已被设置阈值,相关要素【${type}】,所属边坡【${desc}】", "设备基准值设置"),
+    /**
+     * 设备基准值调整
+     */
+    DEVICE_SETVALUE("slope_manage", "PROJECT_LOG", "设备基准值调整", "25",
+            "设备【${name}】已被调整阈值,相关要素【${type}】,所属边坡【${desc}】", "设备基准值调整"),
+
     ;
 
 

+ 4 - 0
slope-common/slope-common-core/src/main/java/com/sckw/core/web/constant/HttpStatus.java

@@ -148,6 +148,10 @@ public class HttpStatus {
     public static final String CONTRACT_NOT_EXISTS = "未查询到合同或已失效";
     public static final String BANNER_NOT_EXISTS = "未查询到banner数据或已失效";
 
+    public static final String INTEGRATION_NOT_EXISTS = "未查询到集成元素或已失效";
+    public static final String MODEL_NOT_EXISTS = "未查询到设备型号或已失效";
+    public static final String DEVICE_NOT_EXISTS = "未查询到设备或已失效";
+
 
     /**自定义提示消息*/
     public static final String PASSWD_ERROR = "密码不正确";

+ 2 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/DeviceController.java

@@ -34,10 +34,9 @@ public class DeviceController {
     @Log(description = "设备删除")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备删除", value = "/dels", method = RequestMethod.GET)
-    public HttpResult dels(@RequestParam("ids") @NotBlank(message = "设备id不能为空") String ids) {
+    public HttpResult dels(@RequestParam("ids") @NotBlank(message = "设备id不能为空") String ids, HttpServletRequest request) {
         log.info("设备删除 delete param:{}", ids);
-        return deviceService.dels(ids
-        );
+        return deviceService.dels(ids,request);
     }
 
     @Log(description = "所属设备查询")

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

@@ -35,9 +35,9 @@ public class DeviceModelController {
     @Log(description = "设备型号删除")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "设备型号删除", value = "/dels", method = RequestMethod.GET)
-    public HttpResult dels(@RequestParam("ids") @NotBlank(message = "设备id不能为空") String ids) {
+    public HttpResult dels(@RequestParam("ids") @NotBlank(message = "设备id不能为空") String ids, HttpServletRequest response) {
         log.info("设备型号删除 delete param:{}", ids);
-        return deviceModelService.dels(ids);
+        return deviceModelService.dels(ids,response);
     }
 
 

+ 19 - 5
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/controller/backTrackController.java

@@ -43,17 +43,17 @@ public class backTrackController {
     @Log(description = "返回要素所属于的设备")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "返回要素所属于的设备", value = "/getDeviceByParts", method = RequestMethod.GET)
-    public HttpResult getDeviceByParts(@RequestParam("parts") String parts) {
-        log.info("返回要素所属于的设备 getDeviceByParts param :{}",parts);
-        return backTrackService.getDeviceByParts(parts);
+    public HttpResult getDeviceByParts(@RequestParam("parts") String parts,@RequestParam("projectId") String projectId) {
+        log.info("返回要素所属于的设备 getDeviceByParts param :{},projectId:{}",parts,projectId);
+        return backTrackService.getDeviceByParts(parts,projectId);
     }
 
     @Log(description = "返回设备折线图")
     //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
     @RequestMapping(name = "返回设备折线图", value = "/getDeviceChart", method = RequestMethod.GET)
-    public HttpResult getDeviceChart(@RequestParam("deviceId") String deviceId,@RequestParam("snCode") String snCode, @RequestParam("part") String part, @RequestParam("dateStart") String dateStart, @RequestParam("dateEnd") String dateEnd) {
+    public HttpResult getDeviceChart(@RequestParam("deviceId") String deviceId,@RequestParam("snCode") String snCode, @RequestParam("part") String part, @RequestParam("dateStart") String dateStart, @RequestParam("dateEnd") String dateEnd, @RequestParam("original") Integer original) {
         log.info("返回设备折线图 getDeviceChart param :{},part:{}",deviceId,part);
-        return backTrackService.getDeviceChart(deviceId,snCode,part,dateStart,dateEnd);
+        return backTrackService.getDeviceChart(deviceId,snCode,part,dateStart,dateEnd,original);
     }
 
 
@@ -80,7 +80,21 @@ public class backTrackController {
         log.info("新增集成分析 integrationAdd param:{}", JSONObject.toJSONString(Vo));
         return HttpResult.ok(backTrackService.integrationAdd(Vo, request));
     }
+    @Log(description = "修改集成分析")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "修改集成分析", value = "/integrationUpdate", method = RequestMethod.POST)
+    public HttpResult integrationUpdate(@Valid @RequestBody IntegrationVo Vo, HttpServletRequest request) {
+        log.info("修改集成分析 integrationUpdate param:{}", JSONObject.toJSONString(Vo));
+        return HttpResult.ok(backTrackService.integrationUpdate(Vo, request));
+    }
 
+    @Log(description = "返回选择设备的所有要素")
+    //@RepeatSubmit(interval = 3000, message = "两次请求间隔未超过3秒")
+    @RequestMapping(name = "返回选择设备的所有要素", value = "/getPartsByDeviceId", method = RequestMethod.GET)
+    public HttpResult getPartsByDeviceId(@RequestParam("deviceId") String deviceId) {
+        log.info("返回选择设备的所有要素 getPartsByDeviceId deviceId:{}",deviceId);
+        return backTrackService.getPartsByDeviceId(deviceId);
+    }
 
 
 }

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/param/DeviceQuery.java

@@ -64,4 +64,9 @@ public class DeviceQuery {
      */
 
     private String status;
+    /**
+     * 设备名称
+     */
+
+    private String deviceName;
 }

+ 70 - 13
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/BackTrackService.java

@@ -11,10 +11,7 @@ import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.NumberConstant;
-import com.sckw.core.model.enums.DeviceEnum;
-import com.sckw.core.model.enums.DictEnum;
-import com.sckw.core.model.enums.DictItemEnum;
-import com.sckw.core.model.enums.MessageLogEnum;
+import com.sckw.core.model.enums.*;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.utils.StringUtils;
@@ -90,29 +87,34 @@ public class BackTrackService {
         List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
                 .in(KwsDeviceReference::getDeviceId, devicesId)
                 .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
+                .groupBy(KwsDeviceReference::getItem)
         );
         return HttpResult.ok(references);
     }
 
-    public HttpResult getDeviceByParts(String parts) {
+    public HttpResult getDeviceByParts(String parts,String projectId) {
+        //获取项目中的设备
+        List<DeviceDataDTO> listDevice = deviceMapper.selectDeviceAllNotDeviceRelation(projectId);
+        List<String> devicesId = listDevice.stream().map(DeviceDataDTO::getDeviceId).toList();
         //在获取设备的要素
         String[] arr = parts.split(",");
         List<String> list = Arrays.asList(arr);
         List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
-                .in(KwsDeviceReference::getId, list)
+                .in(KwsDeviceReference::getItem, list)
+                .in(KwsDeviceReference::getDeviceId, devicesId)
                 .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
         );
         //获取对应的设备
-        List<Long> devicesId = references.stream().map(KwsDeviceReference::getDeviceId).toList();
+        List<Long> devicesIds = references.stream().map(KwsDeviceReference::getDeviceId).toList();
 
         List<KwsDevice> devices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>()
-                .in(KwsDevice::getId, devicesId)
+                .in(KwsDevice::getId, devicesIds)
                 .eq(KwsDevice::getDelFlag, NumberConstant.ZERO)
         );
         return HttpResult.ok(devices);
     }
 
-    public HttpResult getDeviceChart(String devicesId,String snCode, String parts, String dateStart,String dateEnd) {
+    public HttpResult getDeviceChart(String devicesId,String snCode, String parts, String dateStart,String dateEnd,Integer original) {
         Map<String, Object> returnData = new HashMap<>();
         //在获取设备的要素
         List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
@@ -139,10 +141,16 @@ public class BackTrackService {
             if(!parts.isEmpty() && !parts.contains(element.getItem())){
                 continue;
             }
-            BigDecimal currentValue = element.getCurrentValue();//当前要素的基准值
+            BigDecimal currentValue =  new BigDecimal("0.00");
+            if(original == 1){
+                currentValue = element.getOriginalValue();//以原始基准参考
+            }else{
+                currentValue = element.getCurrentValue();//以当前基准参考
+            }
+
 
             BigDecimal offsetValue = new BigDecimal("0.00");
-            Map<String, Object> datemap = new HashMap<>();
+            List<Object> datemap = new ArrayList<>();
             Date date = new Date();
             List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, element.getItem(), dateStart, dateEnd);
             if(!Objects.isNull((selected))) {
@@ -163,7 +171,10 @@ public class BackTrackService {
                     }else{//如果是其他
                         offsetValue = subtract;
                     }
-                    datemap.put(key, offsetValue);
+                    Map<String, Object> temp = new HashMap<>();
+                    temp.put("time",key);
+                    temp.put("offset",offsetValue);
+                    datemap.add(temp);
                 }
                 mapList.put(element.getItem(), datemap);
             }
@@ -222,7 +233,7 @@ public class BackTrackService {
     }
 
     /**
-     * 新增设备
+     * 新增集成元素
      *
      * @param vo 请求参数
      * @param request   http流
@@ -253,6 +264,52 @@ public class BackTrackService {
         integration.setDelFlag(zero);
         integration.setMountainId(headerData.getCompanyId());
         integrationMapper.insert(integration);
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", integration.getIntegrationName());
+        logMap.put("type", IntegrationStatusEnum.getDestination(Byte.toUnsignedInt(integration.getStatus())));
+        commonService.insertLog(MessageLogEnum.INTEGRATION_ADD, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
+        return HttpResult.ok();
+    }
+
+    /**
+     * 修改集成分析
+     *
+     * @param vo 请求参数
+     * @param request   http流
+     * @return 返回值
+     */
+    @Transactional
+    public HttpResult integrationUpdate(IntegrationVo vo, HttpServletRequest request) {
+        KwsIntegration has = integrationMapper.selectOne(new LambdaQueryWrapper<KwsIntegration>()
+                .eq(KwsIntegration::getId, vo.getId())
+                .eq(KwsIntegration::getDelFlag, 0)
+        );
+        if (Objects.isNull(has)) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.INTEGRATION_NOT_EXISTS);
+        }
+        HeaderData headerData = commonService.getHeaderData(request);
+        KwsIntegration integration = new KwsIntegration();
+        BeanUtils.copyProperties(vo, integration);
+        Date now = new Date();
+        integration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
+        integration.setUpdateTime(now);
+        integrationMapper.updateById(integration);
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", integration.getIntegrationName());
+        logMap.put("type", IntegrationStatusEnum.getDestination(Byte.toUnsignedInt(integration.getStatus())));
+        commonService.insertLog(MessageLogEnum.INTEGRATION_ADD, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok();
     }
+
+    public HttpResult getPartsByDeviceId(String deviceId) {
+        //在获取设备的要素
+        String[] arr = deviceId.split(",");
+        List<String> list = Arrays.asList(arr);
+        List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
+                .in(KwsDeviceReference::getDeviceId, list)
+                .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
+        );
+
+        return HttpResult.ok(references);
+    }
 }

+ 30 - 3
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceModelService.java

@@ -6,11 +6,15 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.DeviceEnum;
 import com.sckw.core.model.enums.DictEnum;
+import com.sckw.core.model.enums.IntegrationStatusEnum;
+import com.sckw.core.model.enums.MessageLogEnum;
 import com.sckw.core.model.page.PageRes;
 import com.sckw.core.utils.StringUtils;
+import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.KwsDeviceModelMapper;
 import com.sckw.slope.detection.dao.mysql.KwsDeviceModelPartMapper;
@@ -99,6 +103,10 @@ public class DeviceModelService {
         deviceModel.setDelFlag(NumberConstant.ZERO);
         deviceModel.setMountainId(headerData.getCompanyId());
         kwsDeviceModelMapper.insert(deviceModel);
+        //新增log
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", deviceModel.getName());
+        commonService.insertLog(MessageLogEnum.MODEL_ADD, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok();
     }
 
@@ -157,18 +165,37 @@ public class DeviceModelService {
         device.setUpdateBy(Long.parseLong(commonService.getHeaderData(response).getUpdateBy()));
         device.setUpdateTime(now);
         kwsDeviceModelMapper.updateById(device);
+
+        //新增log
+        HeaderData headerData = commonService.getHeaderData(response);
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", device.getName());
+        commonService.insertLog(MessageLogEnum.MODEL_UPDATE, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok();
     }
 
     @Transactional
-    public HttpResult dels(String ids) {
-        List<Long> list = StringUtils.splitStrToList(ids, Long.class);
+    public HttpResult dels(String ids, HttpServletRequest response) {
+        KwsDeviceModel has = kwsDeviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
+                .eq(KwsDeviceModel::getId, ids)
+                .eq(KwsDeviceModel::getDelFlag, 0)
+        );
+        if (Objects.isNull(has)) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.MODEL_NOT_EXISTS);
+        }
+
+        //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
         int update = kwsDeviceModelMapper.update(null, new LambdaUpdateWrapper<KwsDeviceModel>()
-                .in(KwsDeviceModel::getId, list)
+                .eq(KwsDeviceModel::getId, ids)
                 .set(KwsDeviceModel::getDelFlag, NumberConstant.ONE));
         if (update < 1) {
             throw new BusinessException("删除型号异常");
         }
+        //新增log
+        HeaderData headerData = commonService.getHeaderData(response);
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", has.getName());
+        commonService.insertLog(MessageLogEnum.MODEL_DELETE, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok("删除型号成功");
     }
 }

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

@@ -97,14 +97,27 @@ public class DeviceService {
 
 
     @Transactional
-    public HttpResult dels(String ids) {
-        List<Long> list = StringUtils.splitStrToList(ids, Long.class);
+    public HttpResult dels(String ids, HttpServletRequest response) {
+        KwsDevice device = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
+                .eq(KwsDevice::getId, ids));
+        if(Objects.isNull(device)){
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.DEVICE_NOT_EXISTS);
+        }
+        //List<Long> list = StringUtils.splitStrToList(ids, Long.class);
         int update = deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
-                .in(KwsDevice::getId, list)
+                .in(KwsDevice::getId, ids)
                 .set(KwsDevice::getDelFlag, NumberConstant.ONE));
         if (update < 1) {
             throw new BusinessException("删除设备异常");
         }
+        //获取新增设备的型号
+        HeaderData headerData = commonService.getHeaderData(response);
+        KwsDeviceModel model = deviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
+                .eq(KwsDeviceModel::getId, device.getModelId()));
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", device.getName());
+        logMap.put("type", model.getName());
+        commonService.insertLog(MessageLogEnum.DEVICE_DELETE, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok("删除设备成功");
     }
 
@@ -137,7 +150,7 @@ public class DeviceService {
             if (!CollectionUtils.isEmpty(alarmData)) {
                 for (int i = 0; i < alarmData.size(); i++) {
                     Map<String, Long> map = alarmData.get(i);
-                    if (map.get("pid").toString().equals(vo.getId().toString())) {
+                    if (map.get("device_id").toString().equals(vo.getId().toString())) {
                         vo.setDataErrorCount(map.get("count"));
                         vo.setDeviceErrorCount(map.get("count"));
                     }
@@ -194,6 +207,15 @@ public class DeviceService {
             deIntergration.setUpdateTime(now);
             deviceIntegrationMapper.insert(deIntergration);
         }
+
+        //新增log
+        //获取新增设备的型号
+        KwsDeviceModel model = deviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
+                .eq(KwsDeviceModel::getId, device.getModelId()));
+        Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+        logMap.put("name", device.getName());
+        logMap.put("type", model.getName());
+        commonService.insertLog(MessageLogEnum.DEVICE_ADD, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok();
     }
 
@@ -268,49 +290,7 @@ public class DeviceService {
 
 
 
-        //vo.setReference(references);
-        //获取td里面的要数数据
-        /*List<Map<String, DeviceOutputValueVO>> mapList = new ArrayList<>();
-        if (!CollectionUtils.isEmpty(references)) {
-            vo.setReference(references);
-            references.forEach(re -> {
-                String snCode = device.getSnCode();
-                String item = re.getItem();
-                Date date = new Date();
-                BigDecimal decimal = new BigDecimal("0.00");
-                String dateStart = DateUtil.getLastWeekDateEndToString(6);
-                String dateEnd = LocalDateTime.now().toString();
-                List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, item, dateStart,dateEnd);
-                List<Map<String, Object>> mapListXy = 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);
-                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
-                        String key = simpleDateFormat.format(currSlopeData.getTs());
-                        SlopeData lastSlopeData = selected.get(i + 1);
-                        Date localDateTime = currSlopeData.getTs();
-                        long epochMilli1 = 0L;
-                        String val2 = "0";
-                        Date localDateTime1 = lastSlopeData.getTs();
-                        if (lastSlopeData != null) {
-                            epochMilli1 = localDateTime1.getTime();
-                            val2 = lastSlopeData.getVal();
-                        }
-                        long epochMilli = localDateTime.getTime();
-                        epochMilli1 = localDateTime1.getTime();
-                        String val1 = currSlopeData.getVal();
-                        long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
-                        long val = Long.parseLong(val1) - Long.parseLong(val2);
-                        decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
-                        map.put(key, decimal);
-                        mapListXy.add(map);
-                    }
-                }
-                vo.setMonitor(mapListXy);
-            });
 
-        }*/
         return HttpResult.ok(vo);
     }
 
@@ -380,28 +360,39 @@ public class DeviceService {
                     .set(KwsDeviceIntegration::getDelFlag, NumberConstant.ONE)
                     .set(KwsDeviceIntegration::getUpdateBy,Long.parseLong(headerData.getUpdateBy()) )
                     .set(KwsDeviceIntegration::getUpdateTime, now));
-            if (update < 1) {
-                throw new BusinessException("删除设备集成要素异常");
-            }
+            //if (update < 1) {
+                //throw new BusinessException("删除设备集成要素异常");
+            //}
 
             //新增到数据表kws_device_Integration
             KwsDeviceIntegration deIntergration = new KwsDeviceIntegration();
             String[] temp;//接收分割后的数组
-            temp = deviceAdd.getIntegrationId().split(Global.COMMA);
-
-            for (int i = 0; i < temp.length; i++) {
-                long interId = new IdWorker(NumberConstant.ONE).nextId();
-                deIntergration.setId(interId);
-                deIntergration.setDeviceId(Long.parseLong(deviceAdd.getId()));
-                deIntergration.setMountainId(headerData.getCompanyId());
-                deIntergration.setIntegrationId(Long.parseLong(temp[i]));
-                deIntergration.setCreateBy(Long.parseLong(headerData.getCreateBy()));
-                deIntergration.setCreateTime(now);
-                deIntergration.setStatus(NumberConstant.ZERO);
-                deIntergration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
-                deIntergration.setUpdateTime(now);
-                deviceIntegrationMapper.insert(deIntergration);
+            if(!deviceAdd.getIntegrationId().isEmpty()){
+                temp = deviceAdd.getIntegrationId().split(Global.COMMA);
+
+                for (int i = 0; i < temp.length; i++) {
+                    long interId = new IdWorker(NumberConstant.ONE).nextId();
+                    deIntergration.setId(interId);
+                    deIntergration.setDeviceId(Long.parseLong(deviceAdd.getId()));
+                    deIntergration.setMountainId(headerData.getCompanyId());
+                    deIntergration.setIntegrationId(Long.parseLong(temp[i]));
+                    deIntergration.setCreateBy(Long.parseLong(headerData.getCreateBy()));
+                    deIntergration.setCreateTime(now);
+                    deIntergration.setStatus(NumberConstant.ZERO);
+                    deIntergration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
+                    deIntergration.setUpdateTime(now);
+                    deviceIntegrationMapper.insert(deIntergration);
+                }
             }
+
+            //新增log
+            //获取新增设备的型号
+            KwsDeviceModel model = deviceModelMapper.selectOne(new LambdaQueryWrapper<KwsDeviceModel>()
+                    .eq(KwsDeviceModel::getId, device.getModelId()));
+            Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
+            logMap.put("name", device.getName());
+            logMap.put("type", model.getName());
+            commonService.insertLog(MessageLogEnum.DEVICE_UPDATE, headerData, logMap, Long.parseLong(headerData.getUpdateBy()));
             return HttpResult.ok();
         }
 
@@ -633,7 +624,7 @@ public class DeviceService {
                 BigDecimal offset = value.subtract(reference.getValue());
                 kwsDeviceReference.setOffset(offset);
                 kwsDeviceReference.setCurrentValue(reference.getValue());
-                kwsDeviceReference.setOriginalValue(value);
+                kwsDeviceReference.setOriginalValue(reference.getOriginalValue());
             }
             kwsDeviceReference.setId(interId);
             kwsDeviceReference.setDeviceId(deviceId);

+ 0 - 1
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/task/ReportTemplateTaskService.java

@@ -55,6 +55,5 @@ public class ReportTemplateTaskService {
                 }
             }
         }
-
     }
 }

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

@@ -31,16 +31,16 @@
 
   <select id="selectByDevicesId" parameterType="java.lang.String" resultType="java.util.Map">
     <!--@mbg.generated-->
-    select count(id) as count,pid,type
+    select count(id) as count,device_id,type
     from kws_alarm
     where 1 = 1
     <if test="devicesId != null and devicesId.size()>0">
-      AND pid IN
+      AND device_id IN
       <foreach collection="devicesId" open="(" close=")" item="item" separator=",">
         #{item}
       </foreach>
     </if>
- group by pid,type
+ group by device_id,type
   </select>
 
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

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

@@ -41,7 +41,7 @@
         SELECT
         <include refid="Base_List">
         </include>
-        FROM devices.slope_data_#{snCode}
+        FROM devicesv2.device_#{snCode}
         where line = #{item}
         order by ts desc limit 1
     </select>