| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?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.zd.chemical.mapper.HxpCabinetlockLogMapper">
- <resultMap type="com.zd.chemical.domain.HxpCabinetlockLog" id="HxpCabinetlockLogResult">
- <result property="id" column="id"/>
- <result property="cabinetlockId" column="cabinetlock_id"/>
- <result property="unLockTime" column="un_lock_time"/>
- <result property="closeLockTime" column="close_lock_time"/>
- <result property="operationType" column="operation_type"/>
- <result property="unLockVideo" column="un_lock_video"/>
- <result property="closeLockVideo" column="close_lock_video"/>
- <result property="userIds" column="user_ids"/>
- <result property="createTime" column="create_time"/>
- <result property="createBy" column="create_by"/>
- <result property="stockId" column="stock_id"/>
- <result property="userecordId" column="userecord_id"/>
- </resultMap>
- <sql id="selectHxpCabinetlockLogVo">
- select id,
- cabinetlock_id,
- un_lock_time,
- close_lock_time,
- operation_type,
- un_lock_video,
- close_lock_video,
- user_ids,
- create_time,
- create_by,
- stock_id,
- userecord_id
- from hxp_cabinetlock_log
- </sql>
- <sql id="selectHxpCabinetlockLogListVo">
- select t.id,
- t.cabinetlock_id,
- t.un_lock_time,
- t.close_lock_time,
- t.operation_type,
- t.un_lock_video,
- t.close_lock_video,
- t.user_ids,
- t.create_time,
- t.create_by,
- t.stock_id,
- t.userecord_id
- from hxp_cabinetlock_log as t
- </sql>
- <select id="selectHxpCabinetlockLogList" parameterType="com.zd.chemical.domain.vo.HxpCabinetlockLogSearch"
- resultType="com.zd.chemical.domain.vo.HxpCabinetlockLogVo">
- select DISTINCT
- cl.un_lock_time unLockTime,
- cl.close_lock_time closeLockTime,
- concat(TIMESTAMPDIFF(MINUTE,cl.un_lock_time,cl.close_lock_time),'分钟') timeLength,
- case when cl.operation_type = 1 then '入库' else
- case when cl.operation_type = 2 then '出库' else
- case when cl.operation_type = 3 then '领用' else
- case when cl.operation_type = 4 then '归还' else
- case when cl.operation_type = 0 then '系统' else
- '系统'
- end
- end
- end
- end
- end operationTypeContent,
- cl.un_lock_video unLockVideo,
- cl.close_lock_video closeLockVideo,
- (select group_concat(ur.nick_name SEPARATOR '、') from sys_user ur where find_in_set(ur.user_id, cl.user_ids))
- operationNames
- from
- hxp_cabinetlock_log cl left join sys_user ur on FIND_IN_SET(ur.user_id, cl.user_ids)
- <where>
- <if test="cabinetlockId != null ">
- and cl.cabinetlock_id = #{cabinetlockId}
- </if>
- <if test="searchValue != null ">
- and ur.nick_name like concat('%', #{searchValue}, '%')
- </if>
- <if test="unLockTimeBegin != null and unLockTimeBegin != ''"><!-- 开锁开始时间 -->
- AND date_format(cl.un_lock_time,'%y%m%d') >= date_format(#{unLockTimeBegin},'%y%m%d')
- </if>
- <if test="unLockTimeEnd != null and unLockTimeEnd != ''"><!-- 开锁结束时间 -->
- AND date_format(cl.un_lock_time,'%y%m%d') <= date_format(#{unLockTimeEnd},'%y%m%d')
- </if>
- <if test="closeLockTimeBegin != null and closeLockTimeBegin != ''"><!-- 关锁开始时间 -->
- AND date_format(cl.close_lock_time,'%y%m%d') >= date_format(#{closeLockTimeBegin},'%y%m%d')
- </if>
- <if test="closeLockTimeEnd != null and closeLockTimeEnd != ''"><!-- 关锁结束时间 -->
- AND date_format(cl.close_lock_time,'%y%m%d') <= date_format(#{closeLockTimeEnd},'%y%m%d')
- </if>
- <if test="operationType != null ">
- and cl.operation_type = #{operationType}
- </if>
- </where>
- order by cl.un_lock_time desc
- </select>
- <select id="getListByIds" resultMap="HxpCabinetlockLogResult">
- <include refid="selectHxpCabinetlockLogVo"/>
- <where>
- id in
- <foreach item="id" collection="list" open="(" separator="," close=")">
- #{id}
- </foreach>
- </where>
- </select>
- <select id="selectHxpCabinetlockLogById" resultMap="HxpCabinetlockLogResult">
- <include refid="selectHxpCabinetlockLogVo"/>
- where id = #{id}
- </select>
- <select id="selectByLockId" resultType="com.zd.chemical.domain.HxpCabinetlockLog">
- <include refid="selectHxpCabinetlockLogVo"/>
- where cabinetlock_id = (select id from lab_hardware where subject_id = #{subId} and lock_id = #{lockId} limit 1)
- and close_lock_video is null
- order by create_time desc
- limit 1
- </select>
- <insert id="insertHxpCabinetlockLog" parameterType="com.zd.chemical.domain.HxpCabinetlockLog"
- useGeneratedKeys="true" keyProperty="id">
- insert into hxp_cabinetlock_log
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="cabinetlockId != null">cabinetlock_id,</if>
- <if test="unLockTime != null">un_lock_time,</if>
- <if test="closeLockTime != null">close_lock_time,</if>
- <if test="operationType != null">operation_type,</if>
- <if test="unLockVideo != null">un_lock_video,</if>
- <if test="closeLockVideo != null">close_lock_video,</if>
- <if test="userIds != null">user_ids,</if>
- <if test="createTime != null">create_time,</if>
- <if test="createBy != null">create_by,</if>
- <if test="stockId != null">stock_id,</if>
- <if test="userecordId != null">userecord_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="cabinetlockId != null">#{cabinetlockId},</if>
- <if test="unLockTime != null">#{unLockTime},</if>
- <if test="closeLockTime != null">#{closeLockTime},</if>
- <if test="operationType != null">#{operationType},</if>
- <if test="unLockVideo != null">#{unLockVideo},</if>
- <if test="closeLockVideo != null">#{closeLockVideo},</if>
- <if test="userIds != null">#{userIds},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="stockId != null">#{stockId},</if>
- <if test="userecordId != null">#{userecordId},</if>
- </trim>
- </insert>
- <update id="updateHxpCabinetlockLog" parameterType="com.zd.chemical.domain.HxpCabinetlockLog">
- update hxp_cabinetlock_log
- <trim prefix="SET" suffixOverrides=",">
- <if test="cabinetlockId != null">cabinetlock_id = #{cabinetlockId},</if>
- <if test="unLockTime != null">un_lock_time = #{unLockTime},</if>
- <if test="closeLockTime != null">close_lock_time = #{closeLockTime},</if>
- <if test="operationType != null">operation_type = #{operationType},</if>
- <if test="unLockVideo != null">un_lock_video = #{unLockVideo},</if>
- <if test="closeLockVideo != null">close_lock_video = #{closeLockVideo},</if>
- <if test="userIds != null">user_ids = #{userIds},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="stockId != null">stock_id = #{stockId},</if>
- <if test="userecordId != null">userecord_id = #{userecordId},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteHxpCabinetlockLogById">
- delete
- from hxp_cabinetlock_log
- where id = #{id}
- </delete>
- <delete id="deleteHxpCabinetlockLogByIds">
- delete from hxp_cabinetlock_log where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|