QpBottleStorageOutMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.airbottle.mapper.QpBottleStorageOutMapper">
  6. <resultMap type="com.zd.airbottle.domain.vo.QpBottleStorageOutVO" id="QpBottleStorageOutResult">
  7. <result property="id" column="id"/>
  8. <result property="applyUserName" column="apply_user_name"/>
  9. <result property="applyUserid" column="apply_userid"/>
  10. <result property="phone" column="phone"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="storageId" column="storage_id"/>
  13. <result property="carId" column="car_id"/>
  14. <result property="carNumber" column="car_number"/>
  15. <result property="transportId" column="transport_id"/>
  16. <result property="transportName" column="transport_name"/>
  17. <result property="disposeUserid" column="dispose_userid"/>
  18. <result property="disposeUsername" column="dispose_username"/>
  19. <result property="disposeTime" column="dispose_time"/>
  20. <result property="completeTime" column="complete_time"/>
  21. <result property="completeUserid" column="complete_userid"/>
  22. <result property="completeUsername" column="complete_username"/>
  23. <result property="pressure" column="pressure"/>
  24. <result property="outStatus" column="out_status"/>
  25. </resultMap>
  26. <sql id="selectQpBottleStorageOutVo">
  27. select id, apply_user_name, apply_userid, phone, create_time, storage_id, car_id, car_number, transport_id, transport_name, dispose_userid, dispose_username, dispose_time, complete_time, complete_userid, complete_username, pressure ,out_status from qp_bottle_storage_out
  28. </sql>
  29. <sql id="selectQpBottleStorageOutListVo">
  30. select t.id, t.apply_user_name, t.apply_userid, t.phone, t.create_time,
  31. t.storage_id, t.car_id, t.car_number, t.transport_id, t.transport_name,
  32. t.dispose_userid, t.dispose_username, t.dispose_time, t.complete_time,
  33. t.complete_userid, t.complete_username, t.pressure,t.out_status,
  34. (select fl.room_num from lab_build_floor_layout fl where fl.sub_id=ta.location_id) room
  35. from qp_bottle_storage_out t
  36. LEFT JOIN qp_bottle_storage bs on t.storage_id=bs.id
  37. LEFT JOIN qp_task ta on bs.task_id=ta.id
  38. LEFT JOIN sys_dept d on ta.dept_id=d.dept_id
  39. LEFT JOIN sys_user u on ta.user_id=u.user_id
  40. </sql>
  41. <select id="selectQpBottleStorageOutList" parameterType="com.zd.airbottle.domain.vo.QpBottleStorageOutVO" resultMap="QpBottleStorageOutResult">
  42. <include refid="selectQpBottleStorageOutListVo"/>
  43. <where>
  44. <if test="searchValue != null and searchValue != ''">
  45. and ( t.apply_user_name like concat('%', #{searchValue}, '%')
  46. or t.phone like concat('%', #{searchValue}, '%')
  47. or ta.location like concat('%', #{searchValue}, '%')
  48. )
  49. </if>
  50. <if test="applyUserName != null and applyUserName != ''"> and t.apply_user_name like concat('%', #{applyUserName}, '%')</if>
  51. <if test="applyUserid != null "> and t.apply_userid = #{applyUserid}</if>
  52. <if test="phone != null and phone != ''"> and t.phone = #{phone}</if>
  53. <if test="storageId != null "> and t.storage_id = #{storageId}</if>
  54. <if test="carId != null "> and t.car_id = #{carId}</if>
  55. <if test="carNumber != null and carNumber != ''"> and t.car_number = #{carNumber}</if>
  56. <if test="transportId != null "> and t.transport_id = #{transportId}</if>
  57. <if test="transportName != null and transportName != ''"> and t.transport_name like concat('%', #{transportName}, '%')</if>
  58. <if test="disposeUserid != null "> and t.dispose_userid = #{disposeUserid}</if>
  59. <if test="disposeUsername != null and disposeUsername != ''"> and t.dispose_username like concat('%', #{disposeUsername}, '%')</if>
  60. <if test="disposeTime != null "> and t.dispose_time = #{disposeTime}</if>
  61. <if test="completeTime != null "> and t.complete_time = #{completeTime}</if>
  62. <if test="completeUserid != null "> and t.complete_userid = #{completeUserid}</if>
  63. <if test="completeUsername != null and completeUsername != ''"> and t.complete_username like concat('%', #{completeUsername}, '%')</if>
  64. <if test="pressure != null "> and t.pressure = #{pressure}</if>
  65. <if test="outStatus != null "> and t.out_status = #{outStatus}</if>
  66. <if test="startTime != null "> and date_format(t.create_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')</if>
  67. <if test="endTime != null "> and date_format(t.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')</if>
  68. <if test="ids != null ">
  69. and t.id in
  70. <foreach item="id" collection="ids" open="(" separator="," close=")">
  71. #{id}
  72. </foreach>
  73. </if>
  74. </where>
  75. <!-- 数据范围过滤 -->
  76. ${params.dataScope}
  77. order by t.create_time desc
  78. </select>
  79. <select id="selectQpBottleStorageOutById" resultMap="QpBottleStorageOutResult">
  80. <include refid="selectQpBottleStorageOutVo"/>
  81. where id = #{id}
  82. </select>
  83. <insert id="insertQpBottleStorageOut" parameterType="com.zd.airbottle.domain.QpBottleStorageOut" useGeneratedKeys="true" keyProperty="id">
  84. insert into qp_bottle_storage_out
  85. <trim prefix="(" suffix=")" suffixOverrides=",">
  86. <if test="applyUserName != null">apply_user_name,</if>
  87. <if test="applyUserid != null">apply_userid,</if>
  88. <if test="phone != null">phone,</if>
  89. <if test="createTime != null">create_time,</if>
  90. <if test="storageId != null">storage_id,</if>
  91. <if test="carId != null">car_id,</if>
  92. <if test="carNumber != null">car_number,</if>
  93. <if test="transportId != null">transport_id,</if>
  94. <if test="transportName != null">transport_name,</if>
  95. <if test="disposeUserid != null">dispose_userid,</if>
  96. <if test="disposeUsername != null">dispose_username,</if>
  97. <if test="disposeTime != null">dispose_time,</if>
  98. <if test="completeTime != null">complete_time,</if>
  99. <if test="completeUserid != null">complete_userid,</if>
  100. <if test="completeUsername != null">complete_username,</if>
  101. <if test="pressure != null">pressure,</if>
  102. <if test="outStatus != null">out_status,</if>
  103. </trim>
  104. <trim prefix="values (" suffix=")" suffixOverrides=",">
  105. <if test="applyUserName != null">#{applyUserName},</if>
  106. <if test="applyUserid != null">#{applyUserid},</if>
  107. <if test="phone != null">#{phone},</if>
  108. <if test="createTime != null">#{createTime},</if>
  109. <if test="storageId != null">#{storageId},</if>
  110. <if test="carId != null">#{carId},</if>
  111. <if test="carNumber != null">#{carNumber},</if>
  112. <if test="transportId != null">#{transportId},</if>
  113. <if test="transportName != null">#{transportName},</if>
  114. <if test="disposeUserid != null">#{disposeUserid},</if>
  115. <if test="disposeUsername != null">#{disposeUsername},</if>
  116. <if test="disposeTime != null">#{disposeTime},</if>
  117. <if test="completeTime != null">#{completeTime},</if>
  118. <if test="completeUserid != null">#{completeUserid},</if>
  119. <if test="completeUsername != null">#{completeUsername},</if>
  120. <if test="pressure != null">#{pressure},</if>
  121. <if test="outStatus != null">#{outStatus},</if>
  122. </trim>
  123. </insert>
  124. <update id="updateQpBottleStorageOut" parameterType="com.zd.airbottle.domain.QpBottleStorageOut">
  125. update qp_bottle_storage_out
  126. <trim prefix="SET" suffixOverrides=",">
  127. <if test="applyUserName != null">apply_user_name = #{applyUserName},</if>
  128. <if test="applyUserid != null">apply_userid = #{applyUserid},</if>
  129. <if test="phone != null">phone = #{phone},</if>
  130. <if test="createTime != null">create_time = #{createTime},</if>
  131. <if test="storageId != null">storage_id = #{storageId},</if>
  132. <if test="carId != null">car_id = #{carId},</if>
  133. <if test="carNumber != null">car_number = #{carNumber},</if>
  134. <if test="transportId != null">transport_id = #{transportId},</if>
  135. <if test="transportName != null">transport_name = #{transportName},</if>
  136. <if test="disposeUserid != null">dispose_userid = #{disposeUserid},</if>
  137. <if test="disposeUsername != null">dispose_username = #{disposeUsername},</if>
  138. <if test="disposeTime != null">dispose_time = #{disposeTime},</if>
  139. <if test="completeTime != null">complete_time = #{completeTime},</if>
  140. <if test="completeUserid != null">complete_userid = #{completeUserid},</if>
  141. <if test="completeUsername != null">complete_username = #{completeUsername},</if>
  142. <if test="pressure != null">pressure = #{pressure},</if>
  143. <if test="outStatus != null">out_status = #{outStatus},</if>
  144. </trim>
  145. where id = #{id}
  146. </update>
  147. <delete id="deleteQpBottleStorageOutById">
  148. delete from qp_bottle_storage_out where id = #{id}
  149. </delete>
  150. <delete id="deleteQpBottleStorageOutByIds">
  151. delete from qp_bottle_storage_out where id in
  152. <foreach item="id" collection="array" open="(" separator="," close=")">
  153. #{id}
  154. </foreach>
  155. </delete>
  156. <!-- 回收单 实验室关联查询-->
  157. <select id="selectQpBottleStorageOutRelationSubject" parameterType="com.zd.airbottle.domain.vo.QpBottleStorageOutVO" resultMap="QpBottleStorageOutResult">
  158. select t2.id,t2.storage_id,t2.task_id, t2.create_time,taskDetailId,
  159. (select f.name
  160. from lab_build_floor f
  161. where f.type = 1
  162. and f.id = (
  163. select f.parent_id
  164. from lab_build_floor f
  165. where f.id =
  166. (select bfl.build_id
  167. from lab_build_floor_layout bfl
  168. where bfl.sub_id = t2.location_id))) campus,
  169. (select f.`name`
  170. from lab_build_floor f
  171. where f.type = 2
  172. and f.id =
  173. (select bfl.build_id
  174. from lab_build_floor_layout bfl
  175. where bfl.sub_id = t2.location_id)) building,
  176. (select bfl.room_num
  177. from lab_build_floor_layout bfl
  178. where bfl.sub_id = t2.location_id) room
  179. from (
  180. select *, (select ta.location_id from qp_task ta where ta.id=t.task_id ) location_id from (
  181. select * from (
  182. select DISTINCT bs.task_id,bs.task_detail_id taskDetailId,bso.* from qp_bottle_storage_out bso,qp_bottle_storage bs,qp_task ta,qp_task_detail td
  183. where bso.storage_id= bs.id and bs.task_id=ta.id and td.id = bs.task_detail_id
  184. <if test="createTime != null "> and date_format(bso.create_time,'%Y-%m-%d') = date_format( #{createTime},'%Y-%m-%d')</if>
  185. <if test="companyId != null "> and td.supplier_id=#{companyId}</if>
  186. <if test="remark ==0 "> and bso.out_status =0</if> /**未处理**/
  187. <if test="remark ==1 "> and bso.out_status !=0</if> /**已处理**/
  188. ) sto
  189. ) t
  190. ) t2
  191. </select>
  192. </mapper>