ProblemRectificationDetailMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.lutao.cloud.oil.mapper.ProblemRectificationDetailMapper">
  4. <select id="selectProblemRectifyStatus" resultType="com.lutao.cloud.oil.pojo.vo.ProblemRectifyStatusVO">
  5. SELECT
  6. pi.platform_name,
  7. prd.facility_name,
  8. CASE
  9. WHEN sra.score &lt;= 700 THEN '001'
  10. WHEN sra.score > 700 AND sra.score&lt;= 850 THEN '002'
  11. WHEN sra.score > 850 AND sra.score&lt;= 900 THEN '003'
  12. ELSE '004'
  13. END AS riskRank,
  14. prd.deduction AS score,
  15. ai.app_name AS appName,
  16. prd.hidden_problems,
  17. prd.hidden_problems_state,
  18. sra.evaluation_code AS evaluationCode
  19. FROM problem_rectification_detail prd
  20. LEFT JOIN app_info ai ON prd.app_id = ai.id
  21. LEFT JOIN platform_info pi ON prd.platform_code = pi.platform_code
  22. LEFT JOIN security_risk_assessment_summary sra ON sra.origin_id = prd.sra_id
  23. <where>
  24. pi.delete_flag = '0'
  25. <if test="platformId != null and platformId != ''">
  26. and prd.platform_code = #{platformId}
  27. </if>
  28. <if test="appId != null and appId != ''">
  29. and prd.app_id = #{appId}
  30. </if>
  31. <if test="operatingCompany != null and operatingCompany != ''">
  32. and pi.operating_company = #{operatingCompany}
  33. </if>
  34. <if test="oilGasName != null and oilGasName != ''">
  35. and pi.oil_gas_name = #{oilGasName}
  36. </if>
  37. <if test="evaluationType != null and evaluationType != ''">
  38. and sra.evaluation_type = #{evaluationType}
  39. </if>
  40. <if test="year != null and year != ''">
  41. and evaluation_year = #{year}
  42. </if>
  43. <choose>
  44. <when test="status == 1">
  45. and prd.hidden_problems_state = '001'
  46. </when>
  47. <when test="status == 2">
  48. and prd.hidden_problems_state = '002'
  49. </when>
  50. </choose>
  51. </where>
  52. ORDER BY prd.hidden_problems_state ASC, evaluationCode DESC, pi.platform_name IS NULL ASC
  53. </select>
  54. <select id="selectProblemRectifyStatusCheck"
  55. resultType="com.lutao.cloud.oil.pojo.vo.ProblemRectifyStatusCheckVO">
  56. SELECT
  57. -- prd.platform_name AS platformName,
  58. pi.platform_name AS platformName,
  59. -- CASE
  60. -- WHEN prd.score &lt;= 700 THEN '001'
  61. -- WHEN prd.score > 700 AND prd.score&lt;= 850 THEN '002'
  62. -- WHEN prd.score > 850 AND prd.score&lt;= 900 THEN '003'
  63. -- ELSE '004'
  64. -- END AS remediationRequirements,
  65. -- prd.score,
  66. -- prd.remediation_requirements AS remediationRequirements,
  67. prd.hidden_problems AS hiddenProblems,
  68. prd.hidden_problems_state AS hiddenProblemsState,
  69. prd.treatment_measures AS treatmentMeasures
  70. FROM problem_rectification_detail prd
  71. LEFT JOIN security_risk_assessment sra ON sra.origin_id = prd.sra_id
  72. LEFT JOIN platform_info pi ON prd.platform_code = pi.platform_code
  73. <where>
  74. pi.delete_flag = '0'
  75. <if test="platformId != null and platformId != ''">
  76. and prd.platform_code = #{platformId}
  77. </if>
  78. <if test="appId != null and appId != ''">
  79. and prd.app_id = #{appId}
  80. </if>
  81. <if test="year != null and year != ''">
  82. and LEFT(sra.evaluation_code, 4) LIKE CONCAT('%',#{year},'%')
  83. </if>
  84. <if test="operatingCompany != null and operatingCompany != ''">
  85. and pi.operating_company = #{operatingCompany}
  86. </if>
  87. <if test="oilGasName != null and oilGasName != ''">
  88. and pi.oil_gas_name = #{oilGasName}
  89. </if>
  90. </where>
  91. ORDER BY platformName IS NULL ASC
  92. </select>
  93. <select id="deepEvaluation" resultType="com.lutao.cloud.oil.pojo.vo.FourProblemCheckVO">
  94. SELECT
  95. hidden_problems_state AS rectifyStatus,
  96. COUNT(*) AS number
  97. FROM
  98. problem_rectification_detail prd
  99. LEFT JOIN security_risk_assessment_summary sra ON prd.sra_id = sra.origin_id
  100. LEFT JOIN platform_info pi ON prd.platform_code = pi.platform_code
  101. <where>
  102. pi.delete_flag = '0'
  103. <if test="param.platformId != null and param.platformId != ''">
  104. and prd.platform_code = #{param.platformId}
  105. </if>
  106. <if test="param.appId != null and param.appId != ''">
  107. and prd.app_id = #{param.appId}
  108. </if>
  109. <if test="param.year != null and param.year != ''">
  110. and sra.evaluation_year = #{param.year}
  111. </if>
  112. <if test="true">
  113. and sra.evaluation_type = '1'
  114. </if>
  115. </where>
  116. GROUP BY prd.hidden_problems_state
  117. </select>
  118. <select id="selfEvaluation" resultType="com.lutao.cloud.oil.pojo.vo.FourProblemCheckVO">
  119. SELECT
  120. hidden_problems_state AS rectifyStatus,
  121. COUNT(*) AS number
  122. FROM
  123. problem_rectification_detail prd
  124. LEFT JOIN security_risk_assessment_summary sra ON prd.sra_id = sra.origin_id
  125. LEFT JOIN platform_info pi ON prd.platform_code = pi.platform_code
  126. <where>
  127. pi.delete_flag = '0'
  128. <if test="param.platformId != null and param.platformId != ''">
  129. and prd.platform_code = #{param.platformId}
  130. </if>
  131. <if test="param.appId != null and param.appId != ''">
  132. and prd.app_id = #{param.appId}
  133. </if>
  134. <if test="param.year != null and param.year != ''">
  135. and sra.evaluation_year = #{param.year}
  136. </if>
  137. <if test="true">
  138. and sra.evaluation_type = '2'
  139. </if>
  140. </where>
  141. GROUP BY prd.hidden_problems_state
  142. </select>
  143. <select id="divisionEvaluation" resultType="com.lutao.cloud.oil.pojo.vo.FourProblemCheckVO">
  144. SELECT
  145. hidden_problems_state AS rectifyStatus,
  146. COUNT(*) as number
  147. FROM
  148. division_inspection_detail did
  149. LEFT JOIN platform_info pi ON did.platform_code = pi.platform_code
  150. <where>
  151. pi.delete_flag = '0'
  152. <if test="param.platformId != null and param.platformId != ''">
  153. and did.platform_code = #{param.platformId}
  154. </if>
  155. <if test="param.appId != null and param.appId != ''">
  156. and did.app_id = #{param.appId}
  157. </if>
  158. <if test="param.year != null and param.year != ''">
  159. and YEAR(did.input_time) = #{param.year}
  160. </if>
  161. </where>
  162. GROUP BY did.hidden_problems_state
  163. </select>
  164. <select id="ministerEvaluation" resultType="com.lutao.cloud.oil.pojo.vo.FourProblemCheckVO">
  165. SELECT
  166. hidden_problems_state AS rectifyStatus,
  167. COUNT(*) as number
  168. FROM
  169. ministerial_supervision_detail msd
  170. LEFT JOIN platform_info pi ON msd.platform_code = pi.platform_code
  171. <where>
  172. pi.delete_flag = '0'
  173. <if test="param.platformId != null and param.platformId != ''">
  174. and msd.platform_code = #{param.platformId}
  175. </if>
  176. <if test="param.appId != null and param.appId != ''">
  177. and msd.app_id = #{param.appId}
  178. </if>
  179. <if test="param.year != null and param.year != ''">
  180. and YEAR(msd.input_time) = #{param.year}
  181. </if>
  182. </where>
  183. GROUP BY msd.hidden_problems_state
  184. </select>
  185. <select id="queryFourQuartersRectification"
  186. resultType="com.lutao.cloud.oil.pojo.vo.FourQuartersRectificationBO">
  187. SELECT
  188. YEAR(prd.scoring_time) as year,
  189. QUARTER(prd.scoring_time) as quarter,
  190. SUM(CASE WHEN prd.hidden_problems_state = '002' THEN 1 ELSE 0 END) as rectifiedCount,
  191. COUNT(1) as total_count,
  192. SUM(CASE WHEN prd.hidden_problems_state = '002' THEN 1 ELSE 0 END) / COUNT(1) as rectifyRate
  193. FROM
  194. `problem_rectification_detail` prd
  195. LEFT JOIN platform_info pi ON prd.platform_code = pi.platform_code
  196. LEFT JOIN security_risk_assessment_summary sra ON prd.sra_id = sra.origin_id
  197. <where>
  198. pi.delete_flag = '0'
  199. <if test="param.year != null and param.year != ''">
  200. and sra.evaluation_year = #{param.year}
  201. </if>
  202. <if test="param.platformId != null and param.platformId != ''">
  203. and prd.platform_code = #{param.platformId}
  204. </if>
  205. <if test="param.appId != null and param.appId != ''">
  206. and prd.app_id = #{param.appId}
  207. </if>
  208. </where>
  209. GROUP BY
  210. year,
  211. quarter
  212. ORDER BY
  213. year,
  214. quarter;
  215. </select>
  216. </mapper>