CheckRecordEventMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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.CheckRecordEventMapper">
  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" /><!--CheckRecord 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. B.group_id,
  44. D.group_name,
  45. B.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_event 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 A.oc_id = #{ocId ,jdbcType=BIGINT}
  78. AND A.check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  79. </select>
  80. <!--列表查询-->
  81. <select id="getByList" parameterType="java.util.Map" resultMap="CheckRecordDtoMap">
  82. SELECT
  83. <include refid="CheckRecordDto_Cols"/>
  84. FROM check_record_event AS A
  85. LEFT JOIN task AS B ON (A.oc_id = B.oc_id AND A.task_id = B.task_id)
  86. LEFT JOIN ent_risk_point AS C ON (A.oc_id = C.oc_id AND A.risk_point_id = C.risk_point_id)
  87. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.group_id = D.group_id)
  88. LEFT JOIN s_position AS E ON (A.oc_id = E.oc_id AND A.position_id = E.position_id)
  89. LEFT JOIN account AS F ON (A.oc_id = F.oc_id AND A.account_id = F.account_id)
  90. LEFT JOIN task_cat AS G ON (B.task_cat_id = G.task_cat_id )
  91. LEFT JOIN measure_type AS H ON (A.measure_type_id = H.measure_type_id)
  92. WHERE 1 = 1
  93. <if test="ocId != null">
  94. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  95. </if>
  96. <if test="accountId != null">
  97. AND A.account_id = #{accountId, jdbcType=BIGINT}
  98. </if>
  99. <if test="taskId != null">
  100. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  101. </if>
  102. <if test="checklistId != null">
  103. AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
  104. </if>
  105. <if test="keywords != null and keywords != ''">
  106. AND A.measure_content like "%"#{keywords}"%"
  107. </if>
  108. <if test="riskPointId != null">
  109. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  110. </if>
  111. <if test="hazardId != null">
  112. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  113. </if>
  114. <if test="riskId != null">
  115. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  116. </if>
  117. <if test="checkResult != null">
  118. AND A.check_result = #{checkResult ,jdbcType=BIGINT}
  119. </if>
  120. <if test="nodeLeft != null and nodeRight != null">
  121. <![CDATA[
  122. AND D.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  123. AND D.node_right <= #{nodeRight ,jdbcType=BIGINT}
  124. ]]>
  125. </if>
  126. <if test="day != null and day != ''">
  127. AND date_format(A.check_time , '%Y-%m-%d') = #{day}
  128. </if>
  129. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  130. AND A.check_time BETWEEN #{startDate} AND #{endDate}
  131. </if>
  132. ORDER BY A.check_time DESC
  133. </select>
  134. <!--分页查询-->
  135. <select id="getByPage" parameterType="java.util.Map" resultMap="CheckRecordDtoMap">
  136. SELECT
  137. <include refid="CheckRecordDto_Cols"/>
  138. FROM check_record_event AS A
  139. LEFT JOIN task AS B ON (A.oc_id = B.oc_id AND A.task_id = B.task_id)
  140. LEFT JOIN ent_risk_point AS C ON (A.oc_id = C.oc_id AND A.risk_point_id = C.risk_point_id)
  141. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.group_id = D.group_id)
  142. LEFT JOIN s_position AS E ON (A.oc_id = E.oc_id AND A.position_id = E.position_id)
  143. LEFT JOIN account AS F ON (A.oc_id = F.oc_id AND A.account_id = F.account_id)
  144. LEFT JOIN task_cat AS G ON (B.task_cat_id = G.task_cat_id )
  145. LEFT JOIN measure_type AS H ON (A.measure_type_id = H.measure_type_id)
  146. WHERE 1 = 1
  147. <if test="ocId != null">
  148. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  149. </if>
  150. <if test="accountId != null">
  151. AND A.account_id = #{accountId, jdbcType=BIGINT}
  152. </if>
  153. <if test="nodeLeft != null and nodeRight != null">
  154. <![CDATA[
  155. AND D.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  156. AND D.node_right <= #{nodeRight ,jdbcType=BIGINT}
  157. ]]>
  158. </if>
  159. <if test="taskId != null">
  160. AND A.task_id = #{taskId ,jdbcType=BIGINT}
  161. </if>
  162. <if test="checklistId != null">
  163. AND A.checklist_id = #{checklistId, jdbcType=BIGINT}
  164. </if>
  165. <if test="keywords != null and keywords != ''">
  166. AND A.measure_content like "%"#{keywords}"%"
  167. </if>
  168. <if test="riskPointId != null">
  169. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  170. </if>
  171. <if test="hazardId != null">
  172. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  173. </if>
  174. <if test="riskId != null">
  175. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  176. </if>
  177. <if test="checkResult != null">
  178. AND A.check_result = #{checkResult ,jdbcType=BIGINT}
  179. </if>
  180. <if test="day != null and day != ''">
  181. AND date_format(A.check_time , '%Y-%m-%d') = #{day}
  182. </if>
  183. <if test="startDate != null and startDate !='' and endDate != null and endDate != ''">
  184. AND A.check_time BETWEEN #{startDate} AND #{endDate}
  185. </if>
  186. ORDER BY A.check_time DESC
  187. </select>
  188. <!--Create-->
  189. <insert id="create" parameterType="com.zhyc.xps.aqpt.entity.CheckRecord">
  190. INSERT INTO check_record_event
  191. <trim prefix="(" suffix=")" suffixOverrides=",">
  192. <if test="ocId != null">
  193. oc_id,
  194. </if>
  195. <if test="checkRecordId != null">
  196. check_record_id,
  197. </if>
  198. <if test="accountId != null">
  199. account_id,
  200. </if>
  201. <if test="taskId != null">
  202. task_id,
  203. </if>
  204. <if test="checklistId != null">
  205. checklist_id,
  206. </if>
  207. <if test="riskPointId != null">
  208. risk_point_id,
  209. </if>
  210. <if test="hazardId != null">
  211. hazard_id,
  212. </if>
  213. <if test="hazardTitle != null and hazardTitle!=''">
  214. hazard_title,
  215. </if>
  216. <if test="hazardCode != null and hazardCode != ''">
  217. hazard_code,
  218. </if>
  219. <if test="riskId != null">
  220. risk_id,
  221. </if>
  222. <if test="riskTitle != null and riskTitle!=''">
  223. risk_title,
  224. </if>
  225. <if test="riskCode != null and riskCode != ''">
  226. risk_code,
  227. </if>
  228. <if test="measureId != null">
  229. measure_id,
  230. </if>
  231. <if test="measureTypeId != null">
  232. measure_type_id,
  233. </if>
  234. <if test="measureContent != null and measureContent!=''">
  235. measure_content,
  236. </if>
  237. <if test="measureReference != null and measureReference != ''">
  238. measure_reference,
  239. </if>
  240. <if test="checkTime != null">
  241. check_time,
  242. </if>
  243. <if test="checkResult != null">
  244. check_result,
  245. </if>
  246. <if test="dangerId != null">
  247. danger_id,
  248. </if>
  249. <if test="checkDesc != null and checkDesc != ''">
  250. check_desc,
  251. </if>
  252. <if test="createdBy != null">
  253. created_by,
  254. </if>
  255. <if test="createdAt != null">
  256. created_at,
  257. </if>
  258. </trim>
  259. <trim prefix="values (" suffix=")" suffixOverrides=",">
  260. <if test="ocId != null">
  261. #{ocId ,jdbcType=BIGINT},
  262. </if>
  263. <if test="checkRecordId != null">
  264. #{checkRecordId ,jdbcType=BIGINT},
  265. </if>
  266. <if test="accountId != null">
  267. #{accountId ,jdbcType=BIGINT},
  268. </if>
  269. <if test="taskId != null">
  270. #{taskId ,jdbcType=BIGINT},
  271. </if>
  272. <if test="checklistId != null">
  273. #{checklistId ,jdbcType=BIGINT},
  274. </if>
  275. <if test="riskPointId != null">
  276. #{riskPointId ,jdbcType=BIGINT},
  277. </if>
  278. <if test="hazardId != null">
  279. #{hazardId ,jdbcType=BIGINT},
  280. </if>
  281. <if test="hazardTitle != null and hazardTitle!=''">
  282. #{hazardTitle ,jdbcType=VARCHAR},
  283. </if>
  284. <if test="hazardCode != null and hazardCode != ''">
  285. #{hazardCode ,jdbcType=VARCHAR},
  286. </if>
  287. <if test="riskId != null">
  288. #{riskId ,jdbcType=BIGINT},
  289. </if>
  290. <if test="riskTitle != null and riskTitle!=''">
  291. #{riskTitle ,jdbcType=VARCHAR},
  292. </if>
  293. <if test="riskCode != null and riskCode != ''">
  294. #{riskCode ,jdbcType=VARCHAR},
  295. </if>
  296. <if test="measureId != null">
  297. #{measureId ,jdbcType=BIGINT},
  298. </if>
  299. <if test="measureTypeId != null">
  300. #{measureTypeId ,jdbcType=BIGINT},
  301. </if>
  302. <if test="measureContent != null and measureContent!=''">
  303. #{measureContent ,jdbcType=VARCHAR},
  304. </if>
  305. <if test="measureReference != null and measureReference!=''">
  306. #{measureReference ,jdbcType=VARCHAR},
  307. </if>
  308. <if test="checkTime != null">
  309. #{checkTime ,jdbcType=DATE},
  310. </if>
  311. <if test="checkResult != null">
  312. #{checkResult ,jdbcType=BIGINT},
  313. </if>
  314. <if test="dangerId != null">
  315. #{dangerId ,jdbcType=BIGINT},
  316. </if>
  317. <if test="checkDesc != null and checkDesc != ''">
  318. #{checkDesc ,jdbcType=VARCHAR},
  319. </if>
  320. <if test="createdBy != null">
  321. #{createdBy ,jdbcType=BIGINT},
  322. </if>
  323. <if test="createdAt != null">
  324. #{createdAt ,jdbcType=TIMESTAMP},
  325. </if>
  326. </trim>
  327. </insert>
  328. <!--更新-->
  329. <update id="update" parameterType="com.zhyc.xps.common.entity.Checklist">
  330. UPDATE check_record_event
  331. <trim suffixOverrides=",">
  332. <set>
  333. <if test="checkResult != null">
  334. check_result = #{checkResult ,jdbcType=BIGINT},
  335. </if>
  336. <if test="dangerId != null">
  337. danger_id = #{dangerId ,jdbcType=BIGINT},
  338. </if>
  339. <if test="checkDesc != null and checkDesc != ''">
  340. check_desc = #{checkDesc ,jdbcType=VARCHAR},
  341. </if>
  342. <if test="updatedBy != null">
  343. updated_by = #{updatedBy ,jdbcType=BIGINT},
  344. </if>
  345. <if test="updatedAt != null">
  346. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  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="checkRecordId != null">
  355. AND check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  356. </if>
  357. </update>
  358. <!--删除 -->
  359. <delete id="delete" parameterType="java.util.Map">
  360. DELETE FROM check_record_event
  361. WHERE 1 = 1
  362. <if test="ocId != null">
  363. AND oc_id = #{ocId,jdbcType=BIGINT}
  364. </if>
  365. <if test="checkRecordId != null">
  366. AND check_record_id = #{checkRecordId ,jdbcType=BIGINT}
  367. </if>
  368. <if test="accountId != null ">
  369. AND account_id = #{accountId ,jdbcType=BIGINT}
  370. </if>
  371. <if test="taskId != null ">
  372. AND task_id = #{taskId ,jdbcType=BIGINT}
  373. </if>
  374. <if test="checklistId != null ">
  375. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  376. </if>
  377. <if test="riskPointId != null ">
  378. AND risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  379. </if>
  380. <if test="hazardId != null ">
  381. AND hazard_id = #{hazardId ,jdbcType=BIGINT}
  382. </if>
  383. <if test="riskId != null ">
  384. AND risk_id = #{riskId ,jdbcType=BIGINT}
  385. </if>
  386. <if test="measureId != null ">
  387. AND measure_id = #{measureId ,jdbcType=BIGINT}
  388. </if>
  389. <if test="checkResult != null ">
  390. AND check_result = #{checkResult ,jdbcType=BIGINT}
  391. </if>
  392. </delete>
  393. </mapper>