CheckRecordMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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.CheckRecordMapper">
  5. <resultMap id="CheckRecordDtoMap" type="com.zhyc.xps.aqpt.dto.CheckRecordDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--OC ID-->
  7. <result column="check_record_id" property="checkRecordId" jdbcType="BIGINT" /><!--Check Record ID-->
  8. <result column="account_id" property="accountId" jdbcType="BIGINT" /><!--ACCOUNT-->
  9. <result column="task_id" property="taskId" jdbcType="BIGINT" /><!--TASK ID-->
  10. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
  11. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  12. <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
  13. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR"/>
  14. <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR"/>
  15. <result column="risk_id" property="riskId" jdbcType="BIGINT" />
  16. <result column="risk_title" property="riskTitle" jdbcType="VARCHAR"/>
  17. <result column="risk_code" property="riskCode" jdbcType="VARCHAR"/>
  18. <result column="measure_id" property="measureId" jdbcType="BIGINT" />
  19. <result column="measure_type_id" property="measureTypeId" jdbcType="BIGINT" />
  20. <result column="measure_content" property="measureContent" jdbcType="VARCHAR"/>
  21. <result column="measure_reference" property="measureReference" jdbcType="VARCHAR"/>
  22. <result column="check_time" property="checkTime" jdbcType="DATE" />
  23. <result column="check_result" property="checkResult" jdbcType="BIGINT" />
  24. <result column="check_desc" property="checkDesc" jdbcType="VARCHAR"/>
  25. <result column="task_title" property="taskTitle" jdbcType="VARCHAR"/>
  26. <result column="task_priority" property="taskPriority" jdbcType="BIGINT" />
  27. <result column="position_id" property="positionId" jdbcType="BIGINT" />
  28. <result column="position_name" property="positionName" jdbcType="VARCHAR"/>
  29. <result column="group_id" property="groupId" jdbcType="BIGINT" />
  30. <result column="group_name" property="groupName" jdbcType="VARCHAR"/>
  31. <result column="account_name" property="accountName" jdbcType="VARCHAR"/>
  32. <result column="danger_id" property="dangerId" jdbcType="BIGINT" />
  33. </resultMap>
  34. <sql id="CheckRecordDto_Cols">
  35. A.oc_id,
  36. A.check_record_id,
  37. A.account_id,
  38. F.account_name,
  39. A.task_id,
  40. B.task_title,
  41. A.risk_point_id,
  42. C.risk_point_title,
  43. A.group_id,
  44. D.group_name,
  45. A.position_id,
  46. E.position_name,
  47. A.checklist_id,
  48. A.hazard_id,
  49. A.hazard_title,
  50. A.hazard_code,
  51. A.risk_id,
  52. A.risk_title,
  53. A.risk_code,
  54. A.measure_id,
  55. G.task_cat_title,
  56. A.measure_type_id,
  57. H.measure_type_title,
  58. A.measure_content,
  59. A.measure_reference,
  60. A.check_time,
  61. A.check_result,
  62. A.check_desc,
  63. A.danger_id
  64. </sql>
  65. <!--基于ID查询-->
  66. <select id="getById" resultMap="CheckRecordDtoMap">
  67. SELECT
  68. <include refid="CheckRecordDto_Cols"/>
  69. FROM check_record AS A
  70. LEFT JOIN task AS B ON (A.oc_id = B.oc_id AND A.task_id = B.task_id)
  71. LEFT JOIN ent_risk_point AS C ON (A.oc_id = C.oc_id AND A.risk_point_id = C.risk_point_id)
  72. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.group_id = D.group_id)
  73. LEFT JOIN s_position AS E ON (A.oc_id = E.oc_id AND A.position_id = E.position_id)
  74. LEFT JOIN account AS F ON (A.oc_id = F.oc_id AND A.account_id = F.account_id)
  75. LEFT JOIN task_cat AS G ON (B.task_cat_id = G.task_cat_id )
  76. LEFT JOIN measure_type AS H ON (A.measure_type_id = H.measure_type_id)
  77. WHERE 1 = 1
  78. <if test="ocId != null">
  79. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  80. </if>
  81. <if test="taskId != null">
  82. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  83. </if>
  84. <if test="checkRecordId != null">
  85. AND A.check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  86. </if>
  87. </select>
  88. <!--列表查询-->
  89. <select id="getByList" resultMap="CheckRecordDtoMap" parameterType="java.util.Map">
  90. SELECT
  91. <include refid="CheckRecordDto_Cols"/>
  92. FROM check_record AS A
  93. LEFT JOIN task AS B ON (A.oc_id = B.oc_id AND A.task_id = B.task_id)
  94. LEFT JOIN ent_risk_point AS C ON (A.oc_id = C.oc_id AND A.risk_point_id = C.risk_point_id)
  95. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.group_id = D.group_id)
  96. LEFT JOIN s_position AS E ON (A.oc_id = E.oc_id AND A.position_id = E.position_id)
  97. LEFT JOIN account AS F ON (A.oc_id = F.oc_id AND A.account_id = F.account_id)
  98. LEFT JOIN task_cat AS G ON (B.task_cat_id = G.task_cat_id )
  99. LEFT JOIN measure_type AS H ON (A.measure_type_id = H.measure_type_id)
  100. WHERE 1 = 1
  101. <if test="ocId != null">
  102. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  103. </if>
  104. <if test="accountId != null">
  105. AND A.account_id = #{accountId, jdbcType=BIGINT}
  106. </if>
  107. <if test="taskId != null">
  108. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  109. </if>
  110. <if test="checklistId != null">
  111. AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
  112. </if>
  113. <if test="keywords != null and keywords != ''">
  114. AND A.measure_content like "%"#{keywords}"%"
  115. </if>
  116. <if test="riskPointId != null">
  117. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  118. </if>
  119. <if test="hazardId != null">
  120. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  121. </if>
  122. <if test="riskId != null">
  123. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  124. </if>
  125. <if test="checkResult != null">
  126. AND A.check_result = #{checkResult ,jdbcType=BIGINT}
  127. </if>
  128. <if test="nodeLeft != null and nodeRight != null">
  129. <![CDATA[
  130. AND D.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  131. AND D.node_right <= #{nodeRight ,jdbcType=BIGINT}
  132. ]]>
  133. </if>
  134. <if test="day != null and day != ''">
  135. AND date_format(A.check_time , '%Y-%m-%d') = #{day}
  136. </if>
  137. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  138. AND A.check_time BETWEEN #{startDate} AND #{endDate}
  139. </if>
  140. ORDER BY A.check_time DESC
  141. </select>
  142. <!--分页查询-->
  143. <select id="getByPage" resultMap="CheckRecordDtoMap" parameterType="java.util.Map">
  144. SELECT
  145. <include refid="CheckRecordDto_Cols"/>
  146. FROM check_record AS A
  147. LEFT JOIN task AS B ON (A.oc_id = B.oc_id AND A.task_id = B.task_id)
  148. LEFT JOIN ent_risk_point AS C ON (A.oc_id = C.oc_id AND A.risk_point_id = C.risk_point_id)
  149. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.group_id = D.group_id)
  150. LEFT JOIN s_position AS E ON (A.oc_id = E.oc_id AND A.position_id = E.position_id)
  151. LEFT JOIN account AS F ON (A.oc_id = F.oc_id AND A.account_id = F.account_id)
  152. LEFT JOIN task_cat AS G ON (B.task_cat_id = G.task_cat_id )
  153. LEFT JOIN measure_type AS H ON (A.measure_type_id = H.measure_type_id)
  154. WHERE 1 = 1
  155. <if test="ocId != null">
  156. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  157. </if>
  158. <if test="accountId != null">
  159. AND A.account_id = #{accountId, jdbcType=BIGINT}
  160. </if>
  161. <if test="nodeLeft != null and nodeRight != null">
  162. <![CDATA[
  163. AND D.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  164. AND D.node_right <= #{nodeRight ,jdbcType=BIGINT}
  165. ]]>
  166. </if>
  167. <if test="taskId != null">
  168. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  169. </if>
  170. <if test="checklistId != null">
  171. AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
  172. </if>
  173. <if test="keywords != null and keywords != ''">
  174. AND A.measure_content like "%"#{keywords}"%"
  175. </if>
  176. <if test="riskPointId != null">
  177. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  178. </if>
  179. <if test="hazardId != null">
  180. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  181. </if>
  182. <if test="riskId != null">
  183. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  184. </if>
  185. <if test="checkResult != null">
  186. AND A.check_result = #{checkResult ,jdbcType=BIGINT}
  187. </if>
  188. <if test="day != null and day != ''">
  189. AND date_format(A.check_time , '%Y-%m-%d') = #{day}
  190. </if>
  191. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  192. AND A.check_time BETWEEN #{startDate} AND #{endDate}
  193. </if>
  194. ORDER BY A.check_time DESC
  195. </select>
  196. <!--Create-->
  197. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.CheckRecord">
  198. INSERT INTO check_record
  199. <trim prefix="(" suffix=")" suffixOverrides=",">
  200. <if test="ocId != null">
  201. oc_id,
  202. </if>
  203. <if test="checkRecordId != null">
  204. check_record_id,
  205. </if>
  206. <if test="groupId != null">
  207. group_id,
  208. </if>
  209. <if test="positionId != null">
  210. position_id,
  211. </if>
  212. <if test="accountId != null">
  213. account_id,
  214. </if>
  215. <if test="taskId != null">
  216. task_id,
  217. </if>
  218. <if test="checklistId != null">
  219. checklist_id,
  220. </if>
  221. <if test="riskPointId != null">
  222. risk_point_id,
  223. </if>
  224. <if test="hazardId != null">
  225. hazard_id,
  226. </if>
  227. <if test="hazardTitle != null and hazardTitle!=''">
  228. hazard_title,
  229. </if>
  230. <if test="hazardCode != null and hazardCode != ''">
  231. hazard_code,
  232. </if>
  233. <if test="riskId != null">
  234. risk_id,
  235. </if>
  236. <if test="riskTitle != null and riskTitle!=''">
  237. risk_title,
  238. </if>
  239. <if test="riskCode != null and riskCode != ''">
  240. risk_code,
  241. </if>
  242. <if test="measureId != null">
  243. measure_id,
  244. </if>
  245. <if test="measureTypeId != null">
  246. measure_type_id,
  247. </if>
  248. <if test="measureContent != null and measureContent!=''">
  249. measure_content,
  250. </if>
  251. <if test="measureReference != null and measureReference != ''">
  252. measure_reference,
  253. </if>
  254. <if test="checkTime != null">
  255. check_time,
  256. </if>
  257. <if test="checkResult != null">
  258. check_result,
  259. </if>
  260. <if test="checkDesc != null and checkDesc != ''">
  261. check_desc,
  262. </if>
  263. <if test="dangerId != null">
  264. danger_id,
  265. </if>
  266. <if test="createdBy != null">
  267. created_by,
  268. </if>
  269. <if test="createdAt != null">
  270. created_at,
  271. </if>
  272. </trim>
  273. <trim prefix="values (" suffix=")" suffixOverrides=",">
  274. <if test="ocId != null">
  275. #{ocId ,jdbcType=BIGINT},
  276. </if>
  277. <if test="checkRecordId != null">
  278. #{checkRecordId ,jdbcType=BIGINT},
  279. </if>
  280. <if test="groupId != null">
  281. #{groupId ,jdbcType=BIGINT},
  282. </if>
  283. <if test="positionId != null">
  284. #{positionId ,jdbcType=BIGINT},
  285. </if>
  286. <if test="accountId != null">
  287. #{accountId ,jdbcType=BIGINT},
  288. </if>
  289. <if test="taskId != null">
  290. #{taskId ,jdbcType=BIGINT},
  291. </if>
  292. <if test="checklistId != null">
  293. #{checklistId ,jdbcType=BIGINT},
  294. </if>
  295. <if test="riskPointId != null">
  296. #{riskPointId ,jdbcType=BIGINT},
  297. </if>
  298. <if test="hazardId != null">
  299. #{hazardId ,jdbcType=BIGINT},
  300. </if>
  301. <if test="hazardTitle != null and hazardTitle!=''">
  302. #{hazardTitle ,jdbcType=VARCHAR},
  303. </if>
  304. <if test="hazardCode != null and hazardCode != ''">
  305. #{hazardCode ,jdbcType=VARCHAR},
  306. </if>
  307. <if test="riskId != null">
  308. #{riskId ,jdbcType=BIGINT},
  309. </if>
  310. <if test="riskTitle != null and riskTitle!=''">
  311. #{riskTitle ,jdbcType=VARCHAR},
  312. </if>
  313. <if test="riskCode != null and riskCode != ''">
  314. #{riskCode ,jdbcType=VARCHAR},
  315. </if>
  316. <if test="measureId != null">
  317. #{measureId ,jdbcType=BIGINT},
  318. </if>
  319. <if test="measureTypeId != null">
  320. #{measureTypeId ,jdbcType=BIGINT},
  321. </if>
  322. <if test="measureContent != null and measureContent!=''">
  323. #{measureContent ,jdbcType=VARCHAR},
  324. </if>
  325. <if test="measureReference != null and measureReference!=''">
  326. #{measureReference ,jdbcType=VARCHAR},
  327. </if>
  328. <if test="checkTime != null">
  329. #{checkTime ,jdbcType=DATE},
  330. </if>
  331. <if test="checkResult != null">
  332. #{checkResult ,jdbcType=BIGINT},
  333. </if>
  334. <if test="checkDesc != null and checkDesc != ''">
  335. #{checkDesc ,jdbcType=VARCHAR},
  336. </if>
  337. <if test="dangerId != null">
  338. #{dangerId ,jdbcType=BIGINT},
  339. </if>
  340. <if test="createdBy != null">
  341. #{createdBy ,jdbcType=BIGINT},
  342. </if>
  343. <if test="createdAt != null">
  344. #{createdAt ,jdbcType=TIMESTAMP},
  345. </if>
  346. </trim>
  347. </insert>
  348. <!--更新-->
  349. <update id="update" parameterType="com.zhyc.xps.common.entity.Checklist">
  350. UPDATE check_record_event
  351. <trim suffixOverrides=",">
  352. <set>
  353. <if test="checkResult != null">
  354. check_result = #{checkResult ,jdbcType=BIGINT},
  355. </if>
  356. <if test="dangerId != null">
  357. danger_id = #{dangerId ,jdbcType=BIGINT},
  358. </if>
  359. <if test="checkDesc != null and checkDesc != ''">
  360. check_desc = #{checkDesc ,jdbcType=VARCHAR},
  361. </if>
  362. <if test="updatedBy != null">
  363. updated_by = #{updatedBy ,jdbcType=BIGINT},
  364. </if>
  365. <if test="updatedAt != null">
  366. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  367. </if>
  368. </set>
  369. </trim>
  370. WHERE 1 = 1
  371. <if test="ocId != null">
  372. AND oc_id = #{ocId,jdbcType=BIGINT}
  373. </if>
  374. <if test="checkRecordId != null">
  375. AND check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  376. </if>
  377. </update>
  378. <!--删除 -->
  379. <delete id="delete" parameterType="java.util.Map">
  380. DELETE FROM check_record
  381. WHERE 1 = 1
  382. <if test="ocId != null">
  383. AND oc_id = #{ocId,jdbcType=BIGINT}
  384. </if>
  385. <if test="checkRecordId != null">
  386. AND check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  387. </if>
  388. <if test="accountId != null ">
  389. AND account_id = #{accountId ,jdbcType=BIGINT}
  390. </if>
  391. <if test="taskId != null ">
  392. AND task_id = #{taskId ,jdbcType=BIGINT}
  393. </if>
  394. <if test="checklistId != null ">
  395. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  396. </if>
  397. <if test="riskPointId != null ">
  398. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  399. </if>
  400. <if test="hazardId != null ">
  401. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  402. </if>
  403. <if test="riskId != null ">
  404. AND risk_id = #{riskId ,jdbcType=BIGINT}
  405. </if>
  406. <if test="measureId != null ">
  407. AND measure_id = #{measureId ,jdbcType=BIGINT}
  408. </if>
  409. <if test="checkResult != null ">
  410. AND check_result = #{checkResult ,jdbcType=BIGINT}
  411. </if>
  412. </delete>
  413. </mapper>