ReportMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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.ReportMapper">
  5. <resultMap id="RiskPointHazardDtoMap" type="com.zhyc.xps.aqpt.dto.EntRiskPointHazardDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  7. <result column="risk_point_id" property="riskPointId" jdbcType="BIGINT" />
  8. <result column="risk_point_title" property="riskPointTitle" jdbcType="VARCHAR" />
  9. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  10. <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
  11. <result column="status" property="status" jdbcType="BIGINT" />
  12. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR" />
  13. <result column="group_name" property="groupName" jdbcType="VARCHAR" />
  14. <result column="hazard_code" property="hazardCode" jdbcType="VARCHAR" />
  15. <result column="hazard_image" property="hazardImage" jdbcType="VARCHAR" />
  16. <result column="hazard_desc" property="hazardDesc" jdbcType="VARCHAR" />
  17. <result column="hazard_type_id" property="hazardTypeId" jdbcType="BIGINT" />
  18. <result column="hazard_type_title" property="hazardTypeTitle" jdbcType="VARCHAR" />
  19. <result column="hazard_level" property="hazardLevel" jdbcType="BIGINT" />
  20. </resultMap>
  21. <!--列表查询-->
  22. <select id="getHazardByList" parameterType="java.util.Map" resultMap="RiskPointHazardDtoMap">
  23. SELECT
  24. A.oc_id,
  25. A.risk_point_id,
  26. D.risk_point_title,
  27. A.checklist_id,
  28. A.hazard_id,
  29. A.status,
  30. B.hazard_title,
  31. B.hazard_code,
  32. B.hazard_image,
  33. B.hazard_desc,
  34. B.hazard_type_id,
  35. C.hazard_type_title,
  36. E.group_name,
  37. B.hazard_level
  38. FROM ent_risk_point_hazard AS A
  39. LEFT JOIN checklist_hazard AS B ON (A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id)
  40. LEFT JOIN ent_risk_point AS D ON (D.risk_point_id = A.risk_point_id AND D.oc_id = A.oc_id)
  41. LEFT JOIN s_group AS E ON (E.group_id = D.group_id AND D.oc_id = E.oc_id)
  42. LEFT JOIN hazard_type AS C ON (B.hazard_type_id = C.hazard_type_id)
  43. WHERE A.deleted_flag = 0 and D.deleted_flag = 0
  44. <if test="ocId != null">
  45. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  46. </if>
  47. <if test="riskPointId != null">
  48. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  49. </if>
  50. <if test="checklistId != null">
  51. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  52. </if>
  53. <if test="hazardId != null">
  54. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  55. </if>
  56. <if test="keywords != null and keywords != ''">
  57. AND B.hazard_title LIKE "%"#{keywords}"%"
  58. </if>
  59. <if test="status != null">
  60. AND A.status = #{status,jdbcType=BIGINT}
  61. </if>
  62. ORDER BY A.risk_point_id ASC
  63. </select>
  64. <resultMap id="RiskDtoResultMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardRiskDto">
  65. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  66. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  67. <result column="hazard_id" property="hazardId" jdbcType="BIGINT" />
  68. <result column="risk_id" property="riskId" jdbcType="BIGINT" />
  69. <result column="risk_code" property="riskCode" jdbcType="VARCHAR" />
  70. <result column="risk_source" property="riskSource" jdbcType="VARCHAR" />
  71. <result column="risk_reason" property="riskReason" jdbcType="VARCHAR" />
  72. <result column="risk_consequence" property="riskConsequence" jdbcType="VARCHAR" />
  73. <result column="risk_level" property="riskLevel" jdbcType="BIGINT" />
  74. <result column="risk_type_id" property="riskTypeId" jdbcType="BIGINT" />
  75. <result column="ctrl_level_id" property="ctrlLevelId" jdbcType="BIGINT" />
  76. <result column="hazard_title" property="hazardTitle" jdbcType="VARCHAR" />
  77. <result column="position_id_list" property="positionIdList" jdbcType="VARCHAR" />
  78. <result column="position_name_list" property="positionNameList" jdbcType="VARCHAR" />
  79. <result column="ctrl_level_title" property="ctrlLevelTitle" jdbcType="VARCHAR" />
  80. </resultMap>
  81. <select id="getRiskByList" parameterType="java.util.Map" resultMap="RiskDtoResultMap">
  82. SELECT
  83. A.oc_id,
  84. A.checklist_id,
  85. A.hazard_id,
  86. B.hazard_title,
  87. A.risk_id,
  88. A.risk_code,
  89. A.risk_source,
  90. A.risk_reason,
  91. A.risk_consequence,
  92. A.risk_level,
  93. A.risk_type_id,
  94. A.ctrl_level_id,
  95. C.ctrl_level_title,
  96. E.position_id_list,
  97. E.position_name_list
  98. FROM checklist_hazard_risk AS A
  99. LEFT JOIN checklist_hazard AS B ON ( A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id )
  100. LEFT JOIN ent_ctrl_level AS C ON ( A.oc_id = C.oc_id AND A.ctrl_level_id = C.ctrl_level_id )
  101. LEFT JOIN (
  102. SELECT
  103. GROUP_CONCAT( DISTINCT N.position_name ) AS position_name_list,
  104. GROUP_CONCAT( DISTINCT N.position_id ) AS position_id_list,
  105. M.oc_id,
  106. M.checklist_id,
  107. M.hazard_id,
  108. M.risk_id
  109. FROM checklist_hazard_risk_position AS M
  110. LEFT JOIN s_position AS N ON ( M.oc_id = N.oc_id AND M.position_id = N.position_id )
  111. LEFT JOIN checklist_hazard AS K ON ( M.oc_id = K.oc_id AND M.checklist_id = K.checklist_id AND M.hazard_id = K.hazard_id)
  112. WHERE 1 = 1
  113. <if test="ocId != null">
  114. AND M.oc_id = #{ocId ,jdbcType=BIGINT}
  115. </if>
  116. <if test="checklistId != null">
  117. AND M.checklist_id = #{checklistId ,jdbcType=BIGINT}
  118. </if>
  119. <if test="nodeLeft != null and nodeRight != null">
  120. <![CDATA[
  121. AND K.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  122. AND K.node_right <= #{nodeRight ,jdbcType=BIGINT}
  123. ]]>
  124. </if>
  125. <if test="hazardId != null">
  126. AND M.hazard_id = #{hazardId ,jdbcType=BIGINT}
  127. </if>
  128. <if test="riskId != null">
  129. AND M.risk_id = #{riskId ,jdbcType=BIGINT}
  130. </if>
  131. GROUP BY
  132. M.oc_id,
  133. M.checklist_id,
  134. M.hazard_id,
  135. M.risk_id
  136. ) AS E ON ( A.oc_id = E.oc_id AND A.checklist_id = E.checklist_id AND A.hazard_id = E.hazard_id AND A.risk_id =
  137. E.risk_id )
  138. WHERE 1 = 1 AND A.deleted_flag = 0
  139. <if test="ocId != null">
  140. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  141. </if>
  142. <if test="checklistId != null">
  143. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  144. </if>
  145. <if test="hazardId != null">
  146. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  147. </if>
  148. <if test="nodeLeft != null and nodeRight != null">
  149. <![CDATA[
  150. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  151. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  152. ]]>
  153. </if>
  154. <if test="riskId != null">
  155. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  156. </if>
  157. <if test="ctrlLevelId != null">
  158. <![CDATA[
  159. AND A.ctrl_level_id <= #{ctrlLevelId ,jdbcType=BIGINT}
  160. ]]>
  161. </if>
  162. <if test="riskPointId != null">
  163. AND EXISTS (
  164. SELECT
  165. *
  166. FROM ent_risk_point_hazard AS R
  167. WHERE R.deleted_flag = 0
  168. AND A.oc_id = R.oc_id
  169. AND A.checklist_id = R.checklist_id
  170. AND A.hazard_id = R.hazard_id
  171. AND R.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  172. )
  173. </if>
  174. <if test="waitingTaskId != null">
  175. AND EXISTS (
  176. SELECT
  177. *
  178. FROM check_task_doing AS R
  179. WHERE 1 = 1
  180. AND A.oc_id = R.oc_id
  181. AND A.hazard_id = R.hazard_id
  182. AND R.task_id = #{waitingTaskId ,jdbcType=BIGINT}
  183. )
  184. </if>
  185. <if test="handledTaskId != null">
  186. AND EXISTS (
  187. SELECT
  188. *
  189. FROM check_record AS R
  190. WHERE 1 = 1
  191. AND A.oc_id = R.oc_id
  192. AND A.hazard_id = R.hazard_id
  193. AND R.task_id = #{handledTaskId ,jdbcType=BIGINT}
  194. )
  195. </if>
  196. <if test="riskLevel != null and riskLevel > 0">
  197. AND A.risk_level = #{riskLevel ,jdbcType=BIGINT}
  198. </if>
  199. <if test="keywords != null and keywords != ''">
  200. AND A.risk_source like "%"#{keywords}"%"
  201. </if>
  202. ORDER BY A.risk_id ASC
  203. </select>
  204. <resultMap id="RiskMeasureDtoMap" type="com.zhyc.xps.aqpt.dto.ChecklistHazardRiskMeasureDto">
  205. <result column="oc_id" property="ocId" jdbcType="BIGINT"/>
  206. <result column="checklist_id" property="checklistId" jdbcType="BIGINT"/>
  207. <result column="hazard_id" property="hazardId" jdbcType="BIGINT"/>
  208. <result column="risk_id" property="riskId" jdbcType="BIGINT"/>
  209. <result column="measure_id" property="measureId" jdbcType="BIGINT"/>
  210. <result column="measure_content" property="measureContent" jdbcType="VARCHAR"/>
  211. <result column="measure_reference" property="measureReference" jdbcType="VARCHAR"/>
  212. <result column="measure_desc" property="measureDesc" jdbcType="VARCHAR"/>
  213. <result column="measure_type_id" property="measureTypeId" jdbcType="BIGINT"/>
  214. <result column="measure_type_title" property="measureTypeTitle" jdbcType="VARCHAR"/>
  215. </resultMap>
  216. <select id="getMeasureByList" parameterType="java.util.Map" resultMap="RiskMeasureDtoMap">
  217. SELECT
  218. A.oc_id,
  219. A.checklist_id,
  220. A.hazard_id,
  221. A.risk_id,
  222. A.measure_id,
  223. A.measure_content,
  224. A.measure_desc,
  225. A.measure_type_id,
  226. B.measure_type_title,
  227. A.measure_reference
  228. FROM checklist_hazard_risk_measure AS A
  229. LEFT JOIN measure_type AS B ON(A.measure_type_id = B.measure_type_id)
  230. WHERE 1 = 1 AND A.deleted_flag = 0
  231. <if test="ocId != null">
  232. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  233. </if>
  234. <if test="checklistId != null">
  235. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  236. </if>
  237. <if test="hazardId != null">
  238. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  239. </if>
  240. <if test="riskId != null">
  241. AND A.risk_id = #{riskId ,jdbcType=BIGINT}
  242. </if>
  243. <if test="keywords != null and keywords != ''">
  244. AND A.measure_content like "%"#{keywords}"%"
  245. </if>
  246. <if test="ctrlLevelId != null">
  247. AND EXISTS (
  248. SELECT
  249. *
  250. FROM checklist_hazard_risk AS C
  251. WHERE C.deleted_flag = 0
  252. AND A.oc_id = C.oc_id
  253. AND A.checklist_id = C.checklist_id
  254. AND A.hazard_id = C.hazard_id
  255. AND A.risk_id = C.risk_id
  256. <![CDATA[
  257. AND C.ctrl_level_id <= #{ctrlLevelId ,jdbcType=BIGINT}
  258. ]]>
  259. )
  260. </if>
  261. <if test="riskPointId != null">
  262. AND EXISTS (
  263. SELECT
  264. *
  265. FROM ent_risk_point_hazard AS D
  266. WHERE D.deleted_flag = 0
  267. AND A.oc_id = D.oc_id
  268. AND A.checklist_id = D.checklist_id
  269. AND A.hazard_id = D.hazard_id
  270. AND D.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  271. )
  272. </if>
  273. ORDER BY A.measure_id ASC
  274. </select>
  275. <select id="getHazardByCheckDefList" resultType="com.zhyc.xps.aqpt.dto.EntRiskPointHazardDto">
  276. SELECT
  277. A.oc_id,
  278. A.risk_point_id,
  279. F.risk_point_id,
  280. F.check_def_id,
  281. D.risk_point_title,
  282. A.checklist_id,
  283. A.hazard_id,
  284. A.STATUS,
  285. B.hazard_title,
  286. B.hazard_code,
  287. B.hazard_image,
  288. B.hazard_desc,
  289. B.hazard_type_id,
  290. C.hazard_type_title,
  291. E.group_name,
  292. B.hazard_level
  293. FROM
  294. check_def AS F
  295. LEFT JOIN ent_risk_point_hazard AS A ON ( F.risk_point_id = A.risk_point_id )
  296. LEFT JOIN checklist_hazard AS B ON ( A.checklist_id = B.checklist_id AND A.hazard_id = B.hazard_id )
  297. LEFT JOIN ent_risk_point AS D ON ( D.risk_point_id = A.risk_point_id AND D.oc_id = A.oc_id )
  298. LEFT JOIN s_group AS E ON ( E.group_id = F.group_id AND F.oc_id = E.oc_id )
  299. LEFT JOIN hazard_type AS C ON ( B.hazard_type_id = C.hazard_type_id )
  300. WHERE
  301. F.deleted_flag = 0
  302. AND D.deleted_flag = 0
  303. <if test="ocId != null">
  304. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  305. </if>
  306. <if test="riskPointId != null">
  307. AND A.risk_point_id = #{riskPointId ,jdbcType=BIGINT}
  308. </if>
  309. <if test="checklistId != null">
  310. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  311. </if>
  312. <if test="hazardId != null">
  313. AND A.hazard_id = #{hazardId ,jdbcType=BIGINT}
  314. </if>
  315. <if test="keywords != null and keywords != ''">
  316. AND B.hazard_title LIKE "%"#{keywords}"%"
  317. </if>
  318. <if test="status != null">
  319. AND A.status = #{status,jdbcType=BIGINT}
  320. </if>
  321. ORDER BY F.risk_point_id ASC
  322. </select>
  323. </mapper>