From 7b7f52e057434bf7e2edc2273e1d334d87ba65f6 Mon Sep 17 00:00:00 2001
From: xusd <hugeinfo123>
Date: Fri, 25 Oct 2024 17:14:16 +0800
Subject: [PATCH] Merge branch 'gzdyh_test' into gzdyh_grid

---
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/service/AnalysisService.java          |   66 +++++++
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/controller/AnalysisWebController.java |   42 ++++
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/xml/AnalysisMapper.xml     |  202 ++++++++++++++++++++++
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/po/CaseInfoUnfold.java            |   12 +
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoUnfoldMapper.xml  |   12 +
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/AnalysisMapper.java        |   26 ++
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml        |   71 ++++++-
 dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java             |   68 +++++-
 8 files changed, 469 insertions(+), 30 deletions(-)

diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/controller/AnalysisWebController.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/controller/AnalysisWebController.java
new file mode 100644
index 0000000..865f8f4
--- /dev/null
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/controller/AnalysisWebController.java
@@ -0,0 +1,42 @@
+package cn.huge.module.analysis.controller;
+
+import cn.huge.base.common.utils.ReturnFailUtils;
+import cn.huge.base.common.utils.ReturnSucUtils;
+import cn.huge.module.analysis.service.AnalysisService;
+import cn.huge.module.cases.domain.po.CaseInfo;
+import cn.huge.module.cases.service.CaseInfoService;
+import com.google.common.collect.Maps;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * @title: 纠纷信息主表接口api-web端
+ * @description: 纠纷信息主表接口api-web端
+ * @company: hugeinfo
+ * @author: wangwh
+ * @time: 2024-08-27 10:00:57
+ * @version: 1.0.0
+ */
+@Slf4j
+@RestController
+@RequestMapping("/api/web/analysis")
+public class AnalysisWebController {
+
+    @Autowired(required = false)
+    private HttpServletRequest request;
+
+    @Autowired
+    private AnalysisService service;
+
+
+
+
+}
diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/AnalysisMapper.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/AnalysisMapper.java
new file mode 100644
index 0000000..a78f61d
--- /dev/null
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/AnalysisMapper.java
@@ -0,0 +1,26 @@
+package cn.huge.module.analysis.dao.mapper;
+
+import cn.huge.module.cases.domain.dto.*;
+import cn.huge.module.cases.domain.po.CaseInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+* @title: 纠纷信息主表持久层业务处理
+* @Description 此处仅涉及复杂SQL操作,务必不要在此再次写单表的CRUD操作,因为mybatisPlus已经实现。
+* @company: hugeinfo
+* @author: wangwh
+* @time: 2024-08-27 10:00:57
+* @version 1.0.0
+*/
+@Repository
+public interface AnalysisMapper extends BaseMapper<CaseInfo>{
+
+
+
+}
diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/xml/AnalysisMapper.xml b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/xml/AnalysisMapper.xml
new file mode 100644
index 0000000..af7666f
--- /dev/null
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/dao/mapper/xml/AnalysisMapper.xml
@@ -0,0 +1,202 @@
+<?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">
+<!-- 
+ * @title: 纠纷信息主表
+ * @description: 自定义sql,请自行实现业务逻辑
+ * @company: hugeinfo
+ * @author: wangwh
+ * @time:2024-08-27 10:00:57
+ * @version 1.0.0
+-->
+<mapper namespace="cn.huge.module.analysis.dao.mapper.AnalysisMapper">
+    <!-- 条件 -->
+    <sql id="statisticsAVG-wherePart">
+        <if test="terms != null">
+            <if test="terms.queProv != null and terms.queProv !=''">
+                and t1.que_prov = #{terms.queProv}
+            </if>
+            <if test="terms.queCity != null and terms.queCity !=''">
+                and t1.que_city = #{terms.queCity}
+            </if>
+            <if test="terms.queArea != null and terms.queArea !=''">
+                and t1.que_area = #{terms.queArea}
+            </if>
+            <if test="terms.queRoad != null and terms.queRoad !=''">
+                and t1.que_road = #{terms.queRoad}
+            </if>
+            <if test="terms.queVillage != null and terms.queVillage !=''">
+                and t1.que_village = #{terms.queVillage}
+            </if>
+            <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+                and (DATE_FORMAT(t2.create_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.createStart}
+                and DATE_FORMAT(t2.create_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.createEnd})
+            </if>
+            <if test="terms.handleStart != null and terms.handleStart !='' and terms.handleEnd != null and terms.handleEnd !=''">
+                and (DATE_FORMAT(t2.handle_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.handleStart}
+                and DATE_FORMAT(t2.handle_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.handleEnd})
+            </if>
+            <if test="terms.queVillage != null and terms.queVillage !=''">
+                and t1.que_village = #{terms.queVillage}
+            </if>
+            <if test="terms.mediType != null and terms.mediType !=''">
+                and medi_type = #{terms.mediType}
+            </if>
+            <if test="terms.caseTypeFirst != null and terms.caseTypeFirst !=''">
+                and case_type_first = #{terms.caseTypeFirst}
+            </if>
+        </if>
+    </sql>
+
+    <!--  统计任务平均时长  -->
+    <select id="statisticsAVG" resultType="java.lang.Long">
+        select AVG(case when (t2.node_id = 'ZJ_DFP' or t2.node_id = 'QJ_DFP' or t2.node_id = 'SJ_DFP' or t2.node_id = 'DFP') then count(usetime_hour) end) as fp,
+               AVG(case when (t2.node_id = 'ZJ_DSL' or t2.node_id = 'QJ_DSL' or t2.node_id = 'SJ_DSL' or t2.node_id = 'DSL') then usetime_hour end) as sl,
+               AVG(case when (t2.node_id = 'BLFK' and t2.status = '2') then usetime_hour end) as sl,
+               count(case when (t2.node_id = 'ZJ_DFP' or t2.node_id = 'QJ_DFP' or t2.node_id = 'SJ_DFP' or t2.node_id = 'DFP') and t2.overtime_status = 1 then overtime_hour end) as fpcs,
+               count(case when (t2.node_id = 'ZJ_DSL' or t2.node_id = 'QJ_DSL' or t2.node_id = 'SJ_DSL' or t2.node_id = 'DSL') and t2.overtime_status = 1 then overtime_hour end) as slcs
+        from dyh_case_info t1 left join dyh_case_task t2 on t1.id = t2.case_id
+        where
+            t2.status = 2
+        <include refid="statisticsAVG-wherePart"/>
+    </select>
+
+    <!-- 条件 -->
+    <sql id="statisticsApplyAVG-wherePart">
+        <if test="terms.queProv != null and terms.queProv !=''">
+            and t1.que_prov = #{terms.queProv}
+        </if>
+        <if test="terms.queCity != null and terms.queCity !=''">
+            and t1.que_city = #{terms.queCity}
+        </if>
+        <if test="terms.queArea != null and terms.queArea !=''">
+            and t1.que_area = #{terms.queArea}
+        </if>
+        <if test="terms.queRoad != null and terms.queRoad !=''">
+            and t1.que_road = #{terms.queRoad}
+        </if>
+        <if test="terms.queVillage != null and terms.queVillage !=''">
+            and t1.que_village = #{terms.queVillage}
+        </if>
+        <if test="terms.queVillage != null and terms.queVillage !=''">
+            and t1.que_village = #{terms.queVillage}
+        </if>
+        <if test="terms.mediType != null and terms.mediType !=''">
+            and t1.medi_type = #{terms.mediType}
+        </if>
+        <if test="terms.caseTypeFirst != null and terms.caseTypeFirst !=''">
+            and t1.case_type_first = #{terms.caseTypeFirst}
+        </if>
+    </sql>
+
+    <!--  统计审批平均时长  -->
+    <select id="statisticsApplyAVG" resultType="java.lang.Long">
+        select select avg(usetime_hour)
+        form
+        (
+        select usetime_hour
+        from dyh_case_info t1 left join dyh_case_appear t2 on t1.id = t2.case_id
+        where t2.apply_status = 1
+        <if test="terms != null">
+            <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+                and (DATE_FORMAT(t2.appear_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.createStart}
+                and DATE_FORMAT(t2.appear_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.createEnd})
+            </if>
+            <if test="terms.handleStart != null and terms.handleStart !='' and terms.handleEnd != null and terms.handleEnd !=''">
+                and (DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.handleStart}
+                and DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.handleEnd})
+            </if>
+            <include refid="statisticsApplyAVG-wherePart"/>
+        </if>
+        union all
+        select usetime_hour
+        from dyh_case_info t1 left join dyh_case_assist_apply t2 on t1.id = t2.case_id
+        where t2.apply_status = 1
+        <if test="terms != null">
+            <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+                and (DATE_FORMAT(t2.apply_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.createStart}
+                and DATE_FORMAT(t2.apply_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.createEnd})
+            </if>
+            <if test="terms.handleStart != null and terms.handleStart !='' and terms.handleEnd != null and terms.handleEnd !=''">
+                and (DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.handleStart}
+                and DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.handleEnd})
+            </if>
+            <include refid="statisticsApplyAVG-wherePart"/>
+        </if>
+        union all
+        select usetime_hour
+        from dyh_case_info t1 left join dyh_case_return t2 on t1.id = t2.case_id
+        where t2.return_status = 1
+        <if test="terms != null">
+            <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+                and (DATE_FORMAT(t2.return_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.createStart}
+                and DATE_FORMAT(t2.return_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.createEnd})
+            </if>
+            <if test="terms.handleStart != null and terms.handleStart !='' and terms.handleEnd != null and terms.handleEnd !=''">
+                and (DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.handleStart}
+                and DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.handleEnd})
+            </if>
+            <include refid="statisticsApplyAVG-wherePart"/>
+        </if>
+        union all
+        select usetime_hour
+        from dyh_case_info t1 left join dyh_case_windup_apply t2 on t1.id = t2.case_id
+        where t2.apply_status = 1
+        <if test="terms != null">
+            <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+                and (DATE_FORMAT(t2.apply_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.createStart}
+                and DATE_FORMAT(t2.apply_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.createEnd})
+            </if>
+            <if test="terms.handleStart != null and terms.handleStart !='' and terms.handleEnd != null and terms.handleEnd !=''">
+                and (DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.handleStart}
+                and DATE_FORMAT(t2.audit_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.handleEnd})
+            </if>
+            <include refid="statisticsApplyAVG-wherePart"/>
+        </if>
+        )
+    </select>
+
+    <!-- 条件 -->
+    <sql id="statisticsSuperviseAVG-wherePart">
+        t2.sup_status = 1
+        <if test="terms.queProv != null and terms.queProv !=''">
+            and t1.que_prov = #{terms.queProv}
+        </if>
+        <if test="terms.queCity != null and terms.queCity !=''">
+            and t1.que_city = #{terms.queCity}
+        </if>
+        <if test="terms.queArea != null and terms.queArea !=''">
+            and t1.que_area = #{terms.queArea}
+        </if>
+        <if test="terms.queRoad != null and terms.queRoad !=''">
+            and t1.que_road = #{terms.queRoad}
+        </if>
+        <if test="terms.queVillage != null and terms.queVillage !=''">
+            and t1.que_village = #{terms.queVillage}
+        </if>
+        <if test="terms.queVillage != null and terms.queVillage !=''">
+            and t1.que_village = #{terms.queVillage}
+        </if>
+        <if test="terms.mediType != null and terms.mediType !=''">
+            and t1.medi_type = #{terms.mediType}
+        </if>
+        <if test="terms.caseTypeFirst != null and terms.caseTypeFirst !=''">
+            and t1.case_type_first = #{terms.caseTypeFirst}
+        </if>
+        <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
+            and (DATE_FORMAT(t2.sup_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.createStart}
+            and DATE_FORMAT(t2.sup_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.createEnd})
+        </if>
+        <if test="terms.handleStart != null and terms.handleStart !='' and terms.handleEnd != null and terms.handleEnd !=''">
+            and (DATE_FORMAT(t2.reply_time,'%Y-%m-%d %H:%i') <![CDATA[ >= ]]> #{terms.handleStart}
+            and DATE_FORMAT(t2.reply_time,'%Y-%m-%d %H:%i') <![CDATA[ <= ]]> #{terms.handleEnd})
+        </if>
+    </sql>
+
+    <!--  统计督办平均时长  -->
+    <select id="statisticsSuperviseAVG" resultType="java.lang.Long">
+        select usetime_hour
+        from dyh_case_info t1 left join dyh_case_supervise t2 on t1.id = t2.case_id
+        <include refid="statisticsSuperviseAVG-wherePart"/>
+    </select>
+
+</mapper> 
\ No newline at end of file
diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/service/AnalysisService.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/service/AnalysisService.java
new file mode 100644
index 0000000..0aaf9a6
--- /dev/null
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/analysis/service/AnalysisService.java
@@ -0,0 +1,66 @@
+package cn.huge.module.analysis.service;
+
+import cn.huge.base.common.exception.ServiceException;
+import cn.huge.base.common.utils.*;
+import cn.huge.module.analysis.dao.mapper.AnalysisMapper;
+import cn.huge.module.cases.dao.mapper.CaseInfoMapper;
+import cn.huge.module.cases.domain.dto.*;
+import cn.huge.module.cases.domain.po.CaseAgent;
+import cn.huge.module.cases.domain.po.CaseInfo;
+import cn.huge.module.cases.domain.po.CaseInfoUnfold;
+import cn.huge.module.cases.domain.po.CasePerson;
+import cn.huge.module.cases.service.*;
+import cn.huge.module.client.api.impl.CustClientImpl;
+import cn.huge.module.client.api.impl.SysClientImpl;
+import cn.huge.module.client.api.impl.UtilsClientImpl;
+import cn.huge.module.constant.BaseConsts;
+import cn.huge.module.cust.dto.CtUserDTO;
+import cn.huge.module.cust.dto.PaUserDTO;
+import cn.huge.module.draft.service.CasedraftInfoService;
+import cn.huge.module.mediate.constant.*;
+import cn.huge.module.mediate.dto.WechatBindCaseDTO;
+import cn.huge.module.sys.dto.FileIdTypeInfoBaseDTO;
+import cn.huge.module.sys.dto.QueAddrBaseDTO;
+import cn.huge.module.sys.dto.QueAreaDTO;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageImpl;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @author wangwh
+ * @version 1.0.0
+ * @title: 纠纷信息主表业务逻辑处理
+ * @Description 纠纷信息主表业务逻辑处理
+ * @company hugeinfo
+ * @Time 2024-08-27 10:00:57
+ */
+@Slf4j
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class AnalysisService extends ServiceImpl<AnalysisMapper, CaseInfo> {
+
+    @Autowired
+    private CaseInfoMapper mapper;
+
+    @Autowired
+    private UtilsClientImpl utilsClient;
+
+
+
+
+}
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 97be16f..2cd8bc4 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
@@ -358,16 +358,59 @@
                     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 ((b.mediate_unit_id is not null and c.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 terms.statistics != null">
-                    and ((b.mediate_unit_id is not null and c.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.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})
+                    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 !=''">
@@ -850,13 +893,16 @@
     <!--  统计分析(区域)  -->
     <select id="statisticsArea" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsAreaDTO">
         SELECT
-        <if test="terms.areaType == null or terms.areaType ==''">
-            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 =="1"'>
-            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 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"'>
+            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,
@@ -871,7 +917,6 @@
         LEFT JOIN dyh_ct_unit c ON b.mediate_unit_id = c.id
         <include refid="where-part-all"/>
         group by areaCode
-
     </select>
     <!--  统计分析(基础)  -->
     <select id="statisticsBase" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsBaseDTO">
diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoUnfoldMapper.xml b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoUnfoldMapper.xml
index de1ed1d..154deb1 100644
--- a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoUnfoldMapper.xml
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoUnfoldMapper.xml
@@ -13,6 +13,8 @@
     <resultMap id="dataResult" type="cn.huge.module.cases.domain.po.CaseInfoUnfold">
             <result property="id" column="id"/>
             <result property="acceptTime" column="accept_time"/>
+            <result property="belongUnitId" column="belong_unit_id"/>
+            <result property="belongUnitName" column="belong_unit_name"/>
             <result property="mediateUnitId" column="mediate_unit_id"/>
             <result property="mediateUnitName" column="mediate_unit_name"/>
             <result property="mediateDeptId" column="mediate_dept_id"/>
@@ -65,6 +67,8 @@
     <sql id="column-part">
         id,
         accept_time,
+        belong_unit_id,
+        belong_unit_name,
         mediate_unit_id,
         mediate_unit_name,
         mediate_dept_id,
@@ -114,6 +118,8 @@
     <!-- 更新实体字段 -->
     <sql id="set-part">
             <if test="entity.acceptTime != null">accept_time = #{entity.acceptTime},</if>
+            <if test="entity.belongUnitId != null">belong_unit_id = #{entity.belongUnitId},</if>
+            <if test="entity.belongUnitName != null">belong_unit_name = #{entity.belongUnitName},</if>
             <if test="entity.mediateUnitId != null">mediate_unit_id = #{entity.mediateUnitId},</if>
             <if test="entity.mediateUnitName != null">mediate_unit_name = #{entity.mediateUnitName},</if>
             <if test="entity.mediateDeptId != null">mediate_dept_id = #{entity.mediateDeptId},</if>
@@ -170,6 +176,12 @@
                 <if test="terms.acceptTime != null and terms.acceptTime !=''">
                     and accept_time = #{terms.acceptTime}
                 </if>
+                <if test="terms.belongUnitId != null and terms.belongUnitId !=''">
+                    and belong_unit_id = #{terms.belongUnitId}
+                </if>
+                <if test="terms.belongUnitName != null and terms.belongUnitName !=''">
+                    and belong_unit_name = #{terms.belongUnitName}
+                </if>
                 <if test="terms.mediateUnitId != null and terms.mediateUnitId !=''">
                     and mediate_unit_id = #{terms.mediateUnitId}
                 </if>
diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/po/CaseInfoUnfold.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/po/CaseInfoUnfold.java
index f69440a..66e3f37 100644
--- a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/po/CaseInfoUnfold.java
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/po/CaseInfoUnfold.java
@@ -33,6 +33,18 @@
     private Date acceptTime;
 
     /**
+    * 实际归属组织编号
+    */
+    @TableField(value = "belong_unit_id")
+    private String belongUnitId;
+
+    /**
+    * 实际归属组织名称
+    */
+    @TableField(value = "belong_unit_name")
+    private String belongUnitName;
+
+    /**
     * 实际调解组织编号
     */
     @TableField(value = "mediate_unit_id")
diff --git a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java
index e154e08..e64388e 100644
--- a/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java
+++ b/dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java
@@ -1017,22 +1017,37 @@
         }
 
         //目前没有村居,所以区和街道进来都是按街道展示
-        String areaType = null;//兼容白云数据
+        String areaType = null;
+        String childAreaType = null;
         List<Integer> unitGrades = new ArrayList<>();
+        List<Integer> childUnitGrades = new ArrayList<>();
+        Boolean isLast = false;
         if(ObjectUtils.isNotEmpty(terms.get("queRoad"))){
-            terms.put("areaType","2");
-            areaType = "2";
+            terms.remove("queArea");
+            terms.remove("queCity");
+            areaType = "3";
+            childAreaType = "4";
             areaCode = terms.get("queRoad")+"";
             unitGrades.add(3);
             unitGrades.add(4);
+            childUnitGrades.add(3);
+            childUnitGrades.add(4);
+            isLast = true;
         }else if(ObjectUtils.isNotEmpty(terms.get("queArea"))){
-            terms.put("areaType","2");
+            terms.remove("queCity");
             areaType = "2";
+            childAreaType = "3";
             areaCode = terms.get("queArea")+"";
             unitGrades.add(2);
+            childUnitGrades.add(3);
+            childUnitGrades.add(4);
         }else{
             areaType = "1";
+            childAreaType = "2";
             unitGrades.add(1);
+            childUnitGrades.add(2);
+            childUnitGrades.add(3);
+            childUnitGrades.add(4);
             areaCode = ctUnitDTO.getCity();
         }
         //基础数据统计
@@ -1047,28 +1062,47 @@
         caseStatisticsBaseDTO.setTwoLevelRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getTwoLevelNum() * 100, levelTotalNum, 1));
         caseStatisticsBaseDTO.setThreeLevelRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getThreeLevelNum() * 100, levelTotalNum, 1));
         //区域数据统计
