|
@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.message.BaseServiceNewsDao;
|
|
|
import com.yihu.jw.care.service.patient.CarePatientService;
|
|
|
import com.yihu.jw.care.service.role.RoleService;
|
|
|
import com.yihu.jw.care.util.CommonUtil;
|
|
|
import com.yihu.jw.care.util.ConstantUtil;
|
|
|
import com.yihu.jw.care.vo.NumVo;
|
|
@ -14,14 +16,13 @@ import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.entity.care.message.BaseServiceNews;
|
|
|
import com.yihu.jw.es.es.ElasticSearchHelperUtil;
|
|
|
import com.yihu.jw.es.util.ElasticsearchUtil;
|
|
|
import com.yihu.jw.es.util.SaveModel;
|
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.message.dao.MessageDao;
|
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
@ -29,25 +30,16 @@ import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.nlpcn.es4sql.jdbc.ObjectResult;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.persistence.Transient;
|
|
|
import javax.persistence.criteria.CriteriaBuilder;
|
|
|
import java.awt.print.Pageable;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
@ -94,6 +86,10 @@ public class StatisticsService {
|
|
|
private String esType;
|
|
|
@Autowired
|
|
|
private CarePatientService carePatientService;
|
|
|
@Autowired
|
|
|
private RoleService roleService;
|
|
|
@Autowired
|
|
|
private BaseServiceNewsDao baseServiceNewsDao;
|
|
|
|
|
|
private static final String defalutArea = "330100";
|
|
|
|
|
@ -118,6 +114,9 @@ public class StatisticsService {
|
|
|
// 39 老人-生活照料-服务工单数
|
|
|
// 44 老人-生活照料-代预约
|
|
|
// 54 新生儿-上门辅导-工单发起数
|
|
|
// 64 活动浏览数
|
|
|
// 65 课程播放数
|
|
|
// 66 活动报名数
|
|
|
|
|
|
String index = "28,31,35,37,39,44,54";
|
|
|
String[] indexes = index.split(",");
|
|
@ -126,6 +125,17 @@ public class StatisticsService {
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
|
|
|
res.put("index_" + ind, saveModel.getResult2().longValue());
|
|
|
}
|
|
|
// activity-1 活动浏览次数64
|
|
|
// activity-2 公艺课程播放65
|
|
|
// activity-3 公艺课程播放65
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "64", SaveModel.timeLevel_DDL);
|
|
|
res.put("activity_1", saveModel.getResult2().longValue());
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "65", SaveModel.timeLevel_DDL);
|
|
|
res.put("activity_2", saveModel.getResult2().longValue());
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "66", SaveModel.timeLevel_DDL);
|
|
|
res.put("activity_3", saveModel.getResult2().longValue());
|
|
|
|
|
|
|
|
|
//41紧急预警43安防要与实时一样,查sql
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
|
|
|
List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
@ -159,21 +169,6 @@ public class StatisticsService {
|
|
|
//居民健康标签纬度
|
|
|
res.put("patientLabelStatistic", statisticsOrderServer("47", endDate, 2, "2"));
|
|
|
|
|
|
// activity-1 活动浏览次数
|
|
|
// activity-2 公艺课程播放
|
|
|
res.put("activity_1", 0);
|
|
|
res.put("activity_2", 0);
|
|
|
String sql = " SELECT activity_type, COUNT(id) total FROM base_activity_click WHERE activity_type IN (1, 2) GROUP BY activity_type";
|
|
|
List<Map<String, Object>> lists = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> tmp : lists) {
|
|
|
Integer num = Integer.parseInt(tmp.get("total").toString());
|
|
|
res.put("activity_" + tmp.get("activity_type").toString(), num);
|
|
|
}
|
|
|
|
|
|
//activity-3 幼儿活动报名-总数
|
|
|
sql = " select count(id) as total from base_child_activity_registration ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
res.put("activity_3", count);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@ -194,7 +189,8 @@ public class StatisticsService {
|
|
|
/*---------sql----------*/
|
|
|
// 3 幼儿活动
|
|
|
if ("3".equals(type)) {
|
|
|
sqlbuff.append("SELECT count(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') as `range` FROM base_child_activity_registration WHERE DATE_SUB(CURDATE(), INTERVAL " + day + " DAY) <= date(create_time) GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
|
|
|
sqlbuff.append("SELECT count(id) amount,DATE_FORMAT(create_time,'%Y-%m-%d') as `range` FROM base_child_activity_registration WHERE DATE_SUB(CURDATE(), INTERVAL " + day + " DAY) <= date(create_time) " +
|
|
|
" and org_code not in (SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org') GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') ORDER BY create_time");
|
|
|
listMaps = jdbcTemplate.queryForList(String.valueOf(sqlbuff));
|
|
|
res.put("count", listMaps);
|
|
|
}
|
|
@ -315,7 +311,7 @@ public class StatisticsService {
|
|
|
}
|
|
|
|
|
|
/*幼儿活动报名 总数*/
|
|
|
String sqlActivity = " select count(id) as total from base_child_activity_registration ";
|
|
|
String sqlActivity = " select count(id) as total from base_child_activity_registration where org_code not in (SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org') ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sqlActivity, Integer.class);
|
|
|
res.put("activity_3", count);
|
|
|
}
|
|
@ -334,12 +330,14 @@ public class StatisticsService {
|
|
|
|
|
|
JSONObject res = new JSONObject();
|
|
|
String medicalInstitutionSql = "SELECT COUNT(1) FROM base_org WHERE (type = 1 OR type = 2) AND del = 1 " + orgFilter;
|
|
|
String elderlyCarServiceSql = "SELECT COUNT(1) FROM base_org WHERE type = 3 AND del = 1" + orgFilter;
|
|
|
String elderlyCarServiceSql = "SELECT COUNT(1) FROM base_org WHERE type = 3 AND del = 1 and code not in ('zdjsylfwyxgszhfgs') " + orgFilter;
|
|
|
String childcareInstitutionsssSql = "SELECT COUNT(1) FROM base_org WHERE type = 4 AND del = 1" + orgFilter;
|
|
|
String careCenterNumSql = "SELECT COUNT(1) FROM base_org WHERE type = 6 AND del = 1" + orgFilter;
|
|
|
|
|
|
//社工和教师注册人数
|
|
|
Integer doctorNum = 0;
|
|
|
Integer helperNum = 0;
|
|
|
Integer helper4Num = 0;
|
|
|
Integer teacherNum = 0;
|
|
|
String sql2 = "SELECT COUNT(a.id) c,a.doctor_level from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +
|
|
|
"and a.doctor_level is not null and h.org_code not in ( " +
|
|
@ -357,6 +355,10 @@ public class StatisticsService {
|
|
|
helperNum = num;
|
|
|
continue;
|
|
|
}
|
|
|
if ("4".equals(archive_type)) {
|
|
|
helper4Num = num;
|
|
|
continue;
|
|
|
}
|
|
|
if ("3".equals(archive_type)) {
|
|
|
teacherNum = num;
|
|
|
}
|
|
@ -364,11 +366,14 @@ public class StatisticsService {
|
|
|
Integer medicalInstitutionNum = jdbcTemplate.queryForObject(medicalInstitutionSql, Integer.class);
|
|
|
Integer elderlyCarServiceNum = jdbcTemplate.queryForObject(elderlyCarServiceSql, Integer.class);
|
|
|
Integer childcareInstitutionsssNum = jdbcTemplate.queryForObject(childcareInstitutionsssSql, Integer.class);
|
|
|
Integer careCenterNum = jdbcTemplate.queryForObject(careCenterNumSql, Integer.class);
|
|
|
res.put("medicalInstitutionNum", medicalInstitutionNum); //医疗结构
|
|
|
res.put("elderlyCarServiceNum", elderlyCarServiceNum); //养老机构
|
|
|
res.put("childcareInstitutionsssNum", childcareInstitutionsssNum); //托育机构
|
|
|
res.put("careCenterNum", careCenterNum); //照料中心
|
|
|
res.put("doctorNum", doctorNum); //医生
|
|
|
res.put("helperNum", helperNum); //社工
|
|
|
res.put("helper4Num", helper4Num); //助老员
|
|
|
res.put("teacherNum", teacherNum); //教师
|
|
|
return res;
|
|
|
}
|
|
@ -377,19 +382,18 @@ public class StatisticsService {
|
|
|
public JSONObject realTimeDataNew() throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
|
String filter = "";
|
|
|
String userfilter = "";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if (listtmp.size() > 0) {
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
filter = " and id not in ('" + orgCodes + "')";
|
|
|
userfilter = " not in ('" + orgCodes + "') ";
|
|
|
}
|
|
|
|
|
|
Integer olderTotal = 0;
|
|
|
Integer childTotal = 0;
|
|
|
String sql1 = "SELECT COUNT(*) c,archive_type*1 as archive_type from base_patient WHERE archive_type is not null and del='1' ";
|
|
|
sql1 += filter;
|
|
|
String sql1 = "SELECT COUNT(*) c,archive_type*1 as archive_type from base_patient WHERE archive_type is not null and del='1' and id "+userfilter;
|
|
|
sql1 += " GROUP BY archive_type";
|
|
|
|
|
|
List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
|
|
@ -412,17 +416,15 @@ public class StatisticsService {
|
|
|
|
|
|
sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
|
|
|
listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
filter = "";
|
|
|
String filter2 = "";
|
|
|
String orgFilter = "";
|
|
|
if (listtmp.size() > 0) {
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
filter = " and hospital not in ('" + orgCodes + "') ";
|
|
|
filter2 = " and org_code not in ('" + orgCodes + "') ";
|
|
|
orgFilter = " not in ('" + orgCodes + "') ";
|
|
|
}
|
|
|
String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status <> -1 " + filter2;
|
|
|
String emergencyCallSql = "SELECT COUNT(1) FROM base_emergency_assistance_order WHERE status <> -1 and org_code " + orgFilter;
|
|
|
Integer emergencyCallNum = jdbcTemplate.queryForObject(emergencyCallSql, Integer.class);
|
|
|
String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 " + filter;
|
|
|
String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 and hospital " + orgFilter;
|
|
|
Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql, Integer.class);
|
|
|
res.put("olderTotal", olderTotal); //老人注册人数
|
|
|
res.put("childTotal", childTotal); //儿童注册人数
|
|
@ -430,6 +432,27 @@ public class StatisticsService {
|
|
|
res.put("securityEquipmentNum", securityEquipmentNum); //安防设备
|
|
|
res.put("emergencyCallNum", emergencyCallNum); //紧急呼叫的次数
|
|
|
res.put("securityMonitoringNum", securityMonitoringNum); //安防监护触发工单的次数
|
|
|
//离线的设备数 超过6小时未受理的预警数 超6小时未响应服务(审核照料发起6小时未接单)
|
|
|
sqltmp = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where (dev.contact_status=0 or dev.contact_status is null ) and pd.user "+userfilter;
|
|
|
Long count = jdbcTemplate.queryForObject(sqltmp,Long.class);//离线设备
|
|
|
res.put("offlineDevice", count);
|
|
|
sqltmp = " select sum(total) from ( " +
|
|
|
"select count(o.id) total from " +
|
|
|
"base_emergency_assistance_order o INNER JOIN base_patient p on o.patient = p.id where status=1 and o.patient " +userfilter+
|
|
|
" and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=6) and not EXISTS ( " +
|
|
|
"select 1 from base_emergency_warn_log log where log.order_id = o.id) " +
|
|
|
"union all " +
|
|
|
"select count(o.id) total from " +
|
|
|
"base_security_monitoring_order o INNER JOIN base_patient p on o.patient = p.id where status=1 and o.patient " +userfilter+
|
|
|
" and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=6) and not EXISTS ( " +
|
|
|
"select 1 from base_emergency_warn_log log where log.order_id = o.id))B ";
|
|
|
count = jdbcTemplate.queryForObject(sqltmp,Long.class);
|
|
|
res.put("overTimeWarnOrder", count);//超过6小时未受理的预警数
|
|
|
sqltmp = " select count(o.id) from base_life_care_order o where `status`=1 and (TIMESTAMPDIFF(hour,o.create_time,NOW())) >=6 and o.hospital "+orgFilter;
|
|
|
count = jdbcTemplate.queryForObject(sqltmp,Long.class);
|
|
|
res.put("overTimeServerOrder", count);//超6小时未响应服务
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@ -450,8 +473,8 @@ public class StatisticsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String sql = "select * from base_login_log where create_time>='" + dateStr + "' " + filter + " order by create_time desc limit " + (page - 1) * size + "," + size;
|
|
|
String sqlCount = "select count(id) from base_login_log where create_time>='" + dateStr + "' " + filter;
|
|
|
String sql = "select * from base_login_log where login_type<>1 and create_time>='" + dateStr + "' " + filter + " order by create_time desc limit " + (page - 1) * size + "," + size;
|
|
|
String sqlCount = "select count(id) from base_login_log where login_type<>1 and create_time>='" + dateStr + "' " + filter;
|
|
|
Long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
|
|
|
List<BaseLoginLogDO> loginLogDOs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseLoginLogDO.class));
|
|
|
for (BaseLoginLogDO log : loginLogDOs) {
|
|
@ -638,8 +661,11 @@ public class StatisticsService {
|
|
|
|
|
|
/**
|
|
|
* 平台人员实时统计
|
|
|
* @param area 查询区域 目前仅支持查询老人、社工、家属
|
|
|
* @param level 区域等级 2市3区4机构5团队6医生
|
|
|
*/
|
|
|
public JSONObject platformPeople() {
|
|
|
public JSONObject platformPeople(String area,Integer level) {
|
|
|
String areaFilter = " ";
|
|
|
JSONObject result = new JSONObject();
|
|
|
Integer olderTotal = 0;
|
|
|
Integer childTotal = 0;
|
|
@ -659,6 +685,14 @@ public class StatisticsService {
|
|
|
Integer olderFamilyOn = 0;
|
|
|
Integer olderFamilyOff = 0;
|
|
|
Integer olderFamilyBinding = 0;//家属绑定老人数量
|
|
|
Integer helper4On=0;
|
|
|
Integer helper4Off=0;
|
|
|
Integer helper4Total=0;
|
|
|
Integer unSignOlderTotal=0;
|
|
|
Integer unSignOlderOff=0;
|
|
|
Integer unSignOlderOn=0;
|
|
|
|
|
|
|
|
|
//儿童注册人数
|
|
|
String childFilter = "";
|
|
|
String sqlChildtmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
@ -680,7 +714,6 @@ public class StatisticsService {
|
|
|
childOff += num;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//老人
|
|
|
String oldFilter = "";
|
|
|
String sqlOldtmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
|
|
@ -691,9 +724,14 @@ public class StatisticsService {
|
|
|
oldFilter = " and a.id not in ('" + orgCodes + "')";
|
|
|
}
|
|
|
|
|
|
|
|
|
String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1" +
|
|
|
" and del='1' " + oldFilter + " GROUP BY online";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
areaFilter = " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+area+"') ";
|
|
|
}
|
|
|
String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and sign_status=1 " +
|
|
|
" and del='1' "+areaFilter+" " + oldFilter + " GROUP BY online";
|
|
|
List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
|
|
|
for (Map<String, Object> map : list1) {
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
@ -707,8 +745,27 @@ public class StatisticsService {
|
|
|
olderTotal = olderOff + olderOn;
|
|
|
childTotal = childOff + childOn;
|
|
|
|
|
|
sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and (sign_status=0 or sign_status is null ) " +
|
|
|
" and del='1' " + oldFilter + " GROUP BY online";
|
|
|
list1 = jdbcTemplate.queryForList(sql1);
|
|
|
for (Map<String, Object> map : list1) {
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
|
Integer online = Integer.valueOf(map.get("online").toString());
|
|
|
if (online == 1) {
|
|
|
unSignOlderOn += num;
|
|
|
} else {
|
|
|
unSignOlderOff += num;
|
|
|
}
|
|
|
}
|
|
|
unSignOlderTotal = unSignOlderOff+unSignOlderOn;
|
|
|
|
|
|
//社工和教师注册人数
|
|
|
String sql2 = "SELECT COUNT(a.id) c,a.doctor_level,IFNULL(a.on_line,0) online from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
areaFilter = " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
|
|
|
" and mem.team_code='"+area+"' and mem.del=1 ) ";
|
|
|
}
|
|
|
String sql2 = "SELECT COUNT(a.id) c,a.doctor_level,IFNULL(a.on_line,0) online " +
|
|
|
"from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +areaFilter+
|
|
|
"and a.doctor_level is not null and h.org_code not in ( " +
|
|
|
"SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' " +
|
|
|
") GROUP BY a.doctor_level,on_line";
|
|
@ -732,9 +789,17 @@ public class StatisticsService {
|
|
|
teacherOff += num;
|
|
|
}
|
|
|
}
|
|
|
if ("4".equals(archive_type)) {
|
|
|
if (online == 1) {
|
|
|
helper4On += num;
|
|
|
} else {
|
|
|
helper4Off += num;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
helperTotal = helperOff + helperOn;
|
|
|
teacherTotal = teacherOff + teacherOn;
|
|
|
helper4Total = helper4On + helper4Off;
|
|
|
|
|
|
//老人家属
|
|
|
String olderRelativeFilter = "";
|
|
@ -745,7 +810,21 @@ public class StatisticsService {
|
|
|
orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
olderRelativeFilter = " and t2.id not in ('" + orgCodes + "') ";
|
|
|
}
|
|
|
sql2 = " select count(id) count,if(openid is null,0,1) online from base_patient t2 where archive_type=3 and del=1 "+olderRelativeFilter+" GROUP BY online; ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
//有社区只查询该社区老人的家属列表
|
|
|
areaFilter = " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = t3.id and r.team_code='"+area+"' ) ";
|
|
|
|
|
|
sql2 = " select count(distinct t2.id) count,if(t2.openid is null,0,1) online " +
|
|
|
"from base_patient t2 left JOIN base_patient_family_member t1 on t1.family_member = t2.id " +
|
|
|
"left join base_patient t3 on t3.id = t1.patient " +
|
|
|
"where t2.archive_type=3 and t2.del=1 and t3.archive_type=1 and t3.del=1 "+olderRelativeFilter+areaFilter + "GROUP BY online ";
|
|
|
|
|
|
}else {
|
|
|
sql2 = " select count(id) count,if(openid is null,0,1) online from base_patient t2 where archive_type=3 and del=1 "+olderRelativeFilter+" GROUP BY online; ";
|
|
|
}
|
|
|
List<Map<String, Object>> oldFamilyList2 = jdbcTemplate.queryForList(sql2);
|
|
|
for(Map<String,Object>tmp:oldFamilyList2){
|
|
|
Integer num = Integer.valueOf(tmp.get("count").toString());
|
|
@ -759,26 +838,39 @@ public class StatisticsService {
|
|
|
}
|
|
|
olderFamilyTotal = olderFamilyOff+olderFamilyOn;
|
|
|
//家属绑定老人数量
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
areaFilter = " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = t3.id and r.team_code='"+area+"' ) ";
|
|
|
}
|
|
|
sql2 = " select count(distinct t3.id) total from base_patient t2 left JOIN base_patient_family_member t1 on t1.family_member = t2.id " +
|
|
|
" Inner join base_patient t3 on t3.id = t1.patient " +
|
|
|
" where t2.archive_type=3 and t2.del=1 and t3.archive_type=1 and t3.del=1 ";
|
|
|
" where t2.archive_type=3 and t2.del=1 and t3.archive_type=1 and t3.del=1 "+areaFilter ;
|
|
|
|
|
|
olderFamilyBinding = jdbcTemplate.queryForObject(sql2,Integer.class);
|
|
|
|
|
|
//helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板
|
|
|
//helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板 olderFamily老人家属
|
|
|
//helper4助老员 unSignOlder社区老人
|
|
|
result.put("olderTotal", olderTotal);
|
|
|
result.put("olderOn", olderOn);
|
|
|
result.put("olderOff", olderOff);
|
|
|
result.put("childTotal", childTotal);
|
|
|
result.put("helperTotal", helperTotal);
|
|
|
result.put("teacherTotal", teacherTotal);
|
|
|
result.put("helperOn", helperOn);
|
|
|
result.put("teacherOn", teacherOn);
|
|
|
result.put("childOn", childOn);
|
|
|
result.put("olderOn", olderOn);
|
|
|
|
|
|
result.put("childOff", childOff);
|
|
|
result.put("unSignOlderTotal", unSignOlderTotal);
|
|
|
result.put("unSignOlderOff", unSignOlderOff);
|
|
|
result.put("unSignOlderOn", unSignOlderOn);
|
|
|
|
|
|
result.put("helperTotal", helperTotal);
|
|
|
result.put("helperOff", helperOff);
|
|
|
result.put("helperOn", helperOn);
|
|
|
result.put("teacherTotal", teacherTotal);
|
|
|
result.put("teacherOff", teacherOff);
|
|
|
result.put("olderOff", olderOff);
|
|
|
result.put("teacherOn", teacherOn);
|
|
|
result.put("helper4Total", helper4Total);
|
|
|
result.put("helper4On", helper4On);
|
|
|
result.put("helper4Off", helper4Off);
|
|
|
|
|
|
//老人家属
|
|
|
result.put("olderFamilyTotal", olderFamilyTotal);
|
|
@ -793,7 +885,7 @@ public class StatisticsService {
|
|
|
*
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level 2 市 3区 4医院 5、科室 6医生
|
|
|
* @param level 2 市 3区 4医院 5、团队 6医生
|
|
|
* @param index
|
|
|
* @param type
|
|
|
* @return
|
|
@ -851,7 +943,6 @@ public class StatisticsService {
|
|
|
res.put("inTime", saveModel3.getResult2().longValue());
|
|
|
res.put("noReplyRate", statisticsUtilService.getTwoRange(saveModel2.getResult2(), saveModel1.getResult2()));
|
|
|
res.put("inTimeRate", statisticsUtilService.getTwoRange(saveModel3.getResult2(), saveModel1.getResult2()));
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@ -973,6 +1064,30 @@ public class StatisticsService {
|
|
|
arrTmp.put("patientLabelList", labelArr);
|
|
|
res.put("patientLabelStatistic", arrTmp);
|
|
|
|
|
|
//居民类型标签
|
|
|
list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "56", SaveModel.timeLevel_DDL, null, null, "2");
|
|
|
labelArr = new JSONArray();
|
|
|
total = 0l;
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
if (saveModel.getResult2().longValue() == 0 && StringUtils.isBlank(saveModel.getSlaveKey1())) {
|
|
|
continue;
|
|
|
}
|
|
|
if ("0".equals(saveModel.getSlaveKey1())) {//去除60岁以下老人
|
|
|
continue;
|
|
|
}
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
total += saveModel.getResult2().longValue();
|
|
|
labelArr.add(json);
|
|
|
}
|
|
|
arrTmp = new JSONObject();
|
|
|
arrTmp.put("patientLabelTotal", total);
|
|
|
arrTmp.put("patientLabelList", labelArr);
|
|
|
res.put("olderLabelStatistic", arrTmp);
|
|
|
|
|
|
//年龄分布 50
|
|
|
// ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL,null,null,"2");
|
|
|
List<SaveModel> ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL, null, null, "2");
|
|
@ -1022,7 +1137,8 @@ public class StatisticsService {
|
|
|
if ("37".equals(index)) {
|
|
|
archiType = "1";
|
|
|
}
|
|
|
List<SaveModel> sexList = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate, defalutArea, level, "51", SaveModel.timeLevel_DDL, null, archiType, null, null, "2", "1");
|
|
|
List<SaveModel> sexList = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate, area, level,
|
|
|
"51", SaveModel.timeLevel_DDL, null, archiType, null, null, null, "1");
|
|
|
JSONArray sexArray = new JSONArray();
|
|
|
for (int i = 0; i < sexList.size(); i++) {
|
|
|
SaveModel saveModel = sexList.get(i);
|
|
@ -1042,9 +1158,9 @@ public class StatisticsService {
|
|
|
*/
|
|
|
public JSONObject lifeCareAnalysis(String endDate, String area, int level) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
String totalIndex = "38";
|
|
|
String noReplyIndex = "39";
|
|
|
String inTimeIndex = "40";
|
|
|
String totalIndex = "38";//已服务人数
|
|
|
String noReplyIndex = "39"; //工单数 (除了已取消与未支付)
|
|
|
String inTimeIndex = "48"; //工单项目数 (除了已取消与未支付)
|
|
|
//老人数
|
|
|
SaveModel saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL);
|
|
|
//工单数
|
|
@ -1266,7 +1382,12 @@ public class StatisticsService {
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
long total = 0l;
|
|
|
//总量
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, defalutArea, level, ind, SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
|
List<SaveModel> list = new ArrayList<>();
|
|
|
if (ind.equals("46")){
|
|
|
list = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(DateUtil.getStringDateShort(), DateUtil.getStringDateShort(), defalutArea, 2, "46", SaveModel.timeLevel_DDL, null, "-2,0,1", null, null, "4", "1");
|
|
|
}else {
|
|
|
list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, defalutArea, level, ind, SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
|
}
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
@ -1290,23 +1411,27 @@ public class StatisticsService {
|
|
|
|
|
|
/**
|
|
|
* 管理端首页老人接入情况,关联家属
|
|
|
*
|
|
|
* @param area 权限范围
|
|
|
* @param level 1省2市3区县4机构5团队6医生
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject olderBindingDeviceStatus(String area) {
|
|
|
public JSONObject olderBindingDeviceStatus(String area,String level) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String filter = "";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if (listtmp.size() > 0) {
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
filter = " not in ('" + orgCodes + "')";
|
|
|
}
|
|
|
String sql = " select count(id) from base_patient where del=1 and archive_type=1 and id " + filter;
|
|
|
String olderFilter = roleService.getOlderRoleSQL(area,level);
|
|
|
|
|
|
// String filter = "";
|
|
|
// String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
// List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
// if (listtmp.size() > 0) {
|
|
|
// String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
// orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
// filter = " not in ('" + orgCodes + "')";
|
|
|
// }
|
|
|
String sql = " select count(p.id) from base_patient p where p.del=1 and p.archive_type=1 " + olderFilter.replace("{patient}","p.id");
|
|
|
Integer olderCount = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
|
|
|
sql = " select count(DISTINCT p.id) from base_patient p INNER JOIN wlyy_patient_device pd on p.id = pd.user and p.archive_type=1 and pd.del=0 where p.del=1 and p.id " + filter;
|
|
|
sql = " select count(DISTINCT p.id) from base_patient p INNER JOIN wlyy_patient_device pd on p.id = pd.user and p.archive_type=1 and pd.del=0 where p.del=1 "+
|
|
|
olderFilter.replace("{patient}","p.id");
|
|
|
Integer bindingCount = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
//老人接入情况
|
|
|
result.put("olderCount", olderCount);
|
|
@ -1315,18 +1440,13 @@ public class StatisticsService {
|
|
|
|
|
|
//关联家属
|
|
|
String sqlfamily = "SELECT COUNT(DISTINCT p.id) FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr " +
|
|
|
"on p.id = sr.patient and sr.`status`=1 and p.id not in " +
|
|
|
"(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older') " +
|
|
|
",(SELECT DISTINCT fm.family_member from base_patient_family_member fm,base_patient p1 " +
|
|
|
"base_patient p , (SELECT DISTINCT fm.family_member from base_patient_family_member fm,base_patient p1 " +
|
|
|
"WHERE p1.id = fm.patient and p1.archive_type = '3') f1 " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and p.id = f1.family_member ";
|
|
|
"WHERE p.del = 1 and p.archive_type =1 and p.id = f1.family_member "+olderFilter.replace("{patient}","p.id");
|
|
|
|
|
|
String sqlSign = "SELECT COUNT(DISTINCT p.id) FROM " +
|
|
|
"base_patient p INNER JOIN base_service_package_sign_record sr " +
|
|
|
"on p.id = sr.patient and sr.`status`=1 and p.id not in " +
|
|
|
"(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older') " +
|
|
|
"WHERE p.del = 1 and p.archive_type =1 ";
|
|
|
"base_patient p "+
|
|
|
"WHERE p.del = 1 and p.archive_type =1 "+olderFilter.replace("{patient}","p.id");
|
|
|
|
|
|
Integer familyOlderCount = jdbcTemplate.queryForObject(sqlfamily, Integer.class);
|
|
|
Integer familySignCount = jdbcTemplate.queryForObject(sqlSign, Integer.class);
|
|
@ -1338,18 +1458,18 @@ public class StatisticsService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 管理端安防监护新增分析
|
|
|
* 管理端首页安防预警统计分析
|
|
|
*/
|
|
|
public JSONObject statisticsSecurityOlder(String endDate, String area, int level, String type) throws Exception {
|
|
|
public JSONObject statisticsSecurityOlder(String endDate, String area, Integer level, String type) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
String areaLevel = "4";
|
|
|
areaLevel = "4";
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, areaLevel);
|
|
|
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, null, null, "-2,0,1" );
|
|
|
|
|
|
res.put("index_" + 46 + "_total", saveModel.getResult2().longValue());
|
|
|
if (StringUtils.isNotBlank(type)) {
|
|
|
//周/月 增量
|
|
|
String start = statisticsUtilService.calStart(endDate, type);
|
|
|
SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevel0(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, areaLevel);
|
|
|
SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevels(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, null,null,"-2,0,1");
|
|
|
res.put("index_" + 46 + "_add", saveModelAdd.getResult2().longValue());
|
|
|
}
|
|
|
JSONArray addDetail = new JSONArray();
|
|
@ -1357,16 +1477,25 @@ public class StatisticsService {
|
|
|
//周/月 增量
|
|
|
String start = statisticsUtilService.calStart(endDate, type);
|
|
|
|
|
|
List<SaveModel> saveModelAdds = elasticsearchUtil.findDateQuotaLevelList(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, "3", null, null, null);
|
|
|
List<SaveModel> saveModelAdds = elasticsearchUtil.findDateQuotaLevelList(start, endDate, area, level, "46", SaveModel.timeLevel_ZL, null,null,"3", null, "-2,0,1" );
|
|
|
for (SaveModel saveModelTmp : saveModelAdds) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, "3", null, null, saveModelTmp.getSlaveKey3());
|
|
|
SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, "3", null, "-2,0,1", saveModelTmp.getSlaveKey3());
|
|
|
json.put("total", saveMode2.getResult2().longValue());
|
|
|
json.put("num", saveModelTmp.getResult2().longValue());
|
|
|
json.put("code", saveModelTmp.getSlaveKey3());
|
|
|
json.put("name", saveModelTmp.getSlaveKey3Name());
|
|
|
addDetail.add(json);
|
|
|
}
|
|
|
SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "53", SaveModel.timeLevel_DDL, null, null, "-2,0,1" );
|
|
|
SaveModel saveModelTmp = elasticsearchUtil.findOneDateQuotaLevels(start, endDate, area, level, "53", SaveModel.timeLevel_ZL, null, null, "-2,0,1" );
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("total", saveMode2.getResult2().longValue());
|
|
|
json.put("num", saveModelTmp.getResult2().longValue());
|
|
|
json.put("code", "jjhj");
|
|
|
json.put("name", "紧急呼叫");
|
|
|
addDetail.add(json);
|
|
|
System.out.println("1");
|
|
|
}
|
|
|
res.put("index_add_detail", addDetail);
|
|
|
return res;
|
|
@ -1749,8 +1878,7 @@ public class StatisticsService {
|
|
|
public JSONObject patientAnalysisDP(String endDate, String area, int level, String index) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
String areaLevel = "6";
|
|
|
if ("42".equals(index)) {
|
|
|
areaLevel = "4";
|
|
|
if ("42".equals(index)) {//幼儿
|
|
|
//新生儿
|
|
|
//是否入学
|
|
|
List<SaveModel> statusList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, index, SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
@ -1764,13 +1892,13 @@ public class StatisticsService {
|
|
|
statusArray.add(json);
|
|
|
}
|
|
|
res.put("statusList", statusArray);
|
|
|
} else {
|
|
|
} else {//老人
|
|
|
//老人
|
|
|
//能力评估 从签约时服务标签取
|
|
|
res.put("levelList", cloudCareForTheElderly(null, null, null));
|
|
|
res.put("levelList", cloudCareForTheElderly(endDate, area, level));
|
|
|
|
|
|
//居民健康标签
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "47", SaveModel.timeLevel_DDL, null, null, "2");
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "47", SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
|
JSONArray labelArr = new JSONArray();
|
|
|
Long total = 0l;
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
@ -1795,7 +1923,7 @@ public class StatisticsService {
|
|
|
|
|
|
//年龄分布 50
|
|
|
// ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL,null,null,"2");
|
|
|
List<SaveModel> ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL, null, null, "2");
|
|
|
List<SaveModel> ageList = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "50", SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
|
JSONArray ageArray = new JSONArray();
|
|
|
for (int i = 0; i < ageList.size(); i++) {
|
|
|
SaveModel saveModel = ageList.get(i);
|
|
@ -1859,36 +1987,20 @@ public class StatisticsService {
|
|
|
|
|
|
/*大屏 老人云照护 评估*/
|
|
|
public JSONArray cloudCareForTheElderly(String endDate, String area, Integer level) throws Exception {
|
|
|
//评估类型
|
|
|
String filter = "";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if (listtmp.size() > 0) {
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
if (StringUtils.isNotBlank(orgCodes)) {
|
|
|
orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
filter = " and lab.patient not in ('" + orgCodes + "')";
|
|
|
}
|
|
|
}
|
|
|
//居民类型标签
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, area, level, "56", SaveModel.timeLevel_DDL, null, null, "2");
|
|
|
SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, "56", SaveModel.timeLevel_DDL);
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
String sql = " select dict.dict_code,dict_value,count(DISTINCT A.patient) total from wlyy_hospital_sys_dict dict \n" +
|
|
|
" LEFT JOIN (select distinct lab.patient,lab.label_code from wlyy_patient_label lab INNER JOIN base_patient p on p.id = lab.patient AND lab.label_type='3' " +
|
|
|
filter + " \n" +
|
|
|
")A on dict.dict_code = A.label_code " +
|
|
|
"where dict.dict_name='older_label' and dict.dict_code is not null and dict_code <= 7 \n" +
|
|
|
" GROUP BY dict.dict_code; ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
String older = " select count(distinct lab.patient) from wlyy_patient_label lab INNER JOIN base_patient p on p.id = lab.patient AND lab.label_type='1' " + filter;
|
|
|
Integer count = jdbcTemplate.queryForObject(older, Integer.class);
|
|
|
|
|
|
for (Map<String, Object> map : list) {
|
|
|
Long total = saveModel3.getResult1().longValue();
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
json.put("rate", df.format((Integer.parseInt(map.get("total").toString()) * 1.00) / count * 100));
|
|
|
json.put("num", map.get("total"));
|
|
|
json.put("code", map.get("dict_code").toString());
|
|
|
json.put("name", map.get("dict_value").toString());
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
json.put("rate", df.format((saveModel.getResult2().longValue() * 1.00) / total * 100));
|
|
|
total += saveModel.getResult2().longValue();
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
return jsonArray;
|
|
@ -1926,5 +2038,850 @@ public class StatisticsService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
//新生儿上门辅导 类型
|
|
|
//老人整体概况
|
|
|
public Map<String,Object> getOlderOverview(String currentUserRole,String currentUserRoleLevel){
|
|
|
String year = DateUtil.getNowYear()+"";
|
|
|
String sql = " select * from base_older_num where type='"+currentUserRoleLevel+"' and code='"+currentUserRole+"' and year='"+year+"' ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if (list.size()>0){
|
|
|
return list.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 紧急预警事件饼图、预警数量
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject adminStatisticsEmeWarnServer(String endDate,String area ,int level ) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
//总量
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, null, "-2,0,1", null, null, "4", "1");
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
//紧急呼叫
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, "68", SaveModel.timeLevel_DDL, "-2,0,1");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", "jjhj");
|
|
|
json.put("name", "紧急呼叫");
|
|
|
jsonArray.add(json);
|
|
|
jsonArray.sort(Comparator.comparing(obj -> ((JSONObject) obj).getLongValue("num")).reversed());
|
|
|
res.put("orderServerArray", jsonArray);
|
|
|
//预警总数 未处理数量
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "67", SaveModel.timeLevel_DDL,"-2,0,1");
|
|
|
res.put("emeWarnTotal", saveModel.getResult2().longValue());
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, area, level, "67", SaveModel.timeLevel_DDL,"1");
|
|
|
res.put("emeWarnNotDeal", saveModel.getResult2().longValue());
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 紧急预警紧急预警响应率
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject statisticsEmeWarnList(String endDate,String area ,int level ) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
//总量
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevelList(endDate, endDate, area, level, "67", SaveModel.timeLevel_DDL,null,"5", null, "-2,0,1");
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("emeWarnTotal", saveModel.getResult2().longValue());
|
|
|
json.put("dept", saveModel.getDept());
|
|
|
json.put("deptName", saveModel.getDeptName());
|
|
|
//已响应数量
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(endDate, saveModel.getDept(), 5, "67", SaveModel.timeLevel_DDL,"-2,0");
|
|
|
json.put("emeWarnDealt", saveModel2.getResult2().longValue());
|
|
|
json.put("emeWarnDealtLaw", commonUtil.getRangeDouble(saveModel2.getResult2().intValue(),saveModel.getResult2().intValue()));
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
jsonArray.sort(Comparator.comparing(obj -> ((JSONObject) obj).getDouble("emeWarnDealtLaw")).reversed());
|
|
|
res.put("orderServerArray", jsonArray);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 人文关怀祝福未发送率
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject statisticsNotWishesList(String endDate,String area ,int level ) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
//总量
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevelList(endDate, endDate, area, level, "60", SaveModel.timeLevel_DDL,null,"5", null, null);
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("dept", saveModel.getDept());
|
|
|
json.put("deptName", saveModel.getDeptName());
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, saveModel.getDept(), 5, "61", SaveModel.timeLevel_DDL);
|
|
|
json.put("birthDayTotal", saveModel2.getResult2().longValue()+saveModel.getResult2().longValue());
|
|
|
json.put("notWishesTotal", saveModel2.getResult2().longValue());
|
|
|
json.put("notWishesLaw", commonUtil.getRangeDouble(saveModel2.getResult2().intValue(),(saveModel2.getResult2().intValue()+saveModel.getResult2().intValue())));
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
res.put("wishesArray", jsonArray);
|
|
|
jsonArray.sort(Comparator.comparing(obj -> ((JSONObject) obj).getDouble("notWishesLaw")).reversed());
|
|
|
//祝福人次
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, area, level, "60", SaveModel.timeLevel_DDL);
|
|
|
res.put("wishesTotal", saveModel.getResult2().longValue());
|
|
|
//祝福人数
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, area, level, "69", SaveModel.timeLevel_DDL);
|
|
|
res.put("wishesPeople", saveModel.getResult2().longValue());
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param area
|
|
|
* @param level 2 市 3区 4医院 5、团队 6医生
|
|
|
*获取老人服务情况(助老服务、紧急救助、医生服务、监测设备)
|
|
|
*/
|
|
|
public JSONObject getServerSituation(String area,int level) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Long finishCount = 0l;
|
|
|
Long unfinishCount = 0l;
|
|
|
//助老服务 生活照料
|
|
|
JSONObject olderServiceInfo = new JSONObject();
|
|
|
olderServiceInfo.put("finish",0);
|
|
|
olderServiceInfo.put("unfinish",0);
|
|
|
olderServiceInfo.put("total",0);
|
|
|
olderServiceInfo.put("law",0);
|
|
|
//紧急救助 呼叫+安防 指标67
|
|
|
JSONObject emeAssistance = new JSONObject();
|
|
|
emeAssistance.put("finish",0);
|
|
|
emeAssistance.put("unfinish",0);
|
|
|
olderServiceInfo.put("total",0);
|
|
|
emeAssistance.put("law",0);
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
JSONObject doctorServiceInfo = new JSONObject();
|
|
|
doctorServiceInfo.put("finish",0);
|
|
|
doctorServiceInfo.put("unfinish",0);
|
|
|
olderServiceInfo.put("total",0);
|
|
|
doctorServiceInfo.put("law",0);
|
|
|
//监测设备
|
|
|
JSONObject monitorDevice = new JSONObject();
|
|
|
monitorDevice.put("healthDevice",0);
|
|
|
monitorDevice.put("securityDevice",0);
|
|
|
olderServiceInfo.put("total",0);
|
|
|
monitorDevice.put("offlineDevice",0);
|
|
|
String areaFilter = "";
|
|
|
|
|
|
if (StringUtils.isNotBlank(area)&&2!=level){
|
|
|
if (4==level){
|
|
|
areaFilter = " and pack.org_code='"+area+"' ";
|
|
|
}
|
|
|
if (5==level){//团队
|
|
|
areaFilter = " and r.team_code='"+area+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String olderFilter = " and EXISTS ( select 1 from " +
|
|
|
" base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 " +
|
|
|
" and sr.`status`=1 and CONVERT(sr.patient USING utf8) = {patient} " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') "+areaFilter+" ) ";
|
|
|
//助老服务 生活照料 已完成
|
|
|
String sql = " select count(life.id) from base_life_care_order life where life.`status`=2 "+olderFilter.replace("{patient}","life.patient") +"" ;
|
|
|
finishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
olderServiceInfo.put("finish",finishCount);
|
|
|
sql = " select count(life.id) from base_life_care_order life where life.status in (1,3) "+olderFilter.replace("{patient}","life.patient")+" " ;
|
|
|
unfinishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
olderServiceInfo.put("unfinish",unfinishCount);
|
|
|
olderServiceInfo.put("total",finishCount.intValue()+unfinishCount.intValue());
|
|
|
olderServiceInfo.put("law",commonUtil.getRangeDouble(finishCount.intValue(),(finishCount.intValue()+unfinishCount.intValue())));
|
|
|
result.put("olderServiceInfo",olderServiceInfo);
|
|
|
|
|
|
//紧急救助 呼叫+安防
|
|
|
//紧急救助 已响应
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getStringDateShort(), area, level, "67", SaveModel.timeLevel_DDL,"-2,0");
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getStringDateShort(), area, level, "67", SaveModel.timeLevel_DDL,"1");
|
|
|
finishCount = saveModel.getResult2().longValue();
|
|
|
unfinishCount = saveModel2.getResult2().longValue();
|
|
|
emeAssistance.put("finish",finishCount);
|
|
|
emeAssistance.put("unfinish",unfinishCount);
|
|
|
emeAssistance.put("total",finishCount.intValue()+unfinishCount.intValue());
|
|
|
emeAssistance.put("law",commonUtil.getRangeDouble(finishCount.intValue(),(finishCount.intValue()+unfinishCount.intValue())));
|
|
|
result.put("emeAssistance",emeAssistance);
|
|
|
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
sql = " SELECT count(p.id) FROM base_care_prescription p where p.status=2 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
finishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
sql = " SELECT count(p.id) FROM base_care_prescription p where p.status=1 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
unfinishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
//老人健康咨询咨询
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where o.status=1 and o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
finishCount += jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where o.status=0 and o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
unfinishCount += jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
doctorServiceInfo.put("finish",finishCount);
|
|
|
doctorServiceInfo.put("unfinish",unfinishCount);
|
|
|
doctorServiceInfo.put("total",finishCount.intValue()+unfinishCount.intValue());
|
|
|
doctorServiceInfo.put("law",commonUtil.getRangeDouble(finishCount.intValue(),(finishCount.intValue()+unfinishCount.intValue())));
|
|
|
|
|
|
//监测设备
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where pd.device_type=0 "+olderFilter.replace("{patient}","pd.user");
|
|
|
Long count = jdbcTemplate.queryForObject(sql,Long.class);//健康设备
|
|
|
monitorDevice.put("healthDevice",count);
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where pd.device_type=1 "+olderFilter.replace("{patient}","pd.user");
|
|
|
count = jdbcTemplate.queryForObject(sql,Long.class);//安防设备
|
|
|
monitorDevice.put("securityDevice",count);
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where (dev.contact_status=0 or dev.contact_status is null ) "+olderFilter.replace("{patient}","pd.user");
|
|
|
count = jdbcTemplate.queryForObject(sql,Long.class);//离线设备
|
|
|
monitorDevice.put("offlineDevice",count);
|
|
|
monitorDevice.put("total",monitorDevice.getInteger("securityDevice")+monitorDevice.getInteger("healthDevice"));
|
|
|
|
|
|
result.put("olderServiceInfo",olderServiceInfo);
|
|
|
result.put("emeAssistance",emeAssistance);
|
|
|
result.put("doctorServiceInfo",doctorServiceInfo);
|
|
|
result.put("monitorDevice",monitorDevice);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
*获取老人服务情况(助老服务、紧急救助、医生服务 项目数量)
|
|
|
*/
|
|
|
public JSONObject getServerSituationItem(String endDate,String area,int level) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
//助老服务 生活照料 (出去已取消和未支付)
|
|
|
JSONArray olderServiceInfo = new JSONArray();
|
|
|
List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate, endDate, area, level, "48", SaveModel.timeLevel_DDL, null, null);
|
|
|
for (int i = 0; (i < list.size() && i < 5); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
olderServiceInfo.add(json);
|
|
|
}
|
|
|
//紧急救助 呼叫68+安防46 已取消不算
|
|
|
JSONArray emeAssistance = new JSONArray();
|
|
|
list = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, null, "-2,0,1", null, null, "4", "1");
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
emeAssistance.add(json);
|
|
|
}
|
|
|
//紧急呼叫
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, "68", SaveModel.timeLevel_DDL, "-2,0,1");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", "jjhj");
|
|
|
json.put("name", "紧急呼叫");
|
|
|
emeAssistance.add(json);
|
|
|
emeAssistance.sort(Comparator.comparing(obj -> ((JSONObject) obj).getLongValue("num")).reversed());
|
|
|
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
String areaFilter = "";
|
|
|
|
|
|
if (StringUtils.isNotBlank(area)&&2!=level){
|
|
|
if (4==level){
|
|
|
areaFilter = " and pack.org_code='"+area+"' ";
|
|
|
}
|
|
|
if (5==level){//团队
|
|
|
areaFilter = " and r.team_code='"+area+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String olderFilter = " and EXISTS ( select 1 from " +
|
|
|
" base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 " +
|
|
|
" and sr.`status`=1 and CONVERT(sr.patient USING utf8) = {patient} " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') "+areaFilter+" ) ";
|
|
|
|
|
|
JSONArray doctorServiceInfo = new JSONArray();
|
|
|
String sql = " SELECT count(p.id) FROM base_care_prescription p where 1=1 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
Long count = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
json = new JSONObject();
|
|
|
json.put("num", count);
|
|
|
json.put("code", "cfxf");
|
|
|
json.put("name", "处方续方");
|
|
|
doctorServiceInfo.add(json);
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
json = new JSONObject();
|
|
|
json.put("num", count);
|
|
|
json.put("code", "jkzx");
|
|
|
json.put("name", "健康咨询");
|
|
|
doctorServiceInfo.add(json);
|
|
|
|
|
|
result.put("olderServiceItemInfo",olderServiceInfo);
|
|
|
result.put("emeAssistanceItem",emeAssistance);
|
|
|
result.put("doctorServiceItemInfo",doctorServiceInfo);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取养老服务社区团队列表
|
|
|
*/
|
|
|
public List<Map<String,Object>> getOlderTeamList() throws Exception {
|
|
|
List<Map<String,Object>> teamList = new ArrayList<>();
|
|
|
String sql = " select distinct org.code as orgCode,org.name as orgName,te.id as teamId,te.name as teamName from " +
|
|
|
" base_service_package pack INNER JOIN base_org org on pack.org_code = org.code " +
|
|
|
"INNER JOIN base_team te on te.org_code = org.`code` " +
|
|
|
" where org.del=1 and org.type=3 and te.del=1 and org.code not in " +
|
|
|
" (select dict_code from wlyy_hospital_sys_dict where dict_name='jkzl_org') ";
|
|
|
teamList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:teamList){
|
|
|
//1 获取社工人数(该团队人数) 2.预警数(紧急呼叫+安防监护 已取消的不算)
|
|
|
//3助老服务(该社区所有老人的生活照料总数 已取消的不算) 4物联设备(健康设备绑定量+安防设备绑定量)
|
|
|
String teamName = map.get("teamName").toString();
|
|
|
String teamId = map.get("teamId").toString();
|
|
|
teamName = teamName.replace("团队","社区");
|
|
|
teamName = teamName.replace("服务","");
|
|
|
if(!teamName.contains("社区")){
|
|
|
teamName = teamName+"社区";
|
|
|
}
|
|
|
map.put("teamName",teamName);
|
|
|
sql = " select count(doc.id) from base_team_member mem ,base_doctor doc where mem.team_code='"+teamId+"' " +
|
|
|
" and mem.doctor_code = doc.id and mem.del=1 and doc.del=1 ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("doctorCount",count);
|
|
|
sql = " SELECT count(o.bussiness_id) " +
|
|
|
"FROM ( SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_security_monitoring_order o " +
|
|
|
" where o.team_code='"+teamId+"' and o.`status` in (-2,0,1) " +
|
|
|
" UNION ALL SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_emergency_assistance_order o " +
|
|
|
" where o.team_code='"+teamId+"' and o.`status` in (-2,0,1) )o ";
|
|
|
Long emeAssistanceCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
map.put("emeAssistanceCount",emeAssistanceCount);
|
|
|
sql = " SELECT count(o.id) FROM base_life_care_order o WHERE o.status<>0 and o.status<>-1 and EXISTS ( " +
|
|
|
" select 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i," +
|
|
|
" base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = o.patient " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` " +
|
|
|
" WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("olderServiceCount",count);
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
" where 1=1 and EXISTS ( " +
|
|
|
" select 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i," +
|
|
|
" base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = p.id " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` " +
|
|
|
" WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("bindingDeviceCount",count);
|
|
|
//社工数量
|
|
|
String filter = "";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
|
|
|
List<Map<String,Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if(listtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
filter = " and a.id not in ('"+orgCodes+"')";
|
|
|
}
|
|
|
sql = "SELECT count(a.id) from base_patient a WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' ";
|
|
|
sql += " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+teamId+"' ) "+filter;
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("oldTotal",count);
|
|
|
//照护老人数量
|
|
|
filter = "";
|
|
|
sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
|
|
|
listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if(listtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
filter = " and h.org_code not in ('"+orgCodes+"')";
|
|
|
}
|
|
|
sql = "SELECT count(a.id) from base_doctor a,base_doctor_hospital h WHERE a.id=h.doctor_code and " +
|
|
|
" a.doctor_level = 2 and a.del = '1' and h.del = '1' ";
|
|
|
sql += " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
|
|
|
" and mem.team_code='"+teamId+"' and mem.del=1 ) "+filter;
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("helperTotal",count);
|
|
|
}
|
|
|
return teamList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public PageEnvelop<List<Map<String,Object>>> getOlderTeamListWithPage(String area,String level,Integer page,Integer size) throws Exception {
|
|
|
List<Map<String,Object>> teamList = new ArrayList<>();
|
|
|
page = page>0?page-1:0;
|
|
|
String areaFilter = " ";
|
|
|
if ("5".equals(level)){
|
|
|
areaFilter += " and te.id='"+area+"' ";
|
|
|
}
|
|
|
String sql = " select count(distinct org.code) from " +
|
|
|
" base_service_package pack INNER JOIN base_org org on pack.org_code = org.code " +
|
|
|
"INNER JOIN base_team te on te.org_code = org.`code` " +
|
|
|
" where org.del=1 and org.type=3 and te.del=1 and org.code not in " +
|
|
|
" (select dict_code from wlyy_hospital_sys_dict where dict_name='jkzl_org') "+areaFilter;
|
|
|
Long totalNum = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
sql = " select distinct org.code as orgCode,org.name as orgName,te.id as teamId,te.name as teamName from " +
|
|
|
" base_service_package pack INNER JOIN base_org org on pack.org_code = org.code " +
|
|
|
"INNER JOIN base_team te on te.org_code = org.`code` " +
|
|
|
" where org.del=1 and org.type=3 and te.del=1 and org.code not in " +
|
|
|
" (select dict_code from wlyy_hospital_sys_dict where dict_name='jkzl_org') "+areaFilter+" order by org.code asc " +
|
|
|
"limit "+(page*size)+","+size ;
|
|
|
teamList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:teamList){
|
|
|
//1 获取社工人数(该团队人数) 2.预警数(紧急呼叫+安防监护 已取消的不算)
|
|
|
//3助老服务(该社区所有老人的生活照料总数 已取消的不算) 4物联设备(健康设备绑定量+安防设备绑定量)
|
|
|
String teamName = map.get("teamName").toString();
|
|
|
String teamId = map.get("teamId").toString();
|
|
|
teamName = teamName.replace("团队","社区");
|
|
|
teamName = teamName.replace("服务","");
|
|
|
if(!teamName.contains("社区")){
|
|
|
teamName = teamName+"社区";
|
|
|
}
|
|
|
map.put("teamName",teamName);
|
|
|
sql = " select count(doc.id) from base_team_member mem ,base_doctor doc where mem.team_code='"+teamId+"' " +
|
|
|
" and mem.doctor_code = doc.id and mem.del=1 and doc.del=1 ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("doctorCount",count);
|
|
|
sql = " SELECT count(o.bussiness_id) " +
|
|
|
"FROM ( SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_security_monitoring_order o " +
|
|
|
" where o.team_code='"+teamId+"' and o.`status` in (-2,0,1) " +
|
|
|
" UNION ALL SELECT o.id AS bussiness_id,o.team_code as dept,o.`status`,o.update_time FROM base_emergency_assistance_order o " +
|
|
|
" where o.team_code='"+teamId+"' and o.`status` in (-2,0,1) )o ";
|
|
|
Long emeAssistanceCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
map.put("emeAssistanceCount",emeAssistanceCount);//救助服务
|
|
|
sql = " SELECT count(o.id) FROM base_life_care_order o WHERE o.status<>0 and o.status<>-1 and EXISTS ( " +
|
|
|
" select 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i," +
|
|
|
" base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = o.patient " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` " +
|
|
|
" WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("olderServiceCount",count);//助老服务
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
" where 1=1 and EXISTS ( " +
|
|
|
" select 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i," +
|
|
|
" base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = p.id " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` " +
|
|
|
" WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("bindingDeviceCount",count);
|
|
|
|
|
|
|
|
|
String filter = "";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
|
|
|
List<Map<String,Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if(listtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
filter = " and a.id not in ('"+orgCodes+"')";
|
|
|
}
|
|
|
sql = "SELECT count(a.id) from base_patient a WHERE a.archive_type = 1 and a.sign_status=1 and a.del = '1' ";
|
|
|
sql += " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+teamId+"' ) "+filter;
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("oldTotal",count);//照护老人数量
|
|
|
|
|
|
filter = "";
|
|
|
sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
|
|
|
listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if(listtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
filter = " and h.org_code not in ('"+orgCodes+"')";
|
|
|
}
|
|
|
sql = "SELECT count(a.id) from base_doctor a,base_doctor_hospital h WHERE a.id=h.doctor_code and " +
|
|
|
" a.doctor_level = 2 and a.del = '1' and h.del = '1' ";
|
|
|
sql += " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
|
|
|
" and mem.team_code='"+teamId+"' and mem.del=1 ) "+filter;
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("helperTotal",count);//社工数量
|
|
|
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
String olderFilter = " and EXISTS ( select 1 from " +
|
|
|
" base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 " +
|
|
|
" and sr.`status`=1 and CONVERT(sr.patient USING utf8) = {patient} " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
sql = " SELECT count(p.id) FROM base_care_prescription p where 1=1 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
Long doctorServiceCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
//老人健康咨询咨询
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where 1=1 and o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
doctorServiceCount += jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
map.put("doctorServiceTotal",doctorServiceCount);//医生服务数量
|
|
|
}
|
|
|
return PageEnvelop.getSuccessListWithPage("success",teamList,page,size,totalNum);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取助老机构生活照料服务响应率情况
|
|
|
*/
|
|
|
public List<Map<String,Object>> getOrgLifeCareStatistic() {
|
|
|
String sql = " select code,name from base_org where type=3 and code not in (select dict_code from wlyy_hospital_sys_dict " +
|
|
|
" where dict_name ='jkzl_org') and del=1 ";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
sql = " select count(life.id) total,life.hospital,org.name from base_life_care_order life INNER JOIN base_org org " +
|
|
|
" on life.hospital = org.code where life.`status`=2 and org.code not in (select dict_code from wlyy_hospital_sys_dict "+
|
|
|
" where dict_name ='jkzl_org') and org.del=1 ";
|
|
|
List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql);
|
|
|
try {
|
|
|
Map<String,List<Map<String,Object>>> numList = tmpList.stream().collect(Collectors.groupingBy(e->e.get("hospital").toString()));
|
|
|
sql = " select count(life.id) total,life.hospital,org.name from base_life_care_order life INNER JOIN base_org org " +
|
|
|
" on life.hospital = org.code where life.`status` in (1,3) and org.code not in (select dict_code from wlyy_hospital_sys_dict "+
|
|
|
" where dict_name ='jkzl_org') and org.del=1 ";
|
|
|
tmpList = jdbcTemplate.queryForList(sql);
|
|
|
Map<String,List<Map<String,Object>>> numList2 = tmpList.stream().collect(Collectors.groupingBy(e->e.get("hospital").toString()));
|
|
|
for (Map<String, Object> tmp : list) {
|
|
|
if (numList.containsKey(tmp.get("code"))||numList2.containsKey(tmp.get("code"))) {
|
|
|
Long finish=0l;
|
|
|
Long unfinish=0l;
|
|
|
if (numList.containsKey(tmp.get("code"))){
|
|
|
finish =Long.valueOf(numList.get(tmp.get("code")).get(0).get("total").toString());
|
|
|
}
|
|
|
if (numList2.containsKey(tmp.get("code"))){
|
|
|
unfinish =Long.valueOf(numList2.get(tmp.get("code")).get(0).get("total").toString());
|
|
|
}
|
|
|
tmp.put("finish", finish);
|
|
|
tmp.put("unfinish", unfinish);
|
|
|
tmp.put("total", finish+unfinish);
|
|
|
tmp.put("law", commonUtil.getRangeDouble(finish.intValue(),(finish.intValue()+unfinish.intValue())));
|
|
|
} else {
|
|
|
tmp.put("finish", 0);
|
|
|
tmp.put("unfinish", 0);
|
|
|
tmp.put("total", 0);
|
|
|
tmp.put("law", 0);
|
|
|
}
|
|
|
}
|
|
|
if (list.size()>0){
|
|
|
list.sort(Comparator.comparing(obj -> Double.parseDouble(((Map<String,Object>) obj).get("law").toString())).reversed());
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
return null;
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
public List<BaseServiceNews> serviceDynamics(Integer page,Integer size,String area,String level){
|
|
|
|
|
|
|
|
|
List<String> jkzlPatients = jdbcTemplate.queryForList("SELECT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name LIKE '%jkzl%' ",String.class);
|
|
|
|
|
|
List<BaseServiceNews> result = new ArrayList<>();
|
|
|
String olderFilter = roleService.getOlderRoleSQL(area,level);
|
|
|
String baseServiceSql = "select sn.* from base_service_news sn where sn.user_type = 1 and (relation_code <> '' or relation_code is not null )" + olderFilter.replace("{patient}","sn.code");
|
|
|
|
|
|
/*if ("330100".equals(area)){
|
|
|
baseServiceSql +=" UNION SELECT sn.* FROM base_service_news sn WHERE sn.user_type =2 ";
|
|
|
}else {
|
|
|
// 1省 2市 3区县 4机构 5团队 6医生
|
|
|
baseServiceSql +=" UNION SELECT sn.* FROM base_service_news sn LEFT JOIN base_team_member tm ON sn.`code` = tm.doctor_code WHERE sn.user_type =2 AND tm.del =1 ";
|
|
|
if ("4".equals(level)){
|
|
|
baseServiceSql +=" AND tm.org_code ='"+area+"'";
|
|
|
}
|
|
|
if ("5".equals(level)){
|
|
|
baseServiceSql += " AND tm.team_code ='"+area+"'";
|
|
|
}
|
|
|
}*/
|
|
|
baseServiceSql += " ORDER BY sn.create_time DESC LIMIT "+(page-1)*size+","+size+"";
|
|
|
|
|
|
List<BaseServiceNews> list = jdbcTemplate.query(baseServiceSql,new BeanPropertyRowMapper<>(BaseServiceNews.class));
|
|
|
|
|
|
for (BaseServiceNews tmp:list){
|
|
|
if (jkzlPatients.contains(tmp.getCode())){
|
|
|
continue;
|
|
|
}
|
|
|
BasePatientDO patientDO = patientDao.findById(tmp.getCode());
|
|
|
if (null!=patientDO){
|
|
|
tmp.setArchiveType(patientDO.getArchiveType());
|
|
|
tmp.setResidentialArea(patientDO.getResidentialArea());
|
|
|
}
|
|
|
String relationCode = tmp.getRelationCode();
|
|
|
if (StringUtils.isNotBlank(relationCode)){
|
|
|
if ("1".equals(tmp.getType())){//上门
|
|
|
String sql = " select group_concat(Distinct name SEPARATOR '、') from base_door_coach_fee_detail where order_id ='"+relationCode+"' and status =1 ";
|
|
|
List<String> serviceItems = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serviceItems.size()>0){
|
|
|
tmp.setServeItems(serviceItems.get(0));
|
|
|
}
|
|
|
}
|
|
|
if ("3".equals(tmp.getType())||"4".equals(tmp.getType())){//生活照料
|
|
|
String sql = " select group_concat(Distinct name SEPARATOR '、') from base_life_care_fee_detail where order_id ='"+relationCode+"' ";
|
|
|
List<String> serviceItems = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serviceItems.size()>0){
|
|
|
tmp.setServeItems(serviceItems.get(0));
|
|
|
}
|
|
|
}
|
|
|
if ("6".equals(tmp.getType())){//安防
|
|
|
String sql = "SELECT serve_desc FROM base_security_monitoring_order WHERE id = '"+relationCode+"'";
|
|
|
List<String> serviceItems = jdbcTemplate.queryForList(sql,String.class);
|
|
|
if (serviceItems.size()>0){
|
|
|
tmp.setServeItems(serviceItems.get(0));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 咨询排名情况
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level 1省2市3区县4机构5团队6医生
|
|
|
* @param type 咨询类型 23新生儿在线咨询 24老人在线咨询,25老人健康咨询
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getConsultAnalysisRank(String endDate,String area,int level,String type) throws Exception {
|
|
|
JSONArray result = new JSONArray();
|
|
|
String totalIndex = "";
|
|
|
String noReplyIndex = "";
|
|
|
String inTimeIndex = "";
|
|
|
String finishIndex = " " ;
|
|
|
Integer lowLevel ;
|
|
|
if ("23".equals(type)){
|
|
|
totalIndex = "28";
|
|
|
noReplyIndex = "29";
|
|
|
inTimeIndex = "30";
|
|
|
finishIndex = "70";
|
|
|
lowLevel = 4;//按机构分组
|
|
|
}else if ("24".equals(type)){
|
|
|
totalIndex = "31";
|
|
|
noReplyIndex = "32";
|
|
|
inTimeIndex = "33";
|
|
|
finishIndex = "71";
|
|
|
lowLevel = 5;//按社区分组
|
|
|
}else if ("25".equals(type)){
|
|
|
totalIndex = "57";
|
|
|
noReplyIndex = "58";
|
|
|
inTimeIndex = "59";
|
|
|
finishIndex = "72";
|
|
|
lowLevel = 5;//按社区分组
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
//按机构排名
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevelList(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL,null,lowLevel+"", null);
|
|
|
for (SaveModel tmp:list){
|
|
|
JSONObject res = new JSONObject();
|
|
|
String areaTmp ="";
|
|
|
if (4==lowLevel){
|
|
|
areaTmp = tmp.getHospital();
|
|
|
}if (5==lowLevel){
|
|
|
areaTmp = tmp.getDept();
|
|
|
}
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, areaTmp, lowLevel, noReplyIndex, SaveModel.timeLevel_DDL);
|
|
|
//及时回复数
|
|
|
|
|
|
SaveModel saveModel3 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, areaTmp, lowLevel, inTimeIndex, SaveModel.timeLevel_DDL);
|
|
|
SaveModel saveModel4 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, areaTmp, lowLevel, finishIndex, SaveModel.timeLevel_DDL);
|
|
|
res.put("total", tmp.getResult2().longValue());
|
|
|
res.put("dept", tmp.getDept());
|
|
|
res.put("deptName", tmp.getDeptName());
|
|
|
res.put("hospital", tmp.getHospital());
|
|
|
res.put("hospitalName", tmp.getHospitalName());
|
|
|
res.put("noReply", saveModel2.getResult2().longValue());
|
|
|
res.put("inTime", saveModel3.getResult2().longValue());
|
|
|
res.put("finish", saveModel4.getResult2().longValue());
|
|
|
res.put("noReplyRate", commonUtil.getRangeDouble(saveModel2.getResult2().intValue(), tmp.getResult2().intValue()));
|
|
|
res.put("inTimeRate", commonUtil.getRangeDouble(saveModel3.getResult2().intValue(), tmp.getResult2().intValue()));
|
|
|
res.put("finishRate", commonUtil.getRangeDouble(saveModel4.getResult2().intValue(), tmp.getResult2().intValue()));
|
|
|
result.add(res);
|
|
|
}
|
|
|
result.sort(Comparator.comparing(obj -> ((JSONObject) obj).getDouble("finishRate")).reversed());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<EmergencyAssistanceDO> getAdminOrderList(String patient, String patientName, String doctor, String status, Integer page, Integer pageSize,String area,String level){
|
|
|
String olderFilter = roleService.getOlderRoleSQL(area,level);
|
|
|
StringBuilder sql = new StringBuilder(" select ord.* from base_emergency_assistance_order ord inner join base_patient pa on pa.id = ord.patient and pa.del=1 where 1=1 ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(doctor)){
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
if (null!=doctorDO){
|
|
|
if (2==doctorDO.getLevel()){//社工
|
|
|
sql.append(" AND EXISTS (" +
|
|
|
"SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
"base_team_member m " +
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and m.team_code = r.team_code " +
|
|
|
" and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
|
|
|
}
|
|
|
if (4==doctorDO.getLevel()){//助老员
|
|
|
sql.append(" and EXISTS (" +
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(patient)){
|
|
|
sql.append(" and ( ord.patient = '"+patient+"' or ord.proxy_patient='"+patient+"' )");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(patientName)){
|
|
|
sql.append(" and (pa.name like '%"+patientName+"%' or pa.idcard like '%"+patientName+"%') ");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(status)) {
|
|
|
sql.append(" and ord.status in ( '").append(status.replace(",","','")).append("') ");
|
|
|
}
|
|
|
|
|
|
sql.append(olderFilter.replace("{patient}","pa.id"));
|
|
|
sql.append(" order by ord.create_time DESC limit "+page*pageSize+","+pageSize);
|
|
|
|
|
|
List<EmergencyAssistanceDO> resultList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(EmergencyAssistanceDO.class));
|
|
|
for (EmergencyAssistanceDO obj:resultList){
|
|
|
BasePatientDO patientDO = patientDao.findById(obj.getPatient());
|
|
|
obj.setPatientPhoto(patientDO.getPhoto());
|
|
|
obj.setPatientSex(patientDO.getSex());
|
|
|
obj.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
|
|
|
}
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取上门辅导排名
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray getDoorCoachRank(String endDate,String area,Integer level) throws Exception {
|
|
|
JSONArray result = new JSONArray();
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevelList(endDate, endDate, area, level, "54", SaveModel.timeLevel_DDL,null,"4", null);
|
|
|
for (SaveModel tmp:list){
|
|
|
JSONObject res = new JSONObject();
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, tmp.getHospital(), 4, "35", SaveModel.timeLevel_DDL);
|
|
|
res.put("total", tmp.getResult2().longValue());
|
|
|
res.put("hospital", tmp.getHospital());
|
|
|
res.put("hospitalName", tmp.getHospitalName());
|
|
|
res.put("finish", saveModel2.getResult2().longValue());
|
|
|
res.put("finishRate", commonUtil.getRangeDouble(saveModel2.getResult2().intValue(), tmp.getResult2().intValue()));
|
|
|
result.add(res);
|
|
|
}
|
|
|
result.sort(Comparator.comparing(obj -> ((JSONObject) obj).getDouble("finishRate")).reversed());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取生活照料排名
|
|
|
* @param endDate
|
|
|
* @param area
|
|
|
* @param level
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getLifeCareRank(String endDate,String area,Integer level) throws Exception {
|
|
|
JSONArray result = new JSONArray();
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevelList(endDate, endDate, area, level, "49", SaveModel.timeLevel_DDL,null,"5", null,"1,2,3");
|
|
|
for (SaveModel tmp:list){
|
|
|
JSONObject res = new JSONObject();
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, tmp.getHospital(), 4, "49", SaveModel.timeLevel_DDL,null,"2");
|
|
|
res.put("total", tmp.getResult2().longValue());
|
|
|
res.put("hospital", tmp.getHospital());
|
|
|
res.put("hospitalName", tmp.getHospitalName());
|
|
|
res.put("dept", tmp.getDept());
|
|
|
res.put("deptName", tmp.getDeptName());
|
|
|
res.put("finish", saveModel2.getResult2().longValue());
|
|
|
res.put("finishRate", commonUtil.getRangeDouble(saveModel2.getResult2().intValue(), tmp.getResult2().intValue()));
|
|
|
result.add(res);
|
|
|
}
|
|
|
result.sort(Comparator.comparing(obj -> ((JSONObject) obj).getDouble("finishRate")).reversed());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 管理端首页智慧照护生活照料项目新增情况
|
|
|
*/
|
|
|
public JSONObject statisticsLifeCareItemAdd(String endDate, String area, Integer level, String type) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "48", SaveModel.timeLevel_DDL, null, null);
|
|
|
|
|
|
res.put("index_" + 48 + "_total", saveModel.getResult2().longValue());
|
|
|
if (StringUtils.isNotBlank(type)) {
|
|
|
//周/月 增量
|
|
|
String start = statisticsUtilService.calStart(endDate, type);
|
|
|
SaveModel saveModelAdd = elasticsearchUtil.findOneDateQuotaLevels(start, endDate, area, level, "48", SaveModel.timeLevel_ZL, null,null);
|
|
|
res.put("index_" + 48 + "_add", saveModelAdd.getResult2().longValue());
|
|
|
}
|
|
|
JSONArray addDetail = new JSONArray();
|
|
|
if (StringUtils.isNotBlank(type)) {
|
|
|
//周/月 增量
|
|
|
String start = statisticsUtilService.calStart(endDate, type);
|
|
|
|
|
|
List<SaveModel> saveModelAdds = elasticsearchUtil.findDateQuotaLevelList(start, endDate, area, level, "48", SaveModel.timeLevel_ZL, null,null,"1", null );
|
|
|
for (SaveModel saveModelTmp : saveModelAdds) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
SaveModel saveMode2 = elasticsearchUtil.findOneDateQuotaLevels(endDate, endDate, area, level, "48", SaveModel.timeLevel_DDL, null, saveModelTmp.getSlaveKey1());
|
|
|
json.put("total", saveMode2.getResult2().longValue());
|
|
|
json.put("num", saveModelTmp.getResult2().longValue());
|
|
|
json.put("code", saveModelTmp.getSlaveKey1());
|
|
|
json.put("name", saveModelTmp.getSlaveKey1Name());
|
|
|
addDetail.add(json);
|
|
|
}
|
|
|
}
|
|
|
res.put("index_add_detail", addDetail);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通用增量趋势接口
|
|
|
*/
|
|
|
public JSONArray addLineIndexs(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel) throws Exception {
|
|
|
String[] indexs = index.split(",");
|
|
|
JSONArray result = new JSONArray();
|
|
|
List<List<SaveModel>> indexResultList = new ArrayList<>();
|
|
|
for (String tmp:indexs){
|
|
|
List<SaveModel> list = elasticsearchUtil.findDateQuotaLevel0(startDate, endDate, area, level, tmp, timeLevel, interval, lowLevel);
|
|
|
indexResultList.add(list);
|
|
|
}
|
|
|
if (indexResultList.size()>0){
|
|
|
List<SaveModel> list = indexResultList.get(0);
|
|
|
Integer length = list.size();
|
|
|
Integer indexLength = indexResultList.size();
|
|
|
for (int i=0;i<length;i++) {
|
|
|
JSONObject range = new JSONObject();
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
Double amount = saveModel.getResult2();
|
|
|
String date = DateUtil.dateToStr(saveModel.getQuotaDate(), "yyyy-MM-dd");
|
|
|
for (int j=1;j<indexLength;j++){
|
|
|
try {
|
|
|
List<SaveModel> tmpList = indexResultList.get(j);
|
|
|
SaveModel saveModelTmp = tmpList.get(i);
|
|
|
amount +=saveModelTmp.getResult2();
|
|
|
}catch (Exception e){}
|
|
|
}
|
|
|
range.put("range", date);
|
|
|
range.put("amount", amount);
|
|
|
result.add(range);
|
|
|
}
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|