328 lines
12 KiB
XML
328 lines
12 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.zhwl.device.handheld.mapper.ZdyDeviceHandheldMapper">
|
||
|
|
||
|
<resultMap type="ZdyDeviceHandheld" id="ZdyDeviceHandheldResult">
|
||
|
<result property="id" column="id"/>
|
||
|
<result property="deviceName" column="device_name"/>
|
||
|
<result property="sn" column="sn"/>
|
||
|
<result property="onlineStatus" column="online_status"/>
|
||
|
<result property="useStatus" column="use_status"/>
|
||
|
<result property="lastDisableSet" column="last_disable_set"/>
|
||
|
<result property="lastDisableTime" column="last_disable_time"/>
|
||
|
<result property="delFlag" column="del_flag"/>
|
||
|
<result property="createBy" column="create_by"/>
|
||
|
<result property="createTime" column="create_time"/>
|
||
|
<result property="updateBy" column="update_by"/>
|
||
|
<result property="updateTime" column="update_time"/>
|
||
|
<result property="remark" column="remark"/>
|
||
|
<result property="lastOnlineTime" column="last_online_time"/>
|
||
|
<result property="lastOfflineTime" column="last_offline_time"/>
|
||
|
<result property="deptId" column="dept_id"/>
|
||
|
<result property="scenicId" column="scenic_id"/>
|
||
|
<result property="scenicName" column="scenic_name"/>
|
||
|
<result property="ownerType" column="owner_type"/>
|
||
|
<result property="storeId" column="store_id"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<sql id="selectZdyDeviceHandheldVo">
|
||
|
select id,
|
||
|
device_name,
|
||
|
sn,
|
||
|
online_status,
|
||
|
use_status,
|
||
|
last_disable_set,
|
||
|
last_disable_time,
|
||
|
del_flag,
|
||
|
create_by,
|
||
|
create_time,
|
||
|
update_by,
|
||
|
update_time,
|
||
|
remark,
|
||
|
last_online_time,
|
||
|
last_offline_time,
|
||
|
dept_id,
|
||
|
scenic_id,
|
||
|
owner_type,
|
||
|
store_id
|
||
|
from zdy_device_handheld
|
||
|
</sql>
|
||
|
|
||
|
<select id="selectZdyDeviceHandheldList" parameterType="ZdyDeviceHandheld" resultMap="ZdyDeviceHandheldResult">
|
||
|
select zdh.id,
|
||
|
zdh.device_name,
|
||
|
zdh.sn,
|
||
|
zdh.online_status,
|
||
|
zdh.use_status,
|
||
|
zdh.last_disable_set,
|
||
|
zdh.last_disable_time,
|
||
|
zdh.del_flag,
|
||
|
zdh.create_by,
|
||
|
zdh.create_time,
|
||
|
zdh.update_by,
|
||
|
zdh.update_time,
|
||
|
zdh.remark,
|
||
|
zdh.last_online_time,
|
||
|
zdh.last_offline_time,
|
||
|
zdh.dept_id,
|
||
|
zdh.scenic_id,
|
||
|
zs.scenic_name,
|
||
|
zdh.owner_type,
|
||
|
zdh.store_id
|
||
|
from zdy_device_handheld zdh
|
||
|
left join sys_dept d on d.dept_id = zdh.dept_id
|
||
|
left join zdy_scenic zs on zs.id = zdh.scenic_id
|
||
|
<where>
|
||
|
zdh.del_flag = '0'
|
||
|
<if test="deviceName != null and deviceName != ''">
|
||
|
and zdh.device_name like concat('%', #{deviceName}, '%')
|
||
|
</if>
|
||
|
<if test="sn != null and sn != ''">
|
||
|
and zdh.sn = #{sn}
|
||
|
</if>
|
||
|
<if test="onlineStatus != null and onlineStatus != ''">
|
||
|
and zdh.online_status = #{onlineStatus}
|
||
|
</if>
|
||
|
<if test="useStatus != null and useStatus != ''">
|
||
|
and zdh.use_status = #{useStatus}
|
||
|
</if>
|
||
|
<if test="lastDisableSet != null and lastDisableSet != ''">
|
||
|
and zdh.last_disable_set = #{lastDisableSet}
|
||
|
</if>
|
||
|
<if test="lastDisableTime != null ">
|
||
|
and zdh.last_disable_time = #{lastDisableTime}
|
||
|
</if>
|
||
|
<if test="ownerType !=null">
|
||
|
and zdh.owner_type = #{ownerType}
|
||
|
</if>
|
||
|
<if test="storeId != null">
|
||
|
and zdh.store_id = #{storeId}
|
||
|
</if>
|
||
|
${params.dataScope}
|
||
|
</where>
|
||
|
</select>
|
||
|
|
||
|
<select id="selectZdyDeviceHandheldById" parameterType="Long"
|
||
|
resultMap="ZdyDeviceHandheldResult">
|
||
|
<include refid="selectZdyDeviceHandheldVo"/>
|
||
|
where id = #{id}
|
||
|
</select>
|
||
|
|
||
|
<insert id="insertZdyDeviceHandheld" parameterType="ZdyDeviceHandheld" useGeneratedKeys="true"
|
||
|
keyProperty="id">
|
||
|
insert into zdy_device_handheld
|
||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
|
<if test="deviceName != null">device_name,
|
||
|
</if>
|
||
|
<if test="sn != null">sn,
|
||
|
</if>
|
||
|
<if test="onlineStatus != null and onlineStatus != ''">online_status,
|
||
|
</if>
|
||
|
<if test="useStatus != null and useStatus != ''">use_status,
|
||
|
</if>
|
||
|
<if test="lastDisableSet != null">last_disable_set,
|
||
|
</if>
|
||
|
<if test="lastDisableTime != null">last_disable_time,
|
||
|
</if>
|
||
|
<if test="delFlag != null and delFlag != ''">del_flag,
|
||
|
</if>
|
||
|
<if test="createBy != null">create_by,
|
||
|
</if>
|
||
|
<if test="createTime != null">create_time,
|
||
|
</if>
|
||
|
<if test="updateBy != null">update_by,
|
||
|
</if>
|
||
|
<if test="updateTime != null">update_time,
|
||
|
</if>
|
||
|
<if test="remark != null">remark,
|
||
|
</if>
|
||
|
<if test="lastOnlineTime != null">last_online_time,
|
||
|
</if>
|
||
|
<if test="lastOfflineTime != null">last_offline_time,
|
||
|
</if>
|
||
|
<if test="deptId != null">dept_id,
|
||
|
</if>
|
||
|
<if test="scenicId != null">scenic_id,
|
||
|
</if>
|
||
|
<if test="ownerType != null">owner_type,
|
||
|
</if>
|
||
|
<if test="storeId != null">store_id,
|
||
|
</if>
|
||
|
</trim>
|
||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
|
<if test="deviceName != null">#{deviceName},
|
||
|
</if>
|
||
|
<if test="sn != null">#{sn},
|
||
|
</if>
|
||
|
<if test="onlineStatus != null and onlineStatus != ''">#{onlineStatus},
|
||
|
</if>
|
||
|
<if test="useStatus != null and useStatus != ''">#{useStatus},
|
||
|
</if>
|
||
|
<if test="lastDisableSet != null">#{lastDisableSet},
|
||
|
</if>
|
||
|
<if test="lastDisableTime != null">#{lastDisableTime},
|
||
|
</if>
|
||
|
<if test="delFlag != null and delFlag != ''">#{delFlag},
|
||
|
</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="remark != null">#{remark},
|
||
|
</if>
|
||
|
<if test="lastOnlineTime != null">#{lastOnlineTime},
|
||
|
</if>
|
||
|
<if test="lastOfflineTime != null">#{lastOfflineTime},
|
||
|
</if>
|
||
|
<if test="deptId != null">#{deptId},
|
||
|
</if>
|
||
|
<if test="scenicId != null">#{scenicId},
|
||
|
</if>
|
||
|
<if test="ownerType != null">#{ownerType},
|
||
|
</if>
|
||
|
<if test="storeId != null">#{storeId},
|
||
|
</if>
|
||
|
</trim>
|
||
|
</insert>
|
||
|
|
||
|
<update id="updateZdyDeviceHandheld" parameterType="ZdyDeviceHandheld">
|
||
|
update zdy_device_handheld
|
||
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
<if test="deviceName != null">device_name =
|
||
|
#{deviceName},
|
||
|
</if>
|
||
|
<if test="sn != null">sn =
|
||
|
#{sn},
|
||
|
</if>
|
||
|
<if test="onlineStatus != null and onlineStatus != ''">online_status =
|
||
|
#{onlineStatus},
|
||
|
</if>
|
||
|
<if test="useStatus != null and useStatus != ''">use_status =
|
||
|
#{useStatus},
|
||
|
</if>
|
||
|
<if test="lastDisableSet != null">last_disable_set =
|
||
|
#{lastDisableSet},
|
||
|
</if>
|
||
|
<if test="lastDisableTime != null">last_disable_time =
|
||
|
#{lastDisableTime},
|
||
|
</if>
|
||
|
<if test="delFlag != null and delFlag != ''">del_flag =
|
||
|
#{delFlag},
|
||
|
</if>
|
||
|
<if test="createBy != null">create_by =
|
||
|
#{createBy},
|
||
|
</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="remark != null">remark =
|
||
|
#{remark},
|
||
|
</if>
|
||
|
<if test="lastOnlineTime != null">last_online_time =
|
||
|
#{lastOnlineTime},
|
||
|
</if>
|
||
|
<if test="lastOfflineTime != null">last_offline_time =
|
||
|
#{lastOfflineTime},
|
||
|
</if>
|
||
|
<if test="deptId != null">dept_id =
|
||
|
#{deptId},
|
||
|
</if>
|
||
|
<if test="scenicId != null">scenic_id =
|
||
|
#{scenicId},
|
||
|
</if>
|
||
|
<if test="ownerType != null">owner_type =
|
||
|
#{ownerType},
|
||
|
</if>
|
||
|
<if test="storeId != null">store_id =
|
||
|
#{storeId},
|
||
|
</if>
|
||
|
</trim>
|
||
|
where id = #{id}
|
||
|
</update>
|
||
|
|
||
|
<update id="deleteZdyDeviceHandheldById" parameterType="Long">
|
||
|
update zdy_device_handheld
|
||
|
set del_flag = '1'
|
||
|
where id = #{id}
|
||
|
</update>
|
||
|
|
||
|
<delete id="deleteZdyDeviceHandheldByIds" parameterType="String">
|
||
|
update zdy_device_handheld
|
||
|
set del_flag = '1'
|
||
|
where id in
|
||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||
|
#{id}
|
||
|
</foreach>
|
||
|
</delete>
|
||
|
|
||
|
<select id="existSn" parameterType="ZdyDeviceHandheld" resultType="java.lang.Integer">
|
||
|
select exists(
|
||
|
select 1
|
||
|
from zdy_device_handheld
|
||
|
<where>
|
||
|
del_flag = '0'
|
||
|
and sn = #{sn}
|
||
|
<if test="id != null">
|
||
|
and id != #{id}
|
||
|
</if>
|
||
|
</where>
|
||
|
)
|
||
|
</select>
|
||
|
|
||
|
<update id="enable" parameterType="ZdyDeviceHandheld">
|
||
|
update zdy_device_handheld
|
||
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
<if test="useStatus != null and useStatus != ''">use_status =
|
||
|
#{useStatus},
|
||
|
</if>
|
||
|
last_disable_set = null,
|
||
|
last_disable_time = null,
|
||
|
<if test="updateTime != null">update_time =
|
||
|
#{updateTime},
|
||
|
</if>
|
||
|
</trim>
|
||
|
where id = #{id}
|
||
|
</update>
|
||
|
|
||
|
<select id="existDeviceDisableExpiry" parameterType="ZdyDeviceHandheld" resultType="java.lang.Integer">
|
||
|
select exists(select 1
|
||
|
from zdy_device_handheld
|
||
|
where del_flag = '0'
|
||
|
and use_status = #{useStatus}
|
||
|
and last_disable_time <= #{lastDisableTime})
|
||
|
</select>
|
||
|
|
||
|
<select id="reactivateDisableExpiredDevice" parameterType="ZdyDeviceHandheld">
|
||
|
update zdy_device_handheld
|
||
|
<trim prefix="SET" suffixOverrides=",">
|
||
|
<if test="updateData.useStatus != null and updateData.useStatus != ''">use_status =
|
||
|
#{updateData.useStatus},
|
||
|
</if>
|
||
|
last_disable_set = null,
|
||
|
last_disable_time = null,
|
||
|
<if test="updateData.updateTime != null">update_time =
|
||
|
#{updateData.updateTime},
|
||
|
</if>
|
||
|
</trim>
|
||
|
where del_flag = '0'
|
||
|
and use_status = #{updateParam.useStatus}
|
||
|
and last_disable_time <= #{updateParam.lastDisableTime}
|
||
|
</select>
|
||
|
|
||
|
<select id="countQuantity" resultType="int">
|
||
|
select count(1) from zdy_device_handheld where del_flag = '0'
|
||
|
</select>
|
||
|
</mapper>
|