forked from gzzfw/backEnd/gz-dyh

wangwh
2024-10-28 e79d8c8f9679839bf983341fe2cf3212e1bb3001
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml
@@ -299,7 +299,7 @@
    <sql id="where-part-all">
        <if test="terms != null">
            <where>
                and delete_status = 0
                and a.delete_status = 0
                <if test="terms.ids != null and terms.ids.size > 0">
                    and a.id in
                    <foreach collection="terms.ids" item="id" index="index" open="(" separator="," close=")">
@@ -358,20 +358,69 @@
                    and (DATE_FORMAT(b.file_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.fileStart}
                    and DATE_FORMAT(b.file_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.fileEnd})
                </if>
                <if test="terms.queCity != null and terms.queCity !=''">
                    and ((b.mediate_unit_id is not null and b.mediate_unit_id in (select id from "gzdyh_dev"."dyh_ct_unit" where que_city = #{terms.queCity}))
                    or (b.mediate_unit_id is null and a.que_city = #{terms.queCity}))
                <if test='terms.queCity != null and terms.queCity !="" and terms.statistics != null and terms.areaType == "1"'>
                    and (b.mediate_unit_id is not null and c.city = #{terms.queCity}
                    <if test="terms.unitGrades != null and terms.unitGrades.size > 0">
                        and c.unit_grade in
                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator="," close=")">
                            #{unitGrade}
                        </foreach>
                    </if>
                    )
                </if>
                <if test="terms.queArea != null and terms.queArea !=''">
                    and ((b.mediate_unit_id is not null and b.mediate_unit_id in (select id from "gzdyh_dev"."dyh_ct_unit" where que_area = #{terms.queArea}))
                    or (b.mediate_unit_id is null and a.que_area = #{terms.queArea}))
                <if test='terms.queCity != null and terms.queCity !="" and terms.statistics != null and terms.areaType != "1"'>
                    and ((b.mediate_unit_id is not null and c.city = #{terms.queCity}
                    <if test="terms.unitGrades != null and terms.unitGrades.size > 0">
                        and c.unit_grade in
                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
                                 close=")">
                            #{unitGrade}
                        </foreach>
                    </if>)
                    or (b.mediate_unit_id is null and a.que_city = #{terms.queCity})
                    )
                </if>
                <if test="terms.queRoad != null and terms.queRoad !=''">
                    and ((b.mediate_unit_id is not null and b.mediate_unit_id in (select id from "gzdyh_dev"."dyh_ct_unit" where que_road = #{terms.queRoad}))
                <if test='terms.queArea != null and terms.queArea !="" and terms.statistics != null and terms.areaType == "2"'>
                    and (b.mediate_unit_id is not null and c.area = #{terms.queArea}
                    <if test="terms.unitGrades != null and terms.unitGrades.size > 0">
                        and c.unit_grade in
                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator="," close=")">
                            #{unitGrade}
                        </foreach>
                    </if>
                    )
                </if>
                <if test='terms.queArea != null and terms.queArea !="" and terms.statistics != null and terms.areaType != "2"'>
                    and ((b.mediate_unit_id is not null and c.area = #{terms.queArea}
                    <if test="terms.unitGrades != null and terms.unitGrades.size > 0">
                        and c.unit_grade in
                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator="," close=")">
                            #{unitGrade}
                        </foreach>
                    </if>
                    )
                    or (b.mediate_unit_id is null and a.que_area = #{terms.queArea})
                    )
                </if>
                <if test="terms.queRoad != null and terms.queRoad !='' and terms.statistics != null">
                    and ((b.mediate_unit_id is not null and c.road = #{terms.queRoad}
                    <if test="terms.unitGrades != null and terms.unitGrades.size > 0">
                        and c.unit_grade in
                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator="," close=")">
                            #{unitGrade}
                        </foreach>
                    </if>
                    )
                    or (b.mediate_unit_id is null and a.que_road = #{terms.queRoad}))
                </if>
                <if test="terms.isArea != null and terms.isArea !=''">
                    and a.que_city is not null and a.que_area is not null and a.que_road is not null
                </if>
                <if test="terms.queArea != null and terms.queArea !='' and terms.statistics == null">
                    and a.que_area = #{terms.queArea}
                </if>
                <if test="terms.queRoad != null and terms.queRoad !='' and terms.statistics == null">
                    and a.que_road = #{terms.queRoad}
                </if>
                <if test="terms.caseRef != null and terms.caseRef !=''">
                    and a.case_ref = #{terms.caseRef}
@@ -844,41 +893,38 @@
    <!--  统计分析(区域)  -->
    <select id="statisticsArea" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsAreaDTO">
        SELECT
        <if test="terms.areaType == null or terms.areaType ==''">
            a.que_area as areaCode,a.que_area_name as areaName,
        </if>
        <if test='terms.areaType != null and terms.areaType =="1"'>
            a.que_area as areaCode,a.que_area_name as areaName,
        <if test='terms.areaType == null or terms.areaType =="1"'>
            IF(c.area is null,a.que_city,c.city) as areaCode,IF(c.city_name is null,a.que_city_name,c.city_name) as areaName,
        </if>
        <if test='terms.areaType != null and terms.areaType =="2"'>
            a.que_road as areaCode,a.que_road_name as areaName,
            IF(c.area is null,a.que_area,c.area) as areaCode,IF(c.area_name is null,a.que_area_name,c.area_name) as areaName,
        </if>
        <if test='terms.areaType != null and terms.areaType =="3"'>
            IF(c.road is null,a.que_road,c.road) as areaCode,IF(c.road_name is null,a.que_road_name,c.road_name) as areaName,
        </if>
        <if test='terms.areaType != null and terms.areaType =="4"'>
            IF(c.road is null,a.que_road,c.road) as areaCode,IF(c.road_name is null,a.que_road_name,c.road_name) as areaName,
        </if>
        c.unit_grade as unitGrade,
        count(1) as caseNum,
        sum(case when b.medi_result = '22_00025-1' then 1 else 0 end) as resolveNum,
        sum(case when b.medi_result is null and a.info_process <![CDATA[ < ]]> 4 then 1 else 0 end) as resolveingNum,
        sum(case when b.medi_result = '22_00025-2' then 1 else 0 end) as unResolveNum,
        sum(case when b.medi_result = '22_00025-1' and a.info_process = 3 then 1 else 0 end) as resolveNum,
        sum(case when a.info_process <![CDATA[ < ]]> 3 then 1 else 0 end) as resolveingNum,
        sum(case when b.medi_result = '22_00025-2' and a.info_process = 3 then 1 else 0 end) as unResolveNum,
        sum(case when a.info_process = 4 then 1 else 0 end) as rejectNum
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
        dyh_case_info a
        inner JOIN dyh_case_info_unfold b on a.id = b.id
        LEFT JOIN dyh_ct_unit c ON b.mediate_unit_id = c.id
        <include refid="where-part-all"/>
        <if test="terms.areaType == null or terms.areaType ==''">
            group by a.que_area
        </if>
        <if test='terms.areaType != null and terms.areaType =="1"'>
            group by a.que_area
        </if>
        <if test='terms.areaType != null and terms.areaType =="2"'>
            group by a.que_road
        </if>
        group by areaCode
    </select>
    <!--  统计分析(基础)  -->
    <select id="statisticsBase" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsBaseDTO">
        SELECT
        count(1) as totalNum,
        sum(case when b.medi_result = '22_00025-1' then 1 else 0 end) as resolveNum,
        sum(case when b.medi_result is null and a.info_process <![CDATA[ < ]]> 4 then 1 else 0 end) as resolveingNum,
        sum(case when b.medi_result = '22_00025-2' then 1 else 0 end) as unResolveNum,
        sum(case when b.medi_result = '22_00025-1' and a.info_process = 3 then 1 else 0 end) as resolveNum,
        sum(case when a.info_process <![CDATA[ < ]]> 3 then 1 else 0 end) as resolveingNum,
        sum(case when b.medi_result = '22_00025-2' and a.info_process = 3 then 1 else 0 end) as unResolveNum,
        sum(case when a.case_level = 1 then 1 else 0 end) as oneLevelNum,
        sum(case when a.case_level = 2 then 1 else 0 end) as twoLevelNum,
        sum(case when a.case_level = 3 then 1 else 0 end) as threeLevelNum,
@@ -886,7 +932,9 @@
        sum(case when a.info_process = 3 then 1 else 0 end) as finishNum,
        sum(case when a.info_process = 4 then 1 else 0 end) as rejectNum
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
        dyh_case_info a
        inner JOIN dyh_case_info_unfold b on a.id = b.id
        LEFT JOIN dyh_ct_unit c ON b.mediate_unit_id = c.id
        <include refid="where-part-all"/>
    </select>
    <!--  统计分析(类型)  -->
@@ -894,7 +942,9 @@
        SELECT
        a.case_type_first as caseType,a.case_type_first_name as caseTypeName,count(1) as caseNum
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
        dyh_case_info a
        inner JOIN dyh_case_info_unfold b on a.id = b.id
        LEFT JOIN dyh_ct_unit c ON b.mediate_unit_id = c.id
        <include refid="where-part-all"/>
        group by a.case_type_first
    </select>
@@ -904,7 +954,9 @@
        SELECT
        a.case_type as caseType,a.case_type_name as caseTypeName,count(1) as caseNum
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
        dyh_case_info a
        inner JOIN dyh_case_info_unfold b on a.id = b.id
        LEFT JOIN dyh_ct_unit c ON b.mediate_unit_id = c.id
        <include refid="where-part-all"/>
        group by a.case_type
    </select>
@@ -913,12 +965,14 @@
    <select id="statisticsSource" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsSourceDTO">
        SELECT
        a.canal,a.canal_name as canalName,count(1) as caseNum,
        sum(case when b.medi_result = '22_00025-1' then 1 else 0 end) as resolveNum,
        sum(case when b.medi_result is null and a.info_process <![CDATA[ < ]]> 4 then 1 else 0 end) as resolveingNum,
        sum(case when b.medi_result = '22_00025-2' then 1 else 0 end) as unResolveNum,
        sum(case when b.medi_result = '22_00025-1' and a.info_process = 3 then 1 else 0 end) as resolveNum,
        sum(case when a.info_process <![CDATA[ < ]]> 3 then 1 else 0 end) as resolveingNum,
        sum(case when b.medi_result = '22_00025-2' and a.info_process = 3 then 1 else 0 end) as unResolveNum,
        sum(case when a.info_process = 4 then 1 else 0 end) as rejectNum
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
        dyh_case_info a
        inner JOIN dyh_case_info_unfold b on a.id = b.id
        LEFT JOIN dyh_ct_unit c ON b.mediate_unit_id = c.id
        <include refid="where-part-all"/>
        group by a.canal
    </select>