Răsfoiți Sursa

mqtt逻辑修改

lengfaqiang 2 ani în urmă
părinte
comite
a3d70b280f

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

@@ -1,15 +1,14 @@
 package com.sckw.slope.detection.consumer;
 
-import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.AlarmTitleEnum;
 import com.sckw.core.model.enums.AlarmTypeEnum;
-import com.sckw.core.model.enums.DictEnum;
 import com.sckw.core.model.enums.DictItemEnum;
 import com.sckw.core.utils.CollectionUtils;
+import com.sckw.core.utils.DateUtils;
 import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.log.TraceLog.TraceLog;
@@ -17,10 +16,11 @@ import com.sckw.slope.detection.dao.mysql.*;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.*;
 import com.sckw.slope.detection.model.dos.tdengine.Devices;
+import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import com.sckw.slope.detection.model.dto.DevicesAlarm;
 import com.sckw.slope.detection.model.dto.DevicesItem;
-import com.sckw.slope.detection.model.dto.SystemDict;
 import com.sckw.slope.detection.model.param.SmsMessageParam;
+import com.sckw.slope.detection.model.vo.DeviceIntegrationVo;
 import com.sckw.slope.detection.service.CommonService;
 import com.sckw.slope.detection.service.TdengineService;
 import com.sckw.slope.detection.service.api.DetectionApiService;
