HxpCabinetlockLogMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 = 5 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. </select>
  97. <select id="getListByIds" resultMap="HxpCabinetlockLogResult">
  98. <include refid="selectHxpCabinetlockLogVo"/>
  99. <where>
  100. id in
  101. <foreach item="id" collection="list" open="(" separator="," close=")">
  102. #{id}
  103. </foreach>
  104. </where>
  105. </select>
  106. <select id="selectHxpCabinetlockLogById" resultMap="HxpCabinetlockLogResult">
  107. <include refid="selectHxpCabinetlockLogVo"/>
  108. where id = #{id}
  109. </select>
  110. <select id="selectByLockId" resultType="com.zd.chemical.domain.HxpCabinetlockLog">
  111. <include refid="selectHxpCabinetlockLogVo"/>
  112. where cabinetlock_id = (select id from lab_hardware where subject_id = #{subId} and lock_id = #{lockId} limit 1)
  113. and close_lock_video is null
  114. order by create_time desc
  115. limit 1
  116. </select>
  117. <insert id="insertHxpCabinetlockLog" parameterType="com.zd.chemical.domain.HxpCabinetlockLog"
  118. useGeneratedKeys="true" keyProperty="id">
  119. insert into hxp_cabinetlock_log
  120. <trim prefix="(" suffix=")" suffixOverrides=",">
  121. <if test="cabinetlockId != null">cabinetlock_id,</if>
  122. <if test="unLockTime != null">un_lock_time,</if>
  123. <if test="closeLockTime != null">close_lock_time,</if>
  124. <if test="operationType != null">operation_type,</if>
  125. <if test="unLockVideo != null">un_lock_video,</if>
  126. <if test="closeLockVideo != null">close_lock_video,</if>
  127. <if test="userIds != null">user_ids,</if>
  128. <if test="createTime != null">create_time,</if>
  129. <if test="createBy != null">create_by,</if>
  130. <if test="stockId != null">stock_id,</if>
  131. <if test="userecordId != null">userecord_id,</if>
  132. </trim>
  133. <trim prefix="values (" suffix=")" suffixOverrides=",">
  134. <if test="cabinetlockId != null">#{cabinetlockId},</if>
  135. <if test="unLockTime != null">#{unLockTime},</if>
  136. <if test="closeLockTime != null">#{closeLockTime},</if>
  137. <if test="operationType != null">#{operationType},</if>
  138. <if test="unLockVideo != null">#{unLockVideo},</if>
  139. <if test="closeLockVideo != null">#{closeLockVideo},</if>
  140. <if test="userIds != null">#{user_ids},</if>
  141. <if test="createTime != null">#{createTime},</if>
  142. <if test="createBy != null">#{createBy},</if>
  143. <if test="stockId != null">#{stockId},</if>
  144. <if test="userecordId != null">#{userecordId},</if>
  145. </trim>
  146. </insert>
  147. <update id="updateHxpCabinetlockLog" parameterType="com.zd.chemical.domain.HxpCabinetlockLog">
  148. update hxp_cabinetlock_log
  149. <trim prefix="SET" suffixOverrides=",">
  150. <if test="cabinetlockId != null">cabinetlock_id = #{cabinetlockId},</if>
  151. <if test="unLockTime != null">un_lock_time = #{unLockTime},</if>
  152. <if test="closeLockTime != null">close_lock_time = #{closeLockTime},</if>
  153. <if test="operationType != null">operation_type = #{operationType},</if>
  154. <if test="unLockVideo != null">un_lock_video = #{unLockVideo},</if>
  155. <if test="closeLockVideo != null">close_lock_video = #{closeLockVideo},</if>
  156. <if test="userIds != null">user_ids = #{userIds},</if>
  157. <if test="createTime != null">create_time = #{createTime},</if>
  158. <if test="createBy != null">create_by = #{createBy},</if>
  159. <if test="stockId != null">stock_id = #{stockId},</if>
  160. <if test="userecordId != null">userecord_id = #{userecordId},</if>
  161. </trim>
  162. where id = #{id}
  163. </update>
  164. <delete id="deleteHxpCabinetlockLogById">
  165. delete
  166. from hxp_cabinetlock_log
  167. where id = #{id}
  168. </delete>
  169. <delete id="deleteHxpCabinetlockLogByIds">
  170. delete from hxp_cabinetlock_log where id in
  171. <foreach item="id" collection="array" open="(" separator="," close=")">
  172. #{id}
  173. </foreach>
  174. </delete>
  175. </mapper>