123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ruoyi.powerdistribution.mapper.PdmReportAppointmentDayMapper">
- <resultMap type="PdmReportAppointmentDay" id="PdmReportAppointmentDayResult">
- <result property="id" column="id" />
- <result property="company" column="company" />
- <result property="reportDate" column="report_date" />
- <result property="bossSum" column="boss_sum" />
- <result property="manageSum" column="manage_sum" />
- <result property="absentSum" column="absent_sum" />
- <result property="absentDetail" column="absent_detail" />
- <result property="absentBadSum" column="absent_bad_sum" />
- <result property="absentBadDetail" column="absent_bad_detail" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <sql id="selectPdmReportAppointmentDayVo">
- 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
- </sql>
- <select id="selectPdmReportAppointmentDayList" parameterType="PdmReportAppointmentDay" resultMap="PdmReportAppointmentDayResult">
- select * from (
- <include refid="selectPdmReportAppointmentDayVo"/>
- <where>
- <if test="company != null and company != ''"> and company = #{company}</if>
- <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
- <if test="bossSum != null "> and boss_sum = #{bossSum}</if>
- <if test="manageSum != null "> and manage_sum = #{manageSum}</if>
- <if test="absentSum != null "> and absent_sum = #{absentSum}</if>
- <if test="absentDetail != null and absentDetail != ''"> and absent_detail = #{absentDetail}</if>
- <if test="absentBadSum != null "> and absent_bad_sum = #{absentBadSum}</if>
- <if test="absentBadDetail != null and absentBadDetail != ''"> and absent_bad_detail = #{absentBadDetail}</if>
- </where>
- UNION
- SELECT
- sum(id) as id,
- '总计' as company,
- report_date,
- sum(ifnull(boss_sum,0)) boss_sum,
- sum(ifnull(manage_sum,0)) manage_sum,
- sum(ifnull(absent_sum,0)) absent_sum,
- null absent_detail,
- sum(ifnull(absent_bad_sum,0)) absent_bad_sum,
- null absent_bad_detail,
- null create_by ,
- null create_time,
- null update_by,
- null update_time FROM
- pdm_report_appointment_day
- <where>
- <if test="company != null and company != ''"> and company = #{company}</if>
- <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
- <if test="bossSum != null "> and boss_sum = #{bossSum}</if>
- <if test="manageSum != null "> and manage_sum = #{manageSum}</if>
- <if test="absentSum != null "> and absent_sum = #{absentSum}</if>
- <if test="absentDetail != null and absentDetail != ''"> and absent_detail = #{absentDetail}</if>
- <if test="absentBadSum != null "> and absent_bad_sum = #{absentBadSum}</if>
- <if test="absentBadDetail != null and absentBadDetail != ''"> and absent_bad_detail = #{absentBadDetail}</if>
- </where>
- GROUP BY report_date) a order by id asc
- </select>
- <select id="selectPdmReportAppointmentDayById" parameterType="Long" resultMap="PdmReportAppointmentDayResult">
- <include refid="selectPdmReportAppointmentDayVo"/>
- where id = #{id}
- </select>
- <insert id="insertPdmReportAppointmentDay" parameterType="PdmReportAppointmentDay" useGeneratedKeys="true" keyProperty="id">
- insert into pdm_report_appointment_day
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="company != null">company,</if>
- <if test="reportDate != null">report_date,</if>
- <if test="bossSum != null">boss_sum,</if>
- <if test="manageSum != null">manage_sum,</if>
- <if test="absentSum != null">absent_sum,</if>
- <if test="absentDetail != null">absent_detail,</if>
- <if test="absentBadSum != null">absent_bad_sum,</if>
- <if test="absentBadDetail != null">absent_bad_detail,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="company != null">#{company},</if>
- <if test="reportDate != null">#{reportDate},</if>
- <if test="bossSum != null">#{bossSum},</if>
- <if test="manageSum != null">#{manageSum},</if>
- <if test="absentSum != null">#{absentSum},</if>
- <if test="absentDetail != null">#{absentDetail},</if>
- <if test="absentBadSum != null">#{absentBadSum},</if>
- <if test="absentBadDetail != null">#{absentBadDetail},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updatePdmReportAppointmentDay" parameterType="PdmReportAppointmentDay">
- update pdm_report_appointment_day
- <trim prefix="SET" suffixOverrides=",">
- <if test="company != null">company = #{company},</if>
- <if test="reportDate != null">report_date = #{reportDate},</if>
- <if test="bossSum != null">boss_sum = #{bossSum},</if>
- <if test="manageSum != null">manage_sum = #{manageSum},</if>
- <if test="absentSum != null">absent_sum = #{absentSum},</if>
- <if test="absentDetail != null">absent_detail = #{absentDetail},</if>
- <if test="absentBadSum != null">absent_bad_sum = #{absentBadSum},</if>
- <if test="absentBadDetail != null">absent_bad_detail = #{absentBadDetail},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deletePdmReportAppointmentDayById" parameterType="Long">
- delete from pdm_report_appointment_day where id = #{id}
- </delete>
- <delete id="deletePdmReportAppointmentDayByIds" parameterType="String">
- delete from pdm_report_appointment_day where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="selectAppointmentReport" parameterType="PdmReportAppointmentDay" resultMap="PdmReportAppointmentDayResult">
- select t1.organ_abbr company,
- IFNULL(tt1.boss_sum,0) boss_sum,
- IFNULL(tt1.manage_sum,0) manage_sum,
- IFNULL(tt1.absent_sum,0) absent_sum,
- IFNULL(tt2.absent_detail,'') absent_detail,
- IFNULL(tt3.absent_bad_sum,0) absent_bad_sum,
- IFNULL(tt3.absent_bad_detail,'') absent_bad_detail,
- IFNULL(tt4.check_num3,0) check_num3,
- IFNULL(tt4.check_num4,0) check_num4,
- IFNULL(tt4.check_num5,0) check_num5,
- IFNULL(tt4.problem_sum,0) problem_sum,
- IFNULL(tt4.city_check_sum,0) city_check_sum
- from pdm_work_organ t1
- LEFT JOIN (
- select
- sum(if((to_post_in_place_person_pos_lvl_no in ('3019014','3019015','3019016') and is_in_place = '1'),1,0)) boss_sum,
- sum(if((to_post_in_place_person_pos_lvl_no in ('3019007','3019008','3019009') and is_in_place = '1'),1,0)) manage_sum,
- sum(if(is_in_place = '0',1,0)) absent_sum,
- submit_org_nm
- from ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
- t2.uuid = t1.relation_id
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- GROUP BY submit_org_nm
- ) tt1 on t1.organ_name = tt1.submit_org_nm
- LEFT JOIN(
- select submit_org_nm,
- GROUP_CONCAT(to_post_in_place_person_nm,';') AS absent_detail FROM
- ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
- t2.uuid = t1.relation_id and is_in_place = '0'
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate} and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- GROUP BY submit_org_nm
- ) tt2 on t1.organ_name = tt2.submit_org_nm
- LEFT JOIN(
- select sum(1) absent_bad_sum,
- GROUP_CONCAT(t1.to_post_in_place_person_nm,';') AS absent_bad_detail,
- submit_org_nm
- from ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
- t2.uuid = t1.relation_id and t1.is_safe_resumption = '0'
- 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')
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- GROUP BY submit_org_nm
- )tt3 on t1.organ_name = tt3.submit_org_nm
- LEFT JOIN(
- select
- sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
- sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
- sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
- sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
- sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum,
- submit_org_nm
- from ads_cst_hygszdbb_pdminspectionrecords_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
- t2.uuid = t1.day_op_info_id
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- GROUP BY submit_org_nm
- )tt4 on t1.organ_name = tt4.submit_org_nm
- UNION ALL
- select '总计' company,
- IFNULL(ttt1.boss_sum,0) boss_sum,
- IFNULL(ttt1.manage_sum,0) manage_sum,
- IFNULL(ttt1.absent_sum,0) absent_sum,
- '' absent_detail,
- IFNULL(ttt2.absent_bad_sum,0) absent_bad_sum,
- '' absent_bad_detail,
- IFNULL(ttt3.check_num3,0) check_num3,
- IFNULL(ttt3.check_num4,0) check_num4,
- IFNULL(ttt3.check_num5,0) check_num5,
- IFNULL(ttt3.problem_sum,0) problem_sum,
- IFNULL(ttt3.city_check_sum,0) city_check_sum
- from (
- (select
- sum(if((to_post_in_place_person_pos_lvl_no in ('3019014','3019015','3019016') and is_in_place = '1'),1,0)) boss_sum,
- sum(if((to_post_in_place_person_pos_lvl_no in ('3019007','3019008','3019009') and is_in_place = '1'),1,0)) manage_sum,
- sum(if(is_in_place = '0',1,0)) absent_sum
- from ads_cst_hygszdbb_pdmworkplaninplace_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
- t2.uuid = t1.relation_id
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- ) ttt1,
- (select sum(1) absent_bad_sum,
- GROUP_CONCAT(to1.to_post_in_place_person_nm,';') AS absent_bad_detail
- from ads_cst_hygszdbb_pdmworkplaninplace_df to1,ads_cst_hygszdbb_pdmworkplan_df to2 where
- to2.uuid = to1.relation_id and to1.is_safe_resumption = '0'
- 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')
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- )ttt2,
- (select
- sum(if(op_risk_cd ='2007003' ,1,0)) check_num3,
- sum(if(op_risk_cd ='2007004' ,1,0)) check_num4,
- sum(if(op_risk_cd ='2007005' ,1,0)) check_num5,
- sum(if(scene_rating_cd !='2018002',1,0)) problem_sum,
- sum(if(scene_rating_cd !='2018002' and audit_lvl_cd = '2025002',1,0)) city_check_sum
- from ads_cst_hygszdbb_pdminspectionrecords_df t1,ads_cst_hygszdbb_pdmworkplan_df t2 where
- t2.uuid = t1.day_op_info_id
- and date_format(plan_start_wk_tm,'%Y%m%d') >= #{startDate} and date_format(plan_start_wk_tm,'%Y%m%d') <= #{endDate}
- ) ttt3
- )
- </select>
- </mapper>
|