refactor(ems): 优化报警数据相关功能

- 修改异常类型描述,将"低于阈值"改为"小于阈值"
- 更新获取异常数据总数的方法,包含所有告警类型
- 优化报警数据查询 SQL,添加排序条件
- 更新触发规则描述,将"设备报警"改为"小于阈值"
- 在 RecordIotenvInstant 实体中添加能源类型相关字段
- 优化 RecordIotenvInstant 服务实现,设置能源类型相关属性
boardTest
zch 1 month ago
parent 49329f4055
commit f100f1771b

@ -116,7 +116,7 @@ public class EmsRecordAlarmDataController extends BaseController
}
/**
* alarm_type = 0)
*
*/
@GetMapping("/getAlarmDataTotalCount")
public int getAlarmDataTotalCount()

@ -41,8 +41,8 @@ public class EmsRecordAlarmData extends BaseEntity
@Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date collectTime;
/** 异常类型0超过阈值 1低于阈值 */
// @Excel(name = "异常类型", readConverterExp = "0=超过阈值,1=设备离线")
/** 异常类型0超过阈值 1小于阈值) */
// @Excel(name = "异常类型", readConverterExp = "0=超过阈值,1=小于阈值")
private Long alarmType;
/** 异常状态0已处理 1未处理 */

@ -44,8 +44,8 @@ public class EmsRecordAlarmRule extends BaseEntity
@Excel(name = "能源类型")
private Long energyType;
/** 触发规则0超过阈值 1设备报警 */
@Excel(name = "触发规则", readConverterExp = "0=超过阈值,1=设备报警")
/** 触发规则0大于 1小于 */
@Excel(name = "触发规则", readConverterExp = "0=超过阈值,1=小于阈值")
private Long triggerRule;
/** 监测字段 */

@ -86,6 +86,10 @@ public class RecordIotenvInstant extends BaseEntity
@Excel(name = "计量设备编号")
private String monitorCode;
/** 能源类型 */
private Long monitorType;
private String energyName;
//
// public void setObjid(Long objid)

@ -84,7 +84,7 @@ public interface EmsRecordAlarmDataMapper
@Param("endTime") Date endTime);
/**
* alarm_type = 0
*
*/
Integer getAlarmDataTotalCount();
}

@ -72,7 +72,7 @@ public interface IEmsRecordAlarmDataService
void checkIotenvThresholdAlarms();
/**
* alarm_type = 0)
*
*/
public int getAlarmDataTotalCount();
}

@ -744,7 +744,7 @@ public class EmsRecordAlarmDataServiceImpl implements IEmsRecordAlarmDataService
}
/**
* alarm_type = 0
*
*/
@Override
public int getAlarmDataTotalCount() {

@ -330,6 +330,7 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
String monitorCode = baseMonitorInfo.getMonitorCode();
String monitorName = baseMonitorInfo.getMonitorName();
Long monitorType = baseMonitorInfo.getMonitorType();
String energyName = baseMonitorInfo.getEnergyName();
RecordIotenvInstant iotenvInstant = recordMap.get(monitorCode);
if (iotenvInstant == null) {
@ -341,6 +342,8 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
// 设置设备基本信息
iotenvInstant.setMonitorName(monitorName);
iotenvInstant.setMonitorCode(monitorCode);
iotenvInstant.setEnergyName(energyName);
iotenvInstant.setMonitorType(monitorType);
result.add(iotenvInstant);
}
@ -351,6 +354,8 @@ public class RecordIotenvInstantServiceImpl implements IRecordIotenvInstantServi
iotenvInstant.setMonitorId(baseMonitorInfo.getMonitorCode());
iotenvInstant.setMonitorName(baseMonitorInfo.getMonitorName());
iotenvInstant.setMonitorCode(baseMonitorInfo.getMonitorCode());
iotenvInstant.setEnergyName(baseMonitorInfo.getEnergyName());
iotenvInstant.setMonitorType(baseMonitorInfo.getMonitorType());
// 数据值字段保持null前端会显示"无最新数据"
result.add(iotenvInstant);
}

