QpUsegasApplyMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.QpUsegasApplyMapper">
  6. <resultMap type="com.zd.airbottle.domain.vo.QpUsegasApplyVO" id="QpUsegasApplyResult">
  7. <result property="id" column="id"/>
  8. <result property="location" column="location"/>
  9. <result property="subjectId" column="subject_id"/>
  10. <result property="applyUser" column="apply_user"/>
  11. <result property="userId" column="user_id"/>
  12. <result property="deptId" column="dept_id"/>
  13. <result property="deptName" column="dept_name"/>
  14. <result property="phone" column="phone"/>
  15. <result property="startTime" column="start_time"/>
  16. <result property="endTime" column="end_time"/>
  17. <result property="gasUse" column="gas_use"/>
  18. <result property="applyCertificate" column="apply_certificate"/>
  19. <result property="safetyPrecautions" column="safety_precautions"/>
  20. <result property="useGasId" column="use_gas_id"/>
  21. <result property="useGasName" column="use_gas_name"/>
  22. <result property="leadAuditStaus" column="lead_audit_staus"/>
  23. <result property="leadAuditUserid" column="lead_audit_userid"/>
  24. <result property="leadAuditUsername" column="lead_audit_username"/>
  25. <result property="leadAuditTime" column="lead_audit_time"/>
  26. <result property="leadAuditCause" column="lead_audit_cause"/>
  27. <result property="centerAuditStatus" column="center_audit_status"/>
  28. <result property="centerAuditUserid" column="center_audit_userid"/>
  29. <result property="centerAuditUsername" column="center_audit_username"/>
  30. <result property="centerAuditTime" column="center_audit_time"/>
  31. <result property="centerAuditCause" column="center_audit_cause"/>
  32. <result property="createTime" column="create_time"/>
  33. </resultMap>
  34. <sql id="selectQpUsegasApplyVo">
  35. select id, location, subject_id, apply_user, user_id, dept_id, dept_name,
  36. phone, start_time, end_time, gas_use, apply_certificate, safety_precautions,
  37. use_gas_id,use_gas_name, lead_audit_staus, lead_audit_userid, lead_audit_username,
  38. lead_audit_time, lead_audit_cause, center_audit_status, center_audit_userid,
  39. center_audit_username, center_audit_time, center_audit_cause, create_time
  40. from qp_usegas_apply
  41. </sql>
  42. <sql id="selectQpUsegasApplyListVo">
  43. select t.id, t.location, t.subject_id, t.apply_user, t.user_id, t.dept_id,
  44. t.dept_name, t.phone, t.start_time, t.end_time, t.gas_use, t.apply_certificate,
  45. t.safety_precautions, t.use_gas_id,t.use_gas_name, t.lead_audit_staus,
  46. t.lead_audit_userid, t.lead_audit_username, t.lead_audit_time, t.lead_audit_cause,
  47. t.center_audit_status, t.center_audit_userid, t.center_audit_username, t.center_audit_time,
  48. t.center_audit_cause, t.create_time,
  49. (select fl.room_num from lab_build_floor_layout fl where fl.sub_id = t.subject_id) room,
  50. ( select admin_id from lab_subject su where su.id=t.subject_id ) admin_id
  51. from qp_usegas_apply as t
  52. LEFT JOIN sys_dept d on t.dept_id=d.dept_id
  53. LEFT JOIN sys_user u on t.user_id=u.user_id
  54. </sql>
  55. <select id="selectQpUsegasApplyList" parameterType="com.zd.airbottle.domain.vo.QpUsegasApplyVO" resultMap="QpUsegasApplyResult">
  56. <include refid="selectQpUsegasApplyListVo"/>
  57. where 1=1
  58. <if test="searchValue != null and searchValue != ''">
  59. and
  60. (t.apply_user like concat('%', #{searchValue}, '%') or
  61. t.phone like concat('%', #{searchValue}, '%') or
  62. t.location like concat('%', #{searchValue}, '%'))
  63. </if>
  64. <if test="location != null and location != ''"> and t.location = #{location}</if>
  65. <if test="subjectId != null "> and t.subject_id = #{subjectId}</if>
  66. <if test="applyUser != null and applyUser != ''"> and t.apply_user = #{applyUser}</if>
  67. <if test="userId != null "> and t.user_id = #{userId}</if>
  68. <if test="deptId != null "> and t.dept_id = #{deptId}</if>
  69. <if test="deptName != null and deptName != ''"> and t.dept_name like concat('%', #{deptName}, '%')</if>
  70. <if test="phone != null and phone != ''"> and t.phone = #{phone}</if>
  71. <if test="startTime != null and endTime != null">
  72. and (
  73. #{startTime} BETWEEN t.start_time and t.end_time
  74. or #{endTime} BETWEEN t.start_time and t.end_time
  75. or t.start_time BETWEEN #{startTime} and #{endTime}
  76. )
  77. </if>
  78. <!--<if test="startTime != null "> and t.start_time &gt;= #{startTime}</if>
  79. <if test="endTime != null "> and t.end_time &lt;= #{endTime}</if>-->
  80. <if test="gasUse != null and gasUse != ''"> and t.gas_use = #{gasUse}</if>
  81. <if test="applyCertificate != null and applyCertificate != ''"> and t.apply_certificate = #{applyCertificate}</if>
  82. <if test="safetyPrecautions != null and safetyPrecautions != ''"> and t.safety_precautions = #{safetyPrecautions}</if>
  83. <if test="useGasId != null "> and t.use_gas_id = #{useGasId}</if>
  84. <if test="useGasName != null and useGasName != ''"> and t.use_gas_name like concat('%', #{useGasName}, '%')</if>
  85. <if test="leadAuditStaus != null "> and t.lead_audit_staus = #{leadAuditStaus}</if>
  86. <if test="leadAuditUserid != null "> and t.lead_audit_userid = #{leadAuditUserid}</if>
  87. <if test="leadAuditUsername != null and leadAuditUsername != ''"> and lead_audit_username like concat('%', #{leadAuditUsername}, '%')</if>
  88. <if test="leadAuditTime != null "> and t.lead_audit_time = #{leadAuditTime}</if>
  89. <if test="leadAuditCause != null and leadAuditCause != ''"> and t.lead_audit_cause = #{leadAuditCause}</if>
  90. <if test="centerAuditStatus != null "> and t.center_audit_status = #{centerAuditStatus}</if>
  91. <if test="centerAuditUserid != null "> and t.center_audit_userid = #{centerAuditUserid}</if>
  92. <if test="centerAuditUsername != null and centerAuditUsername != ''"> and t.center_audit_username like concat('%', #{centerAuditUsername}, '%')</if>
  93. <if test="centerAuditTime != null "> and t.center_audit_time = #{centerAuditTime}</if>
  94. <if test="centerAuditCause != null and centerAuditCause != ''"> and t.center_audit_cause = #{centerAuditCause}</if>
  95. <if test="auditStatus !=null and auditStatus == 0 "> and (t.lead_audit_staus=0 or t.center_audit_status=0 ) and t.lead_audit_staus !=2</if> /**待审核**/
  96. <if test="auditStatus !=null and auditStatus == 1 "> and t.center_audit_status=1 </if> /**通过**/
  97. <if test="auditStatus !=null and auditStatus == 2 "> and (t.lead_audit_staus=2 or t.center_audit_status=2) </if> /**驳回**/
  98. <!-- 数据范围过滤 -->
  99. ${params.dataScope}
  100. order by
  101. <if test="remark != '100' "> t.create_time </if>
  102. <if test="remark == '100' "> t.lead_audit_time </if>
  103. desc
  104. </select>
  105. <select id="selectQpUsegasApplyById" resultMap="QpUsegasApplyResult">
  106. <include refid="selectQpUsegasApplyListVo"/>
  107. where t.id = #{id}
  108. </select>
  109. <insert id="insertQpUsegasApply" parameterType="com.zd.airbottle.domain.QpUsegasApply" useGeneratedKeys="true" keyProperty="id">
  110. insert into qp_usegas_apply
  111. <trim prefix="(" suffix=")" suffixOverrides=",">
  112. <if test="location != null">location,</if>
  113. <if test="subjectId != null">subject_id,</if>
  114. <if test="applyUser != null">apply_user,</if>
  115. <if test="userId != null">user_id,</if>
  116. <if test="deptId != null">dept_id,</if>
  117. <if test="deptName != null">dept_name,</if>
  118. <if test="phone != null">phone,</if>
  119. <if test="startTime != null">start_time,</if>
  120. <if test="endTime != null">end_time,</if>
  121. <if test="gasUse != null">gas_use,</if>
  122. <if test="applyCertificate != null">apply_certificate,</if>
  123. <if test="safetyPrecautions != null">safety_precautions,</if>
  124. <if test="useGasId != null">use_gas_id,</if>
  125. <if test="useGasName != null">use_gas_name,</if>
  126. <if test="leadAuditStaus != null">lead_audit_staus,</if>
  127. <if test="leadAuditUserid != null">lead_audit_userid,</if>
  128. <if test="leadAuditUsername != null">lead_audit_username,</if>
  129. <if test="leadAuditTime != null">lead_audit_time,</if>
  130. <if test="leadAuditCause != null">lead_audit_cause,</if>
  131. <if test="centerAuditStatus != null">center_audit_status,</if>
  132. <if test="centerAuditUserid != null">center_audit_userid,</if>
  133. <if test="centerAuditUsername != null">center_audit_username,</if>
  134. <if test="centerAuditTime != null">center_audit_time,</if>
  135. <if test="centerAuditCause != null">center_audit_cause,</if>
  136. <if test="createTime != null">create_time,</if>
  137. </trim>
  138. <trim prefix="values (" suffix=")" suffixOverrides=",">
  139. <if test="location != null">#{location},</if>
  140. <if test="subjectId != null">#{subjectId},</if>
  141. <if test="applyUser != null">#{applyUser},</if>
  142. <if test="userId != null">#{userId},</if>
  143. <if test="deptId != null">#{deptId},</if>
  144. <if test="deptName != null">#{deptName},</if>
  145. <if test="phone != null">#{phone},</if>
  146. <if test="startTime != null">#{startTime},</if>
  147. <if test="endTime != null">#{endTime},</if>
  148. <if test="gasUse != null">#{gasUse},</if>
  149. <if test="applyCertificate != null">#{applyCertificate},</if>
  150. <if test="safetyPrecautions != null">#{safetyPrecautions},</if>
  151. <if test="useGasId != null">#{useGasId},</if>
  152. <if test="useGasName != null">#{useGasName},</if>
  153. <if test="leadAuditStaus != null">#{leadAuditStaus},</if>
  154. <if test="leadAuditUserid != null">#{leadAuditUserid},</if>
  155. <if test="leadAuditUsername != null">#{leadAuditUsername},</if>
  156. <if test="leadAuditTime != null">#{leadAuditTime},</if>
  157. <if test="leadAuditCause != null">#{leadAuditCause},</if>
  158. <if test="centerAuditStatus != null">#{centerAuditStatus},</if>
  159. <if test="centerAuditUserid != null">#{centerAuditUserid},</if>
  160. <if test="centerAuditUsername != null">#{centerAuditUsername},</if>
  161. <if test="centerAuditTime != null">#{centerAuditTime},</if>
  162. <if test="centerAuditCause != null">#{centerAuditCause},</if>
  163. <if test="createTime != null">#{createTime},</if>
  164. </trim>
  165. </insert>
  166. <update id="updateQpUsegasApply" parameterType="com.zd.airbottle.domain.QpUsegasApply">
  167. update qp_usegas_apply
  168. <trim prefix="SET" suffixOverrides=",">
  169. <if test="location != null">location = #{location},</if>
  170. <if test="subjectId != null">subject_id = #{subjectId},</if>
  171. <if test="applyUser != null">apply_user = #{applyUser},</if>
  172. <if test="userId != null">user_id = #{userId},</if>
  173. <if test="deptId != null">dept_id = #{deptId},</if>
  174. <if test="deptName != null">dept_name = #{deptName},</if>
  175. <if test="phone != null">phone = #{phone},</if>
  176. <if test="startTime != null">start_time = #{startTime},</if>
  177. <if test="endTime != null">end_time = #{endTime},</if>
  178. <if test="gasUse != null">gas_use = #{gasUse},</if>
  179. <if test="applyCertificate != null">apply_certificate = #{applyCertificate},</if>
  180. <if test="safetyPrecautions != null">safety_precautions = #{safetyPrecautions},</if>
  181. <if test="useGasId != null">use_gas_id = #{useGasId},</if>
  182. <if test="useGasName != null">use_gas_name = #{useGasName},</if>
  183. <if test="leadAuditStaus != null">lead_audit_staus = #{leadAuditStaus},</if>
  184. <if test="leadAuditUserid != null">lead_audit_userid = #{leadAuditUserid},</if>
  185. <if test="leadAuditUsername != null">lead_audit_username = #{leadAuditUsername},</if>
  186. <if test="leadAuditTime != null">lead_audit_time = #{leadAuditTime},</if>
  187. <if test="leadAuditCause != null">lead_audit_cause = #{leadAuditCause},</if>
  188. <if test="centerAuditStatus != null">center_audit_status = #{centerAuditStatus},</if>
  189. <if test="centerAuditUserid != null">center_audit_userid = #{centerAuditUserid},</if>
  190. <if test="centerAuditUsername != null">center_audit_username = #{centerAuditUsername},</if>
  191. <if test="centerAuditTime != null">center_audit_time = #{centerAuditTime},</if>
  192. <if test="centerAuditCause != null">center_audit_cause = #{centerAuditCause},</if>
  193. <if test="createTime != null">create_time = #{createTime},</if>
  194. </trim>
  195. where id = #{id}
  196. </update>
  197. <delete id="deleteQpUsegasApplyById" >
  198. delete from qp_usegas_apply where id = #{id}
  199. </delete>
  200. <delete id="deleteQpUsegasApplyByIds">
  201. delete from qp_usegas_apply where id in
  202. <foreach item="id" collection="array" open="(" separator="," close=")">
  203. #{id}
  204. </foreach>
  205. </delete>
  206. <!-- 用气重新申请-->
  207. <update id="updateQpUsegasApplyRepeat" parameterType="com.zd.airbottle.domain.QpUsegasApply">
  208. update qp_usegas_apply
  209. <trim prefix="SET" suffixOverrides=",">
  210. <if test="location != null">location = #{location},</if>
  211. <if test="subjectId != null">subject_id = #{subjectId},</if>
  212. <if test="applyUser != null">apply_user = #{applyUser},</if>
  213. <if test="userId != null">user_id = #{userId},</if>
  214. <if test="deptId != null">dept_id = #{deptId},</if>
  215. <if test="deptName != null">dept_name = #{deptName},</if>
  216. <if test="phone != null">phone = #{phone},</if>
  217. <if test="startTime != null">start_time = #{startTime},</if>
  218. <if test="endTime != null">end_time = #{endTime},</if>
  219. <if test="gasUse != null">gas_use = #{gasUse},</if>
  220. <if test="applyCertificate != null">apply_certificate = #{applyCertificate},</if>
  221. <if test="safetyPrecautions != null">safety_precautions = #{safetyPrecautions},</if>
  222. <if test="useGasId != null">use_gas_id = #{useGasId},</if>
  223. <if test="useGasName != null">use_gas_name = #{useGasName},</if>
  224. <if test="centerAuditTime != null">center_audit_time = #{centerAuditTime},</if>
  225. <if test="centerAuditCause != null">center_audit_cause = #{centerAuditCause},</if>
  226. <if test="createTime != null">create_time = #{createTime},</if>
  227. lead_audit_staus=0,lead_audit_userid=null,lead_audit_username=null,lead_audit_time=null,
  228. lead_audit_cause=null,center_audit_status=0,center_audit_userid=null,center_audit_username=null,
  229. center_audit_time=null,center_audit_cause=null
  230. </trim>
  231. where id = #{id}
  232. </update>
  233. <!-- 用气申请导出查询-->
  234. <select id="qpUsegasApplyExportExcel" parameterType="com.zd.airbottle.domain.QpUsegasApply"
  235. resultType="com.zd.airbottle.domain.vo.QpUsegasApplyExcelVo">
  236. select ua.apply_user,ua.phone,ua.use_gas_name,
  237. concat_ws(' - ',
  238. date_format(ua.start_time,'%Y-%m-%d'),
  239. date_format(ua.end_time,'%Y-%m-%d') ) usageTime,
  240. ua.location
  241. from qp_usegas_apply ua
  242. where ua.center_audit_status=1
  243. <if test="searchValue != null and searchValue!=''">
  244. and ( ua.apply_user like concat('%', #{searchValue}, '%') or
  245. ua.phone like concat('%', #{searchValue}, '%') or
  246. ua.location like concat('%', #{searchValue}, '%') )
  247. </if>
  248. <if test="startTime != null and startTime != ''"><!-- 开始时间检索 -->
  249. and date_format(ua.start_time,'%Y-%m-%d') &gt;= date_format(#{startTime},'%Y-%m-%d')
  250. </if>
  251. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  252. and date_format(ua.end_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
  253. </if>
  254. <if test="ids !=null ">
  255. and ua.id in
  256. <foreach item="id" collection="ids" open="(" separator="," close=")">
  257. #{id}
  258. </foreach>
  259. </if>
  260. </select>
  261. </mapper>