<?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.cloud.device.dao.DeviceDao">
|
<resultMap id="BaseResultMap" type="com.cloud.device.model.Device">
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
<result column="orgId" jdbcType="INTEGER" property="orgId" />
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
<result column="code" jdbcType="VARCHAR" property="code" />
|
<result column="address" jdbcType="VARCHAR" property="address" />
|
<result column="longitude" jdbcType="VARCHAR" property="longitude" />
|
<result column="latitude" jdbcType="VARCHAR" property="latitude" />
|
<result column="ip" jdbcType="VARCHAR" property="ip" />
|
<result column="port" jdbcType="VARCHAR" property="port" />
|
<result column="username" jdbcType="VARCHAR" property="username" />
|
<result column="password" jdbcType="VARCHAR" property="password" />
|
<result column="revJson" jdbcType="CHAR" property="revJson" />
|
<result column="createBy" jdbcType="VARCHAR" property="createBy" />
|
<result column="createTime" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="updateBy" jdbcType="VARCHAR" property="updateBy" />
|
<result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
|
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
|
<result column="delFlag" jdbcType="VARCHAR" property="delFlag" />
|
<result column="layerId" jdbcType="VARCHAR" property="layerId" />
|
<result column="status" jdbcType="INTEGER" property="status" />
|
<result column="nodeId" jdbcType="VARCHAR" property="nodeId" />
|
<result column="brand" jdbcType="VARCHAR" property="brand" />
|
<result column="basePhoto" jdbcType="VARCHAR" property="basePhoto" />
|
<result column="cameraType" jdbcType="INTEGER" property="cameraType" />
|
</resultMap>
|
<sql id="Base_Column_List">
|
id, orgId, type, name, code, address, longitude, latitude, ip, port, username, password,
|
revJson, createBy, createTime, updateBy, updateTime, remarks, delFlag, layerId, status, nodeId, brand, basePhoto, cameraType
|
</sql>
|
<select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from device
|
where delFlag='0' and id = #{id,jdbcType=VARCHAR}
|
</select>
|
<delete id="deleteById" parameterType="java.lang.String">
|
update device set delFlag = '1'
|
where id = #{id,jdbcType=VARCHAR}
|
</delete>
|
<delete id="deleteByClusterId" parameterType="java.lang.String">
|
update device set delFlag = '1'
|
where nodeId in (select id from node where clusterId=#{id,jdbcType=VARCHAR})
|
</delete>
|
<insert id="insert" parameterType="com.cloud.device.model.Device">
|
insert into device (id, orgId, type, name,
|
code, address, longitude,
|
latitude, ip, port,
|
username, password, revJson,
|
createBy, createTime, updateBy,
|
updateTime, remarks, delFlag, layerId, status, nodeId, brand, basePhoto, cameraType
|
)
|
values (#{id,jdbcType=VARCHAR}, #{orgId,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
#{code,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{longitude,jdbcType=VARCHAR},
|
#{latitude,jdbcType=VARCHAR}, #{ip,jdbcType=VARCHAR}, #{port,jdbcType=VARCHAR},
|
#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{revJson,jdbcType=CHAR},
|
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
|
#{updateTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=VARCHAR},
|
#{layerId,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{nodeId,jdbcType=VARCHAR}, #{brand,jdbcType=VARCHAR}, #{basePhoto,jdbcType=VARCHAR},
|
#{cameraType,jdbcType=INTEGER}
|
)
|
</insert>
|
<insert id="insertSelective" parameterType="com.cloud.device.model.Device">
|
insert into device
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id !=null">
|
id,
|
</if>
|
<if test="orgId != null">
|
orgId,
|
</if>
|
<if test="type != null">
|
type,
|
</if>
|
<if test="name != null">
|
name,
|
</if>
|
<if test="code != null">
|
code,
|
</if>
|
<if test="address != null">
|
address,
|
</if>
|
<if test="longitude != null">
|
longitude,
|
</if>
|
<if test="latitude != null">
|
latitude,
|
</if>
|
<if test="ip != null">
|
ip,
|
</if>
|
<if test="port != null">
|
port,
|
</if>
|
<if test="username != null">
|
username,
|
</if>
|
<if test="password != null">
|
password,
|
</if>
|
<if test="revJson != null">
|
revJson,
|
</if>
|
<if test="createBy != null">
|
createBy,
|
</if>
|
<if test="createTime != null">
|
createTime,
|
</if>
|
<if test="updateBy != null">
|
updateBy,
|
</if>
|
<if test="updateTime != null">
|
updateTime,
|
</if>
|
<if test="remarks != null">
|
remarks,
|
</if>
|
<if test="delFlag != null">
|
delFlag,
|
</if>
|
<if test="layerId != null">
|
layerId,
|
</if>
|
<if test="status != null">
|
status,
|
</if>
|
<if test="nodeId != null">
|
nodeId,
|
</if>
|
<if test="brand !=null">
|
brand
|
</if>
|
<if test="basePhoto !=null">
|
basePhoto
|
</if>
|
<if test="cameraType !=null">
|
cameraType
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id !=null">
|
#{id,jdbcType=VARCHAR},
|
</if>
|
<if test="orgId != null">
|
#{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="type != null">
|
#{type,jdbcType=VARCHAR},
|
</if>
|
<if test="name != null">
|
#{name,jdbcType=VARCHAR},
|
</if>
|
<if test="code != null">
|
#{code,jdbcType=VARCHAR},
|
</if>
|
<if test="address != null">
|
#{address,jdbcType=VARCHAR},
|
</if>
|
<if test="longitude != null">
|
#{longitude,jdbcType=VARCHAR},
|
</if>
|
<if test="latitude != null">
|
#{latitude,jdbcType=VARCHAR},
|
</if>
|
<if test="ip != null">
|
#{ip,jdbcType=VARCHAR},
|
</if>
|
<if test="port != null">
|
#{port,jdbcType=VARCHAR},
|
</if>
|
<if test="username != null">
|
#{username,jdbcType=VARCHAR},
|
</if>
|
<if test="password != null">
|
#{password,jdbcType=VARCHAR},
|
</if>
|
<if test="revJson != null">
|
#{revJson,jdbcType=CHAR},
|
</if>
|
<if test="createBy != null">
|
#{createBy,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateBy != null">
|
#{updateBy,jdbcType=VARCHAR},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="remarks != null">
|
#{remarks,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
#{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="layerId != null">
|
#{layerId,jdbcType=VARCHAR},
|
</if>
|
<if test="status != null">
|
#{status,jdbcType=INTEGER},
|
</if>
|
<if test="nodeId != null">
|
#{nodeId,jdbcType=VARCHAR},
|
</if>
|
<if test="brand != null">
|
#{brand,jdbcType=VARCHAR},
|
</if>
|
<if test="basePhoto != null">
|
#{basePhoto,jdbcType=VARCHAR},
|
</if>
|
<if test="cameraType !=null">
|
#{cameraType,jdbcType=INTEGER}
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByIdSelective" parameterType="com.cloud.device.model.Device">
|
update device
|
<set>
|
<if test="orgId != null">
|
orgId = #{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="ip !=null">
|
ip = #{ip,jdbcType=VARCHAR},
|
</if>
|
<if test="port != null">
|
port = #{port,jdbcType=VARCHAR},
|
</if>
|
<if test="name != null">
|
name = #{name,jdbcType=VARCHAR},
|
</if>
|
<if test="code != null">
|
code = #{code,jdbcType=VARCHAR},
|
</if>
|
<if test="address != null">
|
address = #{address,jdbcType=VARCHAR},
|
</if>
|
<if test="longitude != null">
|
longitude = #{longitude,jdbcType=VARCHAR},
|
</if>
|
<if test="latitude != null">
|
latitude = #{latitude,jdbcType=VARCHAR},
|
</if>
|
<if test="revJson != null">
|
revJson = #{revJson,jdbcType=CHAR},
|
</if>
|
<if test="createBy != null">
|
createBy = #{createBy,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateBy != null">
|
updateBy = #{updateBy,jdbcType=VARCHAR},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="remarks != null">
|
remarks = #{remarks,jdbcType=VARCHAR},
|
</if>
|
<if test="layerId != null">
|
layerId = #{layerId,jdbcType=VARCHAR},
|
</if>
|
<if test="status != null">
|
status = #{status,jdbcType=INTEGER},
|
</if>
|
<if test="nodeId != null">
|
nodeId = #{nodeId,jdbcType=VARCHAR},
|
</if>
|
<if test="basePhoto != null">
|
basePhoto = #{basePhoto,jdbcType=VARCHAR},
|
</if>
|
<if test="cameraType !=null">
|
cameraType = #{cameraType,jdbcType=INTEGER}
|
</if>
|
</set>
|
where id = #{id,jdbcType=VARCHAR}
|
</update>
|
<update id="updateById" parameterType="com.cloud.device.model.Device">
|
update device
|
set orgId = #{orgId,jdbcType=INTEGER},
|
type = #{type,jdbcType=VARCHAR},
|
name = #{name,jdbcType=VARCHAR},
|
code = #{code,jdbcType=VARCHAR},
|
address = #{address,jdbcType=VARCHAR},
|
longitude = #{longitude,jdbcType=VARCHAR},
|
latitude = #{latitude,jdbcType=VARCHAR},
|
ip = #{ip,jdbcType=VARCHAR},
|
port = #{port,jdbcType=VARCHAR},
|
username = #{username,jdbcType=VARCHAR},
|
password = #{password,jdbcType=VARCHAR},
|
revJson = #{revJson,jdbcType=CHAR},
|
createBy = #{createBy,jdbcType=VARCHAR},
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
updateBy = #{updateBy,jdbcType=VARCHAR},
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
remarks = #{remarks,jdbcType=VARCHAR},
|
layerId = #{layerId,jdbcType=VARCHAR},
|
status = #{status,jdbcType=INTEGER},
|
nodeId = #{nodeId,jdbcType=VARCHAR},
|
brand = #{brand,jdbcType=VARCHAR},
|
delFlag = #{delFlag,jdbcType=VARCHAR},
|
cameraType = #{cameraType,jdbcType=INTEGER}
|
where id = #{id,jdbcType=VARCHAR}
|
</update>
|
|
<select id="findByNodeId" parameterType="java.lang.String" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where nodeId = #{nodeId,jdbcType=VARCHAR} and delFlag = '0'
|
</select>
|
<select id="findAllOrgDevice" parameterType="java.util.Map" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag ='0' and nodeId is null
|
<if test="condition !=null and condition !=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
</select>
|
|
<select id="findAllClusterDevice" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag='0' and nodeId is not null
|
<if test="condition !=null and condition !=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
</select>
|
|
<select id="findAllDevice" parameterType="java.util.Map" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag = '0'
|
<if test="condition !=null and condition !=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
</select>
|
|
<select id="countPlatDevice" parameterType="java.util.Map" resultType="int">
|
select count(1)
|
from device
|
where delFlag ='0' and nodeId is null and (orgId in (select id from org where parentIds like concat("%,",#{orgId},",%")) or orgId = #{orgId})
|
<if test="condition!=null and condition !=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
</select>
|
|
<select id="countAllDevice" parameterType="java.util.Map" resultType="int">
|
select count(1)
|
from device
|
where delFlag ='0' and (orgId in (select id from org where parentIds like concat("%,",#{orgId},",%")) or orgId = #{orgId})
|
<if test="condition!=null and condition !=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
</select>
|
|
<select id="findAllDeviceList" resultMap="BaseResultMap" parameterType="java.util.Map">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag = '0'
|
and (orgId in (select id from org where parentIds like concat("%,",#{orgId},",%")) or orgId = #{orgId})
|
<if test="condition !=null and condition!=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
order by id desc
|
</select>
|
|
<select id="findPlatDevicePageList" resultMap="BaseResultMap" parameterType="java.util.Map">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag = '0' and nodeId is null
|
and (orgId in (select id from org where parentIds like concat("%,",#{orgId},",%")) or orgId = #{orgId})
|
<if test="condition !=null and condition!=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
order by id desc
|
limit #{start},#{length}
|
</select>
|
<select id="findAllPlatDeviceList" resultMap="BaseResultMap" parameterType="java.util.Map">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag = '0' and nodeId is null
|
and (orgId in (select id from org where parentIds like concat("%,",#{orgId},",%")) or orgId = #{orgId})
|
<if test="condition !=null and condition!=''">
|
and (name like concat('%',#{condition},'%') or ip like concat('%',#{condition},'%') or address like concat('%',#{condition},'%'))
|
</if>
|
</select>
|
|
<select id="findByOrgId" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag ='0' and orgId=#{orgId}
|
</select>
|
|
<select id="findByIp" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag = '0' and ip = #{ip,jdbcType=VARCHAR}
|
limit 0,1
|
</select>
|
|
<select id="findNoPosDevices" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag ='0' and (longitude is null or longitude='' or latitude is null or latitude = '')
|
</select>
|
|
<select id="findPosDevices" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" />
|
from device
|
where delFlag ='0' and (longitude is not null and longitude!='' and latitude is not null and latitude != '')
|
</select>
|
|
</mapper>
|