|
@ -3,6 +3,7 @@ package com.yihu.iot.service.monitorPlatform;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.gson.JsonArray;
|
|
|
import com.yihu.iot.dao.dict.IotSystemDictDao;
|
|
|
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
|
|
|
import com.yihu.iot.service.analyzer.WlyyIotTzDict;
|
|
@ -43,7 +44,7 @@ import java.util.*;
|
|
|
* Created by yeshijie on 2020/5/11.
|
|
|
*/
|
|
|
@Service
|
|
|
public class MonitorPlatformService {
|
|
|
public class MonitorPlatformService {
|
|
|
|
|
|
@Value("${spring.wlyy.url}")
|
|
|
private String wlyyUrl;
|
|
@ -55,7 +56,9 @@ public class MonitorPlatformService {
|
|
|
private String wxId;
|
|
|
@Value("${wechat.flag}")
|
|
|
private boolean flag;
|
|
|
public static Map<String,String> tokenMap = new HashMap<>();
|
|
|
@Value("${hlw.baseUrl}")
|
|
|
private String baseUrl;
|
|
|
public static Map<String, String> tokenMap = new HashMap<>();
|
|
|
|
|
|
@Autowired
|
|
|
private HttpClientUtil httpClientUtil;
|
|
@ -82,26 +85,27 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 获取位置信息
|
|
|
*
|
|
|
* @param diseaseCondition
|
|
|
* @return
|
|
|
*/
|
|
|
public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type,String deviceType,String deviceName) throws IOException {
|
|
|
public MixEnvelop<LocationDataVO, LocationDataVO> findDeviceLocations(Integer diseaseCondition, Integer page, Integer size, String type, String deviceType, String deviceName) throws IOException {
|
|
|
MixEnvelop<LocationDataVO, LocationDataVO> envelop = new MixEnvelop<>();
|
|
|
MixEnvelop<LocationDataVO, LocationDataVO> envelopTmp = null;
|
|
|
Integer total = 0;
|
|
|
if(org.apache.commons.lang.StringUtils.isNotBlank(type)){
|
|
|
JSONObject json = iotSearchPatientDeviceSN(type,page,size,deviceName);
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(type)) {
|
|
|
JSONObject json = iotSearchPatientDeviceSN(type, page, size, deviceName);
|
|
|
total = json.getInteger("total");
|
|
|
JSONArray list = json.getJSONArray("list");
|
|
|
for(int i=0;i<list.size();i++){
|
|
|
String sql ="select id, idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
|
|
|
"create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and device_sn='"+list.getString(i)+"'";
|
|
|
List<Map<String,Object>> result = jdbcTemplate.queryForList(sql.toString());
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
String sql = "select id, idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
|
|
|
"create_time createTime,device_name equimentName from device.wlyy_patient_device_location where del=0 and device_sn='" + list.getString(i) + "'";
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
|
|
|
List<LocationDataVO> locationDataVOList = new ArrayList<>();
|
|
|
result.forEach(map->{
|
|
|
result.forEach(map -> {
|
|
|
LocationDataVO locationDataVO = new LocationDataVO();
|
|
|
JSONObject location = JSONObject.parseObject(map.get("location").toString());
|
|
|
GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()),Double.parseDouble(location.get("lon").toString()));
|
|
|
GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()), Double.parseDouble(location.get("lon").toString()));
|
|
|
locationDataVO.setId(map.get("id").toString());
|
|
|
locationDataVO.setIdCard(AesEncryptUtils.decrypt(map.get("idCard").toString()));
|
|
|
locationDataVO.setCategoryCode(map.get("categoryCode").toString());
|
|
@ -120,50 +124,49 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
envelop.setTotalCount(total);
|
|
|
return envelop;
|
|
|
}else {
|
|
|
} else {
|
|
|
List<LocationDataVO> euipmentList = new ArrayList<>();
|
|
|
int totalEqCount=0;
|
|
|
int totalCount=0;
|
|
|
int totalEqCount = 0;
|
|
|
int totalCount = 0;
|
|
|
//小屋总数
|
|
|
String manufacturerCode = deviceType;
|
|
|
manufacturerCode = manufacturerCode.replace(",","','").replace("5","yituo").replace("10","xeek").replace("11","xiaomi");
|
|
|
if(deviceType.contains("5")||deviceType.contains("10")||deviceType.contains("11")){
|
|
|
manufacturerCode = manufacturerCode.replace(",", "','").replace("5", "yituo").replace("10", "xeek").replace("11", "xiaomi");
|
|
|
if (deviceType.contains("5") || deviceType.contains("10") || deviceType.contains("11")) {
|
|
|
totalEqCount = iotEqtDetailService.getEquipmentCount(manufacturerCode);
|
|
|
}
|
|
|
String[] categoryCodes= deviceType.split(",");
|
|
|
if(categoryCodes.length==1&&(deviceType.contains("5")||deviceType.contains("10")||deviceType.contains("11"))){
|
|
|
euipmentList = iotEqtDetailService.getEquipmentLocation(page,size,manufacturerCode);
|
|
|
String[] categoryCodes = deviceType.split(",");
|
|
|
if (categoryCodes.length == 1 && (deviceType.contains("5") || deviceType.contains("10") || deviceType.contains("11"))) {
|
|
|
euipmentList = iotEqtDetailService.getEquipmentLocation(page, size, manufacturerCode);
|
|
|
envelop.getDetailModelList().addAll(euipmentList);
|
|
|
}
|
|
|
else{
|
|
|
if(deviceType.contains("5")||deviceType.contains("10")||deviceType.contains("11")){
|
|
|
euipmentList = iotEqtDetailService.getEquipmentLocation(page,size,manufacturerCode);
|
|
|
} else {
|
|
|
if (deviceType.contains("5") || deviceType.contains("10") || deviceType.contains("11")) {
|
|
|
euipmentList = iotEqtDetailService.getEquipmentLocation(page, size, manufacturerCode);
|
|
|
envelop.getDetailModelList().addAll(euipmentList);
|
|
|
}
|
|
|
StringBuffer sql = new StringBuffer("select id,idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
|
|
|
"create_time createTime,device_name equimentName\n" +
|
|
|
"from device.wlyy_patient_device_location ");
|
|
|
StringBuffer sqlCounts = new StringBuffer("select count(*) from device.wlyy_patient_device_location ");
|
|
|
StringBuffer sqlCondition = new StringBuffer("where del=0 ");
|
|
|
if (diseaseCondition!=null){
|
|
|
sqlCondition.append(" and disease_condition ="+diseaseCondition);
|
|
|
StringBuffer sqlCondition = new StringBuffer("where del=0 ");
|
|
|
if (diseaseCondition != null) {
|
|
|
sqlCondition.append(" and disease_condition =" + diseaseCondition);
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sqlCondition.append(" and category_code in('").append(deviceType.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
sqlCondition.append(" and category_code in('").append(deviceType.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
sqlCondition.append(" and device_name in ('").append(deviceName.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)) {
|
|
|
sqlCondition.append(" and device_name in ('").append(deviceName.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
sql.append(sqlCondition);
|
|
|
sqlCounts.append(sqlCondition);
|
|
|
sql.append( " limit "+(page-1)*size+","+size);
|
|
|
totalCount = jdbcTemplate.queryForObject(sqlCounts.toString(),Integer.class);
|
|
|
List<Map<String,Object>> result = jdbcTemplate.queryForList(sql.toString());
|
|
|
sql.append(" limit " + (page - 1) * size + "," + size);
|
|
|
totalCount = jdbcTemplate.queryForObject(sqlCounts.toString(), Integer.class);
|
|
|
List<Map<String, Object>> result = jdbcTemplate.queryForList(sql.toString());
|
|
|
List<LocationDataVO> locationDataVOList = new ArrayList<>();
|
|
|
result.forEach(map->{
|
|
|
result.forEach(map -> {
|
|
|
LocationDataVO locationDataVO = new LocationDataVO();
|
|
|
JSONObject location = JSONObject.parseObject(map.get("location").toString());
|
|
|
GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()),Double.parseDouble(location.get("lon").toString()));
|
|
|
GeoPoint geoPoint = new GeoPoint(Double.parseDouble(location.get("lat").toString()), Double.parseDouble(location.get("lon").toString()));
|
|
|
locationDataVO.setId(map.get("id").toString());
|
|
|
locationDataVO.setIdCard(AesEncryptUtils.decrypt(map.get("idCard").toString()));
|
|
|
locationDataVO.setCategoryCode(map.get("categoryCode").toString());
|
|
@ -180,45 +183,45 @@ public class MonitorPlatformService {
|
|
|
});
|
|
|
envelop.getDetailModelList().addAll(locationDataVOList);
|
|
|
}
|
|
|
envelop.setTotalCount(totalCount>totalEqCount?totalCount:totalEqCount);
|
|
|
envelop.setTotalCount(totalCount > totalEqCount ? totalCount : totalEqCount);
|
|
|
return envelop;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public com.alibaba.fastjson.JSONObject iotSearchPatientDeviceSN(String type,Integer page,Integer pageSize,String deviceName){
|
|
|
public com.alibaba.fastjson.JSONObject iotSearchPatientDeviceSN(String type, Integer page, Integer pageSize, String deviceName) {
|
|
|
|
|
|
if(page != 0){
|
|
|
if (page != 0) {
|
|
|
page = page - 1;
|
|
|
}
|
|
|
|
|
|
StringBuffer sql = new StringBuffer("select t.device_sn from");
|
|
|
sql.append(" ( SELECT DISTINCT d.* FROM wlyy.wlyy_patient_device d, wlyy.wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user` ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
sql.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)) {
|
|
|
sql.append("and d.device_name in ('").append(deviceName.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
sql.append(" ) t, wlyy.wlyy_patient p " );
|
|
|
sql.append(" ) t, wlyy.wlyy_patient p ");
|
|
|
sql.append(" LEFT JOIN wlyy.wlyy_sign_patient_label_info l on p. CODE = l.patient");
|
|
|
sql.append(" and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'");
|
|
|
sql.append(" WHERE t.user = p. CODE limit "+page+","+pageSize);
|
|
|
List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
|
|
|
sql.append(" and l.`status`=1 AND l.label_type = 3 and l.label='" + type + "'");
|
|
|
sql.append(" WHERE t.user = p. CODE limit " + page + "," + pageSize);
|
|
|
List<String> list = jdbcTemplate.queryForList(sql.toString(), String.class);
|
|
|
|
|
|
Integer count = 0;
|
|
|
|
|
|
StringBuffer countsql = new StringBuffer("select count(t.device_sn) total from");
|
|
|
countsql.append(" ( SELECT DISTINCT d.* FROM wlyy.wlyy_patient_device d, wlyy.wlyy_sign_family f WHERE f.`status` > 0 AND f.patient = d.`user` ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
countsql.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)) {
|
|
|
countsql.append("and d.device_name in ('").append(deviceName.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
countsql.append(" ) t,wlyy.wlyy_patient p " );
|
|
|
countsql.append(" ) t,wlyy.wlyy_patient p ");
|
|
|
countsql.append(" LEFT JOIN wlyy.wlyy_sign_patient_label_info l on p. CODE = l.patient");
|
|
|
countsql.append(" and l.`status`=1 AND l.label_type = 3 and l.label='"+type+"'");
|
|
|
countsql.append(" and l.`status`=1 AND l.label_type = 3 and l.label='" + type + "'");
|
|
|
countsql.append(" WHERE t.user = p. CODE ");
|
|
|
|
|
|
count = jdbcTemplate.queryForObject(countsql.toString(),Integer.class);
|
|
|
count = jdbcTemplate.queryForObject(countsql.toString(), Integer.class);
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject();
|
|
|
result.put("total",count);
|
|
|
result.put("list",list);
|
|
|
result.put("total", count);
|
|
|
result.put("list", list);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@ -226,105 +229,106 @@ public class MonitorPlatformService {
|
|
|
* 根据病种类型,搜索已绑定设备的居民设备SN码
|
|
|
* 类型(1高血压 2糖尿病)
|
|
|
*/
|
|
|
public String searchpatientdevicesn(String type,Integer page,Integer size){
|
|
|
public String searchpatientdevicesn(String type, Integer page, Integer size) {
|
|
|
String url = "/wlyygc/iot_monitoring/searchpatientdevicesn";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("type",type);
|
|
|
params.put("page",page);
|
|
|
params.put("pageSize",size);
|
|
|
return sendGet(url,params);
|
|
|
params.put("type", type);
|
|
|
params.put("page", page);
|
|
|
params.put("pageSize", size);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设备发放情况
|
|
|
*/
|
|
|
public String equipmentDistribution(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital){
|
|
|
public String equipmentDistribution(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital) {
|
|
|
String url = "/wlyygc/iot_monitoring/equipmentDistribution";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
String anotherResult = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
String anotherResult = sendGet(url, params);
|
|
|
String sqlAre = dealSql(params);
|
|
|
List<Map<String, Object>> iotEquip = hibenateUtils.createSQLQuery(sqlAre);
|
|
|
if(StringUtils.isEmpty(deviceType)){
|
|
|
if (StringUtils.isEmpty(deviceType)) {
|
|
|
deviceType = "";
|
|
|
}
|
|
|
String[] str =deviceType.split(",");
|
|
|
String[] str = deviceType.split(",");
|
|
|
List<String> list = new ArrayList<>();
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
for (int i = 0; i < str.length; i++) {
|
|
|
list.add(str[i]);
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(anotherResult);
|
|
|
IotSystemDictDO iotSystemDictDO = iotSystemDictDao.findByDictNameAndValueAndDel("DEVICE_TYPE","健康小屋",1);
|
|
|
if (null!=iotSystemDictDO&&list.size()>1&&list.contains(iotSystemDictDO.getCode())){
|
|
|
if("200".equals(jsonObject.get("status").toString())){
|
|
|
JSONArray dataresult= jsonObject.getJSONArray("data");
|
|
|
IotSystemDictDO iotSystemDictDO = iotSystemDictDao.findByDictNameAndValueAndDel("DEVICE_TYPE", "健康小屋", 1);
|
|
|
if (null != iotSystemDictDO && list.size() > 1 && list.contains(iotSystemDictDO.getCode())) {
|
|
|
if ("200".equals(jsonObject.get("status").toString())) {
|
|
|
JSONArray dataresult = jsonObject.getJSONArray("data");
|
|
|
JSONArray resultArray = new JSONArray();
|
|
|
if (dataresult.size()>0){
|
|
|
for(int i=0;i<dataresult.size();i++){
|
|
|
JSONObject item= JSONObject.parseObject(dataresult.get(i).toString());
|
|
|
if(null!=item.get("num")){
|
|
|
if (dataresult.size() > 0) {
|
|
|
for (int i = 0; i < dataresult.size(); i++) {
|
|
|
JSONObject item = JSONObject.parseObject(dataresult.get(i).toString());
|
|
|
if (null != item.get("num")) {
|
|
|
Integer itemCount = Integer.parseInt(item.get("num").toString());
|
|
|
for(Map<String, Object> map:iotEquip){
|
|
|
if (item.get("code").toString().equals(map.get("belong_are_code"))){
|
|
|
itemCount = Integer.parseInt(map.get("total").toString())+itemCount;
|
|
|
item.put("num",itemCount);
|
|
|
for (Map<String, Object> map : iotEquip) {
|
|
|
if (item.get("code").toString().equals(map.get("belong_are_code"))) {
|
|
|
itemCount = Integer.parseInt(map.get("total").toString()) + itemCount;
|
|
|
item.put("num", itemCount);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
resultArray.add(item);
|
|
|
}
|
|
|
}
|
|
|
jsonObject.replace("data",resultArray);
|
|
|
jsonObject.replace("data", resultArray);
|
|
|
System.out.println(jsonObject.toString());
|
|
|
|
|
|
}
|
|
|
return jsonObject.toString();
|
|
|
}else if (list.size()==1&&list.contains(iotSystemDictDO.getCode())){
|
|
|
} else if (list.size() == 1 && list.contains(iotSystemDictDO.getCode())) {
|
|
|
List list1 = new ArrayList();
|
|
|
for (Map<String,Object> mao:iotEquip){
|
|
|
JSONObject jo = new JSONObject(mao);
|
|
|
list1.add(jo);
|
|
|
for (Map<String, Object> mao : iotEquip) {
|
|
|
JSONObject jo = new JSONObject(mao);
|
|
|
list1.add(jo);
|
|
|
}
|
|
|
jsonObject.replace("data",JSONArray.parse(list1.toString()));
|
|
|
jsonObject.replace("data", JSONArray.parse(list1.toString()));
|
|
|
return jsonObject.toString();
|
|
|
}else {
|
|
|
return anotherResult;
|
|
|
} else {
|
|
|
return anotherResult;
|
|
|
}
|
|
|
}
|
|
|
private String dealSql(Map<String, Object> params){
|
|
|
|
|
|
private String dealSql(Map<String, Object> params) {
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
sql.append("select count(1) AS \"num\",t.belong_are AS \"name\",t.belong_are_code AS \"code\" from iot_equipmet_detail t ");
|
|
|
sql.append(" where 1=1 ");
|
|
|
if (null!=params.get("area")){
|
|
|
sql.append(" and t.belong_are_code = '"+params.get("area").toString()+"'");
|
|
|
if (null != params.get("area")) {
|
|
|
sql.append(" and t.belong_are_code = '" + params.get("area").toString() + "'");
|
|
|
}
|
|
|
if (null!=params.get("startTime")) {
|
|
|
if (null != params.get("startTime")) {
|
|
|
//sql.append(" and t.update_time > '" + beginTime+"'");//DateUtil.stringToDate(beginTime,"yyyy-MM-dd HH:mm:ss")
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag){
|
|
|
sql.append( " and t.create_time >= str_to_date('" + params.get("startTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
}else {
|
|
|
sql.append( " and t.create_time >= to_date('" + params.get("startTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
if (flag) {
|
|
|
sql.append(" and t.create_time >= str_to_date('" + params.get("startTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
} else {
|
|
|
sql.append(" and t.create_time >= to_date('" + params.get("startTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
}
|
|
|
} else {
|
|
|
sql.append( " AND t.create_time >='" + params.get("startTime").toString() + " 00:00:00'");
|
|
|
sql.append(" AND t.create_time >='" + params.get("startTime").toString() + " 00:00:00'");
|
|
|
}
|
|
|
}
|
|
|
if (null!=params.get("endTime")) {
|
|
|
if (null != params.get("endTime")) {
|
|
|
//sql.append(" and t.update_time < '" + endTime+"'");//DateUtil.stringToDate(endTime,"yyyy-MM-dd HH:mm:ss")
|
|
|
if ("xm_ykyy_wx".equals(wxId)) {
|
|
|
if (flag){
|
|
|
sql.append( " and t.create_time <= str_to_date('" + params.get("endTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
}else {
|
|
|
sql.append( " and t.create_time <= to_date('" + params.get("endTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
if (flag) {
|
|
|
sql.append(" and t.create_time <= str_to_date('" + params.get("endTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
} else {
|
|
|
sql.append(" and t.create_time <= to_date('" + params.get("endTime").toString() + " 00:00:00','YYYY-MM-DD HH24:MI:SS')");
|
|
|
}
|
|
|
} else {
|
|
|
sql.append( " AND t.create_time <='" + params.get("endTime").toString() + " 00:00:00'");
|
|
|
sql.append(" AND t.create_time <='" + params.get("endTime").toString() + " 00:00:00'");
|
|
|
}
|
|
|
}
|
|
|
sql.append(" group by t.belong_are_code order by \"total\" desc ");
|
|
@ -335,98 +339,105 @@ public class MonitorPlatformService {
|
|
|
* 慢病患者情况-统计
|
|
|
* 类型(2糖尿病,1高血压)
|
|
|
*/
|
|
|
public String chronicDiseaseCount(String type){
|
|
|
public String chronicDiseaseCount(String type) {
|
|
|
String url = "/wlyygc/iot_monitoring/chronicDiseaseCount";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("type",type);
|
|
|
return sendGet(url,params);
|
|
|
params.put("type", type);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预警信息警报
|
|
|
*
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
public String warningInformationAlarm(Integer page,Integer pageSize){
|
|
|
public String warningInformationAlarm(Integer page, Integer pageSize) {
|
|
|
String url = "/wlyygc/iot_monitoring/warningInformationAlarm";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("page",page);
|
|
|
params.put("pageSize",pageSize);
|
|
|
return sendGet(url,params);
|
|
|
params.put("page", page);
|
|
|
params.put("pageSize", pageSize);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 居民 医生搜索
|
|
|
*
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
public String searchPatient(String name,Integer page,Integer pageSize,String idcards){
|
|
|
public String searchPatient(String name, Integer page, Integer pageSize, String idcards) {
|
|
|
String url = "/wlyygc/iot_monitoring/searchPatient";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("name",name);
|
|
|
params.put("page",page);
|
|
|
params.put("pageSize",pageSize);
|
|
|
params.put("idcards",idcards);
|
|
|
return sendGet(url,params);
|
|
|
params.put("name", name);
|
|
|
params.put("page", page);
|
|
|
params.put("pageSize", pageSize);
|
|
|
params.put("idcards", idcards);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设备绑定情况
|
|
|
*
|
|
|
* @param type 设备类型(1血糖仪,2血压计
|
|
|
* @return
|
|
|
*/
|
|
|
public String deviceBinding(String type){
|
|
|
public String deviceBinding(String type) {
|
|
|
String url = "/wlyygc/iot_monitoring/deviceBinding";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("type",type);
|
|
|
return sendGet(url,params);
|
|
|
params.put("type", type);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 个人信息
|
|
|
*
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/persionalInfo",method = RequestMethod.GET)
|
|
|
@RequestMapping(value = "/persionalInfo", method = RequestMethod.GET)
|
|
|
@ApiOperation("个人信息")
|
|
|
public String persionalInfo(String patient){
|
|
|
public String persionalInfo(String patient) {
|
|
|
String url = "/wlyygc/iot_monitoring/persionalInfo";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("patient",patient);
|
|
|
return sendGet(url,params);
|
|
|
params.put("patient", patient);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 家人信息
|
|
|
*
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public String familyMember(String patient){
|
|
|
public String familyMember(String patient) {
|
|
|
String url = "/wlyygc/iot_monitoring/familyMember";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("patient",patient);
|
|
|
return sendGet(url,params);
|
|
|
params.put("patient", patient);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 健康设备
|
|
|
*
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/healthDevice",method = RequestMethod.GET)
|
|
|
@RequestMapping(value = "/healthDevice", method = RequestMethod.GET)
|
|
|
@ApiOperation("健康设备")
|
|
|
public String healthDevice(String patient){
|
|
|
public String healthDevice(String patient) {
|
|
|
String url = "/wlyygc/iot_monitoring/healthDevice";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("patient",patient);
|
|
|
return sendGet(url,params);
|
|
|
params.put("patient", patient);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 体征数据
|
|
|
*
|
|
|
* @param patient
|
|
|
* @param type
|
|
|
* @param gi_type
|
|
@ -434,38 +445,40 @@ public class MonitorPlatformService {
|
|
|
* @param end
|
|
|
* @return
|
|
|
*/
|
|
|
public String getHealthIndexChartByPatient(String patient, Integer type, Integer gi_type, String begin, String end,String time) {
|
|
|
public String getHealthIndexChartByPatient(String patient, Integer type, Integer gi_type, String begin, String end, String time) {
|
|
|
String url = "/wlyygc/iot_monitoring/chart";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("patient",patient);
|
|
|
params.put("type",type);
|
|
|
params.put("time",time);
|
|
|
params.put("begin",begin);
|
|
|
params.put("end",end);
|
|
|
params.put("gi_type",gi_type);
|
|
|
return sendGet(url,params);
|
|
|
params.put("patient", patient);
|
|
|
params.put("type", type);
|
|
|
params.put("time", time);
|
|
|
params.put("begin", begin);
|
|
|
params.put("end", end);
|
|
|
params.put("gi_type", gi_type);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取门诊记录/住院记录(基卫+APP)
|
|
|
*
|
|
|
* @param patient
|
|
|
* @param type 类型(1血糖,2血压)
|
|
|
* @param type 类型(1血糖,2血压)
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
public String getAllEvent(String patient,String type,String page,String pageSize) {
|
|
|
public String getAllEvent(String patient, String type, String page, String pageSize) {
|
|
|
String url = "/wlyygc/iot_monitoring/event";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("patient",patient);
|
|
|
params.put("type",type);
|
|
|
params.put("page",page);
|
|
|
params.put("pageSize",pageSize);
|
|
|
return sendGet(url,params);
|
|
|
params.put("patient", patient);
|
|
|
params.put("type", type);
|
|
|
params.put("page", page);
|
|
|
params.put("pageSize", pageSize);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据患者标志获取健康指标
|
|
|
*
|
|
|
* @param idcard
|
|
|
* @param type
|
|
|
* @param begin
|
|
@ -474,56 +487,58 @@ public class MonitorPlatformService {
|
|
|
* @param pagesize
|
|
|
* @return
|
|
|
*/
|
|
|
public String getHealthIndexByIdcard(String idcard,int type, String begin,String end, int page,int pagesize,HttpServletRequest request) {
|
|
|
public String getHealthIndexByIdcard(String idcard, int type, String begin, String end, int page, int pagesize, HttpServletRequest request) {
|
|
|
String url = "/wlyygc/iot_monitoring/health_index/listByIdcard";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("idcard",idcard);
|
|
|
params.put("begin",begin);
|
|
|
params.put("end",end);
|
|
|
params.put("type",type);
|
|
|
params.put("page",page);
|
|
|
params.put("pagesize",pagesize);
|
|
|
try{
|
|
|
params.put("idcard", idcard);
|
|
|
params.put("begin", begin);
|
|
|
params.put("end", end);
|
|
|
params.put("type", type);
|
|
|
params.put("page", page);
|
|
|
params.put("pagesize", pagesize);
|
|
|
try {
|
|
|
//记录log
|
|
|
iotInterfaceLogService.saveLog("zy808081724b116c017254d437fe000b",JSONObject.toJSONString(params),null, request,200,"getHealthIndexByIdcard");
|
|
|
}catch (Exception e){
|
|
|
iotInterfaceLogService.saveLog("zy808081724b116c017254d437fe000b", JSONObject.toJSONString(params), null, request, 200, "getHealthIndexByIdcard");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
return sendGet(url,params);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取居民信息
|
|
|
*
|
|
|
* @param idcard
|
|
|
* @return
|
|
|
*/
|
|
|
public String patientInfo(String idcard) {
|
|
|
String url = "/wlyygc/iot_monitoring/patientInfo";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("idcard",idcard);
|
|
|
return sendGet(url,params);
|
|
|
params.put("idcard", idcard);
|
|
|
return sendGet(url, params);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 质控情况
|
|
|
*
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @param deviceSn
|
|
|
* @return
|
|
|
*/
|
|
|
public List<JSONObject> deviceOverhaulList(Integer page,Integer pageSize,String deviceSn){
|
|
|
public List<JSONObject> deviceOverhaulList(Integer page, Integer pageSize, String deviceSn) {
|
|
|
String sql = "SELECT o.time,o.`status`,o.remark from iot_patient_device d,iot_device_overhaul o" +
|
|
|
" WHERE d.device_sn = '"+deviceSn+"' and d.id = o.patient_device_id ORDER BY o.time desc limit ?,?";
|
|
|
return myJdbcTemplate.queryJson(sql.toString(),new Object[]{(page-1)*pageSize,pageSize});
|
|
|
" WHERE d.device_sn = '" + deviceSn + "' and d.id = o.patient_device_id ORDER BY o.time desc limit ?,?";
|
|
|
return myJdbcTemplate.queryJson(sql.toString(), new Object[]{(page - 1) * pageSize, pageSize});
|
|
|
}
|
|
|
|
|
|
public Integer deviceOverhaulListTotal(String deviceSn){
|
|
|
public Integer deviceOverhaulListTotal(String deviceSn) {
|
|
|
String sql = "SELECT count(o.id) c from iot_patient_device d,iot_device_overhaul o" +
|
|
|
" WHERE d.device_sn = '"+deviceSn+"' and d.id = o.patient_device_id ";
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
|
|
|
if(list.size()>0){
|
|
|
" WHERE d.device_sn = '" + deviceSn + "' and d.id = o.patient_device_id ";
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql.toString(), new Object[]{});
|
|
|
if (list.size() > 0) {
|
|
|
return list.get(0).getInteger("c");
|
|
|
}
|
|
|
return 0;
|
|
@ -531,18 +546,19 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 入住情况
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject residentUserType(){
|
|
|
public JSONObject residentUserType() {
|
|
|
String sql = "SELECT IFNULL(enter_type,'0') type,COUNT(id) num from iot_company WHERE del =1 GROUP BY enter_type";
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql.toString(), new Object[]{});
|
|
|
int total = 0;
|
|
|
int manufacturer = 0;//厂商
|
|
|
int supplier = 0;// 供应商
|
|
|
int agent = 0;//代理商
|
|
|
int platform = 0;//接入平台
|
|
|
for(JSONObject json:list){
|
|
|
switch (json.getString("type")){
|
|
|
for (JSONObject json : list) {
|
|
|
switch (json.getString("type")) {
|
|
|
case "0":
|
|
|
platform = json.getInteger("num");
|
|
|
break;
|
|
@ -557,25 +573,25 @@ public class MonitorPlatformService {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
total = manufacturer+supplier+agent+platform;
|
|
|
total = manufacturer + supplier + agent + platform;
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("total",total);
|
|
|
json.put("manufacturer",manufacturer);
|
|
|
json.put("supplier",supplier);
|
|
|
json.put("agent",agent);
|
|
|
json.put("platform",platform);
|
|
|
if(total>0){
|
|
|
json.put("total", total);
|
|
|
json.put("manufacturer", manufacturer);
|
|
|
json.put("supplier", supplier);
|
|
|
json.put("agent", agent);
|
|
|
json.put("platform", platform);
|
|
|
if (total > 0) {
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
json.put("manufacturerRange", df.format(manufacturer > 0.0 ? (manufacturer/ (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
json.put("supplierRange", df.format(supplier > 0.0 ? (supplier/ (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
json.put("agentRange", df.format(agent > 0.0 ? (agent/ (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
json.put("platformRange", df.format(platform > 0.0 ? (platform/ (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
|
|
|
}else {
|
|
|
json.put("manufacturerRange","0.0%");
|
|
|
json.put("supplierRange","0.0%");
|
|
|
json.put("agentRange","0.0%");
|
|
|
json.put("platformRange","0.0%");
|
|
|
json.put("manufacturerRange", df.format(manufacturer > 0.0 ? (manufacturer / (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
json.put("supplierRange", df.format(supplier > 0.0 ? (supplier / (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
json.put("agentRange", df.format(agent > 0.0 ? (agent / (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
json.put("platformRange", df.format(platform > 0.0 ? (platform / (total * 1.0000) * 100) : 0.0) + "%");
|
|
|
|
|
|
} else {
|
|
|
json.put("manufacturerRange", "0.0%");
|
|
|
json.put("supplierRange", "0.0%");
|
|
|
json.put("agentRange", "0.0%");
|
|
|
json.put("platformRange", "0.0%");
|
|
|
}
|
|
|
|
|
|
return json;
|
|
@ -583,50 +599,51 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 接口调用情况
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public List<JSONObject> intefaceLogList(String startTime,String endTime,String type){
|
|
|
public List<JSONObject> intefaceLogList(String startTime, String endTime, String type) {
|
|
|
String sql = "SELECT ";
|
|
|
switch (type){
|
|
|
switch (type) {
|
|
|
case "month":
|
|
|
sql+= " date_format(time,'%m') ";
|
|
|
sql += " date_format(time,'%m') ";
|
|
|
break;
|
|
|
case "year":
|
|
|
sql+= " date_format(time,'%Y') ";
|
|
|
sql += " date_format(time,'%Y') ";
|
|
|
break;
|
|
|
case "day":
|
|
|
sql+= " date_format(time,'%Y-%m-%d') ";
|
|
|
sql += " date_format(time,'%Y-%m-%d') ";
|
|
|
break;
|
|
|
case "week":
|
|
|
sql+= " date_format(time,'%u') ";
|
|
|
sql += " date_format(time,'%u') ";
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
sql+= " date ,COUNT(*) num from iot_interface_log where 1=1 ";
|
|
|
if(StringUtils.isEmpty(startTime)){
|
|
|
sql+= " and time>='"+startTime+"'";
|
|
|
sql += " date ,COUNT(*) num from iot_interface_log where 1=1 ";
|
|
|
if (StringUtils.isEmpty(startTime)) {
|
|
|
sql += " and time>='" + startTime + "'";
|
|
|
}
|
|
|
if(StringUtils.isEmpty(endTime)){
|
|
|
sql+= " and time>='"+endTime+"'";
|
|
|
if (StringUtils.isEmpty(endTime)) {
|
|
|
sql += " and time>='" + endTime + "'";
|
|
|
}
|
|
|
|
|
|
sql+=" GROUP BY date ";
|
|
|
sql += " GROUP BY date ";
|
|
|
|
|
|
return myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
|
|
|
return myJdbcTemplate.queryJson(sql.toString(), new Object[]{});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 地区字典
|
|
|
*/
|
|
|
public JSONArray areaDict(){
|
|
|
public JSONArray areaDict() {
|
|
|
String url = "/wlyygc/iot_monitoring/areaDict";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
String response = sendGet(url,params);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONArray("data");
|
|
|
}
|
|
|
|
|
@ -636,13 +653,13 @@ public class MonitorPlatformService {
|
|
|
/**
|
|
|
* 医院字典
|
|
|
*/
|
|
|
public JSONArray hospitalDict(String town){
|
|
|
public JSONArray hospitalDict(String town) {
|
|
|
String url = "/wlyygc/iot_monitoring/hospitalDict";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("town",town);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("town", town);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONArray("data");
|
|
|
}
|
|
|
|
|
@ -652,89 +669,89 @@ public class MonitorPlatformService {
|
|
|
/**
|
|
|
* 智能设备发放
|
|
|
*/
|
|
|
public JSONArray smartDeviceDistribution(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital){
|
|
|
public JSONArray smartDeviceDistribution(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital) {
|
|
|
String url = "/wlyygc/iot_monitoring/smartDeviceDistribution";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
IotSystemDictDO iotSystemDictDO = iotSystemDictDao.findByDictNameAndValueAndDel("DEVICE_TYPE","健康小屋",1);
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
IotSystemDictDO iotSystemDictDO = iotSystemDictDao.findByDictNameAndValueAndDel("DEVICE_TYPE", "健康小屋", 1);
|
|
|
JSONArray jsonArray = json.getJSONArray("data");
|
|
|
String[] str =deviceType.split(",");
|
|
|
String[] str = deviceType.split(",");
|
|
|
List<String> list = new ArrayList<>();
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
for (int i = 0; i < str.length; i++) {
|
|
|
list.add(str[i]);
|
|
|
}
|
|
|
|
|
|
if (iotSystemDictDO!=null){
|
|
|
if (!list.contains(iotSystemDictDO.getCode())){
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
if (iotSystemDictDO != null) {
|
|
|
if (!list.contains(iotSystemDictDO.getCode())) {
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jo = jsonArray.getJSONObject(i);
|
|
|
String tmp = jo.getString("type");
|
|
|
if("1".equals(tmp)){
|
|
|
jo.put("typeName","血糖仪");
|
|
|
}else if("2".equals(tmp)){
|
|
|
jo.put("typeName","血压计");
|
|
|
}else if("3".equals(tmp)){
|
|
|
jo.put("typeName","智能药盒");
|
|
|
}else if("4".equals(tmp)){
|
|
|
jo.put("typeName","智能手表");
|
|
|
if ("1".equals(tmp)) {
|
|
|
jo.put("typeName", "血糖仪");
|
|
|
} else if ("2".equals(tmp)) {
|
|
|
jo.put("typeName", "血压计");
|
|
|
} else if ("3".equals(tmp)) {
|
|
|
jo.put("typeName", "智能药盒");
|
|
|
} else if ("4".equals(tmp)) {
|
|
|
jo.put("typeName", "智能手表");
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
if (jsonArray!=null&&jsonArray.size()!=0){
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
} else {
|
|
|
if (jsonArray != null && jsonArray.size() != 0) {
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject jo = jsonArray.getJSONObject(i);
|
|
|
String tmp = jo.getString("type");
|
|
|
if("1".equals(tmp)){
|
|
|
jo.put("typeName","血糖仪");
|
|
|
}else if("2".equals(tmp)){
|
|
|
jo.put("typeName","血压计");
|
|
|
}else if("3".equals(tmp)){
|
|
|
jo.put("typeName","智能药盒");
|
|
|
}else if("4".equals(tmp)){
|
|
|
jo.put("typeName","智能手表");
|
|
|
if ("1".equals(tmp)) {
|
|
|
jo.put("typeName", "血糖仪");
|
|
|
} else if ("2".equals(tmp)) {
|
|
|
jo.put("typeName", "血压计");
|
|
|
} else if ("3".equals(tmp)) {
|
|
|
jo.put("typeName", "智能药盒");
|
|
|
} else if ("4".equals(tmp)) {
|
|
|
jo.put("typeName", "智能手表");
|
|
|
}
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
JSONObject jsonObject= new JSONObject();
|
|
|
jsonObject.put("type",iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName",iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum",0);
|
|
|
jsonObject.put("unSignNum",0);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("type", iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName", iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum", 0);
|
|
|
jsonObject.put("unSignNum", 0);
|
|
|
jsonArray.add(jsonObject);
|
|
|
}else {
|
|
|
Long count = iotEqtDetailService.findCountByHealthHourse(startTime,endTime,area);
|
|
|
JSONObject jsonObject= new JSONObject();
|
|
|
jsonObject.put("type",iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName",iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum",count);
|
|
|
jsonObject.put("unSignNum",0);
|
|
|
} else {
|
|
|
Long count = iotEqtDetailService.findCountByHealthHourse(startTime, endTime, area);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("type", iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName", iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum", count);
|
|
|
jsonObject.put("unSignNum", 0);
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
}else {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
} else {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)) {
|
|
|
jsonArray = new JSONArray();
|
|
|
JSONObject jsonObject= new JSONObject();
|
|
|
jsonObject.put("type",iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName",iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum",0);
|
|
|
jsonObject.put("unSignNum",0);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("type", iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName", iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum", 0);
|
|
|
jsonObject.put("unSignNum", 0);
|
|
|
jsonArray.add(jsonObject);
|
|
|
}else {
|
|
|
Long count = iotEqtDetailService.findCountByHealthHourse(startTime,endTime,area);
|
|
|
} else {
|
|
|
Long count = iotEqtDetailService.findCountByHealthHourse(startTime, endTime, area);
|
|
|
jsonArray = new JSONArray();
|
|
|
JSONObject jsonObject= new JSONObject();
|
|
|
jsonObject.put("type",iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName",iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum",count);
|
|
|
jsonObject.put("unSignNum",0);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("type", iotSystemDictDO.getCode());
|
|
|
jsonObject.put("typeName", iotSystemDictDO.getValue());
|
|
|
jsonObject.put("signNum", count);
|
|
|
jsonObject.put("unSignNum", 0);
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
|
|
@ -750,20 +767,21 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 设备使用数据
|
|
|
*
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @param deviceSn
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject deviceUseData(Integer page,Integer pageSize,String deviceSn){
|
|
|
public JSONObject deviceUseData(Integer page, Integer pageSize, String deviceSn) {
|
|
|
String url = "/wlyygc/iot_monitoring/deviceUseData";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("page",page);
|
|
|
params.put("pageSize",pageSize);
|
|
|
params.put("deviceSn",deviceSn);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("page", page);
|
|
|
params.put("pageSize", pageSize);
|
|
|
params.put("deviceSn", deviceSn);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
|
|
@ -772,35 +790,36 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 设备使用数据
|
|
|
*
|
|
|
* @param patient
|
|
|
* @param deviceSn
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject deviceInfo(String deviceSn,String patient){
|
|
|
public JSONObject deviceInfo(String deviceSn, String patient) {
|
|
|
String url = "/wlyygc/iot_monitoring/deviceInfo";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("patient",patient);
|
|
|
params.put("deviceSn",deviceSn);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("patient", patient);
|
|
|
params.put("deviceSn", deviceSn);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
JSONObject tmp = json.getJSONObject("data");
|
|
|
//查询物联网获取设备信息
|
|
|
String sql = "SELECT d.device_sn,b.supplier_name supplierName,b.origin_place originPlace,e.product_img productImg" +
|
|
|
",e.description from iot_device d,iot_product_base_info b,iot_product_extend_info e" +
|
|
|
" WHERE d.device_sn = '"+deviceSn+"' and d.product_id = b.id and d.product_id = e.product_id";
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql,new Object[]{});
|
|
|
if(list!=null&&list.size()>0){
|
|
|
" WHERE d.device_sn = '" + deviceSn + "' and d.product_id = b.id and d.product_id = e.product_id";
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql, new Object[]{});
|
|
|
if (list != null && list.size() > 0) {
|
|
|
JSONObject js = list.get(0);
|
|
|
tmp.put("supplierName",js.getString("supplierName"));
|
|
|
tmp.put("originPlace",js.getString("originPlace"));
|
|
|
tmp.put("productImg",js.getString("productImg"));
|
|
|
tmp.put("description",js.getString("description"));
|
|
|
}else{
|
|
|
tmp.put("supplierName","");
|
|
|
tmp.put("originPlace","");
|
|
|
tmp.put("productImg","");
|
|
|
tmp.put("description","");
|
|
|
tmp.put("supplierName", js.getString("supplierName"));
|
|
|
tmp.put("originPlace", js.getString("originPlace"));
|
|
|
tmp.put("productImg", js.getString("productImg"));
|
|
|
tmp.put("description", js.getString("description"));
|
|
|
} else {
|
|
|
tmp.put("supplierName", "");
|
|
|
tmp.put("originPlace", "");
|
|
|
tmp.put("productImg", "");
|
|
|
tmp.put("description", "");
|
|
|
}
|
|
|
return tmp;
|
|
|
}
|
|
@ -810,18 +829,19 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 设备使用情况分析
|
|
|
*
|
|
|
* @param type
|
|
|
* @param name
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject deviceUsageAnalysis(String type,String name){
|
|
|
public JSONObject deviceUsageAnalysis(String type, String name) {
|
|
|
String url = "/wlyygc/iot_monitoring/deviceUsageAnalysis";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("type",type);
|
|
|
params.put("name",name);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("type", type);
|
|
|
params.put("name", name);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
|
|
@ -830,6 +850,7 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 85-发放率,96使用率,86绑定率,88指导率
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param deviceType
|
|
@ -837,19 +858,19 @@ public class MonitorPlatformService {
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject totalRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital,String quotaCode){
|
|
|
public JSONObject totalRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital, String quotaCode) {
|
|
|
String url = "/wlyygc/iot_monitoring/totalRange";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
params.put("quotaCode",quotaCode);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
params.put("quotaCode", quotaCode);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
|
|
@ -857,20 +878,21 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
|
|
|
public JSONObject getTotalRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital){
|
|
|
String deviceType, String area, String hospital) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("grant",totalRange(startTime,endTime,deviceType,area,hospital,"85"));
|
|
|
result.put("binding",totalRange(startTime,endTime,deviceType,area,hospital,"86"));
|
|
|
result.put("guide",totalRange(startTime,endTime,deviceType,area,hospital,"88"));
|
|
|
result.put("malfunction",totalRange(startTime,endTime,deviceType,area,hospital,"0"));
|
|
|
result.put("diseaseUsing",diseaseUseRange(startTime,endTime,deviceType,area,hospital));
|
|
|
result.put("diseaseCover",diseaseRange(startTime,endTime,deviceType,area,hospital));
|
|
|
result.put("grant", totalRange(startTime, endTime, deviceType, area, hospital, "85"));
|
|
|
result.put("binding", totalRange(startTime, endTime, deviceType, area, hospital, "86"));
|
|
|
result.put("guide", totalRange(startTime, endTime, deviceType, area, hospital, "88"));
|
|
|
result.put("malfunction", totalRange(startTime, endTime, deviceType, area, hospital, "0"));
|
|
|
result.put("diseaseUsing", diseaseUseRange(startTime, endTime, deviceType, area, hospital));
|
|
|
result.put("diseaseCover", diseaseRange(startTime, endTime, deviceType, area, hospital));
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 慢病患者设备使用率
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param deviceType
|
|
@ -878,25 +900,27 @@ public class MonitorPlatformService {
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject diseaseUseRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital){
|
|
|
public JSONObject diseaseUseRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital) {
|
|
|
String url = "/wlyygc/iot_monitoring/diseaseUseRange";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
|
|
|
return new JSONObject();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 慢病患者设备覆盖率
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param deviceType
|
|
@ -904,18 +928,18 @@ public class MonitorPlatformService {
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject diseaseRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital){
|
|
|
public JSONObject diseaseRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital) {
|
|
|
String url = "/wlyygc/iot_monitoring/diseaseRange";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
|
|
@ -924,6 +948,7 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 慢病患者设备覆盖率
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param deviceType
|
|
@ -931,26 +956,28 @@ public class MonitorPlatformService {
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject yellowOrRedRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital,Integer diseaseCondition){
|
|
|
public JSONObject yellowOrRedRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital, Integer diseaseCondition) {
|
|
|
String url = "/wlyygc/iot_monitoring/yellowOrRedRange";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
params.put("diseaseCondition",diseaseCondition);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
params.put("diseaseCondition", diseaseCondition);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
|
|
|
return new JSONObject();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预警信息警报
|
|
|
*
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @param startTime
|
|
@ -960,21 +987,21 @@ public class MonitorPlatformService {
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray warningInformationAlarm_new(Integer page,Integer pageSize,String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital,String deviceName){
|
|
|
public JSONArray warningInformationAlarm_new(Integer page, Integer pageSize, String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital, String deviceName) {
|
|
|
String url = "/wlyygc/iot_monitoring/warningInformationAlarm_new";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("page",page);
|
|
|
params.put("pageSize",pageSize);
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
params.put("deviceName",deviceName);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("page", page);
|
|
|
params.put("pageSize", pageSize);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
params.put("deviceName", deviceName);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONArray("data");
|
|
|
}
|
|
|
|
|
@ -983,6 +1010,7 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 预警信息警报
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param deviceType
|
|
@ -990,18 +1018,18 @@ public class MonitorPlatformService {
|
|
|
* @param hospital
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject yellowAndRedRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital){
|
|
|
public JSONObject yellowAndRedRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital) {
|
|
|
String url = "/wlyygc/iot_monitoring/yellowAndRedRange";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("startTime",startTime);
|
|
|
params.put("endTime",endTime);
|
|
|
params.put("deviceType",deviceType);
|
|
|
params.put("area",area);
|
|
|
params.put("hospital",hospital);
|
|
|
String response = sendGet(url,params);
|
|
|
params.put("startTime", startTime);
|
|
|
params.put("endTime", endTime);
|
|
|
params.put("deviceType", deviceType);
|
|
|
params.put("area", area);
|
|
|
params.put("hospital", hospital);
|
|
|
String response = sendGet(url, params);
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
if(json.getInteger("status")==200){
|
|
|
if (json.getInteger("status") == 200) {
|
|
|
return json.getJSONObject("data");
|
|
|
}
|
|
|
return new JSONObject();
|
|
@ -1009,29 +1037,30 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 数据筛选
|
|
|
*
|
|
|
* @param name
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray datafiltering(String name){
|
|
|
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` and d.del=0 ");
|
|
|
if(org.apache.commons.lang3.StringUtils.isNotBlank(name)){
|
|
|
sql.append("and (d.device_sn like '%"+name+"%' or p.`name` = '"+ name+"') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
|
|
|
sql.append("and (d.device_sn like '%" + name + "%' or p.`name` = '" + name + "') ");
|
|
|
// sql.append("and (d.device_sn like '%"+name+"%' or p.`name` = '"+ AesEncryptUtils.encrypt(name)+"') ");待i健康加密
|
|
|
}
|
|
|
List<JSONObject> jsonArray = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
|
|
|
List<JSONObject> jsonArray = myJdbcTemplate.queryJson(sql.toString(), new Object[]{});
|
|
|
// for (JSONObject obj:jsonArray){
|
|
|
// obj.put("name",AesEncryptUtils.decrypt(obj.getString("name")));//待i健康加密
|
|
|
// }
|
|
|
if(jsonArray.size()==0){
|
|
|
sql= new StringBuffer(" select '5' as categoryCode, id,device_code as deviceSn,null as code,null as name,'健康小屋' as deviceName from xmiot.iot_equipmet_detail where device_code like '%"+name+"%'");
|
|
|
jsonArray = myJdbcTemplate.queryJson(sql.toString(),new Object[]{});
|
|
|
if (jsonArray.size() == 0) {
|
|
|
sql = new StringBuffer(" select '5' as categoryCode, id,device_code as deviceSn,null as code,null as name,'健康小屋' as deviceName from xmiot.iot_equipmet_detail where device_code like '%" + name + "%'");
|
|
|
jsonArray = myJdbcTemplate.queryJson(sql.toString(), new Object[]{});
|
|
|
}
|
|
|
|
|
|
for (int i=0;i<jsonArray.size();i++){
|
|
|
com.alibaba.fastjson.JSONObject jsonObj= jsonArray.get(i);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(jsonObj.getString("name"))){
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
com.alibaba.fastjson.JSONObject jsonObj = jsonArray.get(i);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(jsonObj.getString("name"))) {
|
|
|
jsonObj.put("name", ConcealUtil.nameOrAddrConceal(jsonObj.getString("name")));
|
|
|
}
|
|
|
}
|
|
@ -1043,33 +1072,33 @@ public class MonitorPlatformService {
|
|
|
// JSONObject json = JSONObject.parseObject(response);
|
|
|
// if(json.getInteger("status")==200){
|
|
|
// JSONArray jsonArray = json.getJSONArray("data");
|
|
|
for(int i=0;i<jsonArray.size();i++){
|
|
|
JSONObject data = jsonArray.get(i);
|
|
|
String deviceSn = data.getString("deviceSn");
|
|
|
JSONArray jsonArray1 = new JSONArray();
|
|
|
JSONObject json1 = new JSONObject();
|
|
|
json1.put("andOr","and");
|
|
|
json1.put("field","deviceSn");
|
|
|
json1.put("condition","=");
|
|
|
json1.put("value",deviceSn);
|
|
|
jsonArray1.add(json1);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter",jsonArray1);
|
|
|
jsonObject.put("page",1);
|
|
|
jsonObject.put("size",5);
|
|
|
String sqlLocation = "select idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
|
|
|
"create_time createTime,device_name equimentName\n" +
|
|
|
"from device.wlyy_patient_device_location where del=0 and device_sn='"+deviceSn+"' limit 0,5 ";
|
|
|
try {
|
|
|
List<Map<String,Object>> locationDataVOList = jdbcTemplate.queryForList(sqlLocation);
|
|
|
|
|
|
JSONObject location = JSONObject.parseObject(locationDataVOList.get(0).get("location").toString());
|
|
|
if(locationDataVOList.size()>0){
|
|
|
data.put("locationData",location);
|
|
|
data.put("diseaseCondition",Integer.parseInt(locationDataVOList.get(0).get("diseaseCondition").toString()));
|
|
|
}else{
|
|
|
data.put("locationData","{}");
|
|
|
}
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JSONObject data = jsonArray.get(i);
|
|
|
String deviceSn = data.getString("deviceSn");
|
|
|
JSONArray jsonArray1 = new JSONArray();
|
|
|
JSONObject json1 = new JSONObject();
|
|
|
json1.put("andOr", "and");
|
|
|
json1.put("field", "deviceSn");
|
|
|
json1.put("condition", "=");
|
|
|
json1.put("value", deviceSn);
|
|
|
jsonArray1.add(json1);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter", jsonArray1);
|
|
|
jsonObject.put("page", 1);
|
|
|
jsonObject.put("size", 5);
|
|
|
String sqlLocation = "select idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
|
|
|
"create_time createTime,device_name equimentName\n" +
|
|
|
"from device.wlyy_patient_device_location where del=0 and device_sn='" + deviceSn + "' limit 0,5 ";
|
|
|
try {
|
|
|
List<Map<String, Object>> locationDataVOList = jdbcTemplate.queryForList(sqlLocation);
|
|
|
|
|
|
JSONObject location = JSONObject.parseObject(locationDataVOList.get(0).get("location").toString());
|
|
|
if (locationDataVOList.size() > 0) {
|
|
|
data.put("locationData", location);
|
|
|
data.put("diseaseCondition", Integer.parseInt(locationDataVOList.get(0).get("diseaseCondition").toString()));
|
|
|
} else {
|
|
|
data.put("locationData", "{}");
|
|
|
}
|
|
|
// list = iotPatientDeviceService.findDeviceLocationsBySn(jsonObject.toString());
|
|
|
// if(list.size()>0){
|
|
|
// data.put("locationData",list.get(0).getLocation());
|
|
@ -1077,37 +1106,38 @@ public class MonitorPlatformService {
|
|
|
// }else{
|
|
|
// data.put("locationData","{}");
|
|
|
// }
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
JSONArray result = new JSONArray();
|
|
|
result.addAll(jsonArray);
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
JSONArray result = new JSONArray();
|
|
|
result.addAll(jsonArray);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 访问i健康接口,自带登录信息
|
|
|
*
|
|
|
* @param url
|
|
|
* @return
|
|
|
*/
|
|
|
private String sendGet(String url,Map<String, Object> params){
|
|
|
private String sendGet(String url, Map<String, Object> params) {
|
|
|
String response = null;
|
|
|
try{
|
|
|
params.put("accesstoken",getAccessToken());
|
|
|
try {
|
|
|
params.put("accesstoken", getAccessToken());
|
|
|
List<BasicNameValuePair> jsonParams = new ArrayList<>();
|
|
|
//配置参数
|
|
|
if(params!=null) {
|
|
|
if (params != null) {
|
|
|
for (String key : params.keySet()) {
|
|
|
if (!StringUtils.isEmpty(String.valueOf(params.get(key))) && !"null".equals( String.valueOf(params.get(key)))) {
|
|
|
if (!StringUtils.isEmpty(String.valueOf(params.get(key))) && !"null".equals(String.valueOf(params.get(key)))) {
|
|
|
jsonParams.add(new BasicNameValuePair(key, String.valueOf(params.get(key))));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
response = httpClientUtil.get(wlyyUrl+url+"?"+ URLEncodedUtils.format(jsonParams, Consts.UTF_8),"utf-8");
|
|
|
}catch (Exception e){
|
|
|
response = httpClientUtil.get(wlyyUrl + url + "?" + URLEncodedUtils.format(jsonParams, Consts.UTF_8), "utf-8");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return response;
|
|
@ -1115,15 +1145,16 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 返回accessToken
|
|
|
*
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
private synchronized String getAccessToken(){
|
|
|
private synchronized String getAccessToken() {
|
|
|
String token = "";
|
|
|
if(tokenMap.get("token")!=null){
|
|
|
if (tokenMap.get("token") != null) {
|
|
|
token = tokenMap.get("token");
|
|
|
Long outTime = Long.valueOf(tokenMap.get("outTime"));
|
|
|
if(new Date().getTime()<outTime){
|
|
|
if (new Date().getTime() < outTime) {
|
|
|
return token;
|
|
|
}
|
|
|
}
|
|
@ -1135,30 +1166,31 @@ public class MonitorPlatformService {
|
|
|
String url = "/gc/accesstoken";
|
|
|
String response = HttpClientUtil.httpPost(wlyyUrl + url, params);
|
|
|
JSONObject jsonObject = JSON.parseObject(response);
|
|
|
if(jsonObject.getInteger("status")==10000){
|
|
|
if (jsonObject.getInteger("status") == 10000) {
|
|
|
String accesstoken = jsonObject.getJSONObject("result").getString("accesstoken");
|
|
|
tokenMap.put("token",accesstoken);
|
|
|
tokenMap.put("outTime", jsonObject.getJSONObject("result").getLong("outTime")+"");
|
|
|
tokenMap.put("token", accesstoken);
|
|
|
tokenMap.put("outTime", jsonObject.getJSONObject("result").getLong("outTime") + "");
|
|
|
return accesstoken;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 返回健康小屋详情信息
|
|
|
*/
|
|
|
public JSONObject getEquipmentDetail(String deviceSn){
|
|
|
public JSONObject getEquipmentDetail(String deviceSn) {
|
|
|
try {
|
|
|
IotEquipmentDetailDO iotEquipmentDetailDO= iotEquipmentDetailDao.findByDeviceCode(deviceSn);
|
|
|
JSONObject obj = (JSONObject)JSONObject.toJSON(iotEquipmentDetailDO);
|
|
|
if(iotEquipmentDetailDO!=null){
|
|
|
obj.put("deviceSn",iotEquipmentDetailDO.getDeviceCode());
|
|
|
IotEquipmentDetailDO iotEquipmentDetailDO = iotEquipmentDetailDao.findByDeviceCode(deviceSn);
|
|
|
JSONObject obj = (JSONObject) JSONObject.toJSON(iotEquipmentDetailDO);
|
|
|
if (iotEquipmentDetailDO != null) {
|
|
|
obj.put("deviceSn", iotEquipmentDetailDO.getDeviceCode());
|
|
|
}
|
|
|
return obj;
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
@ -1167,9 +1199,9 @@ public class MonitorPlatformService {
|
|
|
/**
|
|
|
* 获取设备品牌以及商家品牌排行
|
|
|
*/
|
|
|
public JSONObject getBrandsAndManufacturer(){
|
|
|
public JSONObject getBrandsAndManufacturer() {
|
|
|
try {
|
|
|
String sql = "select count(DISTINCT A.device_name) as total,A.device_name,A.manufacturer from (\n" +
|
|
|
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 and pd.del=0 \n" +
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
|
|
@ -1179,10 +1211,10 @@ public class MonitorPlatformService {
|
|
|
")A\n" +
|
|
|
"GROUP BY A.manufacturer\n" +
|
|
|
"ORDER BY total desc";
|
|
|
List<Map<String,Object>>Manufacturers = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String, Object>> Manufacturers = jdbcTemplate.queryForList(sql);
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(Manufacturers));
|
|
|
result.put("Manufacturers",arr);
|
|
|
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 and pd.del=0 \n" +
|
|
@ -1191,13 +1223,13 @@ public class MonitorPlatformService {
|
|
|
"UNION\n" +
|
|
|
"select case device_name when '自助体检一体机' then '健康小屋' else device_name end AS device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
|
|
|
")A";
|
|
|
Integer BrandsCount = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
Integer BrandsCount = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
|
|
|
result.put("Brands",BrandsCount);
|
|
|
result.put("manufacturerCount",arr.size());
|
|
|
result.put("Brands", BrandsCount);
|
|
|
result.put("manufacturerCount", arr.size());
|
|
|
return result;
|
|
|
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
@ -1205,149 +1237,147 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 谁设备库存、使用中、总备案、物联率、失联率
|
|
|
*
|
|
|
* @param deviceType
|
|
|
* @param deviceName
|
|
|
* @param showLevel
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getEquipmentStatistics(String deviceType,String deviceName,String showLevel){
|
|
|
public JSONObject getEquipmentStatistics(String deviceType, String deviceName, String showLevel) {
|
|
|
try {
|
|
|
WlyyIotTzDict dictObj =wlyyIotTzDictDao.findByCodeAndDel("IOT_LOST_DAY",1);
|
|
|
WlyyIotTzDict dictObj = wlyyIotTzDictDao.findByCodeAndDel("IOT_LOST_DAY", 1);
|
|
|
String lost_day = dictObj.getValue();
|
|
|
JSONObject result = new JSONObject();
|
|
|
JSONArray arrTmp = new JSONArray();
|
|
|
result.put("deviceInfo",arrTmp);
|
|
|
result.put("iotCount",0);
|
|
|
result.put("grantCount",0);
|
|
|
result.put("lostContact",0);
|
|
|
if (deviceType.contains("1")||deviceType.contains("2")) {
|
|
|
result.put("deviceInfo", arrTmp);
|
|
|
result.put("iotCount", 0);
|
|
|
result.put("grantCount", 0);
|
|
|
result.put("lostContact", 0);
|
|
|
if (deviceType.contains("1") || deviceType.contains("2")) {
|
|
|
StringBuffer sql = new StringBuffer("SELECT a.category_code type,a.device_name,a.c as 'using',b.c-a.c as 'stock',b.c as 'total' from ( ");
|
|
|
StringBuffer sqlCondition = new StringBuffer();
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
sqlCondition.append("and d.device_name in ('").append(deviceName.replace(",","','")).append("') ");
|
|
|
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 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, ");
|
|
|
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, ");
|
|
|
}
|
|
|
sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 "+sqlCondition+" ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("'))b ");
|
|
|
sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 " + sqlCondition + " ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
sql.append("and d.category_code in ('").append(deviceType.replace(",", "','")).append("'))b ");
|
|
|
}
|
|
|
}
|
|
|
else if("1".equals(showLevel)){ //血压计,血糖仪。。。
|
|
|
} else if ("1".equals(showLevel)) { //血压计,血糖仪。。。
|
|
|
sql.append("GROUP BY d.category_code )a, ");
|
|
|
sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 "+sqlCondition+" ");
|
|
|
sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 " + sqlCondition + " ");
|
|
|
sql.append("GROUP BY d.category_code )b ");
|
|
|
sql.append("WHERE a.category_code = b.category_code ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and a.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
sql.append("and a.category_code in ('").append(deviceType.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
}else if ("2".equals(showLevel)){//XX血压计1,XX血压计1
|
|
|
} else if ("2".equals(showLevel)) {//XX血压计1,XX血压计1
|
|
|
sql.append("GROUP BY d.category_code,d.device_name) a, ");
|
|
|
sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 "+sqlCondition+" ");
|
|
|
sql.append("(SELECT d.category_code,d.device_name,COUNT(*) c from wlyy.wlyy_patient_device d where 1=1 " + sqlCondition + " ");
|
|
|
sql.append("GROUP BY d.category_code,d.device_name) b ");
|
|
|
sql.append("WHERE a.category_code = b.category_code and a.device_name = b.device_name ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and a.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
sql.append("and a.category_code in ('").append(deviceType.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
}
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
|
|
|
List<Map<String, Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
|
|
|
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(sqlResult));
|
|
|
for(int i=0;i<arr.size();i++){
|
|
|
for (int i = 0; i < arr.size(); i++) {
|
|
|
JSONObject obj = arr.getJSONObject(i);
|
|
|
if ("0".equals(showLevel)){
|
|
|
obj.put("device_name","单体征测量仪");
|
|
|
obj.put("Subdivision",true);//是否可查看下一层次
|
|
|
if ("0".equals(showLevel)) {
|
|
|
obj.put("device_name", "单体征测量仪");
|
|
|
obj.put("Subdivision", true);//是否可查看下一层次
|
|
|
StringBuffer sqlTmp = new StringBuffer("select code from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and `code` in ('");
|
|
|
sqlTmp.append(deviceType.replace(",","','")).append("') ");
|
|
|
sqlTmp.append(deviceType.replace(",", "','")).append("') ");
|
|
|
sqlTmp.append("and del=1 and parent_code \n" +
|
|
|
"in(select id from xmiot.iot_system_dict where dict_name='DEVICE' and `value`='单体征测量仪' and del=1)");
|
|
|
List<String> list = jdbcTemplate.queryForList(sqlTmp.toString(),String.class);
|
|
|
List<String> list = jdbcTemplate.queryForList(sqlTmp.toString(), String.class);
|
|
|
sqlTmp = new StringBuffer();
|
|
|
for (String s:list){
|
|
|
sqlTmp.append(","+s);
|
|
|
for (String s : list) {
|
|
|
sqlTmp.append("," + s);
|
|
|
}
|
|
|
if (list.size()!=0){
|
|
|
if (list.size() != 0) {
|
|
|
sqlTmp.deleteCharAt(0);
|
|
|
}
|
|
|
obj.put("type",sqlTmp.toString());
|
|
|
}
|
|
|
else if("1".equals(showLevel)){
|
|
|
obj.put("type", sqlTmp.toString());
|
|
|
} else if ("1".equals(showLevel)) {
|
|
|
String temp = obj.getString("type");
|
|
|
if("1".equals(temp)){
|
|
|
obj.put("device_name","血糖仪");
|
|
|
}else if("2".equals(temp)){
|
|
|
obj.put("device_name","血压计");
|
|
|
if ("1".equals(temp)) {
|
|
|
obj.put("device_name", "血糖仪");
|
|
|
} else if ("2".equals(temp)) {
|
|
|
obj.put("device_name", "血压计");
|
|
|
}
|
|
|
obj.put("Subdivision",true);
|
|
|
obj.put("Subdivision", true);
|
|
|
} else {
|
|
|
obj.put("Subdivision", false);
|
|
|
}
|
|
|
else{
|
|
|
obj.put("Subdivision",false);
|
|
|
}
|
|
|
obj.put("showLevel",Integer.parseInt(showLevel));
|
|
|
obj.put("showLevel", Integer.parseInt(showLevel));
|
|
|
}
|
|
|
result.put("deviceInfo",arr);//设备信息统计
|
|
|
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 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("') ");
|
|
|
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);
|
|
|
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 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("') ");
|
|
|
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("') ");
|
|
|
}
|
|
|
Integer grantCount = jdbcTemplate.queryForObject(sql.toString(),Integer.class);//设备发放总数
|
|
|
result.put("grantCount",grantCount);
|
|
|
Integer grantCount = jdbcTemplate.queryForObject(sql.toString(), Integer.class);//设备发放总数
|
|
|
result.put("grantCount", grantCount);
|
|
|
|
|
|
//失联设备(一周未上传当作失联)
|
|
|
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()) <= "+lost_day+")");
|
|
|
Integer lostContact = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
result.put("lostContact",lostContact);
|
|
|
sql.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= " + lost_day + ")");
|
|
|
Integer lostContact = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
result.put("lostContact", lostContact);
|
|
|
}
|
|
|
//deviceType包含小屋且设备名称为空||deviceType包含小屋且设备名称为健康小屋。
|
|
|
if ((deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isBlank(deviceName))||(deviceType.contains("5")&&org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)&&deviceName.contains("健康小屋"))){
|
|
|
if ((deviceType.contains("5") && org.apache.commons.lang3.StringUtils.isBlank(deviceName)) || (deviceType.contains("5") && org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) && deviceName.contains("健康小屋"))) {
|
|
|
String sql = "select COUNT(*) from xmiot.iot_equipmet_detail";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
tmp.put("using",count);
|
|
|
tmp.put("total",count);
|
|
|
tmp.put("type","5");
|
|
|
tmp.put("stock",0);
|
|
|
if("0".equals(showLevel)){
|
|
|
tmp.put("device_name","组合一体机");
|
|
|
tmp.put("Subdivision",true);
|
|
|
}else{
|
|
|
tmp.put("device_name","健康小屋");
|
|
|
tmp.put("Subdivision",false);
|
|
|
tmp.put("using", count);
|
|
|
tmp.put("total", count);
|
|
|
tmp.put("type", "5");
|
|
|
tmp.put("stock", 0);
|
|
|
if ("0".equals(showLevel)) {
|
|
|
tmp.put("device_name", "组合一体机");
|
|
|
tmp.put("Subdivision", true);
|
|
|
} else {
|
|
|
tmp.put("device_name", "健康小屋");
|
|
|
tmp.put("Subdivision", false);
|
|
|
}
|
|
|
tmp.put("showLevel",Integer.parseInt(showLevel));
|
|
|
tmp.put("showLevel", Integer.parseInt(showLevel));
|
|
|
result.getJSONArray("deviceInfo").add(tmp);
|
|
|
result.put("grantCount",result.getInteger("grantCount")+count);
|
|
|
result.put("grantCount", result.getInteger("grantCount") + count);
|
|
|
//统计健康小屋数据/ 小屋全部统计为正常使用
|
|
|
sql ="select count(*) from xmiot.iot_equipmet_detail where device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m)";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
result.put("iotCount",result.getInteger("iotCount")+count);//小屋物联
|
|
|
sql = "select count(*) from xmiot.iot_equipmet_detail where device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m)";
|
|
|
count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
result.put("iotCount", result.getInteger("iotCount") + count);//小屋物联
|
|
|
}
|
|
|
arrTmp = result.getJSONArray("deviceInfo");
|
|
|
for (int i=0;i<arrTmp.size();i++){
|
|
|
for (int i = 0; i < arrTmp.size(); i++) {
|
|
|
JSONObject tmp = arrTmp.getJSONObject(i);
|
|
|
if (tmp.getInteger("total")==0){
|
|
|
if (tmp.getInteger("total") == 0) {
|
|
|
arrTmp.remove(tmp);
|
|
|
}
|
|
|
}
|
|
|
result.put("iotRangeString",result.getInteger("iotCount")+"/"+result.getInteger("grantCount"));
|
|
|
result.put("lostRangeString",result.getInteger("lostContact")+"/"+result.getInteger("grantCount"));
|
|
|
result.put("iotRange",getRange(result.getInteger("iotCount"),result.getInteger("grantCount"),2));
|
|
|
result.put("lostRange",getRange(result.getInteger("lostContact"),result.getInteger("grantCount"),2));
|
|
|
result.put("iotRangeString", result.getInteger("iotCount") + "/" + result.getInteger("grantCount"));
|
|
|
result.put("lostRangeString", result.getInteger("lostContact") + "/" + result.getInteger("grantCount"));
|
|
|
result.put("iotRange", getRange(result.getInteger("iotCount"), result.getInteger("grantCount"), 2));
|
|
|
result.put("lostRange", getRange(result.getInteger("lostContact"), result.getInteger("grantCount"), 2));
|
|
|
return result;
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
@ -1367,6 +1397,7 @@ public class MonitorPlatformService {
|
|
|
|
|
|
/**
|
|
|
* 获取物联率与失联率
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param deviceType
|
|
@ -1375,178 +1406,177 @@ public class MonitorPlatformService {
|
|
|
* @param quotaCode
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject iotAndLostRange(String startTime,String endTime,
|
|
|
String deviceType,String area,String hospital,String quotaCode){
|
|
|
WlyyIotTzDict dictObj =wlyyIotTzDictDao.findByCodeAndDel("IOT_LOST_DAY",1);
|
|
|
public JSONObject iotAndLostRange(String startTime, String endTime,
|
|
|
String deviceType, String area, String hospital, String quotaCode) {
|
|
|
WlyyIotTzDict dictObj = wlyyIotTzDictDao.findByCodeAndDel("IOT_LOST_DAY", 1);
|
|
|
String lost_day = dictObj.getValue();
|
|
|
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 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(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(hospital)) {
|
|
|
sqlCondition.append(" and d.hospital =" + hospital + " ");
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sqlCondition.append("and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
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)){
|
|
|
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)){
|
|
|
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+"' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
sqlCondition.append("and dh.code='"+hospital+"' ");
|
|
|
sqlCondition.append("and dh.town='" + area + "' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)) {
|
|
|
sqlCondition.append("and dh.code='" + hospital + "' ");
|
|
|
}
|
|
|
}
|
|
|
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' ");
|
|
|
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' ");
|
|
|
}
|
|
|
sqlCondition.append(" ) and d.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
sqlCondition.append(" ) and d.category_code in ('").append(deviceType.replace(",", "','")).append("') ");
|
|
|
sql.append(sqlCondition);
|
|
|
total=jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
total = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
}
|
|
|
//失联
|
|
|
if("2".equals(quotaCode)){
|
|
|
if ("2".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)){
|
|
|
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+"' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)){
|
|
|
sqlCondition.append("and dh.code='"+hospital+"' ");
|
|
|
sqlCondition.append("and dh.town='" + area + "' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(hospital)) {
|
|
|
sqlCondition.append("and dh.code='" + hospital + "' ");
|
|
|
}
|
|
|
}
|
|
|
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.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()) <= "+lost_day+" ");
|
|
|
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()) <= " + lost_day + " ");
|
|
|
}
|
|
|
sqlCondition.append(")");
|
|
|
sql.append(sqlCondition);
|
|
|
total=jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
total = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
}
|
|
|
Integer count =0;
|
|
|
if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
|
|
|
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+"' ";
|
|
|
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;
|
|
|
if("1".equals(quotaCode)){//小屋物联率
|
|
|
sql= new StringBuffer("select count(*) from xmiot.iot_equipmet_detail ");
|
|
|
count = jdbcTemplate.queryForObject(sqll, Integer.class);
|
|
|
result.put("totalAll", grantCount + count);
|
|
|
count = 0;
|
|
|
if ("1".equals(quotaCode)) {//小屋物联率
|
|
|
sql = new StringBuffer("select count(*) from xmiot.iot_equipmet_detail ");
|
|
|
sqlCondition = new StringBuffer(" where 1=1 ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
sqlCondition.append("and belong_are_code='"+area+"' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)) {
|
|
|
sqlCondition.append("and belong_are_code='" + area + "' ");
|
|
|
}
|
|
|
sqlCondition.append("and device_code in (select DISTINCT sn device_model from xmiot.wlyy_iot_m where 1=1 ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime)&&org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)){
|
|
|
sqlCondition.append("and create_time >='"+startTime+" 00:00:00' and create_time<='"+endTime+" 23:59:59' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(startTime) && org.apache.commons.lang3.StringUtils.isNoneBlank(endTime)) {
|
|
|
sqlCondition.append("and create_time >='" + startTime + " 00:00:00' and create_time<='" + endTime + " 23:59:59' ");
|
|
|
}
|
|
|
sql.append(sqlCondition+")");
|
|
|
count = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
sql.append(sqlCondition + ")");
|
|
|
count = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
}
|
|
|
if("2".equals(quotaCode)){//小屋失联数0
|
|
|
count=0;
|
|
|
if ("2".equals(quotaCode)) {//小屋失联数0
|
|
|
count = 0;
|
|
|
}
|
|
|
result.put("total",total+count);//互联设备\失联设备数量
|
|
|
}
|
|
|
else{
|
|
|
result.put("total",total+count);//互联设备\失联设备数量
|
|
|
result.put("total", total + count);//互联设备\失联设备数量
|
|
|
} else {
|
|
|
result.put("total", total + count);//互联设备\失联设备数量
|
|
|
}
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
if (result.getInteger("totalAll") > 0) {
|
|
|
result.put("totalRange", df.format(result.getDouble("total") > 0.0 ? ((result.getDouble("total")) / (result.getInteger("totalAll") * 1.0000) * 100) : 0.0) );
|
|
|
result.put("totalRange", df.format(result.getDouble("total") > 0.0 ? ((result.getDouble("total")) / (result.getInteger("totalAll") * 1.0000) * 100) : 0.0));
|
|
|
} else {
|
|
|
result.put("totalRange", 0.0 );
|
|
|
result.put("totalRange", 0.0);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取设备品牌详细
|
|
|
*
|
|
|
* @param deviceType
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getBrandsDetail(String deviceType){
|
|
|
public JSONObject getBrandsDetail(String deviceType) {
|
|
|
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 and pd.del=0 \n" +
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>'' " +
|
|
|
"and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)){
|
|
|
sql.append("and pd.category_code in ('").append(deviceType.replace(",","','")).append("') ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)) {
|
|
|
sql.append("and pd.category_code in ('").append(deviceType.replace(",", "','")).append("') ");
|
|
|
}
|
|
|
sql.append("GROUP BY wd.manufacturer_code,pd.device_name ");
|
|
|
if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
|
|
|
if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType) && deviceType.contains("5")) || org.apache.commons.lang3.StringUtils.isBlank(deviceType)) {
|
|
|
sql.append("UNION select case device_name when '自助体检一体机' then '健康小屋' else device_name end AS device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name");
|
|
|
}
|
|
|
sql.append(")A");
|
|
|
List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
|
|
|
List<String> list = jdbcTemplate.queryForList(sql.toString(), String.class);
|
|
|
List<String> reList = new ArrayList<>();
|
|
|
int i=0;
|
|
|
for(String tmp:list){
|
|
|
if ("三诺血糖仪".equals(tmp)||"血糖仪-三诺亲智".equals(tmp)||"三诺亲智".equals(tmp)||"健康之路亲智血糖仪".equals(tmp)||"血糖仪".equals(tmp)||"血糖仪-健康之路亲智血糖仪".equals(tmp)){
|
|
|
i=1;
|
|
|
int i = 0;
|
|
|
for (String tmp : list) {
|
|
|
if ("三诺血糖仪".equals(tmp) || "血糖仪-三诺亲智".equals(tmp) || "三诺亲智".equals(tmp) || "健康之路亲智血糖仪".equals(tmp) || "血糖仪".equals(tmp) || "血糖仪-健康之路亲智血糖仪".equals(tmp)) {
|
|
|
i = 1;
|
|
|
continue;
|
|
|
}
|
|
|
reList.add(tmp);
|
|
|
}
|
|
|
if (i==1){//上面去除的元素统一返回为三诺血糖仪
|
|
|
if (i == 1) {//上面去除的元素统一返回为三诺血糖仪
|
|
|
reList.add("三诺血糖仪");
|
|
|
}
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("brands",reList);
|
|
|
result.put("brands", reList);
|
|
|
return result;
|
|
|
}catch (Exception e){
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public JSONObject getDeviceData(){
|
|
|
public JSONObject getDeviceData() {
|
|
|
JSONObject object = new JSONObject();
|
|
|
//血糖仪数量
|
|
|
String bloodGlucosemeterCount = "SELECT COUNT(1) FROM wlyy.wlyy_patient_device WHERE category_code = 1 AND del = 0";
|
|
|
//血压计数量
|
|
|
String sphygmomanometerCount = "SELECT COUNT(1) FROM wlyy.wlyy_patient_device WHERE category_code = 2 AND del = 0";
|
|
|
Integer aa = jdbcTemplate.queryForObject(bloodGlucosemeterCount,Integer.class);
|
|
|
Integer bb = jdbcTemplate.queryForObject(sphygmomanometerCount,Integer.class);
|
|
|
object.put("homeHealthEquipment",aa+bb);
|
|
|
Integer aa = jdbcTemplate.queryForObject(bloodGlucosemeterCount, Integer.class);
|
|
|
Integer bb = jdbcTemplate.queryForObject(sphygmomanometerCount, Integer.class);
|
|
|
object.put("homeHealthEquipment", aa + bb);
|
|
|
//血糖仪 血压计 体征数据
|
|
|
String physicalSignData = "SELECT count(1) from wlyy.wlyy_sign_family s,wlyy.wlyy_patient_device d, device.wlyy_patient_health_index p WHERE s.`status`>0 \n" +
|
|
|
"and d.`user` = s.patient and p.`user`=d.`user` and p.del=1 and (p.type=1 or p.type=2)";
|
|
|
Integer cc = jdbcTemplate.queryForObject(physicalSignData,Integer.class);
|
|
|
object.put("homePhysicalSignData",cc);
|
|
|
Integer cc = jdbcTemplate.queryForObject(physicalSignData, Integer.class);
|
|
|
object.put("homePhysicalSignData", cc);
|
|
|
//异常数据
|
|
|
String abnormalPhysicalSignData = "SELECT count(1) from wlyy.wlyy_sign_family s,wlyy.wlyy_patient_device d,device.wlyy_patient_health_index p WHERE s.`status`>0 \n" +
|
|
|
"and d.`user` = s.patient and p.`user`=d.`user` and p.`status`=1 and p.del=1 and (p.type=1 or p.type=2)";
|
|
|
Integer dd = jdbcTemplate.queryForObject(abnormalPhysicalSignData,Integer.class);
|
|
|
object.put("homeAbnormalSignData",dd);
|
|
|
Integer dd = jdbcTemplate.queryForObject(abnormalPhysicalSignData, Integer.class);
|
|
|
object.put("homeAbnormalSignData", dd);
|
|
|
//小屋数量
|
|
|
String cabinCount = "SELECT COUNT(1) FROM xmiot.iot_equipmet_detail";
|
|
|
Integer ee = jdbcTemplate.queryForObject(cabinCount,Integer.class);
|
|
|
object.put("medicalInstitutionIquipment",ee);
|
|
|
Integer ee = jdbcTemplate.queryForObject(cabinCount, Integer.class);
|
|
|
object.put("medicalInstitutionIquipment", ee);
|
|
|
//小屋体征数据
|
|
|
String cabinSignData = "SELECT count(1) FROM xmiot.wlyy_iot_m ";
|
|
|
Integer ff = jdbcTemplate.queryForObject(cabinSignData,Integer.class);
|
|
|
object.put("medicalPhysicalSignData",ff);
|
|
|
Integer ff = jdbcTemplate.queryForObject(cabinSignData, Integer.class);
|
|
|
object.put("medicalPhysicalSignData", ff);
|
|
|
//小屋异常体征数据
|
|
|
String abnormalSignDataOfCabin = "select count(1)\n" +
|
|
|
"from xmiot.wlyy_iot_d d \n" +
|
|
@ -1555,136 +1585,137 @@ public class MonitorPlatformService {
|
|
|
"(d.`code`='HighPressure' and (d.`value` not BETWEEN 90.0 and 140))\n" +
|
|
|
"or (d.`code`='LowPressure' and (d.`value` not BETWEEN 60.0 and 90))\n" +
|
|
|
");";
|
|
|
Integer gg = jdbcTemplate.queryForObject(abnormalSignDataOfCabin,Integer.class);
|
|
|
object.put("medicalAbnormalSignData",gg);
|
|
|
Integer gg = jdbcTemplate.queryForObject(abnormalSignDataOfCabin, Integer.class);
|
|
|
object.put("medicalAbnormalSignData", gg);
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
public JSONArray getSearchTags(){
|
|
|
public JSONArray getSearchTags() {
|
|
|
String sql = "select id,`value` from xmiot.iot_system_dict where dict_name='DEVICE' and (value='组合一体机' or value ='单体征测量仪') and del=1;";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
JSONArray result = new JSONArray();
|
|
|
for (Map<String,Object> map :list){
|
|
|
sql="select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and del=1 and code!=10 and code!=11 and parent_code='"+map.get("id").toString()+"'";
|
|
|
for (Map<String, Object> map : list) {
|
|
|
sql = "select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and del=1 and code!=10 and code!=11 and parent_code='" + map.get("id").toString() + "'";
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
List<Map<String,Object>> reList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> reMap:reList){
|
|
|
List<Map<String, Object>> reList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> reMap : reList) {
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
tmp.put("name",reMap.get("value").toString());
|
|
|
tmp.put("code",reMap.get("code").toString());
|
|
|
buffer.append(","+reMap.get("code").toString());
|
|
|
tmp.put("name", reMap.get("value").toString());
|
|
|
tmp.put("code", reMap.get("code").toString());
|
|
|
buffer.append("," + reMap.get("code").toString());
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(buffer.toString())){
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(buffer.toString())) {
|
|
|
buffer.deleteCharAt(0);
|
|
|
JSONObject tmp = new JSONObject();
|
|
|
tmp.put("name",map.get("value").toString());
|
|
|
tmp.put("code",buffer.toString());
|
|
|
tmp.put("name", map.get("value").toString());
|
|
|
tmp.put("code", buffer.toString());
|
|
|
result.add(tmp);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public JSONObject getDeviceTotalCount(String startTime,String endTime,String deviceType,String area,String hospital){
|
|
|
Integer totalAll=0;
|
|
|
Integer grant=0;
|
|
|
if (deviceType.contains("5")){
|
|
|
public JSONObject getDeviceTotalCount(String startTime, String endTime, String deviceType, String area, String hospital) {
|
|
|
Integer totalAll = 0;
|
|
|
Integer grant = 0;
|
|
|
if (deviceType.contains("5")) {
|
|
|
StringBuffer sql = new StringBuffer("select count(*) from xmiot.iot_equipmet_detail where 1=1 ");
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(area)){
|
|
|
sql.append("and belong_are_code='"+area+"' ");
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(area)) {
|
|
|
sql.append("and belong_are_code='" + area + "' ");
|
|
|
}
|
|
|
Integer tmp = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
|
|
|
totalAll +=tmp;
|
|
|
grant +=tmp;
|
|
|
Integer tmp = jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
totalAll += tmp;
|
|
|
grant += tmp;
|
|
|
}
|
|
|
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+= " ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType) && deviceType.contains("1")) {
|
|
|
allCountSql += " ";
|
|
|
i = 1;
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("2")){
|
|
|
if(i==1){
|
|
|
allCountSql+= " or device_name like '%血压计%'";
|
|
|
}else{
|
|
|
allCountSql+= " and ( device_name like '%血压计%' ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType) && deviceType.contains("2")) {
|
|
|
if (i == 1) {
|
|
|
allCountSql += " or device_name like '%血压计%'";
|
|
|
} else {
|
|
|
allCountSql += " and ( device_name like '%血压计%' ";
|
|
|
}
|
|
|
}
|
|
|
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 )";
|
|
|
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(hospital)) {
|
|
|
allCountSql += " and grant_org_code =" + hospital + " ";
|
|
|
}
|
|
|
if(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&(deviceType.contains("1")||deviceType.contains("2"))){
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType) && (deviceType.contains("1") || deviceType.contains("2"))) {
|
|
|
Integer allCount = jdbcTemplate.queryForObject(allCountSql, Integer.class);//单体征总数
|
|
|
totalAll+=allCount;
|
|
|
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(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(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' ");
|
|
|
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;
|
|
|
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);
|
|
|
result.put("using",grant);
|
|
|
result.put("stock",totalAll-grant);
|
|
|
result.put("totalAll", totalAll);
|
|
|
result.put("using", grant);
|
|
|
result.put("stock", totalAll - grant);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* deviceName处理
|
|
|
*
|
|
|
* @param deviceName
|
|
|
* @return
|
|
|
*/
|
|
|
public String getDeviceNameByRequestParam(String deviceName){
|
|
|
if (deviceName.contains("三诺血糖仪")){
|
|
|
return deviceName.replace("三诺血糖仪","三诺血糖仪,血糖仪-三诺亲智,三诺亲智,健康之路亲智血糖仪,血糖仪,血糖仪-健康之路亲智血糖仪");
|
|
|
public String getDeviceNameByRequestParam(String deviceName) {
|
|
|
if (deviceName.contains("三诺血糖仪")) {
|
|
|
return deviceName.replace("三诺血糖仪", "三诺血糖仪,血糖仪-三诺亲智,三诺亲智,健康之路亲智血糖仪,血糖仪,血糖仪-健康之路亲智血糖仪");
|
|
|
}
|
|
|
return deviceName;
|
|
|
}
|
|
|
|
|
|
public JSONObject savePatientDeviceLocation(String categoryCode){
|
|
|
public JSONObject savePatientDeviceLocation(String categoryCode) {
|
|
|
String sql = "select DISTINCT pd.category_code ,pd.czrq create_time,pd.device_sn ,pd.device_name, p.disease_condition ,p.`code`,p.idcard ,p.address,sf.hospital_name\n" +
|
|
|
"from wlyy.wlyy_patient_device pd \n" +
|
|
|
"INNER JOIN wlyy.wlyy_sign_family sf on pd.`user` = sf.patient and sf.type=2 \n" +
|
|
|
"INNER JOIN wlyy.wlyy_patient p on p.idcard = sf.idcard and p.`status`=1\n" +
|
|
|
"where pd.del=0 and pd.category_code in ("+categoryCode+")";
|
|
|
"where pd.del=0 and pd.category_code in (" + categoryCode + ")";
|
|
|
// "where pd.del=0 and pd.category_code in (1,2)";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
list.forEach(map->{
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
list.forEach(map -> {
|
|
|
try {
|
|
|
if(map.get("disease_condition")==null){
|
|
|
if (map.get("disease_condition") == null) {
|
|
|
//未定标的居民设置成-1
|
|
|
map.put("disease_condition","-1");
|
|
|
map.put("disease_condition", "-1");
|
|
|
}
|
|
|
Map<String, String> json = null;
|
|
|
if (map.get("address")!=null){
|
|
|
if (map.get("address") != null) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(map.get("address").toString())) {
|
|
|
json = LatitudeUtils.getGeocoderLatitude(("福建省厦门市"+map.get("address").toString()).replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
json = LatitudeUtils.getGeocoderLatitude(("福建省厦门市" + map.get("address").toString()).replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
}
|
|
|
}
|
|
|
if (json==null||map.get("address")==null){
|
|
|
if (map.get("hospital_name")!=null){
|
|
|
if (json == null || map.get("address") == null) {
|
|
|
if (map.get("hospital_name") != null) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNoneBlank(map.get("hospital_name").toString())) {
|
|
|
json = LatitudeUtils.getGeocoderLatitude(("福建省厦门市"+map.get("hospital_name").toString()).replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
json = LatitudeUtils.getGeocoderLatitude(("福建省厦门市" + map.get("hospital_name").toString()).replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (json !=null) {
|
|
|
if (json != null) {
|
|
|
JSONObject location = new JSONObject();
|
|
|
location.put("lat", Double.valueOf(json.get("lat")));
|
|
|
location.put("lon", Double.valueOf(json.get("lng")));
|
|
@ -1694,53 +1725,237 @@ public class MonitorPlatformService {
|
|
|
"'" + map.get("category_code").toString() + "','" + map.get("create_time") + "','" + map.get("create_time").toString() + "','" + location.toJSONString() + "')\n";
|
|
|
jdbcTemplate.execute(insertSql);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
System.out.println(map.get("device_sn").toString()+"-----"+map.get("idcard").toString());
|
|
|
} catch (Exception e) {
|
|
|
System.out.println(map.get("device_sn").toString() + "-----" + map.get("idcard").toString());
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public List<Map<String, Object>> getHealthScoreByPatient(String patient,String date,String endDate){
|
|
|
public List<Map<String, Object>> getHealthScoreByPatient(String patient, String date, String endDate) {
|
|
|
String sql = "SELECT chhs.device_sn deviceSn,chhs.export_key exportKey,chhs.export_time exportTime,chhs.name name,chhs.score score,chhs.total total,chhs.date date FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_health_score chhs,wlyy.hm_token t\n" +
|
|
|
"WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chhs.device_sn and chhs.date > '"+endDate+"' and chhs.date < '"+date+"' ORDER BY export_time DESC ";
|
|
|
"WHERE t.patient = '" + patient + "' AND t.patient = chd.patient AND chd.device_sn = chhs.device_sn and chhs.date > '" + endDate + "' and chhs.date < '" + date + "' ORDER BY export_time DESC ";
|
|
|
List<Map<String, Object>> scoreDO = jdbcTemplate.queryForList(sql);
|
|
|
return scoreDO;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getRealtimeDateByPatient(String patient,String date){
|
|
|
public List<Map<String, Object>> getRealtimeDateByPatient(String patient, String date) {
|
|
|
String sql = "SELECT chrd.device_sn deviceSn,chrd.hr hr,chrd.st st,chrd.cal cal,chrd.date date FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_realtime_date chrd,wlyy.hm_token t\n" +
|
|
|
"WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chrd.device_sn and chrd.date = '"+date+"' ORDER BY chrd.`date` DESC";
|
|
|
"WHERE t.patient = '" + patient + "' AND t.patient = chd.patient AND chd.device_sn = chrd.device_sn and chrd.date = '" + date + "' ORDER BY chrd.`date` DESC";
|
|
|
List<Map<String, Object>> realtimeDateDo = jdbcTemplate.queryForList(sql);
|
|
|
return realtimeDateDo;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getRundatePatient(String patient,String date){
|
|
|
public List<Map<String, Object>> getRundatePatient(String patient, String date) {
|
|
|
String sql = "SELECT chr.device_sn deviceSn,chr.date date,chr.last_sync_time lastSyncTime,chr.steps steps,chr.distance distance,chr.run_distance runDistance,chr.run_time runTime,chr.walk_time walkTime,chr.calories calories,chr.run_calories runCalories,chr.hour hour FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_rundate chr,wlyy.hm_token t\n" +
|
|
|
"WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chr.device_sn and chr.date = '"+date+"' ORDER BY chr.`date` DESC";
|
|
|
"WHERE t.patient = '" + patient + "' AND t.patient = chd.patient AND chd.device_sn = chr.device_sn and chr.date = '" + date + "' ORDER BY chr.`date` DESC";
|
|
|
List<Map<String, Object>> rundataDo = jdbcTemplate.queryForList(sql);
|
|
|
return rundataDo;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getPaiPatient(String patient,String date){
|
|
|
public List<Map<String, Object>> getPaiPatient(String patient, String date) {
|
|
|
String sql = "SELECT chp.device_sn deviceSn,chp.calendar_day calendarDay,chp.timestamp timestamp,chp.total_pai totalPai,chp.daily_pai dailyPai,chp.date date FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_pai chp,wlyy.hm_token t\n" +
|
|
|
"WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chp.device_sn and chp.date = '"+date+"' ORDER BY chp.`timestamp` DESC";
|
|
|
"WHERE t.patient = '" + patient + "' AND t.patient = chd.patient AND chd.device_sn = chp.device_sn and chp.date = '" + date + "' ORDER BY chp.`timestamp` DESC";
|
|
|
List<Map<String, Object>> paiDo = jdbcTemplate.queryForList(sql);
|
|
|
return paiDo;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getSleepByPatient(String patient,String date){
|
|
|
public List<Map<String, Object>> getSleepByPatient(String patient, String date) {
|
|
|
String sql = "SELECT chs.device_sn deviceSn,chs.date date,chs.last_sync_time lastSyncTime,chs.deep_sleep_time deepSleepTime,chs.shallow_sleep_time shallowSleepTime,chs.wake_time wakeTime,chs.sleep_score sleepScore,chs.start start,chs.stop stop,chs.mode mode FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_sleep chs,wlyy.hm_token t\n" +
|
|
|
"WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chs.device_sn and chs.date = '"+date+"' ORDER BY chs.`last_sync_time` DESC";
|
|
|
"WHERE t.patient = '" + patient + "' AND t.patient = chd.patient AND chd.device_sn = chs.device_sn and chs.date = '" + date + "' ORDER BY chs.`last_sync_time` DESC";
|
|
|
List<Map<String, Object>> paiDo = jdbcTemplate.queryForList(sql);
|
|
|
return paiDo;
|
|
|
}
|
|
|
|
|
|
public List<Map<String , Object>> getHeartByPatient(String patient,String date,String endDate){
|
|
|
public List<Map<String, Object>> getHeartByPatient(String patient, String date, String endDate) {
|
|
|
String sql = "SELECT chh.device_sn deviceSn,chh.date date,chh.minute minute,chh.last_sync_time lastSyncTime,chh.timestamp timestamp,chh.heart_rate_data heartRateData,chh.measure_type measureType FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_heart chh,wlyy.hm_token t\n" +
|
|
|
"WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chh.device_sn and chh.`date` > '"+endDate+"' and chh.`date` < '"+date+"' ORDER BY chh.`date` DESC";
|
|
|
"WHERE t.patient = '" + patient + "' AND t.patient = chd.patient AND chd.device_sn = chh.device_sn and chh.`date` > '" + endDate + "' and chh.`date` < '" + date + "' ORDER BY chh.`date` DESC";
|
|
|
List<Map<String, Object>> heartDo = jdbcTemplate.queryForList(sql);
|
|
|
return heartDo;
|
|
|
}
|
|
|
|
|
|
/*获取药柜所有设备信息 地址 编号 名字*/
|
|
|
public List<Map<String,String>> getMedicinecabinet() {
|
|
|
JSONArray resultArr = new JSONArray();
|
|
|
List<Map<String, String>> list = new ArrayList<>();
|
|
|
try {
|
|
|
JSONObject resultObject = getUrl("/open/noLogin/getDeviceList", null);
|
|
|
resultArr = resultObject.getJSONArray("usedDeviceList");
|
|
|
for (int i = 0; i < resultArr.size(); i++) {
|
|
|
Map<String, String> resultMap = new HashMap<>();
|
|
|
JSONObject jsonObject = resultArr.getJSONObject(i);
|
|
|
/*获取设备名称*/
|
|
|
String equName = jsonObject.getString("equName");
|
|
|
resultMap.put("equName", equName);
|
|
|
/*获取设备地址*/
|
|
|
String deliveryAddress = jsonObject.getString("deliveryAddress");
|
|
|
resultMap.put("deliveryAddress;", deliveryAddress);
|
|
|
/*获取设备编号*/
|
|
|
String equNum = jsonObject.getString("equNum");
|
|
|
resultMap.put("equNum", equNum);
|
|
|
/*获取设备编号*/
|
|
|
String id = jsonObject.getString("id");
|
|
|
resultMap.put("id", id);
|
|
|
list.add(resultMap);
|
|
|
}
|
|
|
return list;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*总数*/
|
|
|
public Map<String, String> getMedicinecabinetCount() {
|
|
|
|
|
|
Map resultMap = new HashMap<>();
|
|
|
JSONObject jsonObject = getUrl("/open/noLogin/getDeviceList", null);
|
|
|
//设备总数
|
|
|
String total = jsonObject.get("total").toString();
|
|
|
//库存量
|
|
|
String notUsedTotal = jsonObject.get("notUsedTotal").toString();
|
|
|
//使用中
|
|
|
String usedTotal = jsonObject.get("usedTotal").toString();
|
|
|
|
|
|
resultMap.put("total", total);
|
|
|
resultMap.put("notUsedTotal", notUsedTotal);
|
|
|
resultMap.put("usedTotal", usedTotal);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
/*获取药柜详细信息*/
|
|
|
public Map<String, List<Map>> getadddd(String deviceid, String day) throws Exception {
|
|
|
//返回参数
|
|
|
Map<String, List<Map>> resoultMap = new HashMap<>();
|
|
|
|
|
|
//参数加密
|
|
|
Map parameterMap = new HashMap<String, String>();
|
|
|
parameterMap.put("deviceId", deviceid);
|
|
|
parameterMap.put("day", day);
|
|
|
String content = com.alibaba.fastjson.JSONObject.toJSONString(parameterMap);
|
|
|
String params = AesEncryptUtils.agEncrypt(content);
|
|
|
JSONObject jsonObject = getUrl("/open/noLogin/getDeviceInfo", params);
|
|
|
|
|
|
//医保曲线
|
|
|
JSONArray yibaoArray = jsonObject.getJSONArray("yibaoList");
|
|
|
/*for (int i = 0; i < yibaoList.size(); i++) {
|
|
|
Map listMap = new HashMap<>();
|
|
|
JSONObject yibaoListJSONObject = yibaoList.getJSONObject(i);
|
|
|
String date = yibaoListJSONObject.getString("date");
|
|
|
String avg = yibaoListJSONObject.getString("avg");
|
|
|
String count = yibaoListJSONObject.getString("count");
|
|
|
listMap.put("date",date);
|
|
|
listMap.put("avg",avg);
|
|
|
listMap.put("count",count);
|
|
|
yibaoListMap.add(listMap);
|
|
|
}
|
|
|
*/
|
|
|
List<Map> yibaoList = JSONObject.parseArray(yibaoArray.toJSONString(), Map.class);
|
|
|
|
|
|
//扫码曲线获取
|
|
|
JSONArray saomaArray = jsonObject.getJSONArray("saomaList");
|
|
|
List<Map> saomaList = JSONObject.parseArray(yibaoArray.toJSONString(), Map.class);
|
|
|
|
|
|
//取药列表获取
|
|
|
List<Map> mediicineorderListMap = new ArrayList<>();
|
|
|
JSONArray mediicineorderList = jsonObject.getJSONArray("mediicineorderList");
|
|
|
for (int i = 0; i < mediicineorderList.size(); i++) {
|
|
|
Map listMap = new HashMap<>();
|
|
|
JSONObject quyaoQbject = mediicineorderList.getJSONObject(i);
|
|
|
//取药方式(1、扫码,2、医保卡)
|
|
|
String shippingType = quyaoQbject.getString("shippingType");
|
|
|
String payTime = quyaoQbject.getString("payTime");
|
|
|
String name = quyaoQbject.getString("name");
|
|
|
listMap.put("shippingType", shippingType);
|
|
|
listMap.put("payTime", payTime);
|
|
|
listMap.put("name", name);
|
|
|
mediicineorderListMap.add(listMap);
|
|
|
}
|
|
|
|
|
|
//设备信息获取
|
|
|
List<Map> deviceListMap = new ArrayList<>();
|
|
|
JSONObject deviceObject = jsonObject.getJSONObject("device");
|
|
|
Map deviceListMapObject = new HashMap<>();
|
|
|
//设备名称
|
|
|
deviceListMapObject.put("equName", deviceObject.getString("equName"));
|
|
|
//设备地址
|
|
|
deviceListMapObject.put("detailAddress", deviceObject.getString("detailAddress"));
|
|
|
//设备编号
|
|
|
deviceListMapObject.put("equNum", deviceObject.getString("equNum"));
|
|
|
//湿度
|
|
|
deviceListMapObject.put("humidity", deviceObject.getString("humidity"));
|
|
|
//温度
|
|
|
deviceListMapObject.put("temperature", deviceObject.getString("temperature"));
|
|
|
deviceListMap.add(deviceListMapObject);
|
|
|
|
|
|
|
|
|
//取药方式获取
|
|
|
JSONArray shippingTypeArray = jsonObject.getJSONArray("shippingTypeTotal");
|
|
|
List<Map> shippingTypeList = JSONObject.parseArray(shippingTypeArray.toJSONString(), Map.class);
|
|
|
|
|
|
|
|
|
//医保曲线存放
|
|
|
resoultMap.put("yibaoList", yibaoList);
|
|
|
//扫码曲线存放
|
|
|
resoultMap.put("saomaListMap", saomaList);
|
|
|
//取药列表存放
|
|
|
resoultMap.put("mediicineorderListMap", mediicineorderListMap);
|
|
|
//设备信息存放
|
|
|
resoultMap.put("deviceList", deviceListMap);
|
|
|
//取药方式存放
|
|
|
resoultMap.put("shippingTypeListMap", shippingTypeList);
|
|
|
return resoultMap;
|
|
|
}
|
|
|
|
|
|
/*药柜地标*/
|
|
|
public List<Map<String,Object>> getLongitudeAndLatitude(){
|
|
|
JSONArray resultArr = new JSONArray();
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
try {
|
|
|
JSONObject resultObject = getUrl("/open/noLogin/getDeviceList", null);
|
|
|
resultArr = resultObject.getJSONArray("usedDeviceList");
|
|
|
for (int i = 0; i < resultArr.size(); i++) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
JSONObject jsonObject = resultArr.getJSONObject(i);
|
|
|
/*投放经度*/
|
|
|
String lng = jsonObject.getString("lng");
|
|
|
resultMap.put("lng", lng);
|
|
|
/*投放纬度*/
|
|
|
String lat = jsonObject.getString("lat");
|
|
|
resultMap.put("lat;", lat);
|
|
|
list.add(resultMap);
|
|
|
}
|
|
|
return list;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*请求接口*/
|
|
|
public JSONObject getUrl(String url, String parame) {
|
|
|
JSONObject resultObj = new JSONObject();
|
|
|
List<Map<String, String>> list = new ArrayList<>();
|
|
|
try {
|
|
|
//药柜请求地址
|
|
|
String urlResult = httpClientUtil.getBodyRawForm(baseUrl + url, parame);
|
|
|
JSONObject resultObject = JSONObject.parseObject(urlResult);
|
|
|
if (resultObject.get("status").equals("200")) {
|
|
|
JSONObject jsonObjectData = JSONObject.parseObject(AesEncryptUtils.agDecrypt(resultObject.get("data").toString()));
|
|
|
if (jsonObjectData.get("status").equals(200)) {
|
|
|
resultObj = jsonObjectData.getJSONObject("obj");
|
|
|
}
|
|
|
}
|
|
|
return resultObj;
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|