From 3feed5879e5a9b794862bf46d38c7f66cfe41d50 Mon Sep 17 00:00:00 2001
From: xusd <330628789@qq.com>
Date: Wed, 25 Jun 2025 21:36:08 +0800
Subject: [PATCH] feature:增加市民编号,增加AI问答

---
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml |  162 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 116 insertions(+), 46 deletions(-)

diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml
index 0f94532..10fe974 100644
--- a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml
@@ -87,6 +87,7 @@
         <result property="oldCaseTypeName" column="old_case_type_name"/>
         <result property="canalSecond" column="canal_second"/>
         <result property="canalSecondName" column="canal_second_name"/>
+        <result property="caseRemark" column="case_remark"/>
     </resultMap>
     <resultMap id="dataResult-all" type="cn.huge.module.cases.domain.dto.CasePageDTO">
         <result property="id" column="id"/>
@@ -138,7 +139,10 @@
     <!-- 表 -->
     <sql id='table-name'>dyh_case_info</sql>
     <sql id="column-part-all">
-        a.id,
+        a
+        .
+        id
+        ,
         a.status,
         a.status_name,
         a.canal,
@@ -186,7 +190,8 @@
     </sql>
     <!-- 字段 -->
     <sql id="column-part">
-        id,
+        id
+        ,
         case_title,
         case_ref,
         case_level,
@@ -391,7 +396,8 @@
                 </if>
                 <if test="terms.caseTypeFirstList != null and terms.caseTypeFirstList.size > 0">
                     and a.case_type_first in
-                    <foreach collection="terms.caseTypeFirstList" item="caseTypeFirst" index="index" open="(" separator="," close=")">
+                    <foreach collection="terms.caseTypeFirstList" item="caseTypeFirst" index="index" open="("
+                             separator="," close=")">
                         #{caseTypeFirst}
                     </foreach>
                 </if>
@@ -410,27 +416,12 @@
                 <if test="terms.mediatorId != null and terms.mediatorId !=''">
                     and b.mediator_id = #{terms.mediatorId}
                 </if>
-                <if test="terms.visitTimeStart != null and terms.visitTimeStart !='' and terms.visitTimeEnd != null and terms.visitTimeEnd !=''">
-                    and (DATE_FORMAT(a.visit_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.visitTimeStart}
-                    and DATE_FORMAT(a.visit_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.visitTimeEnd})
-                </if>
-                <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
-                    and (DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.createStart}
-                    and DATE_FORMAT(a.create_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.createEnd})
-                </if>
-                <if test="terms.closeStart != null and terms.closeStart !='' and terms.closeEnd != null and terms.closeEnd !=''">
-                    and (DATE_FORMAT(b.close_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.closeStart}
-                    and DATE_FORMAT(b.close_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.closeEnd})
-                </if>
-                <if test="terms.fileStart != null and terms.fileStart !='' and terms.fileEnd != null and terms.fileEnd !=''">
-                    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 terms.statistics != null and terms.areaType == "1"'>
                     and (b.belong_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=")">
+                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
+                                 close=")">
                             #{unitGrade}
                         </foreach>
                     </if>
@@ -445,7 +436,8 @@
                                  close=")">
                             #{unitGrade}
                         </foreach>
-                    </if>)
+                    </if>
+                    )
                     or (b.belong_unit_id is null and a.que_city = #{terms.queCity})
                     )
                 </if>