@@ -67,21 +67,27 @@ public class MqttCallbackHandler extends AbstractHandler {
     @Autowired
     HandlerFactory handlerFactory;
 
+    @Autowired
+    KwsDeviceIntegrationMapper deviceIntegrationMapper;
+
+    @Autowired
+    KwsIntegrationMapper integrationMapper;
+
     @TraceLog(description = "处理system/iot/device_data_slope")
     @DSTransactional
     public HttpResult handle(String topic, String payload) {
         // 根据topic分别进行消息处理。
         log.info("MqttDeviceCallbackHandler:" + topic + "|" + payload);
-        System.out.println("system/iot/device_data_slope");
+
         DevicesAlarm devicesAlarm = JSONObject.parseObject(payload, DevicesAlarm.class);
-        Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
-        JSONObject objects = JSONObject.parseObject(payload);
-        String deviceTs = objects.getString("ts");
-        String deviceGuid = objects.getString("guid");
-        String deviceTslverId = objects.getString("tslver_id");
-        String deviceMsgId = objects.getString("msg_id");
-        String deviceRawTs = objects.getString("raw_ts");
-        JSONArray checkArr = objects.getJSONArray("check_arr");
+//        Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
+//        JSONObject objects = JSONObject.parseObject(payload);
+//        String deviceTs = objects.getString("ts");
+//        String deviceGuid = objects.getString("guid");
+//        String deviceTslverId = objects.getString("tslver_id");
+//        String deviceMsgId = objects.getString("msg_id");
+//        String deviceRawTs = objects.getString("raw_ts");
+//        JSONArray checkArr = objects.getJSONArray("check_arr");
         try {
 //            DevicesAlarm devicesAlarm = JSONObject.parseObject(payload, DevicesAlarm.class);
             String deviceCode = devicesAlarm.getGuid();
@@ -100,6 +106,17 @@ public class MqttCallbackHandler extends AbstractHandler {
             }
             List<DevicesItem> devicesItemList = devicesAlarm.getDevicesItemList();
             if (!CollectionUtils.isEmpty(devicesItemList)) {
+                HashMap<Object, Object> devicesItemMap = devicesItemList.stream().collect(HashMap::new,
+                        (m, v) -> m.put(v.getItemName(), v.getItemValue()), HashMap::putAll);
+                String time = "";
+                long timeDate = 0L;
+                //2023-11-30 22:00:00
+                if (devicesItemMap != null) {
+                    if (Objects.nonNull(devicesItemMap.get("time"))) {
+                        time = String.valueOf(devicesItemMap.get("time").toString());
+                        timeDate = DateUtils.formatDate(time).getTime() / 1000L;
+                    }
+                }
                 for (DevicesItem devicesItem : devicesItemList) {
                     String itemName = devicesItem.getItemName();
                     String itemValue = devicesItem.getItemValue();
@@ -111,7 +128,7 @@ public class MqttCallbackHandler extends AbstractHandler {
                     if (org.springframework.util.CollectionUtils.isEmpty(kwsThresholds)) {
                         continue;
                     }
-                    Long ts = devicesAlarm.getTs();
+                    Long ts = 0L != timeDate ? timeDate : devicesAlarm.getTs();
 //                    //获取到是 十位 1700970600
 //                    if (Objects.nonNull(ts)) {
 //                        ts = ts * 1000;
@@ -145,7 +162,8 @@ public class MqttCallbackHandler extends AbstractHandler {
                         Map<String, Object> messageMap = new HashMap<>();
                         pushSmsMessage(messageUrl, device, level, thresholdId, messageMap);
                     }
-
+                    //集成要素阈值告警
+//                    deviceIntegrationsAlarm(device);
                 }
             }
         } catch (Exception e) {
@@ -154,6 +172,41 @@ public class MqttCallbackHandler extends AbstractHandler {
         return HttpResult.ok();
     }
 
+    private void deviceIntegrationsAlarm(KwsDevice device) {
+        List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(
+                new LambdaQueryWrapper<KwsDeviceIntegration>()
+                        .eq(KwsDeviceIntegration::getDeviceId, device.getId())
+                        .eq(KwsDeviceIntegration::getDelFlag, 0)
+        );
+        List<Long> integrationIds = null;
+        if (!org.springframework.util.CollectionUtils.isEmpty(deviceIntegrations)) {
+            integrationIds = deviceIntegrations.stream().map(KwsDeviceIntegration::getIntegrationId).collect(Collectors.toList());
+        }
+        List<KwsIntegration> integrations = integrationMapper.selectList(
+                new LambdaQueryWrapper<KwsIntegration>()
+                        .in(KwsIntegration::getId, integrationIds)
+                        .eq(KwsIntegration::getDelFlag, NumberConstant.ZERO)
+        );
+        Map<String, Long> integrationMap = new HashMap<>(NumberConstant.SIXTEEN);
+        if (!org.springframework.util.CollectionUtils.isEmpty(integrations)) {
+            integrationMap = integrations.stream().collect(Collectors.toMap(KwsIntegration::getPartNames, KwsIntegration::getId));
+        }
+        //获取集成要素
+        List<DeviceIntegrationVo> intergData = new ArrayList<>();
+        String snCode = device.getSnCode();
+        intergData = deviceIntegrationMapper.selectListParamsAndInterNameByDeviceId(device.getId());
+        if (!Objects.isNull(intergData)) {
+            for (DeviceIntegrationVo inter : intergData) {
+                //获取到当前测量值--现在只有单一值
+                List<SlopeData> slopeData = slopeDataMapper.selectListByTwoLine(snCode, inter.getPartNames());
+                if (!Objects.isNull(slopeData)) {
+                    double offset = commonService.returnIntegrationData(snCode,slopeData,inter);
+                }
+
+            }
+        }
+    }
+
     @Async
     public void pushSmsMessage(String messageUrl, KwsDevice device, Long level, Long thresholdId, Map<String, Object> messageMap) {
         Long deviceId = device.getId();
@@ -294,7 +347,7 @@ public class MqttCallbackHandler extends AbstractHandler {
             }
 //        minList = minList.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
             minList = minList.stream().sorted().distinct().collect(Collectors.toList());
-            maxList = maxList.stream().sorted().distinct().collect(Collectors.toList());
+            maxList = maxList.stream().sorted(Comparator.reverseOrder()).distinct().collect(Collectors.toList());
             /**计算阈值界限*/
             BigDecimal max = getMaxNumber(offset, maxList);
             BigDecimal min = getMinNumber(offset, minList);
@@ -584,8 +637,10 @@ public class MqttCallbackHandler extends AbstractHandler {
     }
 
     public static void main(String[] args) {
-
-        Long ts = 1700969880l;
+        String s = "2023-11-30 22:00:00";
+        Date date = DateUtils.formatDate(s);
+        long time1 = date.getTime();
+        long ts = 1700970600l;
         Instant timestamp = Instant.ofEpochSecond(ts);
 
         ts = ts * 1000;

+ 0 - 6
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/consumer/mqApi/MqttApiHandler.java

@@ -28,12 +28,6 @@ public class MqttApiHandler {
             return handler.handle(topic,payload);
         } catch (Exception e) {
             return HttpResult.error("MQTT回执类型错误");
-//            throw new RuntimeException(e);
         }
-//        if ("ssss".equals(topic)) {
-//            Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
-//            DevicesAlarm devicesAlarm = JSONObject.parseObject(payload, DevicesAlarm.class);
-//            String deviceCode = devicesAlarm.getDeviceCode();
-//        }
     }
 }

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

@@ -34,5 +34,7 @@ public interface KwsDeviceIntegrationMapper extends BaseMapper<KwsDeviceIntegrat
 
     List<KwsDeviceIntegration> selectListByParms(@Param("vo") DeviceVo vo);
 
-    List<DeviceIntegrationVo> selectListByParmsAndInterName(@Param("vo") DeviceVo vo);
+    List<DeviceIntegrationVo> selectListByParamsAndInterName(@Param("vo") DeviceVo vo);
+
+    List<DeviceIntegrationVo> selectListParamsAndInterNameByDeviceId(@Param("id") Long id);
 }

+ 3 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/model/dos/mysql/KwsIntegration.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.TableName;
 import lombok.Data;
 
@@ -42,6 +44,7 @@ public class KwsIntegration implements Serializable {
     /**
      * 备注
      */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private String remark;
 
     /**

+ 48 - 46
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/BackTrackService.java

@@ -11,6 +11,7 @@ import com.sckw.core.utils.IdWorker;
 import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.slope.detection.dao.mysql.*;
+import com.sckw.slope.detection.dao.tdengine.InsTablesMapper;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.mysql.KwsDevice;
 import com.sckw.slope.detection.model.dos.mysql.KwsDeviceReference;
@@ -25,17 +26,17 @@ import com.sckw.slope.detection.model.param.IntegrationQuery;
 import com.sckw.slope.detection.model.vo.IntegrationVo;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
-import com.sckw.slope.detection.dao.tdengine.InsTablesMapper;
+
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @author sky
@@ -75,12 +76,11 @@ public class BackTrackService {
     InsTablesMapper insTablesMapper;
 
 
-
     public HttpResult getParts(String projectId) {
         //首先获取项目中全部设备
         List<DeviceDataDTO> list = deviceMapper.selectAllDeviceByProject(projectId);
         List<String> devicesId = list.stream().map(DeviceDataDTO::getDeviceId).toList();
-        if(devicesId.size() == 0){
+        if (devicesId.size() == 0) {
             return HttpResult.ok(Collections.emptyList());
         }
         //在获取设备的要素
@@ -93,13 +93,13 @@ public class BackTrackService {
             put("code", DictEnum.MODEL_PART.getCodeType());
             put("type", "1");
         }});
-        for (KwsDeviceReference re : references){
+        for (KwsDeviceReference re : references) {
 
         }
         return HttpResult.ok(references);
     }
 
-    public HttpResult getDeviceByParts(String parts,String projectId) {
+    public HttpResult getDeviceByParts(String parts, String projectId) {
         //获取项目中的设备
         List<DeviceDataDTO> listDevice = deviceMapper.selectAllDeviceByProject(projectId);
         List<String> devicesId = listDevice.stream().map(DeviceDataDTO::getDeviceId).toList();
@@ -113,7 +113,7 @@ public class BackTrackService {
         );
         //获取对应的设备
         List<Long> devicesIds = references.stream().map(KwsDeviceReference::getDeviceId).toList();
-        if(Objects.isNull(devicesIds)){
+        if (Objects.isNull(devicesIds)) {
             return HttpResult.ok(Collections.emptyList());
         }
         List<KwsDevice> devices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>()
@@ -123,12 +123,12 @@ public class BackTrackService {
         return HttpResult.ok(devices);
     }
 
-    public HttpResult getDeviceChart(String devicesId,String snCode, String parts, String dateStart,String dateEnd,Integer original) throws ParseException {
+    public HttpResult getDeviceChart(String devicesId, String snCode, String parts, String dateStart, String dateEnd, Integer original) throws ParseException {
         //先查询设备
         KwsDevice deviceHas = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
                 .eq(KwsDevice::getSnCode, snCode));
         String[] arr = parts.split(",");
-        if(!DeviceEnum.ALREADY_REFERRED_TO.getStatus().equals(deviceHas.getStatus().toString())){//未基准
+        if (!DeviceEnum.ALREADY_REFERRED_TO.getStatus().equals(deviceHas.getStatus().toString())) {//未基准
             try {
                 InsTables insTables = insTablesMapper.selectTableIsExit("device_" + snCode);
                 if (insTables == null) {
@@ -139,21 +139,21 @@ public class BackTrackService {
                 return HttpResult.ok(Collections.emptyList());
             }
             List<SlopeData> selectedData = slopeDataMapper.selectLineListByArray(snCode, arr, dateStart, dateEnd);
-            Map<String,List<Object>>  map = new HashMap<>();
+            Map<String, List<Object>> map = new HashMap<>();
 
             if (Objects.isNull(selectedData)) {
-                map = commonService.getDateByNull(dateStart,dateEnd,arr);
+                map = commonService.getDateByNull(dateStart, dateEnd, arr);
                 return HttpResult.ok(map);
             }
             Collections.reverse(selectedData);
-            for(SlopeData slop : selectedData){
-                if(slop.getLine().equals(DictItemEnum.getData(slop.getLine()).getValue())){
+            for (SlopeData slop : selectedData) {
+                if (slop.getLine().equals(DictItemEnum.getData(slop.getLine()).getValue())) {
                     List<Object> list = new ArrayList<>();
                     list.add(slop);
-                    if(map.containsKey(slop.getLine())){
+                    if (map.containsKey(slop.getLine())) {
                         map.get(slop.getLine()).add(slop);
-                    }else{
-                        map.put(slop.getLine(),list);
+                    } else {
+                        map.put(slop.getLine(), list);
                     }
 
                 }
@@ -169,9 +169,9 @@ public class BackTrackService {
         );
         //获取基准值的纬度,X轴偏移量需要
         double angleInRadians = 0;
-        for(KwsDeviceReference element : references) {
+        for (KwsDeviceReference element : references) {
             if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {
-                if(!Objects.isNull(element.getValue())){
+                if (!Objects.isNull(element.getValue())) {
                     angleInRadians = element.getValue().doubleValue();
                 }
 
@@ -186,19 +186,19 @@ public class BackTrackService {
 
         //获取偏移量
         Map<String, Object> mapList = new HashMap<>();
-        for (String st : arr){
-            mapList.put(st,"");
+        for (String st : arr) {
+            mapList.put(st, "");
         }
-        for(KwsDeviceReference element : references) {
-            int index = Arrays.binarySearch(arr,element.getItem());
-            if(index<=0){
+        for (KwsDeviceReference element : references) {
+            int index = Arrays.binarySearch(arr, element.getItem());
+            if (index <= 0) {
                 //continue;
             }
 
-            BigDecimal currentValue =  new BigDecimal("0.00");
-            if(original == 1){
+            BigDecimal currentValue = new BigDecimal("0.00");
+            if (original == 1) {
                 currentValue = element.getOriginalValue();//以原始基准参考
-            }else{
+            } else {
                 currentValue = element.getCurrentValue();//以当前基准参考
             }
 
@@ -206,7 +206,7 @@ public class BackTrackService {
             List<Object> datemap = new ArrayList<>();
             Date date = new Date();
             List<SlopeData> selected = slopeDataMapper.selectLineList(snCode, element.getItem(), dateStart, dateEnd);
-            if(!Objects.isNull((selected))) {
+            if (!Objects.isNull((selected))) {
                 for (SlopeData message : selected) {
                     String line = message.getLine();
                     String val1 = message.getVal();
@@ -217,25 +217,25 @@ public class BackTrackService {
                         double cosValue = Math.cos(angleInRadians);
                         double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
                         offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
-                    }else if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {//如果是Y轴
+                    } else if (DictItemEnum.LATITUDE_Y.getValue().equals(element.getItem())) {//如果是Y轴
                         offsetValue = new BigDecimal(LATITUDE_REFERENCE).multiply(subtract);
                     } else if (DictItemEnum.ALTITUDE_Z.getValue().equals(element.getItem())) {//如果是z轴
                         offsetValue = new BigDecimal(val1).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
-                    }else{//如果是其他
+                    } else {//如果是其他
                         offsetValue = subtract;
                     }
                     Map<String, Object> temp = new HashMap<>();
-                    temp.put("time",key);
-                    temp.put("offset",offsetValue);
+                    temp.put("time", key);
+                    temp.put("offset", offsetValue);
                     datemap.add(temp);
                 }
                 Collections.reverse(datemap);
             }
             mapList.put(element.getItem(), datemap);
         }
-        returnData.put("references",references);
-        returnData.put("threshold",kwsThresholds);
-        returnData.put("chart",mapList);
+        returnData.put("references", references);
+        returnData.put("threshold", kwsThresholds);
+        returnData.put("chart", mapList);
         return HttpResult.ok(returnData);
     }
 
@@ -244,7 +244,7 @@ public class BackTrackService {
      * 集成分析列表
      *
      * @param integrationQuery 请求分页
-     * @param response    http流
+     * @param response         http流
      * @return 返回值
      */
     public PageRes getIntegrationList(IntegrationQuery integrationQuery, HttpServletRequest response) {
@@ -256,16 +256,16 @@ public class BackTrackService {
         if (CollectionUtils.isEmpty(list)) {
             return PageRes.build(pageInfo, list);
         }
-        for(IntegrationVo vo : list){
+        for (IntegrationVo vo : list) {
             List<Object> stringList = new ArrayList<>();
 
             String[] partNames = vo.getPartNames().split(",");
-            for(int i=0;i<partNames.length;i++){
-                Map<String,Object> strArray = new HashMap<>();
-                if(DictItemEnum.getData(partNames[i]).getName().equals("ISNULL")){
-                    strArray.put("name",partNames[i]);
-                }else{
-                    strArray.put("name",DictItemEnum.getData(partNames[i]).getName());
+            for (int i = 0; i < partNames.length; i++) {
+                Map<String, Object> strArray = new HashMap<>();
+                if (DictItemEnum.getData(partNames[i]).getName().equals("ISNULL")) {
+                    strArray.put("name", partNames[i]);
+                } else {
+                    strArray.put("name", DictItemEnum.getData(partNames[i]).getName());
                 }
 
                 stringList.add(strArray);
@@ -289,8 +289,8 @@ public class BackTrackService {
     /**
      * 新增集成元素
      *
-     * @param vo 请求参数
-     * @param request   http流
+     * @param vo      请求参数
+     * @param request http流
      * @return 返回值
      */
     @Transactional
@@ -324,11 +324,12 @@ public class BackTrackService {
         commonService.insertLog(MessageLogEnum.INTEGRATION_ADD, headerData, logMap, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()));
         return HttpResult.ok();
     }
+
     /**
      * 修改集成分析
      *
-     * @param vo 请求参数
-     * @param request   http流
+     * @param vo      请求参数
+     * @param request http流
      * @return 返回值
      */
     @Transactional
@@ -346,6 +347,7 @@ public class BackTrackService {
         Date now = new Date();
         integration.setUpdateBy(Long.parseLong(headerData.getUpdateBy()));
         integration.setUpdateTime(now);
+        integration.setRemark(StringUtils.isBlank(vo.getRemark()) ? null : vo.getRemark());
         integrationMapper.updateById(integration);
         Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
         logMap.put("name", integration.getIntegrationName());

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

@@ -337,7 +337,8 @@ public class DeviceService {
 
         //获取集成要素
         List<DeviceIntegrationVo> intergData = new ArrayList<>();
-        intergData = deviceIntegrationMapper.selectListByParmsAndInterName(vo);
+//        intergData = deviceIntegrationMapper.selectListByParamsAndInterName(vo);
+        intergData = deviceIntegrationMapper.selectListParamsAndInterNameByDeviceId(vo.getId());
         if (!Objects.isNull(intergData)) {
             for (DeviceIntegrationVo inter : intergData) {
                 List<SlopeData> slopeData = slopeDataMapper.selectListByTwoLine(snCode, inter.getPartNames());//获取到当前测量值--现在只有单一值

+ 17 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/task/DeviceAlarmTaskService.java

@@ -0,0 +1,17 @@
+package com.sckw.slope.detection.service.task;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2023-12-01 15:12:59
+ */
+@Slf4j
+@Component
+@EnableScheduling
+public class DeviceAlarmTaskService {
+
+}

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

@@ -52,7 +52,7 @@ mqtt:
     #连接的mqtt地址
     url: tcp://10.10.10.108
     #客户端id
-    clientId: mqttx_45986c5c1ec1
+    clientId: mqttx_45986965ec1
     #推送主题  后面跟着#是监控下面所有的话题
     topic: system/iot/device_data_slope/#
     #topic: my-test

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

@@ -200,7 +200,7 @@
         </if>
     </select>
 
-    <select id="selectListByParmsAndInterName" resultType="com.sckw.slope.detection.model.vo.DeviceIntegrationVo">
+    <select id="selectListByParamsAndInterName" resultType="com.sckw.slope.detection.model.vo.DeviceIntegrationVo">
         <!--@mbg.generated-->
         select
         d.id,d.integration_id,integration_name,part_names,i.unit,formula
@@ -211,4 +211,17 @@
             and device_id = #{vo.id}
         </if>
     </select>
+
+    <select id="selectListParamsAndInterNameByDeviceId"
+            resultType="com.sckw.slope.detection.model.vo.DeviceIntegrationVo">
+        <!--@mbg.generated-->
+        select
+        d.id,d.integration_id,integration_name,part_names,i.unit,formula
+        from kws_device_integration as d
+        inner join kws_integration as i on d.integration_id=i.id
+        where d.del_flag = 0 and i.del_flag = 0
+        <if test="id != null and id != ''">
+            and device_id = #{id}
+        </if>
+    </select>
 </mapper>