Commit 521050c1 by wuchao

统计

parent a117e471
...@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
@Api("重点人员统计") @Api("重点人员统计")
...@@ -17,8 +18,6 @@ public class KeyPersonStatisticsImpl { ...@@ -17,8 +18,6 @@ public class KeyPersonStatisticsImpl {
@Autowired @Autowired
CommonService commonService; CommonService commonService;
private final String SUCCESS = "success";
private String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyPersonStatistics."; private String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyPersonStatistics.";
/** /**
...@@ -66,7 +65,8 @@ public class KeyPersonStatisticsImpl { ...@@ -66,7 +65,8 @@ public class KeyPersonStatisticsImpl {
* 构建分类数据 * 构建分类数据
*/ */
private Object buildCategories(Map<String, Object> data) { private Object buildCategories(Map<String, Object> data) {
Map<String, Object>[] categories = new Map[3]; @SuppressWarnings("unchecked")
Map<String, Object>[] categories = (Map<String, Object>[]) new Map[3];
Map<String, Object> categoryA = new HashMap<>(); Map<String, Object> categoryA = new HashMap<>();
categoryA.put("name", "A类"); categoryA.put("name", "A类");
...@@ -109,25 +109,32 @@ public class KeyPersonStatisticsImpl { ...@@ -109,25 +109,32 @@ public class KeyPersonStatisticsImpl {
* @return * @return
*/ */
@ApiOperation(value = "回访统计数据", desc = "回访统计数据") @ApiOperation(value = "回访统计数据", desc = "回访统计数据")
public Map<String, Object> getOverdueWarningStatistics(Map<String, Object> map) { public Map<String, Object> getOverdueWarningStatistics(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>(); if (params == null) {
params = new HashMap<>();
}
// 获取重点人员总数 Object _user = params.get("_user");
Map<String, Object> peopleCountMap = commonService.getObject(namespace + "selectPeopleCount", new HashMap<>()); if (_user != null) {
Map<String, String> pos = DataScopeUtil.getPosition(_user);
params.put("scope_grade", pos.get("grade"));
params.put("scope_area_id", pos.get("area_id"));
Map<String, Object> officeType = DataScopeUtil.getOfficeType(_user);
if (officeType != null) {
params.put("office_label", officeType.get("office_label"));
params.put("office_value", officeType.get("office_value"));
}
}
Map<String, Object> result = new HashMap<>();
params.put("sys_type", "6");
Map<String, Object> minorsMap = commonService.getObject(namespace + "getVisitRecord", params);
params.put("sys_type", "2");
Map<String, Object> releasedMap = commonService.getObject(namespace + "getVisitRecord", params);
params.put("sys_type", "3");
Map<String, Object> mentalPatientMap = commonService.getObject(namespace + "getVisitRecord", params);
// 获取精神病、未成年、刑满释放待办数据
//total_pending: 待办数量 - 办理状态为待办(do_status='0')且未临期(is_overdue='0')的回访记录数
//total_done: 已办数量 - 办理状态为已办(do_status='1')的回访记录数
//total_overdue: 超期未办数量 - 办理状态为超期未办(do_status='2')的回访记录数
//total_overdue_pending: 临期未办数量 - 办理状态为待办(do_status='0')且已临期(is_overdue='1')的回访记录数
Map<String, Object> mentalPatientMap = commonService.getObject(namespace + "selectMentalPatientOverdueWarningCount", new HashMap<>());
Map<String, Object> minorsMap = commonService.getObject(namespace + "selectMinorsOverdueWarningCount", new HashMap<>());
Map<String, Object> releasedMap = commonService.getObject(namespace + "selectReleasedOverdueWarningCount", new HashMap<>());
// 提取各类人员数据
int mentalPatientCount = getIntValue(peopleCountMap, "mental_patient_count");
int minorsCount = getIntValue(peopleCountMap, "minors_count");
int releasedCount = getIntValue(peopleCountMap, "released_count");
// 精神病患者统计 // 精神病患者统计
int mentalCompleted = getIntValue(mentalPatientMap, "total_done"); int mentalCompleted = getIntValue(mentalPatientMap, "total_done");
...@@ -165,7 +172,8 @@ public class KeyPersonStatisticsImpl { ...@@ -165,7 +172,8 @@ public class KeyPersonStatisticsImpl {
// 构建精神病患者数据 // 构建精神病患者数据
Map<String, Object> mentalPatient = new HashMap<>(); Map<String, Object> mentalPatient = new HashMap<>();
mentalPatient.put("total", mentalPatientCount); int mentalTotal = mentalCompleted + mentalUncompleted + mentalNearOverdue + mentalOverdue;
mentalPatient.put("total", mentalTotal);
mentalPatient.put("completed", mentalCompleted); mentalPatient.put("completed", mentalCompleted);
mentalPatient.put("uncompleted", mentalUncompleted); mentalPatient.put("uncompleted", mentalUncompleted);
mentalPatient.put("nearOverdue", mentalNearOverdue); mentalPatient.put("nearOverdue", mentalNearOverdue);
...@@ -174,7 +182,8 @@ public class KeyPersonStatisticsImpl { ...@@ -174,7 +182,8 @@ public class KeyPersonStatisticsImpl {
// 构建刑满释放人员数据 // 构建刑满释放人员数据
Map<String, Object> released = new HashMap<>(); Map<String, Object> released = new HashMap<>();
released.put("total", releasedCount); int releasedTotal = releasedCompleted + releasedUncompleted + releasedNearOverdue + releasedOverdue;
released.put("total", releasedTotal);
released.put("completed", releasedCompleted); released.put("completed", releasedCompleted);
released.put("uncompleted", releasedUncompleted); released.put("uncompleted", releasedUncompleted);
released.put("nearOverdue", releasedNearOverdue); released.put("nearOverdue", releasedNearOverdue);
...@@ -183,7 +192,8 @@ public class KeyPersonStatisticsImpl { ...@@ -183,7 +192,8 @@ public class KeyPersonStatisticsImpl {
// 构建未成年人数据 // 构建未成年人数据
Map<String, Object> minors = new HashMap<>(); Map<String, Object> minors = new HashMap<>();
minors.put("total", minorsCount); int minorsTotal = minorsCompleted + minorsUncompleted + minorsNearOverdue + minorsOverdue;
minors.put("total", minorsTotal);
minors.put("completed", minorsCompleted); minors.put("completed", minorsCompleted);
minors.put("uncompleted", minorsUncompleted); minors.put("uncompleted", minorsUncompleted);
minors.put("nearOverdue", minorsNearOverdue); minors.put("nearOverdue", minorsNearOverdue);
......
...@@ -151,87 +151,112 @@ ...@@ -151,87 +151,112 @@
) t ) t
</select> </select>
<select id="selectMentalPatientOverdueWarningCount" parameterType="map" resultType="map">
select <select id="getVisitRecord" parameterType="map" resultType="map">
coalesce(sum(case when jkpvr.do_status = '0' and jkpvr.is_overdue = '0' then 1 else 0 end), 0) as total_pending,
coalesce(sum(case when jkpvr.do_status = '1' then 1 else 0 end), 0) as total_done, SELECT
coalesce(sum(case when jkpvr.do_status = '2' then 1 else 0 end), 0) as total_overdue, (
coalesce(sum(case when jkpvr.do_status = '0' and jkpvr.is_overdue = '1' then 1 else 0 end), 0) as total_overdue_pending SELECT COUNT(*)
from jl_key_person_visit_record jkpvr FROM jl_key_person_visit_record
left join jl_key_person jkp on jkp.sys_type = '3' and jkp.id = jkpvr.key_person_id WHERE FIND_IN_SET(key_person_id, GROUP_CONCAT(DISTINCT t1.person_id))
<where> ) AS total_done,
and jkp.id is not null SUM(if(
r.id is NULL
or
(
v.id is NOT NULL
AND r.id is not NULL
AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(DATE_ADD(r.visit_time, INTERVAL v.visit_start_day DAY), '%Y-%m-%d')
AND DATE_FORMAT(NOW(),'%Y-%m-%d') &lt; DATE_FORMAT(DATE_ADD(r.visit_time, INTERVAL v.visit_end_day - v.overdue_warning_day DAY), '%Y-%m-%d')
)
, 1, 0)) AS total_pending,
SUM(if(
v.id is NOT NULL
AND r.id is not NULL
AND DATE_FORMAT(NOW(),'%Y-%m-%d') >= DATE_FORMAT(DATE_ADD(r.visit_time, INTERVAL v.visit_end_day - v.overdue_warning_day DAY), '%Y-%m-%d')
AND DATE_FORMAT(NOW(),'%Y-%m-%d') &lt;= DATE_FORMAT(DATE_ADD(r.visit_time, INTERVAL v.visit_end_day DAY), '%Y-%m-%d')
, 1, 0)) AS total_overdue_pending,
SUM(if(
v.id is NOT NULL
AND r.id is not NULL
AND DATE_FORMAT(NOW(),'%Y-%m-%d') > DATE_FORMAT(DATE_ADD(r.visit_time, INTERVAL v.visit_end_day DAY), '%Y-%m-%d')
, 1, 0)) AS total_overdue
FROM
(
SELECT
kp.id AS person_id,
kp.sys_type,
s.id AS rating_id,
s.rating_type
FROM
(<include refid="getPsersonList"></include>) kp,
jl_key_person_rating_summary s
WHERE
s.key_person_id = kp.id
AND s.is_history = '1'
) t1
LEFT JOIN jl_key_person_visit v ON v.rating_type = t1.rating_type AND v.status = '1' AND v.sys_type_office_label = #{office_label} AND v.rating_dict_type = t1.sys_type
LEFT JOIN jl_key_person_visit_record r ON t1.person_id = r.key_person_id AND r.is_new = '1' AND r.sys_type_office_label = #{office_label}
</select>
<sql id="getPsersonList">
SELECT t1.* FROM
<choose> <choose>
<when test="scope_grade == '3'"> <when test="sys_type != null and (sys_type == '2'.toString() or sys_type == '3'.toString())">
AND jkp.city_id = #{scope_area_id} jl_key_person t1
</when>
<when test="scope_grade == '4'">
AND jkp.area_id = #{scope_area_id}
</when> </when>
<when test="scope_grade == '5'"> <when test="sys_type != null and sys_type == '6'.toString()">
AND jkp.street_id = #{scope_area_id} jl_key_person_minor t1
</when>
<when test="scope_grade == '6'">
AND jkp.community_id = #{scope_area_id}
</when> </when>
<otherwise>
jl_key_person t1
</otherwise>
</choose> </choose>
<where>
<include refid="getPersonWhere"></include>
</where> </where>
</select>
<select id="selectMinorsOverdueWarningCount" parameterType="map" resultType="map"> union ALL
select
coalesce(sum(case when jkpvr.do_status = '0' and jkpvr.is_overdue = '0' then 1 else 0 end), 0) as total_pending, SELECT t1.* FROM
coalesce(sum(case when jkpvr.do_status = '1' then 1 else 0 end), 0) as total_done,
coalesce(sum(case when jkpvr.do_status = '2' then 1 else 0 end), 0) as total_overdue,
coalesce(sum(case when jkpvr.do_status = '0' and jkpvr.is_overdue = '1' then 1 else 0 end), 0) as total_overdue_pending
from jl_key_person_visit_record jkpvr
left join jl_key_person_minor jkpm on jkpm.sys_type = '6' and jkpm.id = jkpvr.key_person_id
<where>
and jkpm.id is not null
<choose> <choose>
<when test="scope_grade == '3'"> <when test="sys_type != null and (sys_type == '2'.toString() or sys_type == '3'.toString())">
AND jkpm.city_id = #{scope_area_id} jl_key_person t1,
</when> </when>
<when test="scope_grade == '4'"> <when test="sys_type != null and sys_type == '6'.toString()">
AND jkpm.area_id = #{scope_area_id} jl_key_person_minor t1,
</when>
<when test="scope_grade == '5'">
AND jkpm.street_id = #{scope_area_id}
</when>
<when test="scope_grade == '6'">
AND jkpm.community_id = #{scope_area_id}
</when> </when>
<otherwise>
jl_key_person t1,
</otherwise>
</choose> </choose>
</where> jl_key_person_rating_dual_person t2
</select> where t1.id = t2.key_person_id
<include refid="getPersonWhere"></include>
</sql>
<select id="selectReleasedOverdueWarningCount" parameterType="map" resultType="map"> <sql id="getPersonWhere">
select
coalesce(sum(case when jkpvr.do_status = '0' and jkpvr.is_overdue = '0' then 1 else 0 end), 0) as total_pending,
coalesce(sum(case when jkpvr.do_status = '1' then 1 else 0 end), 0) as total_done,
coalesce(sum(case when jkpvr.do_status = '2' then 1 else 0 end), 0) as total_overdue,
coalesce(sum(case when jkpvr.do_status = '0' and jkpvr.is_overdue = '1' then 1 else 0 end), 0) as total_overdue_pending
from jl_key_person_visit_record jkpvr
left join jl_key_person jkp on jkp.sys_type = '2' and jkp.id = jkpvr.key_person_id
<where>
and jkp.id is not null
<choose> <choose>
<when test="scope_grade == '3'"> <when test="scope_grade == '3'.toString()">
AND jkp.city_id = #{scope_area_id} AND t1.city_id = #{scope_area_id}
</when> </when>
<when test="scope_grade == '4'"> <when test="scope_grade == '4'.toString()">
AND jkp.area_id = #{scope_area_id} AND t1.area_id = #{scope_area_id}
</when> </when>
<when test="scope_grade == '5'"> <when test="scope_grade == '5'.toString()">
AND jkp.street_id = #{scope_area_id} AND t1.street_id = #{scope_area_id}
</when> </when>
<when test="scope_grade == '6'"> <when test="scope_grade == '6'.toString() ">
AND jkp.community_id = #{scope_area_id} AND t1.community_id = #{scope_area_id}
</when> </when>
</choose> </choose>
</where> AND t1.sys_type = #{sys_type}
</select> </sql>
<select id="selectMentalPatientRatingCount1" parameterType="map" resultType="map"> <select id="selectMentalPatientRatingCount1" parameterType="map" resultType="map">
select select
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
WHERE WHERE
s.key_person_id = kp.id s.key_person_id = kp.id
AND s.is_history = '1' AND s.is_history = '1'
AND kp.sys_type = #{sys_type}
) t1 ) t1
LEFT JOIN jl_key_person_visit v ON v.rating_type = t1.rating_type AND v.status = '1' AND v.sys_type_office_label = #{params.office_label} AND v.rating_dict_type = t1.sys_type LEFT JOIN jl_key_person_visit v ON v.rating_type = t1.rating_type AND v.status = '1' AND v.sys_type_office_label = #{params.office_label} AND v.rating_dict_type = t1.sys_type
LEFT JOIN jl_key_person_visit_record r ON t1.person_id = r.key_person_id AND r.is_new = '1' AND r.sys_type_office_label = #{params.office_label} LEFT JOIN jl_key_person_visit_record r ON t1.person_id = r.key_person_id AND r.is_new = '1' AND r.sys_type_office_label = #{params.office_label}
...@@ -117,6 +118,9 @@ ...@@ -117,6 +118,9 @@
<when test="params.sys_type != null and params.sys_type == '6'.toString()"> <when test="params.sys_type != null and params.sys_type == '6'.toString()">
jl_key_person_minor t1 jl_key_person_minor t1
</when> </when>
<otherwise>
jl_key_person t1
</otherwise>
</choose> </choose>
<where> <where>
<include refid="getPersonWhere"></include> <include refid="getPersonWhere"></include>
...@@ -132,6 +136,9 @@ ...@@ -132,6 +136,9 @@
<when test="params.sys_type != null and params.sys_type == '6'.toString()"> <when test="params.sys_type != null and params.sys_type == '6'.toString()">
jl_key_person_minor t1, jl_key_person_minor t1,
</when> </when>
<otherwise>
jl_key_person t1,
</otherwise>
</choose> </choose>
jl_key_person_rating_dual_person t2 jl_key_person_rating_dual_person t2
where t1.id = t2.key_person_id where t1.id = t2.key_person_id
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论