You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
357 lines
21 KiB
XML
357 lines
21 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.ruoyi.business.mapper.HwAlarmInfoMapper">
|
|
|
|
<resultMap type="HwAlarmInfo" id="HwAlarmInfoResult">
|
|
<result property="alarmInfoId" column="alarm_info_id" />
|
|
<result property="alarmInfoType" column="alarm_info_type" />
|
|
<result property="alarmReleatedId" column="alarm_releated_id" />
|
|
<result property="fenceAreaId" column="fence_area_id" />
|
|
<result property="deviceId" column="device_id" />
|
|
<result property="monitorUnitId" column="monitor_unit_id" />
|
|
<result property="tenantId" column="tenant_id" />
|
|
<result property="sceneId" column="scene_id" />
|
|
<result property="alarmLevelId" column="alarm_level_id" />
|
|
<result property="alarmTypeId" column="alarm_type_id" />
|
|
<result property="modeFunctionId" column="mode_function_id" />
|
|
<result property="functionName" column="function_name" />
|
|
<result property="functionIdentifier" column="function_identifier" />
|
|
<result property="functionValue" column="function_value" />
|
|
<result property="triggerStatus" column="trigger_status" />
|
|
<result property="handleStatus" column="handle_status" />
|
|
<result property="alarmTime" column="alarm_time" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="alarmInfoField" column="alarm_info_field" />
|
|
<result property="monitorUnitName" column="monitor_unit_name" />
|
|
<result property="alarmLevelName" column="alarm_level_name" />
|
|
<result property="alarmTypeName" column="alarm_type_name" />
|
|
<result property="areaName" column="area_name" />
|
|
<result property="monitorUnitTypeName" column="monitor_unit_type_name" />
|
|
|
|
<result property="deviceName" column="device_name"/>
|
|
<result property="areaName" column="area_name"/>
|
|
<result property="tenantName" column="tenant_name"/>
|
|
<result property="sceneName" column="scene_name"/>
|
|
<result property="alarmRuleName" column="alarm_rule_name"/>
|
|
<result property="offlineRuleName" column="offline_rule_name"/>
|
|
<result property="electronicFenceName" column="electronic_fence_name"/>
|
|
<result property="alarmReleatedId" column="alarm_releated_id"/>
|
|
|
|
</resultMap>
|
|
|
|
<resultMap type="AlarmTypeVo" id="AlarmTypeVoResult">
|
|
<result property="alarmCount" column="alarm_count" />
|
|
<result property="alarmTypeId" column="alarm_type_id" />
|
|
<result property="alarmTypeName" column="alarm_type_name" />
|
|
</resultMap>
|
|
|
|
<resultMap type="AlarmInfoVo" id="AlarmInfoVoResult">
|
|
<result property="alarmCount" column="alarm_count" />
|
|
</resultMap>
|
|
|
|
<resultMap id="AlarmInfoExportVoResult" type="com.ruoyi.business.domain.VO.AlarmInfoExportVo">
|
|
<result property="alarmInfoId" column="alarm_info_id" />
|
|
<result property="areaName" column="area_name" />
|
|
<result property="monitorUnitName" column="monitor_unit_name" />
|
|
<result property="alarmLevelName" column="alarm_level_name" />
|
|
<result property="alarmTypeName" column="alarm_type_name" />
|
|
<result property="alarmTime" column="alarm_time" />
|
|
<result property="monitor_unit_id" column="monitor_unit_id" />
|
|
<result property="monitor_unit_status" column="monitor_unit_status" />
|
|
<result property="monitor_unit_type_name" column="monitor_unit_type_name" />
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectHwAlarmInfoVo">
|
|
/*select hai.alarm_info_id, hai.alarm_info_type, hai.alarm_releated_id, hai.device_id,
|
|
hai.monitor_unit_id, hai.tenant_id, hai.scene_id, hai.alarm_level_id,
|
|
hai.alarm_type_id, hai.mode_function_id, hai.function_name, hai.function_identifier,
|
|
hai.function_value, hai.trigger_status, hai.handle_status, hai.alarm_time,
|
|
hai.create_time, hai.update_by, hai.update_time, hai.alarm_info_field,
|
|
hmu.monitor_unit_name,hal.alarm_level_name,hat.alarm_type_name
|
|
from hw_alarm_info hai left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id
|
|
left join hw_alarm_level hal on hai.alarm_level_id=hal.alarm_level_id
|
|
left join hw_alarm_type hat on hai.alarm_type_id=hat.alarm_type_id*/
|
|
select hai.alarm_info_id,
|
|
hai.alarm_info_type,
|
|
hai.alarm_releated_id,
|
|
hai.device_id,
|
|
hai.monitor_unit_id,
|
|
hai.tenant_id,
|
|
hai.scene_id,
|
|
hai.alarm_level_id,
|
|
hai.alarm_type_id,
|
|
hai.mode_function_id,
|
|
hai.function_name,
|
|
hai.function_identifier,
|
|
hai.function_value,
|
|
hai.trigger_status,
|
|
hai.handle_status,
|
|
hai.alarm_time,
|
|
hai.create_time,
|
|
hai.update_by,
|
|
hai.update_time,
|
|
hai.alarm_info_field,
|
|
hmu.monitor_unit_name,
|
|
hal.alarm_level_name,
|
|
hat.alarm_type_name,
|
|
ha.area_name,
|
|
hmut.monitor_unit_type_name,
|
|
|
|
hd.device_name,
|
|
ht.tenant_id,
|
|
ht.tenant_name as tenant_name,
|
|
hs.scene_name as scene_name,
|
|
har.alarm_rule_name as alarm_rule_name,
|
|
hor.offline_rule_name as offline_rule_name,
|
|
hef.electronic_fence_name as electronic_fence_name
|
|
|
|
|
|
from hw_alarm_info hai
|
|
left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id
|
|
left join hw_alarm_level hal on hai.alarm_level_id = hal.alarm_level_id
|
|
left join hw_alarm_type hat on hai.alarm_type_id = hat.alarm_type_id
|
|
left join hw_area ha on ha.area_id = hmu.area_id
|
|
left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id
|
|
|
|
LEFT JOIN hw_fence_area hfa ON hai.fence_area_id = hfa.fence_area_id
|
|
LEFT JOIN hw_device hd ON hai.device_id = hd.device_id
|
|
LEFT JOIN hw_tenant ht ON hai.tenant_id = ht.tenant_id
|
|
LEFT JOIN hw_scene hs ON hai.scene_id = hs.scene_id
|
|
LEFT JOIN hw_alarm_rule har ON hai.alarm_releated_id = har.alarm_rule_id
|
|
LEFT JOIN hw_offline_rule hor ON hai.alarm_releated_id = hor.offline_rule_id
|
|
LEFT JOIN hw_electronic_fence hef ON hai.alarm_releated_id = hef.electronic_fence_id
|
|
|
|
</sql>
|
|
|
|
<select id="selectHwAlarmInfoList" parameterType="HwAlarmInfo" resultMap="HwAlarmInfoResult">
|
|
<include refid="selectHwAlarmInfoVo"/>
|
|
<where>
|
|
hai.handle_status = '0'
|
|
<if test="alarmInfoType != null and alarmInfoType != ''"> and alarm_info_type = #{alarmInfoType}</if>
|
|
<if test="alarmReleatedId != null "> and alarm_releated_id = #{alarmReleatedId}</if>
|
|
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
|
<if test="monitorUnitId != null "> and monitor_unit_id = #{monitorUnitId}</if>
|
|
<if test="tenantId != null and tenantId != 1"> and hai.tenant_id = #{tenantId}</if>
|
|
<if test="sceneId != null "> and hai.scene_id = #{sceneId}</if>
|
|
<if test="alarmLevelId != null "> and alarm_level_id = #{alarmLevelId}</if>
|
|
<if test="alarmTypeId != null "> and alarm_type_id = #{alarmTypeId}</if>
|
|
<if test="modeFunctionId != null "> and mode_function_id = #{modeFunctionId}</if>
|
|
<if test="functionName != null and functionName != ''"> and function_name like concat('%', #{functionName}, '%')</if>
|
|
<if test="functionIdentifier != null and functionIdentifier != ''"> and function_identifier = #{functionIdentifier}</if>
|
|
<if test="functionValue != null and functionValue != ''"> and function_value = #{functionValue}</if>
|
|
<if test="triggerStatus != null and triggerStatus != ''"> and trigger_status = #{triggerStatus}</if>
|
|
<if test="handleStatus != null and handleStatus != ''"> and handle_status = #{handleStatus}</if>
|
|
<if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
|
|
<if test="alarmInfoField != null and alarmInfoField != ''"> and alarm_info_field = #{alarmInfoField}</if>
|
|
|
|
<if test="deviceName != null and deviceName != ''"> and hd.device_name = #{deviceName}</if>
|
|
<if test="monitorUnitName != null and monitorUnitName != ''"> and hmu.monitor_unit_name = #{monitorUnitName}</if>
|
|
<if test="alarmLevelName != null and alarmLevelName != ''"> and hal.alarm_level_name = #{alarmLevelName}</if>
|
|
<if test="alarmTypeName != null and alarmTypeName != ''"> and hat.alarm_type_name = #{alarmTypeName}</if>
|
|
<if test="areaName != null and areaName != ''"> and ha.area_name = #{areaName}</if>
|
|
<if test="monitorUnitTypeName != null and monitorUnitTypeName != ''"> and hmut.monitor_unit_type_name = #{monitorUnitTypeName}</if>
|
|
<if test="tenantName != null and tenantName != ''"> and ht.tenant_name = #{tenantName}</if>
|
|
<if test="sceneName != null and sceneName != ''"> and hs.scene_name = #{sceneName}</if>
|
|
<if test="alarmRuleName != null and alarmRuleName != ''"> and har.alarm_rule_name = #{alarmRuleName}</if>
|
|
<if test="electronicFenceName != null and electronicFenceName != ''"> and hef.electronic_fence_name =</if>
|
|
<if test="offlineRuleName != null and offlineRuleName != ''"> and hor.offline_rule_name = #{offlineRuleName}</if>
|
|
|
|
<!-- 租户数据范围过滤 -->
|
|
-- ${params.tenantDataScope}
|
|
</where>
|
|
order by alarm_info_id desc,hal.level_number desc
|
|
</select>
|
|
|
|
<select id="selectHwAlarmInfoByAlarmInfoId" parameterType="Long" resultMap="HwAlarmInfoResult">
|
|
<include refid="selectHwAlarmInfoVo"/>
|
|
where alarm_info_id = #{alarmInfoId}
|
|
</select>
|
|
|
|
<insert id="insertHwAlarmInfo" parameterType="HwAlarmInfo" useGeneratedKeys="true" keyProperty="alarmInfoId">
|
|
insert into hw_alarm_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type,</if>
|
|
<if test="alarmReleatedId != null">alarm_releated_id,</if>
|
|
<if test="deviceId != null">device_id,</if>
|
|
<if test="monitorUnitId != null">monitor_unit_id,</if>
|
|
<if test="tenantId != null">tenant_id,</if>
|
|
<if test="sceneId != null">scene_id,</if>
|
|
<if test="alarmLevelId != null">alarm_level_id,</if>
|
|
<if test="alarmTypeId != null">alarm_type_id,</if>
|
|
<if test="modeFunctionId != null">mode_function_id,</if>
|
|
<if test="functionName != null">function_name,</if>
|
|
<if test="functionIdentifier != null">function_identifier,</if>
|
|
<if test="functionValue != null">function_value,</if>
|
|
<if test="triggerStatus != null">trigger_status,</if>
|
|
<if test="handleStatus != null and handleStatus != ''">handle_status,</if>
|
|
<if test="alarmTime != null">alarm_time,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="alarmInfoField != null">alarm_info_field,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="alarmInfoType != null and alarmInfoType != ''">#{alarmInfoType},</if>
|
|
<if test="alarmReleatedId != null">#{alarmReleatedId},</if>
|
|
<if test="deviceId != null">#{deviceId},</if>
|
|
<if test="monitorUnitId != null">#{monitorUnitId},</if>
|
|
<if test="tenantId != null">#{tenantId},</if>
|
|
<if test="sceneId != null">#{sceneId},</if>
|
|
<if test="alarmLevelId != null">#{alarmLevelId},</if>
|
|
<if test="alarmTypeId != null">#{alarmTypeId},</if>
|
|
<if test="modeFunctionId != null">#{modeFunctionId},</if>
|
|
<if test="functionName != null">#{functionName},</if>
|
|
<if test="functionIdentifier != null">#{functionIdentifier},</if>
|
|
<if test="functionValue != null">#{functionValue},</if>
|
|
<if test="triggerStatus != null">#{triggerStatus},</if>
|
|
<if test="handleStatus != null and handleStatus != ''">#{handleStatus},</if>
|
|
<if test="alarmTime != null">#{alarmTime},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="alarmInfoField != null">#{alarmInfoField},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
|
|
|
|
<update id="updateHwAlarmInfo" parameterType="HwAlarmInfo">
|
|
update hw_alarm_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type = #{alarmInfoType},</if>
|
|
<if test="alarmReleatedId != null">alarm_releated_id = #{alarmReleatedId},</if>
|
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
|
<if test="monitorUnitId != null">monitor_unit_id = #{monitorUnitId},</if>
|
|
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
|
<if test="sceneId != null">scene_id = #{sceneId},</if>
|
|
<if test="alarmLevelId != null">alarm_level_id = #{alarmLevelId},</if>
|
|
<if test="alarmTypeId != null">alarm_type_id = #{alarmTypeId},</if>
|
|
<if test="modeFunctionId != null">mode_function_id = #{modeFunctionId},</if>
|
|
<if test="functionName != null">function_name = #{functionName},</if>
|
|
<if test="functionIdentifier != null">function_identifier = #{functionIdentifier},</if>
|
|
<if test="functionValue != null">function_value = #{functionValue},</if>
|
|
<if test="triggerStatus != null">trigger_status = #{triggerStatus},</if>
|
|
<if test="handleStatus != null and handleStatus != ''">handle_status = #{handleStatus},</if>
|
|
<if test="alarmTime != null">alarm_time = #{alarmTime},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="alarmInfoField != null">alarm_info_field = #{alarmInfoField},</if>
|
|
</trim>
|
|
where alarm_info_id = #{alarmInfoId}
|
|
</update>
|
|
|
|
<delete id="deleteHwAlarmInfoByAlarmInfoId" parameterType="Long">
|
|
delete from hw_alarm_info where alarm_info_id = #{alarmInfoId}
|
|
</delete>
|
|
|
|
<delete id="deleteHwAlarmInfoByAlarmInfoIds" parameterType="String">
|
|
delete from hw_alarm_info where alarm_info_id in
|
|
<foreach item="alarmInfoId" collection="array" open="(" separator="," close=")">
|
|
#{alarmInfoId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
|
|
<select id="selectAlarmsByAlarmType" parameterType="Long" resultMap="AlarmTypeVoResult">
|
|
SELECT count(*) as alarm_count,alarm_type_id from hw_alarm_info
|
|
where scene_id = #{sceneId} and alarm_type_id is not null group by alarm_type_id;
|
|
</select>
|
|
|
|
<select id="selectAlarmCountByFenceArea" parameterType="Long" resultMap="AlarmInfoVoResult">
|
|
SELECT count(distinct(device_id)) as alarm_count from hw_alarm_info hai
|
|
where hai.fence_area_id = #{fenceAreaId}
|
|
</select>
|
|
|
|
<select id="selectAlarmCountByMonitorUnitId" parameterType="Long">
|
|
SELECT count(distinct(hai.device_id)) FROM hw_alarm_info hai where hai.handle_status='0' and
|
|
exists (select 1 from hw_device hd where hai.device_id=hd.device_id and hd.device_status='1'
|
|
and hd.monitor_unit_id=#{monitorUnitId})
|
|
</select>
|
|
<select id="selectAlarmInfoExport" parameterType="Date" resultMap="AlarmInfoExportVoResult">
|
|
select hai.alarm_info_id,
|
|
hai.alarm_time,
|
|
hmu.monitor_unit_name,
|
|
hal.alarm_level_name,
|
|
hat.alarm_type_name,
|
|
ha.area_name,
|
|
hmu.monitor_unit_id,
|
|
CASE hmu.monitor_unit_status when 1 then '正常' else '异常' end as monitor_unit_status,
|
|
hmu.monitor_unit_type_id,
|
|
hmut.monitor_unit_type_name
|
|
from hw_alarm_info hai
|
|
left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id
|
|
left join hw_alarm_level hal on hai.alarm_level_id = hal.alarm_level_id
|
|
left join hw_alarm_type hat on hai.alarm_type_id = hat.alarm_type_id
|
|
left join hw_area ha on ha.area_id = hmu.area_id
|
|
left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id
|
|
where hai.alarm_time between #{startTime} and #{endTime}
|
|
</select>
|
|
<select id="selectAlarmInfoExport1" resultType="com.ruoyi.business.domain.VO.AlarmInfoExportVo">
|
|
select hai.monitor_unit_id,hai.alarm_info_id,
|
|
hai.alarm_time,
|
|
hmu.monitor_unit_name,
|
|
-- hal.alarm_level_name,
|
|
hat.alarm_type_name,
|
|
ha.area_name,
|
|
-- hmu.monitor_unit_id,
|
|
CASE hmu.monitor_unit_status when 1 then '正常' else '异常' end as monitor_unit_status,
|
|
hmu.monitor_unit_type_id,
|
|
hmut.monitor_unit_type_name
|
|
from hw_alarm_info hai
|
|
left join hw_monitor_unit hmu on hai.monitor_unit_id = hmu.monitor_unit_id
|
|
left join hw_alarm_level hal on hai.alarm_level_id = hal.alarm_level_id
|
|
left join hw_alarm_type hat on hai.alarm_type_id = hat.alarm_type_id
|
|
left join hw_area ha on ha.area_id = hmu.area_id
|
|
left join hw_monitor_unit_type hmut on hmu.monitor_unit_type_id = hmut.monitor_unit_type_id
|
|
where hai.alarm_time between #{startTime} and #{endTime}
|
|
and hai.monitor_unit_id = #{monitorUnitId}
|
|
</select>
|
|
<select id="selectUnitId" resultType="java.lang.Long">
|
|
select distinct monitor_unit_id monitorUnitId from hw_alarm_info
|
|
</select>
|
|
<update id="updateHwAlarmInfoAllByDevice" parameterType="HwAlarmInfo">
|
|
update hw_alarm_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="handleStatus != null and handleStatus != ''">handle_status = #{handleStatus},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="alarmInfoField != null">alarm_info_field = #{alarmInfoField},</if>
|
|
</trim>
|
|
where device_id = (select t.device_id from (select device_id from hw_alarm_info hai where alarm_info_id = #{alarmInfoId})t) and handle_status = 0
|
|
</update>
|
|
|
|
<!--int updateHwAlarmInformation(HwAlarmInfo hwAlarmInformation);-->
|
|
<update id="updateHwAlarmInformation" parameterType="HwAlarmInfo">
|
|
update hw_alarm_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="alarmInfoType != null and alarmInfoType != ''">alarm_info_type = #{alarmInfoType},</if>
|
|
<if test="alarmReleatedId != null">alarm_releated_id = #{alarmReleatedId},</if>
|
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
|
<if test="monitorUnitId != null">monitor_unit_id = #{monitorUnitId},</if>
|
|
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
|
<if test="sceneId != null">scene_id = #{sceneId},</if>
|
|
<if test="alarmLevelId != null">alarm_level_id = #{alarmLevelId},</if>
|
|
<if test="alarmTypeId != null">alarm_type_id = #{alarmTypeId},</if>
|
|
<if test="modeFunctionId != null">mode_function_id = #{modeFunctionId},</if>
|
|
<if test="functionName != null">function_name = #{functionName},</if>
|
|
<if test="functionIdentifier != null">function_identifier = #{functionIdentifier},</if>
|
|
<if test="functionValue != null">function_value = #{functionValue},</if>
|
|
<if test="triggerStatus != null">trigger_status = #{triggerStatus},</if>
|
|
<if test="handleStatus != null and handleStatus != ''">handle_status = #{handleStatus},</if>
|
|
<if test="alarmTime != null">alarm_time = #{alarmTime},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="alarmInfoField != null">alarm_info_field = #{alarmInfoField},</if>
|
|
</trim>
|
|
where alarm_info_id = #{alarmInfoId}
|
|
</update>
|
|
|
|
</mapper>
|