forked from gzzfw/backEnd/gz-dyh

zhouxiantao
2024-09-19 f7dd6c04223ea30a535e7f340d620435102aad8b
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml
@@ -102,6 +102,7 @@
        <result property="agreeType" column="agree_type"/>
        <result property="agreeTypeName" column="agree_type_name"/>
        <result property="agreeContent" column="agree_content"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
    <!-- 表 -->
    <sql id='table-name'>dyh_case_info</sql>
@@ -116,6 +117,7 @@
        a.case_type_name,
        a.input_unit_id,
        a.input_unit_name,
        a.create_time,
        b.medi_result,
        b.medi_result_name,
        b.mediate_unit_id,
@@ -273,6 +275,7 @@
    <!-- 条件 -->
    <sql id="where-part-all">
        <if test="terms != null">
            <where>
            <if test="terms.status != null and terms.status !=''">
                and a.status = #{terms.status}
            </if>
@@ -316,7 +319,22 @@
                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.queProv != null and terms.queProv !=''">
                    and a.que_prov = #{terms.queProv}
                </if>
                <if test="terms.queCity != null and terms.queCity !=''">
                    and a.que_city = #{terms.queCity}
                </if>
                <if test="terms.queArea != null and terms.queArea !=''">
                    and a.que_area = #{terms.queArea}
                </if>
                <if test="terms.queRoad != null and terms.queRoad !=''">
                    and a.que_road = #{terms.queRoad}
                </if>
                <if test="terms.isArea != null and terms.isArea !=''">
                    and a.que_city is not null
                </if>
            </where>
        </if>
    </sql>
    <!-- 条件 -->
@@ -659,4 +677,58 @@
        limit #{page.offset}, #{page.size}
    </select>
    <!--  统计分析(区域)  -->
    <select id="statisticsArea" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsAreaDTO">
        SELECT
        a.que_area as areaCode,a.que_area_name as areaName,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
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
        <include refid="where-part-all"/>
        group by a.que_area
    </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 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,
        sum(case when a.info_process <![CDATA[ < ]]> 3 then 1 else 0 end) as processNum,
        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
        <include refid="where-part-all"/>
    </select>
    <!--  统计分析(类型)  -->
    <select id="statisticsType" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsTypeDTO">
        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
        <include refid="where-part-all"/>
        group by a.case_type
    </select>
    <!--  统计分析(来源)  -->
    <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 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
        <include refid="where-part-all"/>
        group by a.canal
    </select>
</mapper>