HxpCabinetlockLogMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zd.chemical.mapper.HxpCabinetlockLogMapper">
  6. <resultMap type="com.zd.chemical.domain.HxpCabinetlockLog" id="HxpCabinetlockLogResult">
  7. <result property="id" column="id"/>
  8. <result property="cabinetlockId" column="cabinetlock_id"/>
  9. <result property="unLockTime" column="un_lock_time"/>
  10. <result property="closeLockTime" column="close_lock_time"/>
  11. <result property="operationType" column="operation_type"/>
  12. <result property="unLockVideo" column="un_lock_video"/>
  13. <result property="closeLockVideo" column="close_lock_video"/>
  14. <result property="userIds" column="user_ids"/>
  15. <result property="createTime" column="create_time"/>
  16. <result property="createBy" column="create_by"/>
  17. <result property="stockId" column="stock_id"/>
  18. <result property="userecordId" column="userecord_id"/>
  19. </resultMap>
  20. <sql id="selectHxpCabinetlockLogVo">
  21. select id,
  22. cabinetlock_id,
  23. un_lock_time,
  24. close_lock_time,
  25. operation_type,
  26. un_lock_video,
  27. close_lock_video,
  28. user_ids,
  29. create_time,
  30. create_by,
  31. stock_id,
  32. userecord_id
  33. from hxp_cabinetlock_log
  34. </sql>
  35. <sql id="selectHxpCabinetlockLogListVo">
  36. select t.id,
  37. t.cabinetlock_id,
  38. t.un_lock_time,
  39. t.close_lock_time,
  40. t.operation_type,
  41. t.un_lock_video,
  42. t.close_lock_video,
  43. t.user_ids,
  44. t.create_time,
  45. t.create_by,
  46. t.stock_id,
  47. t.userecord_id
  48. from hxp_cabinetlock_log as t
  49. </sql>
  50. <select id="selectHxpCabinetlockLogList" parameterType="com.zd.chemical.domain.vo.HxpCabinetlockLogSearch"
  51. resultType="com.zd.chemical.domain.vo.HxpCabinetlockLogVo">
  52. select DISTINCT
  53. cl.un_lock_time unLockTime,
  54. cl.close_lock_time closeLockTime,
  55. concat(TIMESTAMPDIFF(MINUTE,cl.un_lock_time,cl.close_lock_time),'分钟') timeLength,
  56. case when cl.operation_type = 1 then '入库' else
  57. case when cl.operation_type = 2 then '出库' else
  58. case when cl.operation_type = 3 then '领用' else
  59. case when cl.operation_type = 4 then '归还' else
  60. case when cl.operation_type = 0 then '系统' else
  61. '系统'
  62. end
  63. end
  64. end
  65. end
  66. end operationTypeContent,
  67. cl.un_lock_video unLockVideo,
  68. cl.close_lock_video closeLockVideo,
  69. (select group_concat(ur.nick_name SEPARATOR '、') from sys_user ur where find_in_set(ur.user_id, cl.user_ids))
  70. operationNames
  71. from
  72. hxp_cabinetlock_log cl left join sys_user ur on FIND_IN_SET(ur.user_id, cl.user_ids)
  73. <where>
  74. <if test="cabinetlockId != null ">
  75. and cl.cabinetlock_id = #{cabinetlockId}
  76. </if>
  77. <if test="searchValue != null ">
  78. and ur.nick_name like concat('%', #{searchValue}, '%')
  79. </if>
  80. <if test="unLockTimeBegin != null and unLockTimeBegin != ''"><!-- 开锁开始时间 -->
  81. AND date_format(cl.un_lock_time,'%y%m%d') &gt;= date_format(#{unLockTimeBegin},'%y%m%d')
  82. </if>
  83. <if test="unLockTimeEnd != null and unLockTimeEnd != ''"><!-- 开锁结束时间 -->
  84. AND date_format(cl.un_lock_time,'%y%m%d') &lt;= date_format(#{unLockTimeEnd},'%y%m%d')
  85. </if>
  86. <if test="closeLockTimeBegin != null and closeLockTimeBegin != ''"><!-- 关锁开始时间 -->
  87. AND date_format(cl.close_lock_time,'%y%m%d') &gt;= date_format(#{closeLockTimeBegin},'%y%m%d')
  88. </if>
  89. <if test="closeLockTimeEnd != null and closeLockTimeEnd != ''"><!-- 关锁结束时间 -->
  90. AND date_format(cl.close_lock_time,'%y%m%d') &lt;= date_format(#{closeLockTimeEnd},'%y%m%d')
  91. </if>
  92. <if test="operationType != null ">
  93. and cl.operation_type = #{operationType}
  94. </if>
  95. </where>
  96. order by cl.un_lock_time desc
  97. </select>
  98. <select id="getListByIds" resultMap="HxpCabinetlockLogResult">
  99. <include refid="selectHxpCabinetlockLogVo"/>
  100. <where>
  101. id in
  102. <foreach item="id" collection="list" open="(" separator="," close=")">
  103. #{id}
  104. </foreach>
  105. </where>
  106. </select>
  107. <select id="selectHxpCabinetlockLogById" resultMap="HxpCabinetlockLogResult">
  108. <include refid="selectHxpCabinetlockLogVo"/>
  109. where id = #{id}
  110. </select>
  111. <select id="selectByLockId" resultType="com.zd.chemical.domain.HxpCabinetlockLog">
  112. <include refid="selectHxpCabinetlockLogVo"/>
  113. where cabinetlock_id = (select id from lab_hardware where subject_id = #{subId} and lock_id = #{lockId} limit 1)
  114. and close_lock_video is null
  115. order by create_time desc
  116. limit 1
  117. </select>
  118. <insert id="insertHxpCabinetlockLog" parameterType="com.zd.chemical.domain.HxpCabinetlockLog"
  119. useGeneratedKeys="true" keyProperty="id">
  120. insert into hxp_cabinetlock_log
  121. <trim prefix="(" suffix=")" suffixOverrides=",">
  122. <if test="cabinetlockId != null">cabinetlock_id,</if>
  123. <if test="unLockTime != null">un_lock_time,</if>
  124. <if test="closeLockTime != null">close_lock_time,</if>
  125. <if test="operationType != null">operation_type,</if>
  126. <if test="unLockVideo != null">un_lock_video,</if>
  127. <if test="closeLockVideo != null">close_lock_video,</if>
  128. <if test="userIds != null">user_ids,</if>
  129. <if test="createTime != null">create_time,</if>
  130. <if test="createBy != null">create_by,</if>
  131. <if test="stockId != null">stock_id,</if>
  132. <if test="userecordId != null">userecord_id,</if>
  133. </trim>
  134. <trim prefix="values (" suffix=")" suffixOverrides=",">
  135. <if test="cabinetlockId != null">#{cabinetlockId},</if>
  136. <if test="unLockTime != null">#{unLockTime},</if>
  137. <if test="closeLockTime != null">#{closeLockTime},</if>
  138. <if test="operationType != null">#{operationType},</if>
  139. <if test="unLockVideo != null">#{unLockVideo},</if>
  140. <if test="closeLockVideo != null">#{closeLockVideo},</if>
  141. <if test="userIds != null">#{userIds},</if>
  142. <if test="createTime != null">#{createTime},</if>
  143. <if test="createBy != null">#{createBy},</if>
  144. <if test="stockId != null">#{stockId},</if>
  145. <if test="userecordId != null">#{userecordId},</if>
  146. </trim>
  147. </insert>
  148. <update id="updateHxpCabinetlockLog" parameterType="com.zd.chemical.domain.HxpCabinetlockLog">
  149. update hxp_cabinetlock_log
  150. <trim prefix="SET" suffixOverrides=",">
  151. <if test="cabinetlockId != null">cabinetlock_id = #{cabinetlockId},</if>
  152. <if test="unLockTime != null">un_lock_time = #{unLockTime},</if>
  153. <if test="closeLockTime != null">close_lock_time = #{closeLockTime},</if>
  154. <if test="operationType != null">operation_type = #{operationType},</if>
  155. <if test="unLockVideo != null">un_lock_video = #{unLockVideo},</if>
  156. <if test="closeLockVideo != null">close_lock_video = #{closeLockVideo},</if>
  157. <if test="userIds != null">user_ids = #{userIds},</if>
  158. <if test="createTime != null">create_time = #{createTime},</if>
  159. <if test="createBy != null">create_by = #{createBy},</if>
  160. <if test="stockId != null">stock_id = #{stockId},</if>
  161. <if test="userecordId != null">userecord_id = #{userecordId},</if>
  162. </trim>
  163. where id = #{id}
  164. </update>
  165. <delete id="deleteHxpCabinetlockLogById">
  166. delete
  167. from hxp_cabinetlock_log
  168. where id = #{id}
  169. </delete>
  170. <delete id="deleteHxpCabinetlockLogByIds">
  171. delete from hxp_cabinetlock_log where id in
  172. <foreach item="id" collection="array" open="(" separator="," close=")">
  173. #{id}
  174. </foreach>
  175. </delete>
  176. </mapper>