<?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.system.mapper.SysDoorDeviceMapper">
|
|
<resultMap type="SysDoorDevice" id="SysDoorDeviceResult">
|
<id property="doorId" column="door_id" />
|
<result property="areaId" column="area_id" />
|
<result property="deviceName" column="device_name" />
|
<result property="brand" column="brand" />
|
<result property="deviceId" column="device_id" />
|
<result property="devicePort" column="device_port" />
|
<result property="loginUsername" column="login_username" />
|
<result property="loginPasswordCipher" column="login_password_cipher" />
|
<result property="doorNo" column="door_no" />
|
<result property="timeSectionNo" column="time_section_no" />
|
<result property="charset" column="device_charset" />
|
<result property="enabled" column="enabled" />
|
<result property="onlineStatus" column="online_status" />
|
<result property="delFlag" column="del_flag" />
|
<result property="remark" column="remark" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
</resultMap>
|
|
<resultMap type="SysDoorDeviceVO" id="SysDoorDeviceVOResult">
|
<id property="doorId" column="door_id" />
|
<result property="areaId" column="area_id" />
|
<result property="areaName" column="area_name" />
|
<result property="deviceName" column="device_name" />
|
<result property="brand" column="brand" />
|
<result property="deviceId" column="device_id" />
|
<result property="devicePort" column="device_port" />
|
<result property="loginUsername" column="login_username" />
|
<result property="passwordConfigured" column="password_configured" />
|
<result property="doorNo" column="door_no" />
|
<result property="timeSectionNo" column="time_section_no" />
|
<result property="charset" column="device_charset" />
|
<result property="enabled" column="enabled" />
|
<result property="onlineStatus" column="online_status" />
|
<result property="remark" column="remark" />
|
<result property="createTime" column="create_time" />
|
</resultMap>
|
|
<sql id="selectDoorDeviceDomain">
|
select door_id,
|
area_id,
|
device_name,
|
brand,
|
device_id,
|
device_port,
|
login_username,
|
login_password_cipher,
|
door_no,
|
time_section_no,
|
device_charset,
|
enabled,
|
online_status,
|
del_flag,
|
remark,
|
create_by,
|
create_time,
|
update_by,
|
update_time
|
from t_door_device
|
</sql>
|
|
<sql id="selectDoorDeviceVo">
|
select d.door_id,
|
d.area_id,
|
a.area_name,
|
d.device_name,
|
d.brand,
|
d.device_id,
|
d.device_port,
|
d.login_username,
|
case when d.login_password_cipher is not null and d.login_password_cipher <> '' then 1 else 0 end as password_configured,
|
d.door_no,
|
d.time_section_no,
|
d.device_charset,
|
d.enabled,
|
d.online_status,
|
d.remark,
|
d.create_time
|
from t_door_device d
|
left join t_visit_area a on a.area_id = d.area_id and a.del_flag = '0'
|
</sql>
|
|
<select id="pageList" resultMap="SysDoorDeviceVOResult">
|
<include refid="selectDoorDeviceVo" />
|
<where>
|
and d.del_flag = '0'
|
<if test="areaId != null">
|
and (d.area_id = #{areaId}
|
or d.area_id in (
|
select area_id from t_visit_area
|
where del_flag = '0'
|
and find_in_set(#{areaId}, ancestors)
|
))
|
</if>
|
<if test="query.deviceName != null and query.deviceName != ''">
|
and d.device_name like concat('%', #{query.deviceName}, '%')
|
</if>
|
<if test="query.deviceId != null and query.deviceId != ''">
|
and d.device_id like concat('%', #{query.deviceId}, '%')
|
</if>
|
<if test="query.enabled != null">
|
and d.enabled = #{query.enabled}
|
</if>
|
<if test="query.onlineStatus != null and query.onlineStatus != ''">
|
and d.online_status = #{query.onlineStatus}
|
</if>
|
</where>
|
order by d.create_time desc, d.door_id desc
|
</select>
|
|
<select id="selectVoById" parameterType="Long" resultMap="SysDoorDeviceVOResult">
|
<include refid="selectDoorDeviceVo" />
|
where d.door_id = #{doorId}
|
and d.del_flag = '0'
|
</select>
|
|
<select id="selectById" parameterType="Long" resultMap="SysDoorDeviceResult">
|
<include refid="selectDoorDeviceDomain" />
|
where door_id = #{doorId}
|
and del_flag = '0'
|
</select>
|
|
<select id="checkDeviceIdUnique" resultMap="SysDoorDeviceResult">
|
<include refid="selectDoorDeviceDomain" />
|
where device_id = #{deviceId}
|
and del_flag = '0'
|
<if test="excludeDoorId != null">
|
and door_id != #{excludeDoorId}
|
</if>
|
limit 1
|
</select>
|
|
<select id="selectEnabledHikvisionDevices" resultMap="SysDoorDeviceResult">
|
<include refid="selectDoorDeviceDomain" />
|
where del_flag = '0'
|
and enabled = 1
|
and (
|
brand like '%海康%'
|
or lower(brand) like '%hikvision%'
|
or device_name like '%海康%'
|
or lower(device_name) like '%hikvision%'
|
or upper(device_id) like '%DS-K%'
|
)
|
order by door_id asc
|
</select>
|
|
<select id="selectEnabledDahuaDevicesByAreaIds" resultMap="SysDoorDeviceResult">
|
<include refid="selectDoorDeviceDomain" />
|
where del_flag = '0'
|
and enabled = 1
|
and area_id in
|
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
#{areaId}
|
</foreach>
|
and (
|
brand like '%大华%'
|
or lower(brand) like '%dahua%'
|
or device_name like '%大华%'
|
or lower(device_name) like '%dahua%'
|
)
|
order by door_id asc
|
</select>
|
|
<insert id="insertDoorDevice" parameterType="SysDoorDevice" useGeneratedKeys="true" keyProperty="doorId">
|
insert into t_door_device (
|
area_id,
|
device_name,
|
brand,
|
device_id,
|
device_port,
|
login_username,
|
login_password_cipher,
|
door_no,
|
time_section_no,
|
device_charset,
|
enabled,
|
online_status,
|
remark,
|
create_by,
|
create_time
|
) values (
|
#{areaId},
|
#{deviceName},
|
#{brand},
|
#{deviceId},
|
#{devicePort},
|
#{loginUsername},
|
#{loginPasswordCipher},
|
#{doorNo},
|
#{timeSectionNo},
|
#{charset},
|
#{enabled},
|
#{onlineStatus},
|
#{remark},
|
#{createBy},
|
sysdate()
|
)
|
</insert>
|
|
<update id="updateDoorDevice" parameterType="SysDoorDevice">
|
update t_door_device
|
set area_id = #{areaId},
|
device_name = #{deviceName},
|
brand = #{brand},
|
device_id = #{deviceId},
|
device_port = #{devicePort},
|
login_username = #{loginUsername},
|
<if test="loginPasswordCipher != null">
|
login_password_cipher = #{loginPasswordCipher},
|
</if>
|
door_no = #{doorNo},
|
time_section_no = #{timeSectionNo},
|
device_charset = #{charset},
|
enabled = #{enabled},
|
remark = #{remark},
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where door_id = #{doorId}
|
and del_flag = '0'
|
</update>
|
|
<update id="updateEnabled">
|
update t_door_device
|
set enabled = #{enabled},
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and door_id in
|
<foreach collection="doorIds" item="doorId" open="(" separator="," close=")">
|
#{doorId}
|
</foreach>
|
</update>
|
|
<update id="updateOnlineStatus">
|
update t_door_device
|
set online_status = #{onlineStatus},
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and door_id in
|
<foreach collection="doorIds" item="doorId" open="(" separator="," close=")">
|
#{doorId}
|
</foreach>
|
</update>
|
|
<update id="deleteByIds">
|
update t_door_device
|
set del_flag = '1',
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and door_id in
|
<foreach collection="doorIds" item="doorId" open="(" separator="," close=")">
|
#{doorId}
|
</foreach>
|
</update>
|
</mapper>
|