|
@@ -40,6 +40,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.*;
|
|
import java.time.*;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -153,10 +154,22 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
Long level = Long.valueOf(map.get("level"));
|
|
Long level = Long.valueOf(map.get("level"));
|
|
|
Long thresholdId = Long.valueOf(map.get("thresholdId"));
|
|
Long thresholdId = Long.valueOf(map.get("thresholdId"));
|
|
|
String offset = map.get("offset");
|
|
String offset = map.get("offset");
|
|
|
|
|
+// /**x、y、z要进行偏移量计算 其他数值保持源数据进行计算*/
|
|
|
|
|
+// List<String> checkItemName = new ArrayList<>();
|
|
|
|
|
+// checkItemName.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
|
|
+// checkItemName.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
|
|
+// checkItemName.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
|
|
+// String itemValueAndUnit = "";
|
|
|
|
|
+// String url = "";
|
|
|
|
|
+// if (checkItemName.contains(itemName)) {
|
|
|
|
|
+//
|
|
|
|
|
+// itemValueAndUnit = StringUtils.isBlank(url) ? itemValue : (itemValue + url);
|
|
|
|
|
+// } else {
|
|
|
|
|
+// url = dictByDictCode.get(itemName) == null ? null : dictByDictCode.get(itemName).getRemark();
|
|
|
|
|
+// itemValueAndUnit = StringUtils.isBlank(url) ? itemValue : (itemValue + url);
|
|
|
|
|
+// }
|
|
|
//阈值表以及明细表存储
|
|
//阈值表以及明细表存储
|
|
|
- String url = dictByDictCode.get(itemName) == null ? null : dictByDictCode.get(itemName).getUrl();
|
|
|
|
|
- String itemValueAndUnit = StringUtils.isBlank(url) ? itemValue : (itemValue + url);
|
|
|
|
|
- long id = insertAlarmAndDetail(level, device, thresholdId, itemValueAndUnit, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
|
|
|
|
+ long id = insertAlarmAndDetail(level, device, thresholdId, offset, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
//todo 不适用redis存统计 使用新字段处理
|
|
//todo 不适用redis存统计 使用新字段处理
|
|
|
/**阈值次数存redis*/
|
|
/**阈值次数存redis*/
|
|
|
// redisPutAlarmCount(id);
|
|
// redisPutAlarmCount(id);
|
|
@@ -186,7 +199,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
templateParam.put("level", level.toString());
|
|
templateParam.put("level", level.toString());
|
|
|
templateParam.put("name", device.getName());
|
|
templateParam.put("name", device.getName());
|
|
|
// templateParam.put("value", itemValue);
|
|
// templateParam.put("value", itemValue);
|
|
|
- templateParam.put("value", offset+url);
|
|
|
|
|
|
|
+ templateParam.put("value", offset);
|
|
|
commonService.pushSmsMessage(pushToPhone
|
|
commonService.pushSmsMessage(pushToPhone
|
|
|
, smsTemplateConfig.getDataAlarm().getSmsCode()
|
|
, smsTemplateConfig.getDataAlarm().getSmsCode()
|
|
|
, smsTemplateConfig.getDataAlarm().getSignName()
|
|
, smsTemplateConfig.getDataAlarm().getSignName()
|
|
@@ -216,7 +229,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
templateParam.put("time", time);
|
|
templateParam.put("time", time);
|
|
|
templateParam.put("project", vo == null ? null : vo.getProjectName());
|
|
templateParam.put("project", vo == null ? null : vo.getProjectName());
|
|
|
// templateParam.put("value", itemValue);
|
|
// templateParam.put("value", itemValue);
|
|
|
- templateParam.put("value", offset+url);
|
|
|
|
|
|
|
+ templateParam.put("value", offset);
|
|
|
commonService.pushEmailMessage(emailAddress
|
|
commonService.pushEmailMessage(emailAddress
|
|
|
, templateParam);
|
|
, templateParam);
|
|
|
}
|
|
}
|
|
@@ -288,9 +301,10 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
Long level = Long.valueOf(map.get("level"));
|
|
Long level = Long.valueOf(map.get("level"));
|
|
|
Long thresholdId = Long.valueOf(map.get("thresholdId"));
|
|
Long thresholdId = Long.valueOf(map.get("thresholdId"));
|
|
|
//阈值表以及明细表存储
|
|
//阈值表以及明细表存储
|
|
|
- String url = deviceIntegration.getUnit() == null ? null : deviceIntegration.getUnit();
|
|
|
|
|
- String itemValueAndUnit = StringUtils.isBlank(url) ? String.valueOf(offset) : (offset + deviceIntegration.getUnit());
|
|
|
|
|
- long id = insertAlarmAndDetail(level, device, thresholdId, itemValueAndUnit, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
|
|
|
|
+// String url = deviceIntegration.getUnit() == null ? null : deviceIntegration.getUnit();
|
|
|
|
|
+// String itemValueAndUnit = StringUtils.isBlank(url) ? String.valueOf(offset) : (offset + deviceIntegration.getUnit());
|
|
|
|
|
+// long id = insertAlarmAndDetail(level, device, thresholdId, itemValueAndUnit, ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
|
|
+ long id = insertAlarmAndDetail(level, device, thresholdId, offset + deviceIntegration.getUnit(), ts, AlarmTitleEnum.ALARM_TITLE_TWO.getStatus(), AlarmTypeEnum.ALARM_ONE.getCode());
|
|
|
/**最初发送短信模式*/
|
|
/**最初发送短信模式*/
|
|
|
// oldPushSms(device,level,thresholdId);
|
|
// oldPushSms(device,level,thresholdId);
|
|
|
/**目前发送短信模式*/
|
|
/**目前发送短信模式*/
|
|
@@ -317,7 +331,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
templateParam.put("level", level.toString());
|
|
templateParam.put("level", level.toString());
|
|
|
templateParam.put("name", device.getName());
|
|
templateParam.put("name", device.getName());
|
|
|
// templateParam.put("value", itemValueAndUnit);
|
|
// templateParam.put("value", itemValueAndUnit);
|
|
|
- templateParam.put("value", String.valueOf(offset)+url);
|
|
|
|
|
|
|
+ templateParam.put("value", String.valueOf(offset) + deviceIntegration.getUnit());
|
|
|
commonService.pushSmsMessage(pushToPhone
|
|
commonService.pushSmsMessage(pushToPhone
|
|
|
, smsTemplateConfig.getDataAlarm().getSmsCode()
|
|
, smsTemplateConfig.getDataAlarm().getSmsCode()
|
|
|
, smsTemplateConfig.getDataAlarm().getSignName()
|
|
, smsTemplateConfig.getDataAlarm().getSignName()
|
|
@@ -347,7 +361,7 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
templateParam.put("time", time);
|
|
templateParam.put("time", time);
|
|
|
templateParam.put("project", vo == null ? null : vo.getProjectName());
|
|
templateParam.put("project", vo == null ? null : vo.getProjectName());
|
|
|
// templateParam.put("value", itemValueAndUnit);
|
|
// templateParam.put("value", itemValueAndUnit);
|
|
|
- templateParam.put("value", String.valueOf(offset)+url);
|
|
|
|
|
|
|
+ templateParam.put("value", String.valueOf(offset) + deviceIntegration.getUnit());
|
|
|
commonService.pushEmailMessage(emailAddress
|
|
commonService.pushEmailMessage(emailAddress
|
|
|
, templateParam);
|
|
, templateParam);
|
|
|
}
|
|
}
|
|
@@ -445,13 +459,16 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
//放入告警数值-告警等级
|
|
//放入告警数值-告警等级
|
|
|
//放入告警等级-告警主键id
|
|
//放入告警等级-告警主键id
|
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
+ Map<String, SystemDict> dictByDictCode = commonService.getDictByDictCode(DictEnum.MODEL_PART);
|
|
|
if (checkItemName.contains(itemName)) {
|
|
if (checkItemName.contains(itemName)) {
|
|
|
BigDecimal offset = commonService.computeOffset(itemValue, itemName, deviceRelation);
|
|
BigDecimal offset = commonService.computeOffset(itemValue, itemName, deviceRelation);
|
|
|
map = newAlarmCompute(offset, kwsThresholds);
|
|
map = newAlarmCompute(offset, kwsThresholds);
|
|
|
- map.put("offset",String.valueOf(offset));
|
|
|
|
|
|
|
+ String url = dictByDictCode.get(itemName) == null ? null : dictByDictCode.get(itemName).getUrl();
|
|
|
|
|
+ map.put("offset", String.valueOf(offset.setScale(2, RoundingMode.HALF_UP)) + url);
|
|
|
} else {
|
|
} else {
|
|
|
map = newAlarmCompute(new BigDecimal(itemValue), kwsThresholds);
|
|
map = newAlarmCompute(new BigDecimal(itemValue), kwsThresholds);
|
|
|
- map.put("offset",itemValue);
|
|
|
|
|
|
|
+ String remarkUnit = dictByDictCode.get(itemName) == null ? null : dictByDictCode.get(itemName).getRemark();
|
|
|
|
|
+ map.put("offset", itemValue + remarkUnit);
|
|
|
}
|
|
}
|
|
|
// map = oldAlarmCompute(checkItemName, itemName, itemValue, deviceRelation, kwsThresholds);
|
|
// map = oldAlarmCompute(checkItemName, itemName, itemValue, deviceRelation, kwsThresholds);
|
|
|
return map;
|
|
return map;
|
|
@@ -705,9 +722,9 @@ public class MqttCallbackHandler extends AbstractHandler {
|
|
|
.orderByDesc(KwsAlarm::getCreateTime);
|
|
.orderByDesc(KwsAlarm::getCreateTime);
|
|
|
if (projectDevice != null) {
|
|
if (projectDevice != null) {
|
|
|
wrapper.eq(Objects.nonNull(projectDevice.getProjectId()), KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
wrapper.eq(Objects.nonNull(projectDevice.getProjectId()), KwsAlarm::getProjectId, projectDevice.getProjectId())
|
|
|
- .eq(StringUtils.isNotBlank(device.getMountainId()),KwsAlarm::getMountainId, projectDevice.getMountainId());
|
|
|
|
|
|
|
+ .eq(StringUtils.isNotBlank(device.getMountainId()), KwsAlarm::getMountainId, projectDevice.getMountainId());
|
|
|
if (projectDevice.getProjectId() != null) {
|
|
if (projectDevice.getProjectId() != null) {
|
|
|
- wrapper.eq(StringUtils.isNotBlank(projectDevice.getCompanyId()),KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
|
|
|
|
+ wrapper.eq(StringUtils.isNotBlank(projectDevice.getCompanyId()), KwsAlarm::getCompanyId, projectDevice.getCompanyId());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|
|
long alarmId = new IdWorker(NumberConstant.ONE).nextId();
|