change - 修改设备报警逻辑

master
yinq 7 months ago
parent 6f1b49a17e
commit 57dfb7e91d

@ -1,5 +1,6 @@
package com.aucma.report.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
@ -22,6 +23,17 @@ public class DeviceAlarmRecord extends BaseEntity {
*/
private Long objId;
/**
* 线
*/
private String productLineCode;
/**
* 线
*/
@Excel(name = "产线名称")
private String productLineName;
/**
*
*/
@ -47,12 +59,25 @@ public class DeviceAlarmRecord extends BaseEntity {
private String alarmInfo;
/**
*
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "报警时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "报警开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date alarmTime;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "报警结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date alarmEndTime;
/**
* ()
*/
@Excel(name = "报警时长(分钟)")
private BigDecimal alarmDuration;
/**
*
*/
@ -86,6 +111,38 @@ public class DeviceAlarmRecord extends BaseEntity {
@Excel(name = "参数值")
private String paramValue;
public BigDecimal getAlarmDuration() {
return alarmDuration;
}
public void setAlarmDuration(BigDecimal alarmDuration) {
this.alarmDuration = alarmDuration;
}
public String getProductLineCode() {
return productLineCode;
}
public void setProductLineCode(String productLineCode) {
this.productLineCode = productLineCode;
}
public String getProductLineName() {
return productLineName;
}
public void setProductLineName(String productLineName) {
this.productLineName = productLineName;
}
public Date getAlarmEndTime() {
return alarmEndTime;
}
public void setAlarmEndTime(Date alarmEndTime) {
this.alarmEndTime = alarmEndTime;
}
public String getParamCode() {
return paramCode;
}

@ -18,6 +18,10 @@
<result property="batchId" column="batch_id"/>
<result property="paramCode" column="param_code"/>
<result property="paramValue" column="param_value"/>
<result property="productLineCode" column="PRODUCT_LINE_CODE"/>
<result property="productLineName" column="PRODUCT_LINE_NAME"/>
<result property="alarmEndTime" column="alarmEndTime"/>
<result property="alarmDuration" column="alarmDuration"/>
</resultMap>
<sql id="selectDeviceAlarmRecordVo">
@ -39,7 +43,44 @@
</sql>
<select id="selectDeviceAlarmRecordList" parameterType="DeviceAlarmRecord" resultMap="DeviceAlarmRecordResult">
<include refid="selectDeviceAlarmRecordVo"/>
SELECT PL.PRODUCT_LINE_CODE,
PL.PRODUCT_LINE_NAME,
RAD.device_code,
BD.DEVICE_NAME,
RAD.param_code,
RAD.device_type,
RAD.alarm_info,
RAD.alarm_time,
RAD.next_alarm_time alarmEndTime,
ROUND((RAD.next_alarm_time - RAD.alarm_time) * 60 * 24, 2) alarmDuration
FROM (
SELECT SD.device_code,
SD.param_code,
SD.device_type,
SD.alarm_info,
MIN(SD.alarm_time) alarm_time,
MAX(SD.next_alarm_time) next_alarm_time
FROM (
SELECT device_code,
param_code,
device_type,
alarm_info,
alarm_time,
next_alarm_time,
SUM(CASE WHEN time_diff > 30 THEN 1 ELSE 0 END)
OVER (PARTITION BY device_code, param_code ORDER BY alarm_time) AS GRP
FROM (SELECT rad.device_code,
rad.param_code,
rad.device_type,
rad.alarm_info,
rad.alarm_time,
LEAD(rad.alarm_time)
OVER (PARTITION BY rad.device_code, rad.param_code ORDER BY rad.alarm_time) AS next_alarm_time,
(LEAD(rad.alarm_time)
OVER (PARTITION BY rad.device_code, rad.param_code ORDER BY rad.alarm_time) -
rad.alarm_time) * 60 * 60 *
24 AS time_diff
FROM record_alarm_device rad
<where>
<if test="deviceCode != null and deviceCode != ''">and rad.device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''">and rad.device_name like concat(concat('%', #{deviceName}),
@ -58,7 +99,16 @@
<if test="paramCode != null and paramCode != ''"> and rad.param_code = #{paramCode}</if>
<if test="paramValue != null and paramValue != ''"> and rad.param_value = #{paramValue}</if>
</where>
order by rad.alarm_time desc
)
) SD
GROUP BY SD.device_code, SD.param_code, SD.device_type, SD.alarm_info, SD.GRP
) RAD
LEFT JOIN BASE_DEVICELEDGER BD on BD.DEVICE_CODE = RAD.DEVICE_CODE
LEFT JOIN BASE_PRODUCTLINE PL ON BD.PRODUCT_LINE_CODE = PL.PRODUCT_LINE_CODE
<where>
<if test="productLineCode != null and productLineCode != ''">and PL.PRODUCT_LINE_CODE = #{productLineCode}</if>
</where>
ORDER BY ALARM_TIME DESC
</select>
<select id="selectDeviceAlarmRecordByObjId" parameterType="Long" resultMap="DeviceAlarmRecordResult">

Loading…
Cancel
Save