|
|
|
@ -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">
|
|
|
|
|