PdmReportAppointmentDayMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.powerdistribution.mapper.PdmReportAppointmentDayMapper">
  6. <resultMap type="PdmReportAppointmentDay" id="PdmReportAppointmentDayResult">
  7. <result property="id" column="id" />
  8. <result property="company" column="company" />
  9. <result property="reportDate" column="report_date" />
  10. <result property="bossSum" column="boss_sum" />
  11. <result property="manageSum" column="manage_sum" />
  12. <result property="absentSum" column="absent_sum" />
  13. <result property="absentDetail" column="absent_detail" />
  14. <result property="absentBadSum" column="absent_bad_sum" />
  15. <result property="absentBadDetail" column="absent_bad_detail" />
  16. <result property="createBy" column="create_by" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateBy" column="update_by" />
  19. <result property="updateTime" column="update_time" />
  20. </resultMap>
  21. <sql id="selectPdmReportAppointmentDayVo">
  22. select id, company, report_date, boss_sum, manage_sum, absent_sum, absent_detail, absent_bad_sum, absent_bad_detail, create_by, create_time, update_by, update_time from pdm_report_appointment_day
  23. </sql>
  24. <select id="selectPdmReportAppointmentDayList" parameterType="PdmReportAppointmentDay" resultMap="PdmReportAppointmentDayResult">
  25. select * from (
  26. <include refid="selectPdmReportAppointmentDayVo"/>
  27. <where>
  28. <if test="company != null and company != ''"> and company = #{company}</if>
  29. <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
  30. <if test="bossSum != null "> and boss_sum = #{bossSum}</if>
  31. <if test="manageSum != null "> and manage_sum = #{manageSum}</if>
  32. <if test="absentSum != null "> and absent_sum = #{absentSum}</if>
  33. <if test="absentDetail != null and absentDetail != ''"> and absent_detail = #{absentDetail}</if>
  34. <if test="absentBadSum != null "> and absent_bad_sum = #{absentBadSum}</if>
  35. <if test="absentBadDetail != null and absentBadDetail != ''"> and absent_bad_detail = #{absentBadDetail}</if>
  36. </where>
  37. UNION
  38. SELECT
  39. sum(id) as id,
  40. '总计' as company,
  41. report_date,
  42. sum(ifnull(boss_sum,0)) boss_sum,
  43. sum(ifnull(manage_sum,0)) manage_sum,
  44. sum(ifnull(absent_sum,0)) absent_sum,
  45. null absent_detail,
  46. sum(ifnull(absent_bad_sum,0)) absent_bad_sum,
  47. null absent_bad_detail,
  48. null create_by ,
  49. null create_time,
  50. null update_by,
  51. null update_time FROM
  52. pdm_report_appointment_day
  53. <where>
  54. <if test="company != null and company != ''"> and company = #{company}</if>
  55. <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
  56. <if test="bossSum != null "> and boss_sum = #{bossSum}</if>
  57. <if test="manageSum != null "> and manage_sum = #{manageSum}</if>
  58. <if test="absentSum != null "> and absent_sum = #{absentSum}</if>
  59. <if test="absentDetail != null and absentDetail != ''"> and absent_detail = #{absentDetail}</if>
  60. <if test="absentBadSum != null "> and absent_bad_sum = #{absentBadSum}</if>
  61. <if test="absentBadDetail != null and absentBadDetail != ''"> and absent_bad_detail = #{absentBadDetail}</if>
  62. </where>
  63. GROUP BY report_date) a order by id asc
  64. </select>
  65. <select id="selectPdmReportAppointmentDayById" parameterType="Long" resultMap="PdmReportAppointmentDayResult">
  66. <include refid="selectPdmReportAppointmentDayVo"/>
  67. where id = #{id}
  68. </select>
  69. <insert id="insertPdmReportAppointmentDay" parameterType="PdmReportAppointmentDay" useGeneratedKeys="true" keyProperty="id">
  70. insert into pdm_report_appointment_day
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test="company != null">company,</if>
  73. <if test="reportDate != null">report_date,</if>
  74. <if test="bossSum != null">boss_sum,</if>
  75. <if test="manageSum != null">manage_sum,</if>
  76. <if test="absentSum != null">absent_sum,</if>
  77. <if test="absentDetail != null">absent_detail,</if>
  78. <if test="absentBadSum != null">absent_bad_sum,</if>
  79. <if test="absentBadDetail != null">absent_bad_detail,</if>
  80. <if test="createBy != null">create_by,</if>
  81. <if test="createTime != null">create_time,</if>
  82. <if test="updateBy != null">update_by,</if>
  83. <if test="updateTime != null">update_time,</if>
  84. </trim>
  85. <trim prefix="values (" suffix=")" suffixOverrides=",">
  86. <if test="company != null">#{company},</if>
  87. <if test="reportDate != null">#{reportDate},</if>
  88. <if test="bossSum != null">#{bossSum},</if>
  89. <if test="manageSum != null">#{manageSum},</if>
  90. <if test="absentSum != null">#{absentSum},</if>
  91. <if test="absentDetail != null">#{absentDetail},</if>
  92. <if test="absentBadSum != null">#{absentBadSum},</if>
  93. <if test="absentBadDetail != null">#{absentBadDetail},</if>
  94. <if test="createBy != null">#{createBy},</if>
  95. <if test="createTime != null">#{createTime},</if>
  96. <if test="updateBy != null">#{updateBy},</if>
  97. <if test="updateTime != null">#{updateTime},</if>
  98. </trim>
  99. </insert>
  100. <update id="updatePdmReportAppointmentDay" parameterType="PdmReportAppointmentDay">
  101. update pdm_report_appointment_day
  102. <trim prefix="SET" suffixOverrides=",">
  103. <if test="company != null">company = #{company},</if>
  104. <if test="reportDate != null">report_date = #{reportDate},</if>
  105. <if test="bossSum != null">boss_sum = #{bossSum},</if>
  106. <if test="manageSum != null">manage_sum = #{manageSum},</if>
  107. <if test="absentSum != null">absent_sum = #{absentSum},</if>
  108. <if test="absentDetail != null">absent_detail = #{absentDetail},</if>
  109. <if test="absentBadSum != null">absent_bad_sum = #{absentBadSum},</if>
  110. <if test="absentBadDetail != null">absent_bad_detail = #{absentBadDetail},</if>
  111. <if test="createBy != null">create_by = #{createBy},</if>
  112. <if test="createTime != null">create_time = #{createTime},</if>
  113. <if test="updateBy != null">update_by = #{updateBy},</if>
  114. <if test="updateTime != null">update_time = #{updateTime},</if>
  115. </trim>
  116. where id = #{id}
  117. </update>
  118. <delete id="deletePdmReportAppointmentDayById" parameterType="Long">
  119. delete from pdm_report_appointment_day where id = #{id}
  120. </delete>
  121. <delete id="deletePdmReportAppointmentDayByIds" parameterType="String">
  122. delete from pdm_report_appointment_day where id in
  123. <foreach item="id" collection="array" open="(" separator="," close=")">
  124. #{id}
  125. </foreach>
  126. </delete>
  127. <select id="selectAppointmentReport" parameterType="PdmReportAppointmentDay" resultMap="PdmReportAppointmentDayResult">
  128. select t1.organ_abbr company,
  129. IFNULL(tt1.boss_sum,0) boss_sum,
  130. IFNULL(tt1.manage_sum,0) manage_sum,
  131. IFNULL(tt1.absent_sum,0) absent_sum,
  132. IFNULL(tt2.absent_detail,'') absent_detail,
  133. IFNULL(tt3.absent_bad_sum,0) absent_bad_sum,
  134. IFNULL(tt3.absent_bad_detail,'') absent_bad_detail,
  135. IFNULL(tt4.check_num3,0) check_num3,
  136. IFNULL(tt4.check_num4,0) check_num4,
  137. IFNULL(tt4.check_num5,0) check_num5,
  138. IFNULL(tt4.problem_sum,0) problem_sum,
  139. IFNULL(tt4.city_check_sum,0) city_check_sum
  140. from pdm_work_organ t1
  141. LEFT JOIN (
  142. select
  143. sum(if((to_post_in_place_person_pos_lvl_no in ('3019014','3019015','3019016') and is_in_place = '1'),1,0)) boss_sum,
  144. sum(if((to_post_in_place_person_pos_lvl_no in ('3019007','3019008','3019009') and is_in_place = '1'),1,0)) manage_sum,
  145. sum(if(is_in_place = '0',1,0)) absent_sum,
  146. submit_org_nm
  147. from ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
  148. t2.uuid = t1.relation_id
  149. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  150. GROUP BY submit_org_nm
  151. ) tt1 on t1.organ_name = tt1.submit_org_nm
  152. LEFT JOIN(
  153. select submit_org_nm,
  154. GROUP_CONCAT(to_post_in_place_person_nm,';') AS absent_detail FROM
  155. ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
  156. t2.uuid = t1.relation_id and is_in_place = '0'
  157. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate} and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  158. GROUP BY submit_org_nm
  159. ) tt2 on t1.organ_name = tt2.submit_org_nm
  160. LEFT JOIN(
  161. select sum(1) absent_bad_sum,
  162. GROUP_CONCAT(t1.to_post_in_place_person_nm,';') AS absent_bad_detail,
  163. submit_org_nm
  164. from ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
  165. t2.uuid = t1.relation_id and t1.is_safe_resumption = '0'
  166. and EXISTS(select 1 from ads_cst_hygszdbb_pdminspectionrecords_df t3 where t3.day_op_info_id = t2.uuid and t3.scene_rating_cd!='2018002')
  167. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  168. GROUP BY submit_org_nm
  169. )tt3 on t1.organ_name = tt3.submit_org_nm
  170. LEFT JOIN(
  171. select
  172. sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
  173. sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
  174. sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
  175. sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
  176. sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum,
  177. submit_org_nm
  178. from ads_cst_hygszdbb_pdminspectionrecords_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
  179. t2.uuid = t1.day_op_info_id
  180. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  181. GROUP BY submit_org_nm
  182. )tt4 on t1.organ_name = tt4.submit_org_nm
  183. UNION ALL
  184. select '总计' company,
  185. IFNULL(ttt1.boss_sum,0) boss_sum,
  186. IFNULL(ttt1.manage_sum,0) manage_sum,
  187. IFNULL(ttt1.absent_sum,0) absent_sum,
  188. '' absent_detail,
  189. IFNULL(ttt2.absent_bad_sum,0) absent_bad_sum,
  190. '' absent_bad_detail,
  191. IFNULL(ttt3.check_num3,0) check_num3,
  192. IFNULL(ttt3.check_num4,0) check_num4,
  193. IFNULL(ttt3.check_num5,0) check_num5,
  194. IFNULL(ttt3.problem_sum,0) problem_sum,
  195. IFNULL(ttt3.city_check_sum,0) city_check_sum
  196. from (
  197. (select
  198. sum(if((to_post_in_place_person_pos_lvl_no in ('3019014','3019015','3019016') and is_in_place = '1'),1,0)) boss_sum,
  199. sum(if((to_post_in_place_person_pos_lvl_no in ('3019007','3019008','3019009') and is_in_place = '1'),1,0)) manage_sum,
  200. sum(if(is_in_place = '0',1,0)) absent_sum
  201. from ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
  202. t2.uuid = t1.relation_id
  203. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  204. ) ttt1,
  205. (select sum(1) absent_bad_sum,
  206. GROUP_CONCAT(to1.to_post_in_place_person_nm,';') AS absent_bad_detail
  207. from ads_cst_hygszdbb_pdmworkplaninplace_df to1,ads_cst_hygszdbb_pdmworkplan_df to2 where
  208. to2.uuid = to1.relation_id and to1.is_safe_resumption = '0'
  209. and EXISTS(select 1 from ads_cst_hygszdbb_pdminspectionrecords_df to3 where to3.day_op_info_id = to2.uuid and to3.scene_rating_cd!='2018002')
  210. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  211. )ttt2,
  212. (select
  213. sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
  214. sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
  215. sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
  216. sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
  217. sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum
  218. from ads_cst_hygszdbb_pdminspectionrecords_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
  219. t2.uuid = t1.day_op_info_id
  220. and date_format(plan_start_wk_tm,'%Y%m%d') &gt;= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') &lt;= #{endDate}
  221. ) ttt3
  222. )
  223. </select>
  224. </mapper>