Commit 7052a6ca authored by KeYong's avatar KeYong

提交告警规则

parent 2185c814
......@@ -125,4 +125,7 @@ public class EquipmentIndex extends BaseEntity {
@TableField(value = "unit")
private String unit;
@TableField(value = "alarm_rule")
private String alarmRule;
}
......@@ -145,9 +145,6 @@ public class EquipmentSpecificIndex extends BaseEntity {
@TableField(exist = false)
private String buildId;
@ApiModelProperty(value = "是否遥测")
@TableField(exist = false)
private Integer isTrend;
@ApiModelProperty(value = "绑定视屏数量")
@TableField(exist = false)
private int num;
......@@ -208,4 +205,12 @@ public class EquipmentSpecificIndex extends BaseEntity {
@ApiModelProperty(value = "网关标识")
@TableField(value = "gateway_id")
private String gatewayId;
@ApiModelProperty(value = "告警规则")
@TableField(value = "alarm_rule")
private String alarmRule;
@ApiModelProperty(value = "是否遥测")
@TableField(value = "is_trend")
private Boolean isTrend;
}
......@@ -90,4 +90,7 @@ public class EquipmentIndexVO {
@ApiModelProperty(value = "装备指标名称")
private String equipmentIndexName;
@ApiModelProperty(value = "告警规则")
private String alarmRule;
}
......@@ -1602,6 +1602,8 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
equipmentSpecificIndex.setUnit(index.getUnit());
equipmentSpecificIndex.setValueEnum(index.getValueEnum());
equipmentSpecificIndex.setTypeCode(index.getTypeCode());
equipmentSpecificIndex.setIsTrend(index.getIsTrend());
equipmentSpecificIndex.setAlamReason(index.getAlarmRule());
equipmentSpecificIndices.add(equipmentSpecificIndex);
});
}
......@@ -1940,7 +1942,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
iotIndexInfoVo.setType(equipmentSpecificIndex.getTypeName()!=null?equipmentSpecificIndex.getTypeName(): equipmentSpecificIndex.getIndexName());
iotIndexInfoVo.setNumber(deviceName);
if (equipmentSpecificIndex.getIsTrend() == 1) {
if (equipmentSpecificIndex.getIsTrend()) {
BigDecimal val = new BigDecimal(String.valueOf(entry.getValue()));
iotIndexInfoVo.setContent(equipmentSpecificIndex.getIndexName() + (val.setScale(2, BigDecimal.ROUND_HALF_UP)) + equipmentSpecificIndex.getIndexUnitName());
} else {
......
......@@ -533,7 +533,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObjectXf = new JSONObject();
jsonObjectXf.put("data_class", "realdata");
if (equipmentSpeIndex.getIsTrend() == 1) {
if (equipmentSpeIndex.getIsTrend()) {
jsonObjectXf.put("data_type", "analog");
} else {
jsonObjectXf.put("data_type", "state");
......@@ -567,7 +567,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
jsonObjectXf.put("data", jsonObjects);
// 遥测
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend() == 1) {
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend()) {
} else {
try {
......@@ -800,7 +800,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObjectXf = new JSONObject();
jsonObjectXf.put("data_class", "realdata");
if (equipmentSpeIndex.getIsTrend() == 1) {
if (equipmentSpeIndex.getIsTrend()) {
jsonObjectXf.put("data_type", "analog");
} else {
jsonObjectXf.put("data_type", "state");
......@@ -832,7 +832,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
jsonObjectXf.put("data", jsonObjects);
// 遥测
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend() == 1) {
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend()) {
} else {
try {
......@@ -1062,7 +1062,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObjectXf = new JSONObject();
jsonObjectXf.put("data_class", "realdata");
if (equipmentSpeIndex.getIsTrend() == 1) {
if (equipmentSpeIndex.getIsTrend()) {
jsonObjectXf.put("data_type", "analog");
} else {
jsonObjectXf.put("data_type", "state");
......@@ -1096,7 +1096,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
jsonObjectXf.put("data", jsonObjects);
// 遥测
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend() == 1) {
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend()) {
} else {
try {
......@@ -1940,41 +1940,89 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
if (verifyNB(equipmentSpcIndex.getNameKey())) {
return getNbEquipAlarmList(indexAlarms, equipmentSpcIndex, equipmentSpecificAlarm, messageBody);
}
// 报警表新增信息
if (ObjectUtils.isEmpty(indexAlarms) && (TrueOrFalseEnum.real.value.equals(equipmentSpcIndex.getValue()))) {
equipmentSpecificAlarms = addEquipmentSpecificAlarm(equipmentSpecificAlarms, equipmentSpcIndex, equipmentSpecificAlarm, messageBody);
Boolean flag = judgeIsAlarm(equipmentSpcIndex.getAlarmRule(), equipmentSpcIndex.getValue());
if (StringUtil.isNotEmpty(equipmentSpcIndex.getAlarmRule())) {
if (ObjectUtils.isEmpty(indexAlarms) && flag) {
equipmentSpecificAlarms = addEquipmentSpecificAlarm(equipmentSpecificAlarms, equipmentSpcIndex, equipmentSpecificAlarm, messageBody);
} else {
for (EquipmentSpecificAlarm action : indexAlarms) {
if (flag) {
// 报警,修改发生频率
action.setFrequency((action.getFrequency() + 1));
} else {
// 报警恢复,修改数据为恢复状态
action.setRecoveryDate(new Date());
action.setEquipmentSpecificIndexValue(equipmentSpcIndex.getValue());
action.setStatus(AlarmStatusEnum.HF.getCode());
}
action.setUpdateDate(new Date());
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
action.setTraceId(equipmentSpcIndex.getTraceId());
action.setSystemIds(equipmentSpcIndex.getSystemId());
action.setSystemCodes(this.getSystemCodeBySpeId(equipmentSpcIndex.getSystemId()));
action.setEquipmentSpecificName(equipmentSpcIndex.getEquipmentSpecificName());
action.setEquipmentCode(equipmentSpcIndex.getEquipmentCode());
// 冗余字段,alarm_log表更新时使用
action.setEquipmentSpecificCode(equipmentSpcIndex.getEquipmentSpecificCode());
action.setBuildId(equipmentSpcIndex.getBuildId());
action.setBizOrgName(equipmentSpcIndex.getBizOrgName());
action.setBizOrgCode(equipmentSpcIndex.getBizOrgCode());
action.setMessageBody(!ObjectUtils.isEmpty(messageBody) ? messageBody.get("messageBody") : "");
equipmentSpecificAlarms.add(action);
}
}
} else {
// 报警表更新信息
for (EquipmentSpecificAlarm action : indexAlarms) {
if (TrueOrFalseEnum.real.value.equals(equipmentSpcIndex.getValue())) {
// 报警,修改发生频率
action.setFrequency((action.getFrequency() + 1));
} else {
// 报警恢复,修改数据为恢复状态
action.setRecoveryDate(new Date());
action.setEquipmentSpecificIndexValue(TrueOrFalseEnum.fake.value);
action.setStatus(AlarmStatusEnum.HF.getCode());
// 报警表新增信息
if (ObjectUtils.isEmpty(indexAlarms) && (TrueOrFalseEnum.real.value.equals(equipmentSpcIndex.getValue()))) {
equipmentSpecificAlarms = addEquipmentSpecificAlarm(equipmentSpecificAlarms, equipmentSpcIndex, equipmentSpecificAlarm, messageBody);
} else {
// 报警表更新信息
for (EquipmentSpecificAlarm action : indexAlarms) {
if (TrueOrFalseEnum.real.value.equals(equipmentSpcIndex.getValue())) {
// 报警,修改发生频率
action.setFrequency((action.getFrequency() + 1));
} else {
// 报警恢复,修改数据为恢复状态
action.setRecoveryDate(new Date());
action.setEquipmentSpecificIndexValue(equipmentSpcIndex.getValue());
action.setStatus(AlarmStatusEnum.HF.getCode());
}
action.setUpdateDate(new Date());
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
action.setTraceId(equipmentSpcIndex.getTraceId());
action.setSystemIds(equipmentSpcIndex.getSystemId());
action.setSystemCodes(this.getSystemCodeBySpeId(equipmentSpcIndex.getSystemId()));
action.setEquipmentSpecificName(equipmentSpcIndex.getEquipmentSpecificName());
action.setEquipmentCode(equipmentSpcIndex.getEquipmentCode());
// 冗余字段,alarm_log表更新时使用
action.setEquipmentSpecificCode(equipmentSpcIndex.getEquipmentSpecificCode());
action.setBuildId(equipmentSpcIndex.getBuildId());
action.setBizOrgName(equipmentSpcIndex.getBizOrgName());
action.setBizOrgCode(equipmentSpcIndex.getBizOrgCode());
action.setMessageBody(!ObjectUtils.isEmpty(messageBody) ? messageBody.get("messageBody") : "");
equipmentSpecificAlarms.add(action);
}
action.setUpdateDate(new Date());
// 更新所在系统,设备可能编辑过,更新所在系统、装备名称、装备定义code
action.setTraceId(equipmentSpcIndex.getTraceId());
action.setSystemIds(equipmentSpcIndex.getSystemId());
action.setSystemCodes(this.getSystemCodeBySpeId(equipmentSpcIndex.getSystemId()));
action.setEquipmentSpecificName(equipmentSpcIndex.getEquipmentSpecificName());
action.setEquipmentCode(equipmentSpcIndex.getEquipmentCode());
// 冗余字段,alarm_log表更新时使用
action.setEquipmentSpecificCode(equipmentSpcIndex.getEquipmentSpecificCode());
action.setBuildId(equipmentSpcIndex.getBuildId());
action.setBizOrgName(equipmentSpcIndex.getBizOrgName());
action.setBizOrgCode(equipmentSpcIndex.getBizOrgCode());
action.setMessageBody(!ObjectUtils.isEmpty(messageBody) ? messageBody.get("messageBody") : "");
equipmentSpecificAlarms.add(action);
}
}
return equipmentSpecificAlarms;
}
/**
* 根据alarm_rule规则字段判断是否是告警
* @return
*/
private Boolean judgeIsAlarm(String rule, String value) {
Boolean bool = Boolean.TRUE;
if (StringUtil.isNotEmpty(rule)) {
if (!rule.equalsIgnoreCase(value)) {
bool = Boolean.FALSE;
}
}
return bool;
}
/**
* 发送数据至换流站
*
* @param
......
......@@ -952,4 +952,20 @@
UPDATE `wl_car` wc SET wc.use_type = '自购';
</sql>
</changeSet>
<changeSet author="keyong" id="1694055999">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_index" columnName="alarm_rule"/>
</not>
</preConditions>
<comment>新增字段 type_code</comment>
<sql>
alter table `wl_equipment_index` add column `alarm_rule` varchar(50) DEFAULT NULL COMMENT '告警规则';
alter table `wl_equipment_specific_index` add column `is_trend` bit(1) DEFAULT b'0' COMMENT '是否支持趋势查看(冗余自wl_equipment_index)';
alter table `wl_equipment_specific_index` add column `alarm_rule` varchar(50) DEFAULT NULL COMMENT '告警规则(冗余自wl_equipment_index)';
UPDATE wl_equipment_specific_index esi SET esi.is_trend = ( SELECT is_trend FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id ),
esi.alarm_rule = ( SELECT alarm_rule FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id );
</sql>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
......@@ -158,7 +158,8 @@
sort_num,
type,
is_trend,
value_enum
value_enum,
alarm_rule AS alarmRule
from
wl_equipment_index
where id = #{id}
......
......@@ -67,7 +67,8 @@
TRIM(CONCAT_WS(' ',wes.position,sd.description)) AS location,
sd.warehouse_structure_id AS buildId,
wes.biz_org_name AS bizOrgName,
wes.biz_org_code AS bizOrgCode
wes.biz_org_code AS bizOrgCode,
wesi.alarm_rule AS alarmRule
FROM
wl_equipment_specific_index AS wesi
LEFT JOIN wl_equipment_specific AS wes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment