|
@ -25,6 +25,7 @@ import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.SqlInOutParameter;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@ -151,7 +152,7 @@ public class MonitorPlatformService {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
String[] deviceNames = deviceName.split(",");
|
|
|
for (String tmp :deviceNames){
|
|
|
String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code where wd.device_name like '%"+tmp+"%'";
|
|
|
String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code where wd.device_name like '%"+tmp+"%' and pd.del=0 ";
|
|
|
List<String> tmpList = jdbcTemplate.queryForList(sql,String.class);
|
|
|
listTmp.addAll(tmpList);
|
|
|
}
|
|
@ -164,7 +165,7 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code ";
|
|
|
String sql="select DISTINCT device_code from device.wlyy_devices wd INNER JOIN wlyy.wlyy_patient_device pd on pd.device_sn = wd.device_code where 1=1 and pd.del=0 ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql+="and pd.category_code in ('"+deviceType.replace(",","','")+"') ";
|
|
|
}
|
|
@ -988,7 +989,7 @@ public class MonitorPlatformService {
|
|
|
public JSONArray datafiltering(String name){
|
|
|
StringBuffer sql = new StringBuffer("SELECT d.category_code as categoryCode,d.id,d.device_sn deviceSn,p.code,p.name,d.device_name deviceName ");
|
|
|
sql.append("from wlyy.wlyy_patient_device d,wlyy.wlyy_patient p ");
|
|
|
sql.append("WHERE d.`user` = p.`code` ");
|
|
|
sql.append("WHERE d.`user` = p.`code` and d.del=0 ");
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(name)){
|
|
|
sql.append("and (d.device_sn like '%"+name+"%' or p.`name` = '"+name+"') ");
|
|
|
}
|
|
@ -1129,7 +1130,7 @@ public class MonitorPlatformService {
|
|
|
try {
|
|
|
String sql = "select count(DISTINCT A.device_name) as total,A.device_name,A.manufacturer from (\n" +
|
|
|
"select pd.device_name,wd.manufacturer from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
|
|
|
"where pd.device_sn = wd.device_code \n" +
|
|
|
"where pd.device_sn = wd.device_code and pd.del=0 \n" +
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>''\n" +
|
|
|
"GROUP BY wd.manufacturer_code,pd.device_name\n" +
|
|
|
"UNION\n" +
|
|
@ -1143,7 +1144,7 @@ public class MonitorPlatformService {
|
|
|
result.put("Manufacturers",arr);
|
|
|
sql = "select count(DISTINCT A.device_name)from (\n" +
|
|
|
"select pd.device_name from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
|
|
|
"where pd.device_sn = wd.device_code \n" +
|
|
|
"where pd.device_sn = wd.device_code and pd.del=0 \n" +
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>''\n" +
|
|
|
"GROUP BY wd.manufacturer_code,pd.device_name\n" +
|
|
|
"UNION\n" +
|
|
@ -1182,7 +1183,7 @@ public class MonitorPlatformService {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
sqlCondition.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') ");
|
|
|
}
|
|
|
sql.append("SELECT d.category_code,d.device_name, COUNT(*) c from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user` "+sqlCondition+" ");
|
|
|
sql.append("SELECT d.category_code,d.device_name, COUNT(*) c from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f WHERE f.`status`>0 and d.del=0 and f.patient = d.`user` "+sqlCondition+" ");
|
|
|
if ("0".equals(showLevel)){//组合一体机(5健康小屋,取自物联网),单体征测量仪(2血压计、1血糖仪)
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("'))a, ");
|
|
@ -1247,14 +1248,14 @@ public class MonitorPlatformService {
|
|
|
result.put("deviceInfo",arr);//设备信息统计
|
|
|
//统计物联率设备,失联设备
|
|
|
sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f ");
|
|
|
sql.append("where f.`status`>0 and f.patient = d.`user` and d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'') "+sqlCondition+" ");
|
|
|
sql.append("where f.`status`>0 and d.del=0 and f.patient = d.`user` and d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'') "+sqlCondition+" ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
}
|
|
|
Integer iotCount = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//物联设备数量
|
|
|
result.put("iotCount",iotCount);
|
|
|
|
|
|
sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user` "+sqlCondition+" ");
|
|
|
sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and d.del=0 and f.patient = d.`user` "+sqlCondition+" ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
}
|
|
@ -1263,7 +1264,7 @@ public class MonitorPlatformService {
|
|
|
|
|
|
//失联设备(一周未上传当作失联)
|
|
|
sql.append("and d.device_sn not in (select device_sn from ( select device_sn,MAX(record_date) record_date from device.wlyy_patient_health_index where device_sn<>'' GROUP BY device_sn)a ");
|
|
|
sql.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= 7)");
|
|
|
sql.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= 30)");
|
|
|
Integer lostContact = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
result.put("lostContact",lostContact);
|
|
|
}
|
|
@ -1334,17 +1335,25 @@ public class MonitorPlatformService {
|
|
|
public JSONObject iotAndLostRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital,String quotaCode){
|
|
|
JSONObject result = new JSONObject();
|
|
|
StringBuffer sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and f.patient = d.`user` ");
|
|
|
StringBuffer sqlCondition = new StringBuffer(" where 1=1 ");
|
|
|
StringBuffer sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and d.del=0 and f.patient = d.`user` ");
|
|
|
StringBuffer sqlCondition = new StringBuffer(" ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
sqlCondition.append(" and f.hospital in (SELECT dh.code from wlyy.dm_hospital dh where dh.town ='"+area+"' and dh.del =1 ) ");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
sqlCondition.append(" and d.hospital ="+hospital+" ");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
sqlCondition.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
}
|
|
|
sql.append(sqlCondition);
|
|
|
Integer grantCount = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//单体征设备发放总数
|
|
|
result.put("totalAll",grantCount);
|
|
|
Integer total=0;
|
|
|
if("1".equals(quotaCode)){
|
|
|
//物联
|
|
|
sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f ");
|
|
|
sqlCondition = new StringBuffer(" where 1=1 ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
sql.append("LEFT JOIN wlyy.dm_hospital dh on f.hospital = dh.`code` ");
|
|
|
sqlCondition.append("and dh.town='"+area+"' ");
|
|
@ -1352,7 +1361,7 @@ public class MonitorPlatformService {
|
|
|
sqlCondition.append("and dh.code='"+hospital+"' ");
|
|
|
}
|
|
|
}
|
|
|
sqlCondition.append("and f.`status`>0 and f.patient = d.`user` and d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'' ");
|
|
|
sqlCondition.append("and f.`status`>0 and d.del=0 and f.patient = d.`user` and d.device_sn in(select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&&org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sqlCondition.append("and record_date >='"+startTime+" 00:00:00' and record_date<='"+endTime+" 23:59:59' ");
|
|
|
}
|
|
@ -1371,12 +1380,15 @@ public class MonitorPlatformService {
|
|
|
sqlCondition.append("and dh.code='"+hospital+"' ");
|
|
|
}
|
|
|
}
|
|
|
sqlCondition.append("and f.`status`>0 and f.patient = d.`user` ");
|
|
|
sqlCondition.append("and f.`status`>0 and d.del=0 and f.patient = d.`user` ");
|
|
|
sqlCondition.append(" and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
sqlCondition.append("and d.device_sn not in (select DISTINCT device_sn from device.wlyy_patient_health_index where device_sn<>'' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&&org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sqlCondition.append("and record_date >='"+startTime+" 00:00:00' and record_date<='"+endTime+" 23:59:59' ");
|
|
|
}
|
|
|
else{
|
|
|
sqlCondition.append("and TIMESTAMPDIFF(DAY,record_date,NOW()) <= 30 ");
|
|
|
}
|
|
|
sqlCondition.append(")");
|
|
|
sql.append(sqlCondition);
|
|
|
total=jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
@ -1384,6 +1396,10 @@ public class MonitorPlatformService {
|
|
|
Integer count =0;
|
|
|
if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
|
|
|
String sqll = "select COUNT(*) from xmiot.iot_equipmet_detail";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
sqll+=" where belong_are_code='"+area+"' ";
|
|
|
}
|
|
|
|
|
|
count = jdbcTemplate.queryForObject(sqll,Integer.class);
|
|
|
result.put("totalAll",grantCount+count);
|
|
|
count =0;
|
|
@ -1426,7 +1442,7 @@ public class MonitorPlatformService {
|
|
|
try {
|
|
|
StringBuffer sql = new StringBuffer("select DISTINCT A.device_name from (\n" +
|
|
|
"select pd.device_name from wlyy.wlyy_patient_device pd,device.wlyy_devices wd\n" +
|
|
|
"where pd.device_sn = wd.device_code \n" +
|
|
|
"where pd.device_sn = wd.device_code and pd.del=0 \n" +
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>'' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and pd.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
@ -1508,7 +1524,7 @@ public class MonitorPlatformService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getDeviceTotalCount(String startTime,String endTime,String deviceType,String area){
|
|
|
public JSONObject getDeviceTotalCount(String startTime,String endTime,String deviceType,String area,String hospital){
|
|
|
Integer totalAll=0;
|
|
|
Integer grant=0;
|
|
|
if (deviceType.contains("5")){
|
|
@ -1520,26 +1536,45 @@ public class MonitorPlatformService {
|
|
|
totalAll +=tmp;
|
|
|
grant +=tmp;
|
|
|
}
|
|
|
String allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d ";
|
|
|
String allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 ";
|
|
|
int i = 0;
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("1")){
|
|
|
allCountSql+= " where device_name like '%血糖仪%' ";
|
|
|
allCountSql+= " and ( device_name like '%血糖仪%' ";
|
|
|
i = 1;
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("2")){
|
|
|
if(i==1){
|
|
|
allCountSql+= " or device_name like '%血压计%'";
|
|
|
}else{
|
|
|
allCountSql+= " where device_name like '%血压计%' ";
|
|
|
allCountSql+= " and ( device_name like '%血压计%' ";
|
|
|
}
|
|
|
}
|
|
|
Integer allCount = jdbcTemplate.queryForObject(allCountSql, Integer.class);
|
|
|
totalAll+=allCount;
|
|
|
allCountSql+= " ) ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
allCountSql+=" and grant_org_code in (SELECT dh.code from wlyy.dm_hospital dh where dh.town ='"+area+"' and dh.del =1 )";
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
allCountSql+=" and grant_org_code ="+hospital+" ";
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&(deviceType.contains("1")||deviceType.contains("2"))){
|
|
|
Integer allCount = jdbcTemplate.queryForObject(allCountSql, Integer.class);//单体征总数
|
|
|
totalAll+=allCount;
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT COUNT(*) from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f WHERE 1=1 and f.`status`>0 and d.del=0 and f.patient = d.`user` ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
sql.append(" and f.hospital in (SELECT dh.code from wlyy.dm_hospital dh where dh.town ='"+area+"' and dh.del =1 ) ");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
sql.append(" and d.hospital ="+hospital+" ");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&& org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sql.append(" and d.czrq <='"+endTime+" 23:59:59' ");
|
|
|
}
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
Integer count = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//发放总数
|
|
|
grant +=count;
|
|
|
}
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT COUNT(*) from wlyy.wlyy_patient_device d,wlyy.wlyy_sign_family f WHERE 1=1 and f.`status`>0 and f.patient = d.`user` ");
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
Integer count = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
grant +=count;
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("totalAll",totalAll);
|