lengfaqiang 2 anni fa
parent
commit
ca6478a0b6

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

@@ -156,7 +156,7 @@ public class MqttCallbackHandler extends AbstractHandler {
                         pushSmsMessage(messageUrl, device, level, thresholdId, messageMap);
                     }
                     //集成要素阈值告警
-                    deviceIntegrationsAlarm(device,ts);
+                    deviceIntegrationsAlarm(device, ts);
                 }
             }
         } catch (Exception e) {
@@ -180,7 +180,7 @@ public class MqttCallbackHandler extends AbstractHandler {
         }
     }
 
-    private void deviceIntegrationsAlarm(KwsDevice device,Long ts) {
+    private void deviceIntegrationsAlarm(KwsDevice device, Long ts) {
         List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(
                 new LambdaQueryWrapper<KwsDeviceIntegration>()
                         .eq(KwsDeviceIntegration::getDeviceId, device.getId())
@@ -195,10 +195,10 @@ public class MqttCallbackHandler extends AbstractHandler {
                         .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));
-        }
+//        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();
@@ -207,10 +207,10 @@ public class MqttCallbackHandler extends AbstractHandler {
             for (DeviceIntegrationVo deviceIntegration : intergData) {
                 //获取到当前测量值--现在只有单一值
                 List<SlopeData> slopeData = slopeDataMapper.selectListByTwoLine(snCode, deviceIntegration.getPartNames());
-                if (!Objects.isNull(slopeData)) {
+                if (!Objects.isNull(slopeData) && slopeData.size() == 2) {
                     List<KwsThreshold> thresholdList = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
                             .eq(KwsThreshold::getDeviceId, device.getId())
-                            .eq(KwsThreshold::getItemName, deviceIntegration.getPartNames())
+                            .eq(KwsThreshold::getItemName, deviceIntegration.getIntegrationName())
                     );
                     double offset = commonService.returnIntegrationData(snCode, slopeData, deviceIntegration);
                     Map<String, String> map = newAlarmCompute(new BigDecimal(offset), thresholdList);

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

@@ -396,7 +396,7 @@ public class ThresholdService {
         KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>().eq(KwsDevice::getId, Long.parseLong(deviceId)));
         Map<String, Object> logMap = new HashMap<>(NumberConstant.SIXTEEN);
         logMap.put("projectName", project.getName());
-        logMap.put("element", dict == null ? itemName : dict.get(itemName).getLabel());
+        logMap.put("element", dict == null ? itemName : (dict.get(itemName) == null ? itemName : dict.get(itemName).getLabel()));
         logMap.put("deviceName", kwsDevice == null ? null : kwsDevice.getName());
         commonService.insertLog(MessageLogEnum.SETTINGS_DEVICE_THRESHOLD, headerData, logMap, headerData.getUpdateBy() == null ?
                 null : Long.parseLong(headerData.getUpdateBy()));