|
@ -152,6 +152,10 @@ public class StatisticsService {
|
|
|
Integer emergencyCallNum = jdbcTemplate.queryForObject(emergencyCallSql, Integer.class);
|
|
|
String securityMonitoringSql = "SELECT COUNT(1) FROM base_security_monitoring_order where 1=1 " + filter;
|
|
|
Integer securityMonitoringNum = jdbcTemplate.queryForObject(securityMonitoringSql, Integer.class);
|
|
|
String infantNumSql = "SELECT infant_num FROM base_older_num WHERE `year` = '2022'";
|
|
|
Integer infantNum = jdbcTemplate.queryForObject(infantNumSql, Integer.class);
|
|
|
String infantOrgSql = "SELECT count(`code`) FROM base_org WHERE type = 4 AND del = 1 and `code` NOT IN (SELECT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org')";
|
|
|
Integer infantOrgNum = jdbcTemplate.queryForObject(infantOrgSql,Integer.class);
|
|
|
|
|
|
/*//男 女 性别总数
|
|
|
String sexCountSql = "SELECT COUNT(*) ss, CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END AS sex " +
|
|
@ -164,6 +168,10 @@ public class StatisticsService {
|
|
|
res.put("index_" + 41, emergencyCallNum);
|
|
|
//老人 安放监护
|
|
|
res.put("index_" + 43, securityMonitoringNum);
|
|
|
//幼儿-数量
|
|
|
res.put("infantNum",infantNum);
|
|
|
// 托幼机构
|
|
|
res.put("infantOrgNum",infantOrgNum);
|
|
|
//评估类型
|
|
|
res.put("capacityAssessment", cloudCareForTheElderly(endDate, defalutArea, defalutLevel));
|
|
|
//居民健康标签纬度
|
|
@ -3115,7 +3123,7 @@ public class StatisticsService {
|
|
|
" GROUP BY p.idcard ";
|
|
|
break;
|
|
|
case 2:
|
|
|
sql +=" SELECT DISTINCT p.id AS id, p.`name` AS `name`, p.sex AS sex, p.idcard AS idcard," +
|
|
|
sql =" SELECT DISTINCT p.id AS id, p.`name` AS `name`, p.sex AS sex, p.idcard AS idcard," +
|
|
|
" CASE WHEN LENGTH( p.idcard )= 18 THEN " +
|
|
|
" YEAR ( now()) - YEAR (substring( p.idcard, 7, 8 )) " +
|
|
|
" WHEN LENGTH( p.idcard )= 15 THEN YEAR (now()) - YEAR (STR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL " +
|
|
@ -3123,6 +3131,8 @@ public class StatisticsService {
|
|
|
" FROM base_patient p " +
|
|
|
" WHERE p.archive_type = 2 and p.del = 1 "+nameSql+idcardSql+" <testUserSql>";
|
|
|
break;
|
|
|
case 3:
|
|
|
sql =" SELECT p.id,p.name,CASE WHEN p.sex = 1 THEN '男' WHEN p.sex =2 THEN '女' END ,TIMESTAMPDIFF(YEAR, p.birthday, CURDATE()) as age,p.idcard,p.mobile,p.address FROM base_patient p WHERE p.del =1 AND p.register = 2"+nameSql+idcardSql;
|
|
|
}
|
|
|
|
|
|
|
|
@ -3162,7 +3172,7 @@ public class StatisticsService {
|
|
|
if (StringUtils.isNotBlank(idcard)) {
|
|
|
idcardSql = " AND p.idcard = '"+idcard+"'";
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(idcard)) {
|
|
|
if (StringUtils.isNotBlank(orgCode)) {
|
|
|
orgCodeSql = " AND t.id = '"+orgCode+"'";
|
|
|
}
|
|
|
|
|
@ -3177,7 +3187,7 @@ public class StatisticsService {
|
|
|
switch (type) {
|
|
|
case 1:
|
|
|
sql = " SELECT DISTINCT" +
|
|
|
" p.name, o.`status`, o.id AS orderId,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time ," +
|
|
|
" p.name, o.`status`, o.id AS orderId,p.id AS patientId,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time ," +
|
|
|
" GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName," +
|
|
|
" GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile," +
|
|
|
" p.mobile AS pmobile, p.address AS address, t.`name` AS orgName," +
|
|
@ -3199,8 +3209,9 @@ public class StatisticsService {
|
|
|
" AND tm.team_code = t.id " +
|
|
|
" AND p.archive_type = 1 " +
|
|
|
" AND d.id = tm.doctor_code " +orgCodeSql+idcardSql+nameSql+
|
|
|
" GROUP BY orderId " +
|
|
|
" union all " +
|
|
|
"SELECT DISTINCT p.name, o.`status`, o.id AS orderId, DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time, " +
|
|
|
" SELECT DISTINCT p.name, o.`status`, o.id AS orderId,p.id AS patientId, DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time, " +
|
|
|
" GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName, " +
|
|
|
" GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile, " +
|
|
|
" p.mobile AS pmobile, p.address AS address, t.`name` AS orgName, " +
|
|
@ -3224,11 +3235,11 @@ public class StatisticsService {
|
|
|
" AND r.team_code = t.id " +
|
|
|
" AND tm.team_code = t.id " +
|
|
|
" AND p.archive_type = 1 " + orgCodeSql+idcardSql+nameSql+
|
|
|
" AND d.id = tm.doctor_code ";
|
|
|
" AND d.id = tm.doctor_code ";
|
|
|
total = overTimeOrderListTotalSql(1,nameSql,idcardSql,orgCodeSql);
|
|
|
break;
|
|
|
case 2:
|
|
|
sql = "SELECT DISTINCT o.id as orderId, p.`name`, p.mobile,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time , fd.NAME AS lifeName, bo.NAME AS serviceOrgName, bo.mobile AS orgMobile, t.`name` AS area " +
|
|
|
sql = "SELECT DISTINCT o.id as orderId,p.id AS patientId, p.`name`, p.mobile,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time , fd.NAME AS lifeName, bo.NAME AS serviceOrgName, bo.mobile AS orgMobile, t.`name` AS area " +
|
|
|
" FROM " +
|
|
|
" base_life_care_order o " +
|
|
|
" INNER JOIN base_patient p ON o.patient = p.id " +
|
|
@ -3252,7 +3263,7 @@ public class StatisticsService {
|
|
|
" AND CONVERT ( sr.patient USING utf8 ) = p.id " +
|
|
|
" AND r.team_code = t.id " +
|
|
|
" AND p.archive_type = 1 "+nameSql+idcardSql+orgCodeSql+" UNION ALL " +
|
|
|
"SELECT DISTINCT co.id as orderId, p.`name`, p.mobile, DATE_FORMAT(co.create_time,'%Y-%m-%d %H:%i:%s') as create_time, fd.NAME AS lifeName, co.hospital_name AS serviceOrgName,bo.mobile AS orgMobile, p.residential_area AS area " +
|
|
|
"SELECT DISTINCT co.id as orderId,p.id AS patientId, p.`name`, p.mobile, DATE_FORMAT(co.create_time,'%Y-%m-%d %H:%i:%s') as create_time, fd.NAME AS lifeName, co.hospital_name AS serviceOrgName,bo.mobile AS orgMobile, p.residential_area AS area " +
|
|
|
"FROM " +
|
|
|
" base_life_care_order co " +
|
|
|
" LEFT JOIN base_patient p ON co.patient = p.id " +
|
|
@ -3272,7 +3283,7 @@ public class StatisticsService {
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("list",list);
|
|
|
jsonObject.put("total",total);
|
|
|
jsonObject.put("total",Integer.parseInt(total));
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
@ -3342,7 +3353,7 @@ public class StatisticsService {
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("list",list);
|
|
|
jsonObject.put("total",emeSecOrderListTotalSql(nameSql,idcardSql,orgCodeSql,statusSql));
|
|
|
jsonObject.put("total",Integer.parseInt(emeSecOrderListTotalSql(nameSql,idcardSql,orgCodeSql,statusSql)));
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
@ -3513,9 +3524,7 @@ public class StatisticsService {
|
|
|
if (StringUtils.isNotBlank(name)) nameSql = " AND p.name LIKE '%" + name + "%'";
|
|
|
if (StringUtils.isNotBlank(deviceSn)) deviceSnSql = " AND pd.device_sn = '" + deviceSn + "'";
|
|
|
|
|
|
if (page == null) page = 1;
|
|
|
if (size == null) size = 10;
|
|
|
page = (page - 1) * size;
|
|
|
page = page>0?page-1:0;
|
|
|
|
|
|
String deviceSql = "";
|
|
|
if ("jk".equals(type)) {
|
|
@ -3546,13 +3555,13 @@ public class StatisticsService {
|
|
|
" LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
|
|
|
" pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
|
|
|
|
|
|
totalSql = " SELECT count(DISTINCT p.id) FROM " +
|
|
|
totalSql = " SELECT count(DISTINCT pd.id) FROM " +
|
|
|
" wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
|
|
|
" LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
|
|
|
" pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
|
|
|
}
|
|
|
|
|
|
deviceSql += " GROUP BY id LIMIT " + page + "," + size + " ";
|
|
|
deviceSql += " GROUP BY id LIMIT " + page*size + "," + size + " ";
|
|
|
|
|
|
List<Map<String, Object>> deviceList = jdbcTemplate.queryForList(deviceSql);
|
|
|
List<String> list = jdbcTemplate.queryForList(totalSql, String.class);
|
|
@ -3562,6 +3571,9 @@ public class StatisticsService {
|
|
|
if (null!=signInfoMap) {
|
|
|
map.put("orgName", signInfoMap.get("orgName"));
|
|
|
jsonArray.add(map);
|
|
|
}else {
|
|
|
map.put("orgName","");
|
|
|
jsonArray.add(map);
|
|
|
}
|
|
|
}
|
|
|
return PageEnvelop.getSuccessListWithPage("success", jsonArray, page, size, Long.parseLong(list.get(0)));
|
|
@ -3595,4 +3607,63 @@ public class StatisticsService {
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取设备
|
|
|
public JSONObject deviceinfoStatisticsNum(String type){
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
//测试用户
|
|
|
String testUsqlSql = "SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_user' OR dict_name = 'jkzl_older' ) AND dict_code IS NOT NULL";
|
|
|
|
|
|
//类型数量
|
|
|
String typeTotalSql = "SELECT count(DISTINCT category_code) AS total FROM dm_device WHERE 1=1 AND device_type = "+type+" AND del = 1 GROUP BY device_type";
|
|
|
|
|
|
//离线设备数量
|
|
|
String offLineDeviceSql="select count(distinct pd.device_sn) total 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.device_type = "+type+" AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
//设备总数
|
|
|
String deviceTotalSql = "SELECT count(DISTINCT device_code) FROM wlyy_devices WHERE (device_code IS NOT NULL OR device_code <> '') AND device_type = "+type+"";
|
|
|
|
|
|
//设备在线量
|
|
|
String lineDeviceSql ="select count(distinct pd.device_sn) total 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=1 and pd.device_type = 0 AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
//七天使用
|
|
|
String sevenDayUseSql ="select count(distinct pd.device_sn) total 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 pd.device_type = "+type+" AND EXISTS(SELECT 1 FROM device_data_push_log pl WHERE pl.device_sn = pd.device_sn AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= pl.create_time ) AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
|
|
|
List<Integer> total = jdbcTemplate.queryForList(typeTotalSql, Integer.class);
|
|
|
jsonObject.put("typeTotal",total.get(0));
|
|
|
total = jdbcTemplate.queryForList(offLineDeviceSql,Integer.class);
|
|
|
jsonObject.put("offLineDevice",total.get(0));
|
|
|
total = jdbcTemplate.queryForList(deviceTotalSql,Integer.class);
|
|
|
jsonObject.put("deviceTotal",total.get(0));
|
|
|
total = jdbcTemplate.queryForList(lineDeviceSql,Integer.class);
|
|
|
jsonObject.put("lineDevice",total.get(0));
|
|
|
total = jdbcTemplate.queryForList(sevenDayUseSql,Integer.class);
|
|
|
Float num = 0F;
|
|
|
if (total.size()>0)
|
|
|
{
|
|
|
num= (float)Integer.parseInt(jsonObject.get("deviceTotal").toString())/(float)total.get(0);
|
|
|
}
|
|
|
jsonObject.put("sevenDayUse",num);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> findByPatientHelper(String patient){
|
|
|
String sql = "SELECT ph.doctor,ph.doctor_name,d.mobile FROM base_patient_helper ph INNER JOIN base_doctor d ON d.id = ph.doctor WHERE ph.del = 1 AND ph.patient = '"+patient+"'";
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|