237 lines
10 KiB
XML
237 lines
10 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.sercurityControl.proteam.mapper.DeviceMapper">
|
|
<!--设备管理分页查询-->
|
|
<select id="getDeviceList" resultType="com.sercurityControl.proteam.domain.vo.DeviceVo" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo">
|
|
select td.id,td.device_name deviceName,td.mac_id macId,td.puid puId,td.gb_code gbCode,
|
|
td.type_code typeCode,td.device_type typeName,td.ss_dw ssdw,td.update_time updateTime,sd1.name macName,sd2.`name` ssdwName,
|
|
if(td.state = 1,'在线','不在线') state,td.t_name tName,td.t_code tCode,td.tw_code twCode,td.td_code tdCode,td.pass_way passWay
|
|
,create_time createTime,td.remark,mac,td.ip_address ipAddress,IFNULL(td.qj_xh,0) qjxh,
|
|
if(td.is_t = 1,'是','否') ist
|
|
from t_device td
|
|
LEFT JOIN sys_dist sd1 on sd1.id=td.mac
|
|
LEFT JOIN sys_dist sd2 on sd2.id=td.ss_dw
|
|
where td.is_flag='0'
|
|
<if test="deviceName!=null and deviceName!=''">
|
|
and td.device_name like concat('%',concat(#{deviceName},'%'))
|
|
</if>
|
|
<if test="macId!=null and macId!=''">
|
|
and td.mac_id like concat('%',concat(#{macId},'%'))
|
|
</if>
|
|
<if test="puId!=null and puId!=''">
|
|
and td.puid like concat('%',concat(#{puId},'%'))
|
|
</if>
|
|
<if test="gbCode!=null and gbCode!=''">
|
|
and td.gb_code like concat('%',concat(#{gbCode},'%'))
|
|
</if>
|
|
<if test="typeCode!=null and typeCode!=''">
|
|
and td.type_code=#{typeCode}
|
|
</if>
|
|
<if test="tName!=null and tName!=''">
|
|
and td.t_name like concat('%',concat(#{tName},'%'))
|
|
</if>
|
|
<if test="tCode!=null and tCode!=''">
|
|
and td.t_code like concat('%',concat(#{tCode},'%'))
|
|
</if>
|
|
<if test="keyWord!=null and keyWord!=''">
|
|
and (
|
|
td.tw_code like concat('%',concat(#{keyWord},'%')) or
|
|
td.td_code like concat('%',concat(#{keyWord},'%')) or
|
|
td.remark like concat('%',concat(#{keyWord},'%'))
|
|
)
|
|
</if>
|
|
<if test="ssdw!=null and ssdw!=''">
|
|
and td.ss_dw =#{ssdw}
|
|
</if>
|
|
<if test="ist!=null and ist!=''">
|
|
and td.is_t =#{ist}
|
|
</if>
|
|
|
|
|
|
</select>
|
|
<!--通过id查询详情-->
|
|
<select id="getDeviceDetail" resultType="com.sercurityControl.proteam.domain.vo.DeviceVo" parameterType="String">
|
|
select td.id,td.device_name deviceName,td.mac_id macId,td.puid puId,td.gb_code gbCode,
|
|
td.type_code typeCode,td.device_type typeName,td.ss_dw ssdw,td.update_time updateTime,sd1.name macName,sd2.`name` ssdwName,
|
|
td.state state,create_time createTime,td.remark,mac,td.ip_address ipAddress
|
|
,is_t ist,t_name tName,t_code tCode,tw_code twCode,td_code tdCode,pass_way passWay
|
|
from t_device td
|
|
LEFT JOIN sys_dist sd1 on sd1.id=td.mac
|
|
LEFT JOIN sys_dist sd2 on sd2.id=td.ss_dw
|
|
where td.id=#{id}
|
|
</select>
|
|
<!--唯一性校验 mac-->
|
|
<select id="getNumByMacId" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" resultType="Integer">
|
|
select count(1)
|
|
from t_device
|
|
where is_flag='0' and mac_id=#{macId}
|
|
<if test="id!=null and id!=''">
|
|
AND id!=#{id}
|
|
</if>
|
|
</select>
|
|
<!--唯一性校验 puid-->
|
|
<select id="getNumByPuId" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" resultType="Integer">
|
|
select count(1)
|
|
from t_device
|
|
where is_flag='0' and puid=#{puId}
|
|
<if test="id!=null and id!=''">
|
|
AND id!=#{id}
|
|
</if>
|
|
</select>
|
|
<!--唯一性校验 国标编码-->
|
|
<select id="getNumByGbCode" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" resultType="Integer">
|
|
select count(1)
|
|
from t_device
|
|
where is_flag='0' and gb_code=#{gbCode}
|
|
<if test="id!=null and id!=''">
|
|
AND id!=#{id}
|
|
</if>
|
|
</select>
|
|
<!--插入-->
|
|
<insert id="insertDevice" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo">
|
|
insert into
|
|
t_device(device_name,mac_id,puid,gb_code,type_code,device_type,ss_dw,update_time,state,remark,mac,ip_address,is_flag,create_time,
|
|
is_t,t_name,t_code,tw_code,td_code,pass_way)
|
|
VALUE (
|
|
#{deviceName}, #{macId}, #{puId}, #{gbCode}, #{typeCode},#{typeName}, #{ssdw}, #{updateTime}, '0', #{remark}, #{mac}, #{ipAddress},'0',
|
|
#{createTime},#{ist},#{tName},#{tCode},#{twCode},#{tdCode},#{passWay}
|
|
)
|
|
</insert>
|
|
<!--修改-->
|
|
<update id="updateDevice" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" >
|
|
update t_device
|
|
<set>
|
|
<if test="deviceName !=null and deviceName !=''">
|
|
,device_name=#{deviceName}
|
|
</if>
|
|
<if test="macId !=null and macId !=''">
|
|
,mac_id=#{macId}
|
|
</if>
|
|
<if test="puId !=null and puId !=''">
|
|
,puid=#{puId}
|
|
</if>
|
|
<if test="gbCode !=null and gbCode !=''">
|
|
,gb_code=#{gbCode}
|
|
</if>
|
|
<if test="typeCode !=null and typeCode !=''">
|
|
,type_code=#{typeCode}
|
|
</if>
|
|
<if test="typeName !=null and typeName !=''">
|
|
,device_type=#{typeName}
|
|
</if>
|
|
<if test="ssdw !=null">
|
|
,ss_dw=#{ssdw}
|
|
</if>
|
|
<if test="updateTime !=null and updateTime !=''">
|
|
,update_time=#{updateTime}
|
|
</if>
|
|
<if test="remark !=null and remark !=''">
|
|
,remark=#{remark}
|
|
</if>
|
|
<if test="mac !=null and mac !=''">
|
|
,mac=#{mac}
|
|
</if>
|
|
<if test="ipAddress !=null and ipAddress !=''">
|
|
,ip_address=#{ipAddress}
|
|
</if>
|
|
,is_t=#{ist}
|
|
,t_name=#{tName}
|
|
,t_code=#{tCode}
|
|
,tw_code=#{twCode}
|
|
,td_code=#{tdCode}
|
|
,pass_way=#{passWay}
|
|
</set>
|
|
WHERE id=#{id}
|
|
</update>
|
|
<update id="deleteDevice" parameterType="String">
|
|
update t_device set is_flag='1' WHERE id=#{id}
|
|
</update>
|
|
<!--查询字典数据 是否存在-->
|
|
<select id="getSysDictId" parameterType="String" resultType="String">
|
|
select sd2.id code
|
|
from sys_dist sd
|
|
left join sys_dist sd2 on sd.id=sd2.p_id and sd2.is_flag='0'
|
|
where sd.p_id=0 and sd.code=#{code} and sd.is_flag=0 and sd2.name=#{name} and sd2.id is not null
|
|
</select>
|
|
<!--查询设备类型 是否存在-->
|
|
<select id="getDeviceTypeByName" resultType="String" parameterType="String">
|
|
select tbt2.id code
|
|
from t_ball_type tbt
|
|
left join t_ball_type tbt2 on tbt2.p_id=tbt.id AND tbt2.is_flag='0'
|
|
where tbt.p_id=0 and tbt2.id is not null and tbt.type_code=#{code} and tbt.is_flag='0' and tbt2.type_name=#{name}
|
|
</select>
|
|
<insert id="addImportData" >
|
|
INSERT INTO t_device(device_name,mac_id,puid,gb_code,type_code,device_type,ss_dw,state,remark,is_flag,is_t,t_name,t_code,tw_code,td_code,pass_way) VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(
|
|
#{item.deviceName},#{item.macId},#{item.puId},#{item.gbCode},#{item.typeCode},#{item.typeName},#{item.ssdw},'0',
|
|
#{item.remark},'0',#{item.ist},#{item.tName},#{item.tCode},#{item.twCode},#{item.tdCode},'to-2'
|
|
)
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
<select id="getNumByTcode" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" resultType="Integer">
|
|
select count(1)
|
|
from t_device
|
|
where is_flag='0' and t_code=#{tCode}
|
|
<if test="id!=null and id!=''">
|
|
AND id!=#{id}
|
|
</if>
|
|
</select>
|
|
<select id="getNumByTWcode" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" resultType="Integer">
|
|
select count(1)
|
|
from t_device
|
|
where is_flag='0' and tw_code=#{twCode}
|
|
<if test="id!=null and id!=''">
|
|
AND id!=#{id}
|
|
</if>
|
|
</select>
|
|
<select id="getNumByTDcode" parameterType="com.sercurityControl.proteam.domain.vo.DeviceVo" resultType="Integer">
|
|
select count(1)
|
|
from t_device
|
|
where is_flag='0' and td_code=#{tdCode}
|
|
<if test="id!=null and id!=''">
|
|
AND id!=#{id}
|
|
</if>
|
|
</select>
|
|
<!--查询设备状态数据-->
|
|
<select id="getAllDeviceList" resultType="String">
|
|
select DISTINCT puid
|
|
from t_device
|
|
WHERE is_flag=0 and puid is not null
|
|
</select>
|
|
|
|
<update id="refreshQXDevice" parameterType="com.sercurityControl.proteam.domain.ReturnDataEntity">
|
|
UPDATE t_device SET state = #{OnlineFlag}
|
|
WHERE puid = #{PUID}
|
|
</update>
|
|
<select id="getAllTyDeviceList" resultType="String">
|
|
select DISTINCT t_code
|
|
from t_device
|
|
WHERE is_flag=0 and pass_way in('1','to-1')
|
|
</select>
|
|
<!--更新统一设备-->
|
|
<update id="refreshTyDevice" parameterType="com.sercurityControl.proteam.domain.ty.ResultValue">
|
|
UPDATE t_device SET state = #{status}
|
|
WHERE t_code = #{devCode}
|
|
</update>
|
|
<update id="refreshDevice" >
|
|
update t_device set state='1' WHERE is_flag=0
|
|
</update>
|
|
<!--更新设备状态-->
|
|
<update id="updateDeviceState">
|
|
UPDATE t_device SET state = #{status}
|
|
WHERE puid = #{puid}
|
|
</update>
|
|
<!--查询当前启用的数据-->
|
|
<select id="getVideoConfigByType" resultType="com.sercurityControl.proteam.domain.vo.SysVideoConfigVo" parameterType="String">
|
|
select id, video_ip videoIp, video_port videoPort, video_type videoType,video_user videoUser,
|
|
video_password videoPassword,video_code videoCode,status, video_url videoUrl,
|
|
q2http_url q2httpUrl, q2http_urlN q2httpUrlN, websocket_url websocketUrl,
|
|
websocket_urlN websocketUrlN,
|
|
epid epid, bfix, remarks
|
|
from sys_video_config
|
|
WHERE video_type=#{videoType} and status='1'
|
|
</select>
|
|
</mapper> |