@@ -453,7 +445,8 @@
                     and (b.belong_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=")">
+                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
+                                 close=")">
                             #{unitGrade}
                         </foreach>
                     </if>
@@ -463,7 +456,8 @@
                     and ((b.belong_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=")">
+                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
+                                 close=")">
                             #{unitGrade}
                         </foreach>
                     </if>
@@ -476,7 +470,8 @@
                     and (b.belong_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=")">
+                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
+                                 close=")">
                             #{unitGrade}
                         </foreach>
                     </if>
@@ -487,7 +482,8 @@
                     and ((b.belong_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=")">
+                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
+                                 close=")">
                             #{unitGrade}
                         </foreach>
                     </if>
@@ -498,7 +494,8 @@
                     and (b.belong_unit_id is not null and c.village = #{terms.queVillage}
                     <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=")">
+                        <foreach collection="terms.unitGrades" item="unitGrade" index="index" open="(" separator=","
+                                 close=")">
                             #{unitGrade}
                         </foreach>
                     </if>
@@ -572,6 +569,28 @@
                 </if>
                 <if test="terms.agreeType != null and terms.agreeType !=''">
                     and b.agree_type = #{terms.agreeType}
+                </if>
+                <if test="terms.systemSource != null and terms.systemSource !=''">
+                    and b.sys_source = #{terms.systemSource}
+                </if>
+                <if test="terms.visitTimeStart != null and terms.visitTimeStart !='' and terms.visitTimeEnd != null and terms.visitTimeEnd !=''">
+                    and (DATE_FORMAT(a.visit_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.visitTimeStart}
+                    and DATE_FORMAT(a.visit_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.visitTimeEnd})
+                </if>
+                <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+                    and (a.create_time <![CDATA[ >= ]]> #{terms.createStart}
+                    and a.create_time <![CDATA[ <= ]]> #{terms.createEnd})
+                </if>
+                <if test="terms.closeStart != null and terms.closeStart !='' and terms.closeEnd != null and terms.closeEnd !=''">
+                    and (DATE_FORMAT(b.close_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.closeStart}
+                    and DATE_FORMAT(b.close_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.closeEnd})
+                </if>
+                <if test="terms.fileStart != null and terms.fileStart !='' and terms.fileEnd != null and terms.fileEnd !=''">
+                    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.cityCode != null and terms.cityCode !=''">
+                    and e.citizen_event_code = #{terms.cityCode}
                 </if>
             </where>
         </if>
@@ -958,7 +977,8 @@
 
     <select id="pageTermsCaseRegister" resultType="cn.huge.module.cases.domain.dto.CaseRegisterDTO">
         SELECT
-        t1.id as caseId,t1.create_time as createTime,t1.input_user_name as inputUserName,t1.status_name as statusName,t1.case_level as
+        t1.id as caseId,t1.create_time as createTime,t1.input_user_name as inputUserName,t1.status_name as
+        statusName,t1.case_level as
         caseLevel,t1.canal_name as canalName,
         t1.case_type_first_name as caseTypeFirstName,t1.case_type_name as caseTypeName,t1.plaintiffs as
         plaintiffs,t1.defendants as defendants,t2.medi_result_name as mediResultName,
@@ -982,7 +1002,7 @@
     </select>
 
 
-    <select id="countTermsCaseRegister" resultType="java.lang.Long" >
+    <select id="countTermsCaseRegister" resultType="java.lang.Long">
         SELECT
         count(t1.id)
         FROM
@@ -997,6 +1017,9 @@
         from
         dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
         LEFT JOIN dyh_ct_unit c ON b.belong_unit_id = c.id
+        <if test="terms.cityCode != null and terms.cityCode !=''">
+            left join dyh_th_grid_citizen_event e on e.case_id = a.id
+        </if>
         <include refid="where-part-all"/>
     </select>
 
@@ -1008,6 +1031,9 @@
         dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id
         LEFT JOIN dyh_ct_unit c ON b.belong_unit_id = c.id
         left join (select id ,case_id from dyh_case_task group by case_id) d on a.id = d.case_id
+        <if test="terms.cityCode != null and terms.cityCode !=''">
+            left join dyh_th_grid_citizen_event d on d.case_id = a.id
+        </if>
         <include refid="where-part-all"/>
         <if test="page.sort != null">
             <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
@@ -1062,16 +1088,20 @@
     <select id="statisticsArea" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsAreaDTO">
         SELECT
         <if test='terms.areaType == null or terms.areaType =="1"'>
-            IF(c.city 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(c.city 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"'>
-            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(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(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.village is null,a.que_village,c.village) as areaCode,IF(c.village_name is null,a.que_village_name,c.village_name) as areaName,
+            IF(c.village is null,a.que_village,c.village) as areaCode,IF(c.village_name is
+            null,a.que_village_name,c.village_name) as areaName,
         </if>
         c.unit_grade as unitGrade,
         count(1) as caseNum,
@@ -1105,6 +1135,33 @@
         LEFT JOIN dyh_ct_unit c ON b.belong_unit_id = c.id
         <include refid="where-part-all"/>
     </select>
+
+    <!--  统计分析(基础)-统计调解过程  -->
+    <select id="statisticsBaseProcess" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsBaseDTO">
+        SELECT
+        count(1) as totalNum,
+        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,
+        sum(case when a.info_process = 2 then 1
+        when a.info_process = 1 then 1 else 0 end) as processNum,
+        sum(case when a.info_process = 3 and b.medi_result = '22_00025-1' then 1 else 0 end) as finishNum,
+        sum(case when a.info_process = 4 then 1 else 0 end) as rejectNum,
+        sum(case when a.info_process = 3 and b.medi_result = '22_00025-2' then 1 else 0 end) as failNum,
+        sum(case when a.canal_second = '22_00003-8' then 1 else 0 end) as bmpcNum,
+        sum(case when a.canal_second = '22_00003-2' then 1 else 0 end) as wgpcNum,
+        sum(case when a.canal_second = '22_00003-1' then 1 else 0 end) as fjwjfNum,
+        sum(case when a.canal_second = '22_00003-7' then 1 else 0 end) as zxjfNum
+        FROM
+        dyh_case_info a
+        inner JOIN dyh_case_info_unfold b on a.id = b.id
+        LEFT JOIN dyh_ct_unit c ON b.belong_unit_id = c.id
+        <include refid="where-part-all"/>
+    </select>
+
     <!--  统计分析(类型)  -->
     <select id="statisticsTypeFirst" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsTypeDTO">
         SELECT
@@ -1247,14 +1304,20 @@
         <if test='terms.areaType != null and terms.areaType =="4"'>
             ifnull(t2.village_name, '本级') as areaName,ifnull(t2.village, '1') as areaCode,
         </if>
-        count(distinct case when (t1.node_id = 'DSRPJ' or t1.node_id = 'JAGD' or t1.node_id = 'ZJ_DFP' or t1.node_id = 'QJ_DFP'
-        or t1.node_id = 'SJ_DFP' or t1.node_id = 'DFP' or t1.node_id = 'ZJ_DSL' or t1.node_id = 'QJ_DSL' or t1.node_id = 'SJ_DSL'
-        or  t1.node_id = 'DSL' or t1.node_id = 'QJ_SBSH' or t1.node_id = 'SJ_SBSH' or t1.node_id = 'HTSH' or t1.node_id = 'ZJ_HTSH'
+        count(distinct case when (t1.node_id = 'DSRPJ' or t1.node_id = 'JAGD' or t1.node_id = 'ZJ_DFP' or t1.node_id =
+        'QJ_DFP'
+        or t1.node_id = 'SJ_DFP' or t1.node_id = 'DFP' or t1.node_id = 'ZJ_DSL' or t1.node_id = 'QJ_DSL' or t1.node_id =
+        'SJ_DSL'
+        or t1.node_id = 'DSL' or t1.node_id = 'QJ_SBSH' or t1.node_id = 'SJ_SBSH' or t1.node_id = 'HTSH' or t1.node_id =
+        'ZJ_HTSH'
         or t1.node_id = 'QJ_HTSH' or t1.node_id = 'SJ_HTSH')then t1.id end) as flowAllNum,
-        count(distinct case when (t1.node_id = 'ZJ_DFP' or t1.node_id = 'QJ_DFP' or t1.node_id = 'SJ_DFP' or t1.node_id = 'DFP') then t1.id end) as flowJbNum,
-        count(distinct case when (t1.node_id = 'ZJ_DSL' or t1.node_id = 'QJ_DSL' or t1.node_id = 'SJ_DSL' or  t1.node_id = 'DSL') then t1.id end) as flowSlNum,
+        count(distinct case when (t1.node_id = 'ZJ_DFP' or t1.node_id = 'QJ_DFP' or t1.node_id = 'SJ_DFP' or t1.node_id
+        = 'DFP') then t1.id end) as flowJbNum,
+        count(distinct case when (t1.node_id = 'ZJ_DSL' or t1.node_id = 'QJ_DSL' or t1.node_id = 'SJ_DSL' or t1.node_id
+        = 'DSL') then t1.id end) as flowSlNum,
         count(distinct case when (t1.node_id = 'QJ_SBSH' or t1.node_id = 'SJ_SBSH') then t1.id end) as flowSbNum,
-        count(distinct case when (t1.node_id = 'HTSH' or t1.node_id = 'ZJ_HTSH' or t1.node_id = 'QJ_HTSH' or t1.node_id = 'SJ_HTSH') then t1.id end) as flowHtNum,
+        count(distinct case when (t1.node_id = 'HTSH' or t1.node_id = 'ZJ_HTSH' or t1.node_id = 'QJ_HTSH' or t1.node_id
+        = 'SJ_HTSH') then t1.id end) as flowHtNum,
         count(distinct case when (t1.node_id = 'DSRPJ' or t1.node_id = 'JAGD') then t1.id end) as flowBjNum
         from
         (SELECT case_id, node_id, handle_time, create_time, cande_unit_id, id, status
@@ -1265,9 +1328,11 @@
         where status = 2 or (status = 1 and (node_id = 'DSRPJ' or node_id = 'JAGD'))
         ) s
         WHERE rn = 1 AND ((DATE_FORMAT(s.handle_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.startDate}
-        and DATE_FORMAT(s.handle_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.endDate}) OR DATE_FORMAT(s.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.startDate}
+        and DATE_FORMAT(s.handle_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.endDate}) OR
+        DATE_FORMAT(s.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.startDate}
         and DATE_FORMAT(s.create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.endDate}) group by s.case_id) t1
-        left join dyh_ct_unit t2 on (t1.cande_unit_id = t2.id) or (t1.cande_unit_id is null and t2.id = (select mediate_unit_id from dyh_case_info_unfold where id = t1.case_id))
+        left join dyh_ct_unit t2 on (t1.cande_unit_id = t2.id) or (t1.cande_unit_id is null and t2.id = (select
+        mediate_unit_id from dyh_case_info_unfold where id = t1.case_id))
         <where>
             <if test="terms.queCity != null and terms.queCity !=''">
                 and t2.city = #{terms.queCity}
@@ -1331,7 +1396,8 @@
         </if>
         count(distinct case when t2.info_process = 1 or t2.info_process = 2 then t2.id end) as sourceHjzNum,
         count(distinct case when t2.info_process = 3 and t3.medi_result = '22_00025-1' then t2.id end) as sourceHjcgNum,
-        count(distinct case when t2.info_process = 3 and t3.medi_result = '22_00025-2' then t2.id end) as sourceHjbcgNum,
+        count(distinct case when t2.info_process = 3 and t3.medi_result = '22_00025-2' then t2.id end) as
+        sourceHjbcgNum,
         count(distinct case when t2.info_process = 4 then t2.id end) as sourceByslNum
         from (SELECT case_id, node_id, create_time, cande_unit_id, id, status,handle_result
         FROM (
@@ -1339,7 +1405,8 @@
         ROW_NUMBER() OVER (PARTITION BY case_id ORDER BY node_type desc, create_time DESC) AS rn
         FROM dyh_case_task where node_id != 'DSRPJ' and delete_status = 0
         ) s
-        WHERE rn = 1 group by s.case_id)t1 left join dyh_case_info t2 on t2.id = t1.case_id left join dyh_case_info_unfold t3 on t2.id = t3.id
+        WHERE rn = 1 group by s.case_id)t1 left join dyh_case_info t2 on t2.id = t1.case_id left join
+        dyh_case_info_unfold t3 on t2.id = t3.id
         left join dyh_ct_unit t4 on t3.belong_unit_id = t4.id
         <where>
             and t2.delete_status = 0 and t4.delete_status = 0
@@ -1422,21 +1489,24 @@
     </select>
 
     <update id="deleteCaseById">
-        update dyh_case_info set delete_status = 1,update_time = #{updateTime} where id = #{id}
+        update dyh_case_info
+        set delete_status = 1,
+            update_time   = #{updateTime}
+        where id = #{id}
     </update>
 
     <!-- 统计指定canal值下按canal_second分组的案件数量 -->
     <select id="countByCanalSecond" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsTypeDTO">
         SELECT
-            a.canal_second as caseType,
-            COUNT(*) as caseNum
+        a.canal_second as caseType,
+        COUNT(*) as caseNum
         FROM
         dyh_case_info a
         inner JOIN dyh_case_info_unfold b on a.id = b.id
         LEFT JOIN dyh_ct_unit c ON b.belong_unit_id = c.id
         <include refid="where-part-all"/>
         GROUP BY
-            a.canal_second
+        a.canal_second
     </select>
 
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0