@ -53,23 +53,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectEmsRecordAlarmDataList" parameterType="EmsRecordAlarmData" resultMap="EmsRecordAlarmDataResult">
<include refid="selectEmsRecordAlarmDataVo"/>
<where>
<if test="monitorId != null and monitorId != ''"> and monitor_id = #{monitorId}</if>
<if test="collectDeviceId != null and collectDeviceId != ''"> and collect_device_id = #{collectDeviceId}</if>
<if test="collectTime != null "> and collect_time = #{collectTime}</if>
<if test="alarmType != null "> and alarm_type = #{alarmType}</if>
<if test="alarmStatus != null "> and alarm_status = #{alarmStatus}</if>
<if test="alarmData != null and alarmData != ''"> and alarm_data = #{alarmData}</if>
<if test="operationName != null and operationName != ''"> and operation_name like concat('%', #{operationName}, '%')</if>
<if test="beginOperationTime != null "> and operation_time >= #{beginOperationTime}</if>
<if test="endOperationTime != null "> and #{endOperationTime} >= operation_time</if>
<if test="cause != null and cause != ''"> and cause = #{cause}</if>
<if test="notifyUser != null and notifyUser != ''"> and notify_user = #{notifyUser}</if>
<if test="monitorId != null and monitorId != ''"> and rad.monitor_id = #{monitorId}</if>
<if test="collectDeviceId != null and collectDeviceId != ''"> and rad.collect_device_id = #{collectDeviceId}</if>
<if test="collectTime != null "> and rad.collect_time = #{collectTime}</if>
<if test="alarmType != null "> and rad.alarm_type = #{alarmType}</if>
<if test="alarmStatus != null "> and rad.alarm_status = #{alarmStatus}</if>
<if test="alarmData != null and alarmData != ''"> and rad.alarm_data = #{alarmData}</if>
<if test="operationName != null and operationName != ''"> and rad.operation_name like concat('%', #{operationName}, '%')</if>
<if test="beginOperationTime != null "> and rad.operation_time >= #{beginOperationTime}</if>
<if test="endOperationTime != null "> and #{endOperationTime} >= rad.operation_time</if>
<if test="cause != null and cause != ''"> and rad.cause = #{cause}</if>
<if test="notifyUser != null and notifyUser != ''"> and rad.notify_user = #{notifyUser}</if>
</where>
ORDER BY rad.obj_id DESC
</select>
<select id="selectEmsRecordAlarmDataByObjId" parameterType="Long" resultMap="EmsRecordAlarmDataResult">
<include refid="selectEmsRecordAlarmDataVo"/>
where RAD.obj_id = #{objId}
where rad.obj_id = #{objId}
</select>
<insert id="insertEmsRecordAlarmData" parameterType="EmsRecordAlarmData" useGeneratedKeys="true" keyProperty="objId">
@ -159,8 +160,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
rad.notify_user
FROM ems_record_alarm_data rad
WHERE rad.alarm_status = 1
AND rad.alarm_type = 0
AND rad.create_time >= #{startTime}
ORDER BY rad.obj_id DESC
</select>
<!-- 检查特定条件的异常数据是否已存在(精确去重) -->
@ -170,16 +171,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM ems_record_alarm_data
WHERE monitor_id = #{monitorId}
AND cause = #{cause}
AND alarm_type = 0
AND alarm_status = 1
AND collect_time BETWEEN #{startTime} AND #{endTime}
</select>
<!-- 获取数据表总数(alarm_type = 0 -->
<!-- 获取数据表总数(包含所有告警类型 -->
<select id="getAlarmDataTotalCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM ems_record_alarm_data
WHERE alarm_type = 0
</select>
</mapper>

Loading…
Cancel
Save