|
@ -3723,17 +3723,22 @@ public class StatisticsService {
|
|
|
}
|
|
|
|
|
|
//健康设备-安防设备 列表
|
|
|
public PageEnvelop healthySecurityDeviceList(String name, String deviceSn, String categoryCode, String contactStatus, String type, Integer page, Integer size) {
|
|
|
public PageEnvelop healthySecurityDeviceList(String name, String deviceSn,String teamId, String categoryCode, String contactStatus, String type, Integer page, Integer size) {
|
|
|
|
|
|
String nameSql = "";
|
|
|
String deviceSnSql = "";
|
|
|
String categoryCodeSql = "";
|
|
|
String contactStatusSql = "";
|
|
|
String totalSql = "";
|
|
|
String teamCodeSql = "";
|
|
|
if (StringUtils.isNotBlank(contactStatus))
|
|
|
contactStatusSql = " AND wd.contact_status = '" + contactStatus + "'";
|
|
|
if (StringUtils.isNotBlank(name)) nameSql = " AND p.name LIKE '%" + name + "%'";
|
|
|
if (StringUtils.isNotBlank(deviceSn)) deviceSnSql = " AND pd.device_sn = '" + deviceSn + "'";
|
|
|
if(StringUtils.isNotBlank(teamId)){
|
|
|
teamCodeSql += " INNER JOIN base_service_package_sign_record sr ON CONVERT( sr.patient USING utf8 ) = p.id AND sr.STATUS = 1 AND sr.`status` = 1 "+
|
|
|
" INNER JOIN base_service_package_record r ON sr.id = r.sign_id and r.team_code = '"+teamId+"'";
|
|
|
}
|
|
|
|
|
|
String filter="AND pd.USER NOT IN ( 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 sqltmp = " SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' OR dict_name ='jkzl_helper' OR dict_name= 'jkzl_olderRelative' OR dict_name ='jkzl_user') ";
|
|
@ -3754,18 +3759,18 @@ public class StatisticsService {
|
|
|
if (StringUtils.isNotBlank(categoryCode))
|
|
|
categoryCodeSql = " AND pd.category_code = '" + categoryCode + "'";
|
|
|
|
|
|
deviceSql = "SELECT p.id AS patient,pd.id AS id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,dd.photo,'健康设备' AS deviceType,p.`name`,p.mobile,p.phone,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " +
|
|
|
deviceSql = "SELECT distinct p.id AS patient,pd.id AS id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,dd.photo,'健康设备' AS deviceType,p.`name`,p.mobile,p.phone,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_device pd " +
|
|
|
" INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " + teamCodeSql +
|
|
|
" LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
|
|
|
"WHERE " +
|
|
|
" 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
|
|
|
totalSql = "SELECT count(pd.id) FROM " +
|
|
|
totalSql = "SELECT count(distinct pd.id) FROM " +
|
|
|
" wlyy_patient_device pd " +
|
|
|
" INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " + teamCodeSql +
|
|
|
" LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
|
|
|
" WHERE " +
|
|
|
" 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
|
|
@ -3777,18 +3782,18 @@ public class StatisticsService {
|
|
|
if (StringUtils.isNotBlank(categoryCode))
|
|
|
categoryCodeSql = " AND pd.category_code = '" + categoryCode + "'";
|
|
|
|
|
|
deviceSql = "SELECT p.id AS patient,pd.id AS id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,dd.photo,'安防设备' AS deviceType,p.`name`,p.mobile,p.phone,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " +
|
|
|
deviceSql = "SELECT distinct p.id AS patient,pd.id AS id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,dd.photo,'安防设备' AS deviceType,p.`name`,p.mobile,p.phone,wd.contact_status * 1 AS contactStatus,pd.category_code as categoryCode " +
|
|
|
" FROM " +
|
|
|
" wlyy_patient_device pd " +
|
|
|
" INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 "+ teamCodeSql +
|
|
|
" LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
|
|
|
"WHERE " +
|
|
|
" 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
|
|
|
totalSql = "SELECT count(pd.id) FROM " +
|
|
|
totalSql = "SELECT count(distinct pd.id) FROM " +
|
|
|
" wlyy_patient_device pd " +
|
|
|
" INNER JOIN wlyy_devices wd ON pd.device_sn = wd.device_code " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " +
|
|
|
" INNER JOIN base_patient p ON pd.USER = p.id AND pd.del = 0 AND p.del = 1 " + teamCodeSql +
|
|
|
" LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
|
|
|
" WHERE " +
|
|
|
" 1=1 "+filter + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
|
|
@ -3842,41 +3847,67 @@ public class StatisticsService {
|
|
|
|
|
|
|
|
|
//获取设备
|
|
|
public JSONObject deviceinfoStatisticsNum(String type,String deviceCategory){
|
|
|
public JSONObject deviceinfoStatisticsNum(String type,String deviceCategory,String teamId){
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
String teamCodeSql = "";
|
|
|
if(StringUtils.isNotBlank(teamId)){
|
|
|
teamCodeSql += " INNER JOIN base_service_package_sign_record sr ON CONVERT( sr.patient USING utf8 ) = p.id AND sr.STATUS = 1 AND sr.`status` = 1 "+
|
|
|
" INNER JOIN base_service_package_record r ON sr.id = r.sign_id and r.team_code = '"+teamId+"'";
|
|
|
}
|
|
|
|
|
|
//测试用户
|
|
|
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 testUsqlSql = "SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE 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";
|
|
|
if(StringUtils.isNotBlank(teamId)){
|
|
|
typeTotalSql = "select count(distinct pd.category_code) 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 " + teamCodeSql +
|
|
|
" where pd.device_type = "+type+" AND pd.user NOT IN ("+testUsqlSql+") ";
|
|
|
}
|
|
|
|
|
|
|
|
|
//离线设备数量
|
|
|
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 " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " + teamCodeSql +
|
|
|
" where dev.contact_status=0 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+"";
|
|
|
if(StringUtils.isNotBlank(teamId)){
|
|
|
deviceTotalSql = "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 " + teamCodeSql +
|
|
|
" where pd.device_type = "+type+" AND pd.user NOT IN ("+testUsqlSql+") ";
|
|
|
}
|
|
|
|
|
|
//设备在线量
|
|
|
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 " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " + teamCodeSql +
|
|
|
" where dev.contact_status=1 and pd.device_type = 0 AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
String deviceCategorySql = "";
|
|
|
String categoryCodeSql = "";
|
|
|
String categoryCodeTotalSql = "";
|
|
|
if (StringUtils.isNotBlank(deviceCategory)){
|
|
|
deviceCategorySql = " AND device_category= '"+deviceCategory+"' ";
|
|
|
categoryCodeSql = " AND category_code= '"+deviceCategory+"' ";
|
|
|
categoryCodeTotalSql = " AND pd.category_code = '"+deviceCategory+"' ";
|
|
|
}
|
|
|
|
|
|
//七天使用 AND device_category= 4 手表
|
|
|
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 " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " + teamCodeSql +
|
|
|
" where pd.device_type = "+type+" AND EXISTS(SELECT 1 FROM device_data_push_log pl WHERE pl.device_sn = pd.device_sn "+deviceCategorySql+" AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= pl.create_time ) AND pd.user NOT IN ("+testUsqlSql+") group by pd.device_type";
|
|
|
|
|
|
//设备类型总数
|
|
|
String deviceCodeTotalSql ="SELECT count(DISTINCT device_code) FROM wlyy_devices WHERE (device_code IS NOT NULL OR device_code <> '') AND category_code = '"+deviceCategory+"'";
|
|
|
String deviceCodeTotalSql ="SELECT count(DISTINCT device_code) FROM wlyy_devices WHERE (device_code IS NOT NULL OR device_code <> '') " + categoryCodeSql;
|
|
|
if(StringUtils.isNotBlank(teamId)){
|
|
|
deviceCodeTotalSql = "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 " + teamCodeSql +
|
|
|
" where pd.user NOT IN ("+testUsqlSql+") "+categoryCodeTotalSql;
|
|
|
}
|
|
|
|
|
|
//long start=System.currentTimeMillis();
|
|
|
List<Integer> total = jdbcTemplate.queryForList(typeTotalSql, Integer.class);
|
|
@ -3890,9 +3921,9 @@ public class StatisticsService {
|
|
|
total = jdbcTemplate.queryForList(lineDeviceSql,Integer.class);
|
|
|
jsonObject.put("lineDevice",total.get(0));
|
|
|
total = jdbcTemplate.queryForList(sevenDayUseSql,Integer.class);
|
|
|
Integer deviceCodeTotal = jdbcTemplate.queryForObject(deviceCodeTotalSql,Integer.class);
|
|
|
Float num = 0F;
|
|
|
if (total.size()>0) {
|
|
|
Integer deviceCodeTotal = jdbcTemplate.queryForObject(deviceCodeTotalSql,Integer.class);
|
|
|
num= (float)total.get(0)/(float)deviceCodeTotal;
|
|
|
}
|
|
|
jsonObject.put("sevenDayUse",num*100);
|