|
@ -169,18 +169,21 @@ public class IotDeviceService {
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
field("and","usercode","=",user,jsonArray);
|
|
|
field("and","sn","=",deviceSn,jsonArray);
|
|
|
field("and","del","=","1",jsonArray);
|
|
|
if("1".equals(type)){
|
|
|
//血糖
|
|
|
field("and","blood_sugar","=",value1,jsonArray);
|
|
|
}else {
|
|
|
//血压
|
|
|
field("and","systolic","=",value1,jsonArray);
|
|
|
field("and","diastolic","=",value2,jsonArray);
|
|
|
if(StringUtils.isNotBlank(value2)){
|
|
|
field("and","diastolic","=",value2,jsonArray);
|
|
|
}
|
|
|
}
|
|
|
field("and","measure_time","=",time,jsonArray);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter",jsonArray);
|
|
|
String url = baseUrl+"/dataSearch/findById";
|
|
|
String url = baseUrl+"/dataSearch/getById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonObject.toString());
|
|
|
|
|
|
return response;
|
|
@ -207,7 +210,9 @@ public class IotDeviceService {
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter",jsonArray);
|
|
|
String url = baseUrl+"/dataSearch/findById";
|
|
|
jsonObject.put("page","1");
|
|
|
jsonObject.put("size","50");
|
|
|
String url = baseUrl+"/dataSearch/getById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonObject.toString());
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
JSONArray ja = json.getJSONArray("obj");
|
|
@ -219,7 +224,7 @@ public class IotDeviceService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* 按居民code和类型查找
|
|
|
* @param patient
|
|
|
* @param type
|
|
|
* @return
|
|
@ -239,9 +244,23 @@ public class IotDeviceService {
|
|
|
JSONArray sort = new JSONArray();
|
|
|
sort(sort,"measure_time","desc");
|
|
|
jsonObject.put("sort",sort);
|
|
|
String url = baseUrl+"/dataSearch/findById";
|
|
|
String url = baseUrl+"/dataSearch/getById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonObject.toString());
|
|
|
|
|
|
try {
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
JSONArray obj = json.getJSONArray("obj");
|
|
|
if(obj!=null&&obj.size()>0){
|
|
|
for (int i=0;i<obj.size();i++){
|
|
|
DevicePatientHealthIndex index = transforHealthIndex(obj.getJSONObject(i),null);
|
|
|
list.add(index);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
@ -274,7 +293,7 @@ public class IotDeviceService {
|
|
|
json.put("order",order);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(key,json);
|
|
|
jsonArray.add(json);
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -298,7 +317,7 @@ public class IotDeviceService {
|
|
|
* - 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<field>","value":"<value>"},<{...}>]
|
|
|
* - 参数说明:andOr跟数据库的中的AND和OR相似;condition指条件匹配程度,?相当于数据库中的like;filed指检索的字段;value为检索的值
|
|
|
* page - 参数说明:页码
|
|
|
* size - 参数说明:分页大小
|
|
|
* size - 参数说明:分页大小 默认1
|
|
|
* sort - 参数格式:排序,key要排序的字段,order固定,取值asc或desc,不需要排序,传""
|
|
|
* 排序[{"key1":{"order":"asc|desc"}},{"key2":{"order":"asc|desc"}}]
|
|
|
* @param json
|
|
@ -630,8 +649,18 @@ public class IotDeviceService {
|
|
|
return null;
|
|
|
}
|
|
|
JSONObject obj = jsonObject.getJSONArray("obj").getJSONObject(0);
|
|
|
return transforHealthIndex(obj,id);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转化成数据库对象
|
|
|
* @param obj
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
private DevicePatientHealthIndex transforHealthIndex(JSONObject obj,Long id){
|
|
|
DevicePatientHealthIndex index = new DevicePatientHealthIndex();
|
|
|
index.setId(id);
|
|
|
|
|
|
index.setDeviceSn(obj.getString("sn"));
|
|
|
index.setUser(obj.getString("usercode"));
|
|
|
index.setIdcard(obj.getString("idcard"));
|
|
@ -642,8 +671,17 @@ public class IotDeviceService {
|
|
|
// "idCard":"350122198601145513","username":"谢挺盛","usercode":"443a196ef8744536a531260eb26c05d7"}]}
|
|
|
|
|
|
JSONObject data = obj.getJSONArray("data").getJSONObject(0);
|
|
|
if(id==null){
|
|
|
//从数据库中取id
|
|
|
DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByRid(data.getString("rid"));
|
|
|
if(mapping!=null){
|
|
|
id = mapping.getIndexId()==null?mapping.getId():mapping.getIndexId();
|
|
|
}
|
|
|
}
|
|
|
index.setId(id);
|
|
|
index.setRecordDate(DateUtil.strToDate(data.getString("measure_time")));
|
|
|
index.setSortDate(index.getRecordDate());
|
|
|
index.setType(data.getInteger("type"));
|
|
|
index.setDel(data.getString("del"));
|
|
|
index.setStatus(data.getInteger("status"));
|
|
|
if(data.getString("blood_sugar")!=null){
|