-        List<CaseStatisticsAreaDTO> caseStatisticsAreaDTOS = mapper.statisticsArea(terms);
-        if (ObjectUtils.isEmpty(caseStatisticsAreaDTOS)) {
-            caseStatisticsAreaDTOS = new ArrayList<>();
+        List<CaseStatisticsAreaDTO> caseStatisticsAreaDTOS = new ArrayList<>();
+        if(!isLast){
+            terms.put("areaType",childAreaType);
+            terms.put("unitGrades",childUnitGrades);
+            caseStatisticsAreaDTOS = mapper.statisticsArea(terms);
+            if (ObjectUtils.isEmpty(caseStatisticsAreaDTOS)) {
+                caseStatisticsAreaDTOS = new ArrayList<>();
+            }
         }
+
+        //本级区数据
+        terms.put("areaType",areaType);
+        terms.put("unitGrades",unitGrades);
+        List<CaseStatisticsAreaDTO> allAreas = mapper.statisticsArea(terms);
         CaseStatisticsAreaDTO allArea = new CaseStatisticsAreaDTO();
+        if (ObjectUtils.isNotEmpty(allAreas)) {
+            allArea = allAreas.get(0);
+        }
+        terms.remove("unitGrades");
         allArea.setAreaName("本级");
-        allArea.setAreaCode("1");
+        allArea.setAreaCode("0");
         List<String> areaCodeList = new ArrayList<>();
         List<CaseStatisticsAreaDTO> areaList = new ArrayList<>();
         List<String> areaNames = new ArrayList<>();//为兼容白云区数据
+        Integer areaTotal = allArea.getCaseNum();
         for (CaseStatisticsAreaDTO caseStatisticsAreaDTO : caseStatisticsAreaDTOS) {
             areaNames.add(caseStatisticsAreaDTO.getAreaName());
+            areaList.add(caseStatisticsAreaDTO);
+            areaCodeList.add(caseStatisticsAreaDTO.getAreaCode());
+            areaTotal = areaTotal + caseStatisticsAreaDTO.getCaseNum();
+
             //本及:承办单位是本及和没有承办单位并且没有下级区域编码
-            if(ObjectUtils.isEmpty(caseStatisticsAreaDTO.getAreaCode()) || unitGrades.contains(caseStatisticsAreaDTO.getUnitGrade())){
-                allArea.setCaseNum(dellNull(caseStatisticsAreaDTO.getCaseNum()) + dellNull(allArea.getCaseNum()));
-                allArea.setResolveNum(dellNull(caseStatisticsAreaDTO.getResolveNum()) + dellNull(allArea.getResolveNum()));
-                allArea.setUnResolveNum(dellNull(caseStatisticsAreaDTO.getUnResolveNum()) + dellNull(allArea.getUnResolveNum()));
-                allArea.setResolveingNum(dellNull(caseStatisticsAreaDTO.getResolveingNum()) + dellNull(allArea.getResolveingNum()));
-            }else{
-                areaList.add(caseStatisticsAreaDTO);
-                areaCodeList.add(caseStatisticsAreaDTO.getAreaCode());
-            }
+//            if(ObjectUtils.isEmpty(caseStatisticsAreaDTO.getAreaCode()) || unitGrades.contains(caseStatisticsAreaDTO.getUnitGrade())){
+//                allArea.setCaseNum(dellNull(caseStatisticsAreaDTO.getCaseNum()) + dellNull(allArea.getCaseNum()));
+//                allArea.setResolveNum(dellNull(caseStatisticsAreaDTO.getResolveNum()) + dellNull(allArea.getResolveNum()));
+//                allArea.setUnResolveNum(dellNull(caseStatisticsAreaDTO.getUnResolveNum()) + dellNull(allArea.getUnResolveNum()));
+//                allArea.setResolveingNum(dellNull(caseStatisticsAreaDTO.getResolveingNum()) + dellNull(allArea.getResolveingNum()));
+//            }else{
+//                areaList.add(caseStatisticsAreaDTO);
+//                areaCodeList.add(caseStatisticsAreaDTO.getAreaCode());
+//            }
         }
         areaList.add(allArea);
         if("1".equals(areaType)){

--
Gitblit v1.8.0