|
@ -3,7 +3,6 @@ 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.JsonObject;
|
|
|
import com.yihu.iot.dao.dict.IotSystemDictDao;
|
|
|
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
|
|
|
import com.yihu.iot.service.common.MyJdbcTemplate;
|
|
@ -24,23 +23,18 @@ import iot.device.LocationDataVO;
|
|
|
import org.apache.http.Consts;
|
|
|
import org.apache.http.client.utils.URLEncodedUtils;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.apache.jasper.tagplugins.jstl.core.ForEach;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.SqlInOutParameter;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
import javax.print.DocFlavor;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.IOException;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.time.temporal.Temporal;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@ -118,19 +112,6 @@ public class MonitorPlatformService {
|
|
|
locationDataVO = iotPatientDeviceService.addNameAndCodeToLocationVO(locationDataVO);
|
|
|
locationDataVOList.add(locationDataVO);
|
|
|
});
|
|
|
// JSONArray jsonArrayTemp = new JSONArray();
|
|
|
// JSONObject deviceSn = new JSONObject();
|
|
|
// deviceSn.put("andOr","or");
|
|
|
// deviceSn.put("field","deviceSn");
|
|
|
// deviceSn.put("condition","=");
|
|
|
// deviceSn.put("value",list.getString(i));
|
|
|
// jsonArrayTemp.add(deviceSn);
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
// jsonObject.put("filter",jsonArrayTemp);
|
|
|
// jsonObject.put("page",page);
|
|
|
// jsonObject.put("size",size);
|
|
|
// List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString());
|
|
|
//figureLabelSerachService.getFigureLabelByList(locationDataVOList);
|
|
|
envelop.getDetailModelList().addAll(locationDataVOList);
|
|
|
}
|
|
|
envelop.setTotalCount(total);
|
|
@ -140,24 +121,20 @@ public class MonitorPlatformService {
|
|
|
int totalEqCount=0;
|
|
|
int totalCount=0;
|
|
|
//小屋总数
|
|
|
if(deviceType.contains("5")){
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
|
|
|
totalEqCount = iotEqtDetailService.getEquipmentCount();
|
|
|
}
|
|
|
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")){
|
|
|
totalEqCount = iotEqtDetailService.getEquipmentCount(manufacturerCode);
|
|
|
}
|
|
|
String[] categoryCodes= deviceType.split(",");
|
|
|
if(categoryCodes.length==1&&"5".equals(deviceType)){
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
|
|
|
euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
|
|
|
envelop.getDetailModelList().addAll(euipmentList);
|
|
|
}
|
|
|
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")){
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
|
|
|
euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
|
|
|
envelop.getDetailModelList().addAll(euipmentList);
|
|
|
}
|
|
|
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" +
|
|
@ -198,60 +175,6 @@ public class MonitorPlatformService {
|
|
|
locationDataVOList.add(locationDataVO);
|
|
|
});
|
|
|
envelop.getDetailModelList().addAll(locationDataVOList);
|
|
|
// for (String categoryCode:categoryCodes){
|
|
|
// JSONObject json = new JSONObject();
|
|
|
// JSONArray jsonArray = new JSONArray();
|
|
|
// if(diseaseCondition!=null){
|
|
|
// json.put("andOr","and");
|
|
|
// json.put("field","diseaseCondition");
|
|
|
// json.put("condition","=");
|
|
|
// json.put("value",diseaseCondition);
|
|
|
// jsonArray.add(json);
|
|
|
// }
|
|
|
// if(!"5".equals(categoryCode)){
|
|
|
// json = new JSONObject();
|
|
|
// List<String> listTmp = new ArrayList<>();
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
// String[] deviceNames = deviceName.split(",");
|
|
|
// for (String tmp :deviceNames){
|
|
|
// String sql="select DISTINCT device_code from device.wlyy_devices wd where wd.device_name like '%"+tmp+"%' ";
|
|
|
// List<String> tmpList = jdbcTemplate.queryForList(sql,String.class);
|
|
|
// listTmp.addAll(tmpList);
|
|
|
// }
|
|
|
// if (listTmp.size()!=0){
|
|
|
// json.put("andOr","and");
|
|
|
// json.put("field","deviceSn");
|
|
|
// json.put("condition","in");
|
|
|
// json.put("value",listTmp);
|
|
|
// jsonArray.add(json);
|
|
|
// }
|
|
|
// }
|
|
|
// else{
|
|
|
// if(!"5".equals(categoryCode)) {
|
|
|
// json.put("andOr", "and");
|
|
|
// json.put("field", "categoryCode");
|
|
|
// json.put("condition", "=");
|
|
|
// json.put("value", Integer.parseInt(categoryCode));
|
|
|
// jsonArray.add(json);
|
|
|
// }
|
|
|
// }
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
// jsonObject.put("filter",jsonArray);
|
|
|
// jsonObject.put("page",page);
|
|
|
// jsonObject.put("size",size);
|
|
|
// if (jsonArray.size()!=0){
|
|
|
// List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString());
|
|
|
// List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList);
|
|
|
// //figureLabelSerachService.getFigureLabelByList(locationDataVOList);
|
|
|
// envelop.getDetailModelList().addAll(list2);
|
|
|
// totalCount += iotPatientDeviceService.getESCount(jsonObject.toString());
|
|
|
// }
|
|
|
// }
|
|
|
// if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
envelop.setTotalCount(totalCount>totalEqCount?totalCount:totalEqCount);
|
|
|
return envelop;
|
|
@ -1206,7 +1129,7 @@ public class MonitorPlatformService {
|
|
|
params.put("appid", appid);
|
|
|
params.put("appSecret", appSecret);
|
|
|
String url = "/gc/accesstoken";
|
|
|
String response = httpClientUtil.httpPost(wlyyUrl + url, params);
|
|
|
String response = HttpClientUtil.httpPost(wlyyUrl + url, params);
|
|
|
JSONObject jsonObject = JSON.parseObject(response);
|
|
|
if(jsonObject.getInteger("status")==10000){
|
|
|
String accesstoken = jsonObject.getJSONObject("result").getString("accesstoken");
|
|
@ -1248,7 +1171,7 @@ public class MonitorPlatformService {
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
|
|
|
"GROUP BY wd.manufacturer_code,pd.device_name\n" +
|
|
|
"UNION\n" +
|
|
|
"select '健康小屋' device_name,manufacturer from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
|
|
|
"select case device_name when '自助体检一体机' then '健康小屋' else device_name end AS device_name,manufacturer from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
|
|
|
")A\n" +
|
|
|
"GROUP BY A.manufacturer\n" +
|
|
|
"ORDER BY total desc";
|
|
@ -1262,7 +1185,7 @@ public class MonitorPlatformService {
|
|
|
"and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
|
|
|
"GROUP BY wd.manufacturer_code,pd.device_name\n" +
|
|
|
"UNION\n" +
|
|
|
"select '健康小屋' device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\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);
|
|
|
|
|
@ -1564,7 +1487,7 @@ public class MonitorPlatformService {
|
|
|
}
|
|
|
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)){
|
|
|
sql.append("UNION select '健康小屋' device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name");
|
|
|
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);
|
|
@ -1726,13 +1649,13 @@ public class MonitorPlatformService {
|
|
|
return deviceName;
|
|
|
}
|
|
|
|
|
|
public JSONObject savePatientDeviceLocation(){
|
|
|
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 (1,2)";
|
|
|
// sql="select * from device.wlyy_patient_device_location_tmp";
|
|
|
"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->{
|
|
|
try {
|