CheckTaskDoingMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.aqpt.mapper.CheckTaskDoingMapper">
  5. <resultMap id="CheckTaskDoingItemDtoMap" type="com.zhyc.xps.aqpt.dto.CheckTaskDoingItemDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  7. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
  8. <result column="task_id" property="taskId" jdbcType="BIGINT" />
  9. <result column="check_record_id" property="checkRecordId" jdbcType="BIGINT" />
  10. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  11. <result column="position_id" property="positionId" jdbcType="BIGINT" />
  12. <result column="account_id" property="accountId" jdbcType="BIGINT" />
  13. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  14. <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
  15. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR" />
  16. <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR" />
  17. <result column="risk_id" property="riskId" jdbcType="BIGINT" />
  18. <result column="risk_title" property="riskTitle" jdbcType="VARCHAR" />
  19. <result column="risk_code" property="riskCode" jdbcType="VARCHAR" />
  20. <result column="measure_id" property="measureId" jdbcType="BIGINT" />
  21. <result column="measure_content" property="measureContent" jdbcType="VARCHAR" />
  22. <result column="measure_type_id" property="measureTypeId" jdbcType="BIGINT" />
  23. <result column="measure_type_title" property="measureTypeTitle" jdbcType="VARCHAR" />
  24. <result column="measure_reference" property="measureReference" jdbcType="VARCHAR" />
  25. <result column="measure_desc" property="measureDesc" jdbcType="VARCHAR" />
  26. <result column="check_time" property="checkTime" jdbcType="TIMESTAMP"/>
  27. <result column="check_result" property="checkResult" jdbcType="BIGINT" />
  28. <result column="check_desc" property="checkDesc" jdbcType="VARCHAR" />
  29. <result column="danger_id" property="dangerId" jdbcType="BIGINT" />
  30. <result column="created_by" property="createdBy" jdbcType="BIGINT" />
  31. <result column="created_at" property="createdAt" jdbcType="TIMESTAMP"/>
  32. </resultMap>
  33. <sql id="CheckTaskDoingItemDto_Cols">
  34. A.oc_id,
  35. A.task_id,
  36. A.check_record_id,
  37. A.account_id,
  38. A.position_id,
  39. A.group_id,
  40. A.risk_point_id,
  41. A.checklist_id,
  42. A.hazard_id,
  43. B.hazard_title,
  44. B.hazard_code,
  45. A.risk_id,
  46. C.risk_source AS risk_title,
  47. C.risk_code,
  48. A.measure_id,
  49. D.measure_type_id,
  50. E.measure_type_title,
  51. D.measure_content,
  52. D.measure_reference,
  53. D.measure_desc,
  54. A.check_time,
  55. A.check_result,
  56. A.check_desc,
  57. A.danger_id,
  58. A.created_by,
  59. A.created_at
  60. </sql>
  61. <!--列表查询-->
  62. <select id="getItemByList" resultMap="CheckTaskDoingItemDtoMap" parameterType="java.util.Map">
  63. SELECT
  64. <include refid="CheckTaskDoingItemDto_Cols"/>
  65. FROM check_task_doing AS A
  66. LEFT JOIN checklist_hazard AS B ON (A.oc_id = B.oc_id AND A.hazard_id = B.hazard_id)
  67. LEFT JOIN checklist_hazard_risk AS C ON (A.oc_id = B.oc_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id)
  68. LEFT JOIN checklist_hazard_risk_measure AS D ON (A.oc_id = B.oc_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id AND A.measure_id = D.measure_id)
  69. LEFT JOIN measure_type AS E ON (D.measure_type_id = E.measure_type_id)
  70. WHERE 1 = 1
  71. <if test="ocId != null">
  72. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  73. </if>
  74. <if test="taskId != null">
  75. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  76. </if>
  77. <if test="checklistId != null">
  78. AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
  79. </if>
  80. <if test="keywords != null and keywords != ''">
  81. AND D.measure_content like "%"#{keywords}"%"
  82. </if>
  83. <if test="riskPointId != null">
  84. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  85. </if>
  86. <if test="hazardId != null">
  87. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  88. </if>
  89. <if test="riskId != null">
  90. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  91. </if>
  92. <if test="checkResult != null">
  93. AND A.check_result = #{checkResult ,jdbcType=BIGINT}
  94. </if>
  95. ORDER BY A.hazard_id ASC, A.risk_id ASC, A.measure_id ASC
  96. </select>
  97. <!--分页查询-->
  98. <select id="getItemByPage" resultMap="CheckTaskDoingItemDtoMap" parameterType="java.util.Map">
  99. SELECT
  100. <include refid="CheckTaskDoingItemDto_Cols"/>
  101. FROM check_task_doing AS A
  102. LEFT JOIN checklist_hazard AS B ON (A.oc_id = B.oc_id AND A.hazard_id = B.hazard_id)
  103. LEFT JOIN checklist_hazard_risk AS C ON (A.oc_id = B.oc_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id)
  104. LEFT JOIN checklist_hazard_risk_measure AS D ON (A.oc_id = B.oc_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id AND A.measure_id = D.measure_id)
  105. LEFT JOIN measure_type AS E ON (D.measure_type_id = E.measure_type_id)
  106. WHERE 1 = 1
  107. <if test="ocId != null">
  108. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  109. </if>
  110. <if test="taskId != null">
  111. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  112. </if>
  113. <if test="checklistId != null">
  114. AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
  115. </if>
  116. <if test="keywords != null and keywords != ''">
  117. AND D.measure_content like "%"#{keywords}"%"
  118. </if>
  119. <if test="riskPointId != null">
  120. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  121. </if>
  122. <if test="hazardId != null">
  123. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  124. </if>
  125. <if test="riskId != null">
  126. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  127. </if>
  128. <if test="checkResult != null">
  129. AND A.check_result = #{checkResult ,jdbcType=BIGINT}
  130. </if>
  131. ORDER BY A.hazard_id ASC, A.risk_id ASC, A.measure_id ASC
  132. </select>
  133. <!--基于ID查询-->
  134. <select id="getItemById" resultMap="CheckTaskDoingItemDtoMap">
  135. SELECT
  136. <include refid="CheckTaskDoingItemDto_Cols"/>
  137. FROM check_task_doing AS A
  138. LEFT JOIN checklist_hazard AS B ON (A.oc_id = B.oc_id AND A.hazard_id = B.hazard_id)
  139. LEFT JOIN checklist_hazard_risk AS C ON (A.oc_id = B.oc_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id)
  140. LEFT JOIN checklist_hazard_risk_measure AS D ON (A.oc_id = B.oc_id AND A.hazard_id = C.hazard_id AND A.risk_id = C.risk_id AND A.measure_id = D.measure_id)
  141. LEFT JOIN measure_type AS E ON (D.measure_type_id = E.measure_type_id)
  142. WHERE 1 = 1
  143. <if test="ocId != null">
  144. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  145. </if>
  146. <if test="taskId != null">
  147. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  148. </if>
  149. <if test="checkRecordId != null">
  150. AND A.check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  151. </if>
  152. </select>
  153. <!--Create-->
  154. <insert id="createItem" parameterType="com.zhyc.xps.aqpt.entity.CheckTaskDoingItem">
  155. INSERT INTO check_task_doing
  156. <trim prefix="(" suffix=")" suffixOverrides=",">
  157. <if test="ocId != null">
  158. oc_id,
  159. </if>
  160. <if test="groupId != null">
  161. group_id,
  162. </if>
  163. <if test="positionId != null">
  164. position_id,
  165. </if>
  166. <if test="accountId != null">
  167. account_id,
  168. </if>
  169. <if test="taskId != null">
  170. task_id,
  171. </if>
  172. <if test="checkRecordId != null">
  173. check_record_id,
  174. </if>
  175. <if test="checklistId != null">
  176. checklist_id,
  177. </if>
  178. <if test="riskPointId != null">
  179. risk_point_id,
  180. </if>
  181. <if test="hazardId != null">
  182. hazard_id,
  183. </if>
  184. <if test="riskId != null">
  185. risk_id,
  186. </if>
  187. <if test="measureId != null">
  188. measure_id,
  189. </if>
  190. <if test="checkTime != null">
  191. check_time,
  192. </if>
  193. <if test="checkResult != null">
  194. check_result,
  195. </if>
  196. <if test="checkDesc != null and checkDesc != ''">
  197. check_desc,
  198. </if>
  199. <if test="createdBy != null">
  200. created_by,
  201. </if>
  202. <if test="createdAt != null">
  203. created_at,
  204. </if>
  205. </trim>
  206. <trim prefix="values (" suffix=")" suffixOverrides=",">
  207. <if test="ocId != null">
  208. #{ocId ,jdbcType=BIGINT},
  209. </if>
  210. <if test="groupId != null">
  211. #{groupId ,jdbcType=BIGINT},
  212. </if>
  213. <if test="positionId != null">
  214. #{positionId ,jdbcType=BIGINT},
  215. </if>
  216. <if test="accountId != null">
  217. #{accountId ,jdbcType=BIGINT},
  218. </if>
  219. <if test="taskId != null">
  220. #{taskId ,jdbcType=BIGINT},
  221. </if>
  222. <if test="checkRecordId != null">
  223. #{checkRecordId ,jdbcType=BIGINT},
  224. </if>
  225. <if test="checklistId != null">
  226. #{checklistId ,jdbcType=BIGINT},
  227. </if>
  228. <if test="riskPointId != null">
  229. #{riskPointId ,jdbcType=BIGINT},
  230. </if>
  231. <if test="hazardId != null">
  232. #{hazardId ,jdbcType=BIGINT},
  233. </if>
  234. <if test="riskId != null">
  235. #{riskId ,jdbcType=BIGINT},
  236. </if>
  237. <if test="measureId != null">
  238. #{measureId ,jdbcType=BIGINT},
  239. </if>
  240. <if test="checkTime != null">
  241. #{checkTime ,jdbcType=DATE},
  242. </if>
  243. <if test="checkResult != null">
  244. #{checkResult ,jdbcType=BIGINT},
  245. </if>
  246. <if test="checkDesc != null and checkDesc != ''">
  247. #{checkDesc ,jdbcType=VARCHAR},
  248. </if>
  249. <if test="createdBy != null">
  250. #{createdBy ,jdbcType=BIGINT},
  251. </if>
  252. <if test="createdAt != null">
  253. #{createdAt ,jdbcType=TIMESTAMP},
  254. </if>
  255. </trim>
  256. </insert>
  257. <insert id="createItemBatch" parameterType="java.util.List">
  258. INSERT INTO check_task_doing(
  259. oc_id,
  260. group_id,
  261. position_id,
  262. account_id,
  263. task_id,
  264. check_record_id,
  265. checklist_id,
  266. risk_point_id,
  267. hazard_id,
  268. risk_id,
  269. measure_id,
  270. check_time,
  271. check_result,
  272. check_desc,
  273. created_by,
  274. created_at)
  275. values
  276. <foreach collection="list" item="item" separator=",">
  277. (#{item.ocId},
  278. #{item.groupId},
  279. #{item.positionId},
  280. #{item.accountId},
  281. #{item.taskId},
  282. #{item.checkRecordId},
  283. #{item.checklistId},
  284. #{item.riskPointId},
  285. #{item.hazardId},
  286. #{item.riskId},
  287. #{item.measureId},
  288. #{item.checkTime},
  289. #{item.checkResult},
  290. #{item.checkDesc},
  291. #{item.createdBy},
  292. #{item.createdAt})
  293. </foreach>
  294. </insert>
  295. <!--更新-->
  296. <update id="updateItem" parameterType="com.zhyc.xps.aqpt.entity.CheckTaskDoingItem">
  297. UPDATE check_task_doing
  298. <trim suffixOverrides=",">
  299. <set>
  300. <if test="accountId != null">
  301. account_id = #{accountId ,jdbcType=BIGINT},
  302. </if>
  303. <if test="checkTime == null">
  304. check_time = NOW(),
  305. </if>
  306. <if test="checkResult != null">
  307. check_result = #{checkResult ,jdbcType=BIGINT},
  308. </if>
  309. <if test="dangerId != null">
  310. danger_id = #{dangerId ,jdbcType=BIGINT},
  311. </if>
  312. <if test="checkDesc != null">
  313. check_desc = #{checkDesc ,jdbcType=VARCHAR},
  314. </if>
  315. </set>
  316. </trim>
  317. WHERE 1 = 1
  318. <if test="ocId != null">
  319. AND oc_id = #{ocId ,jdbcType=BIGINT}
  320. </if>
  321. <if test="taskId != null">
  322. AND task_id = #{taskId ,jdbcType=BIGINT}
  323. </if>
  324. <if test="checkRecordId != null">
  325. AND check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  326. </if>
  327. </update>
  328. <!--更新-->
  329. <update id="batchUpdateItem" parameterType="java.util.Map">
  330. UPDATE check_task_doing
  331. <trim suffixOverrides=",">
  332. <set>
  333. <if test="accountId != null">
  334. account_id = #{accountId ,jdbcType=BIGINT},
  335. </if>
  336. <if test="checkResult != null">
  337. check_result = #{checkResult ,jdbcType=BIGINT},
  338. </if>
  339. <if test="checkDesc != null">
  340. check_desc = #{checkDesc ,jdbcType=VARCHAR},
  341. </if>
  342. <if test="dangerId != null">
  343. danger_id = #{dangerId ,jdbcType=BIGINT},
  344. </if>
  345. <if test="checkTime == null">
  346. check_time = NOW()
  347. </if>
  348. </set>
  349. </trim>
  350. WHERE 1 = 1
  351. <if test="ocId != null">
  352. AND oc_id = #{ocId ,jdbcType=BIGINT}
  353. </if>
  354. <if test="taskId != null">
  355. AND task_id = #{taskId ,jdbcType=BIGINT}
  356. </if>
  357. </update>
  358. <!--删除 -->
  359. <delete id="deleteItem" parameterType="java.util.Map">
  360. DELETE from check_task_doing
  361. WHERE 1 = 1
  362. <if test="ocId != null">
  363. AND oc_id = #{ocId,jdbcType=BIGINT}
  364. </if>
  365. <if test="taskId != null ">
  366. AND task_id = #{taskId ,jdbcType=BIGINT}
  367. </if>
  368. <if test="checkRecordId != null">
  369. AND check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  370. </if>
  371. </delete>
  372. </mapper>