|
@ -40,7 +40,7 @@ public class IotDeviceService {
|
|
|
private Logger logger = LoggerFactory.getLogger(IotDeviceService.class);
|
|
|
|
|
|
// @Value("${}")
|
|
|
private String baseUrl = "http://192.168.131.24:8080/svr-iot-ysj/";
|
|
|
private String baseUrl = "http://192.168.131.24:8088/svr-iot/";
|
|
|
private String grantType = "client_credentials";
|
|
|
private String clientId = "Va5yQRHlA4Fq4eR3LT0vuXV4";
|
|
|
private String clientSecret = "0rDSjzQ20XUj5itV7WRtznPQSzr5pVw2";
|
|
@ -75,7 +75,7 @@ public class IotDeviceService {
|
|
|
return "1".equals(value)?true:false;
|
|
|
}
|
|
|
|
|
|
public JSONObject test(){
|
|
|
public JSONObject testUpload(){
|
|
|
// String sql = "select response from wlyy_http_log_detail where id = 1";
|
|
|
// List<String> list = jdbcTemplate.queryForList(sql,String.class);
|
|
|
String sql = "SELECT i.id,i.user,i.value1,i.value2,i.value3,i.value4,i.type,i.record_date,i.device_sn,i.status,i.del,d.device_name,d.user_type,p.name,p.idcard " +
|
|
@ -108,6 +108,17 @@ public class IotDeviceService {
|
|
|
if(list.size()>0){
|
|
|
JSONObject one = list.get(0);
|
|
|
String response = initUpload(one);
|
|
|
JSONObject re = JSONObject.parseObject(response);
|
|
|
if(re.getInteger("status")!=200){
|
|
|
logger.error("id:"+one.getInteger("id")+" "+re.getString("errorMsg"));
|
|
|
}else {
|
|
|
//保存映射关系
|
|
|
DeviceHealthyInfoMapping info = new DeviceHealthyInfoMapping();
|
|
|
info.setCreateTime(new Date());
|
|
|
info.setIndexId(one.getLong("id"));
|
|
|
info.setRid(re.getJSONObject("obj").getJSONArray("rid").getString(0));
|
|
|
deviceHealthyInfoMappingDao.save(info);
|
|
|
}
|
|
|
return JSONObject.parseObject(response);
|
|
|
}
|
|
|
return null;
|
|
@ -156,51 +167,115 @@ public class IotDeviceService {
|
|
|
*/
|
|
|
public String findRepeat(String user,String deviceSn,String value1,String value2,String type,String time){
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
JSONObject jsonUser = new JSONObject();
|
|
|
jsonUser.put("andOr","and");
|
|
|
jsonUser.put("filed","usercode");
|
|
|
jsonUser.put("condition","=");
|
|
|
jsonUser.put("value",user);
|
|
|
jsonArray.add(jsonUser);
|
|
|
JSONObject jsonSn = new JSONObject();
|
|
|
jsonSn.put("andOr","and");
|
|
|
jsonSn.put("filed","sn");
|
|
|
jsonSn.put("condition","=");
|
|
|
jsonSn.put("value",deviceSn);
|
|
|
jsonArray.add(jsonSn);
|
|
|
field("and","usercode","=",user,jsonArray);
|
|
|
field("and","sn","=",deviceSn,jsonArray);
|
|
|
if("1".equals(type)){
|
|
|
//血糖
|
|
|
JSONObject jsonValue1 = new JSONObject();
|
|
|
jsonValue1.put("andOr","and");
|
|
|
jsonValue1.put("filed","blood_sugar");
|
|
|
jsonValue1.put("condition","=");
|
|
|
jsonValue1.put("value",value1);
|
|
|
jsonArray.add(jsonValue1);
|
|
|
field("and","blood_sugar","=",value1,jsonArray);
|
|
|
}else {
|
|
|
//血压
|
|
|
JSONObject jsonValue1 = new JSONObject();
|
|
|
jsonValue1.put("andOr","and");
|
|
|
jsonValue1.put("filed","systolic");
|
|
|
jsonValue1.put("condition","=");
|
|
|
jsonValue1.put("value",value1);
|
|
|
JSONObject jsonValue2 = new JSONObject();
|
|
|
jsonValue2.put("andOr","and");
|
|
|
jsonValue2.put("filed","diastolic");
|
|
|
jsonValue2.put("condition","=");
|
|
|
jsonValue2.put("value",value2);
|
|
|
jsonArray.add(jsonValue1);
|
|
|
jsonArray.add(jsonValue2);
|
|
|
field("and","systolic","=",value1,jsonArray);
|
|
|
field("and","diastolic","=",value2,jsonArray);
|
|
|
}
|
|
|
JSONObject jsonTime = new JSONObject();
|
|
|
jsonTime.put("andOr","and");
|
|
|
jsonTime.put("filed","measure_time");
|
|
|
jsonTime.put("condition","=");
|
|
|
jsonTime.put("value",time);
|
|
|
String url = baseUrl+"/findById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonArray.toString());
|
|
|
field("and","measure_time","=",time,jsonArray);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter",jsonArray);
|
|
|
String url = baseUrl+"/dataSearch/findById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonObject.toString());
|
|
|
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按条件统计数量
|
|
|
* @param start
|
|
|
* @param end
|
|
|
* @param status
|
|
|
* @param patientCode
|
|
|
* @return
|
|
|
*/
|
|
|
public int getCountByTimeAndStatusAndPatient(String start,String end,Integer status,String patientCode){
|
|
|
int re = 0;
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
field("and","usercode","=",patientCode,jsonArray);
|
|
|
field("and","status","=",String.valueOf(status),jsonArray);
|
|
|
field("and","del","=","1",jsonArray);
|
|
|
field("and","measure_time",">=",start,jsonArray);
|
|
|
field("and","measure_time","<=",end,jsonArray);
|
|
|
field("and","type",">=","1",jsonArray);
|
|
|
field("and","type","<=","2",jsonArray);
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter",jsonArray);
|
|
|
String url = baseUrl+"/dataSearch/findById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonObject.toString());
|
|
|
JSONObject json = JSONObject.parseObject(response);
|
|
|
JSONArray ja = json.getJSONArray("obj");
|
|
|
if(ja!=null){
|
|
|
re = ja.size();
|
|
|
}
|
|
|
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param patient
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DevicePatientHealthIndex> findByPatientAndType(String patient,Integer type){
|
|
|
List<DevicePatientHealthIndex> list = new ArrayList<>();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
field("and","usercode","=",patient,jsonArray);
|
|
|
field("and","del","=","1",jsonArray);
|
|
|
field("and","type","=",String.valueOf(type),jsonArray);
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("filter",jsonArray);
|
|
|
jsonObject.put("page","1");
|
|
|
jsonObject.put("size","5");
|
|
|
|
|
|
JSONArray sort = new JSONArray();
|
|
|
sort(sort,"measure_time","desc");
|
|
|
jsonObject.put("sort",sort);
|
|
|
String url = baseUrl+"/dataSearch/findById";
|
|
|
String response = httpClientUtil.iotPostBody(url, jsonObject.toString());
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加条件
|
|
|
* 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<field>","value":"<value>"},<{...}>]
|
|
|
* @param andOr
|
|
|
* @param field
|
|
|
* @param condition
|
|
|
* @param value
|
|
|
* @param jsonArray
|
|
|
*/
|
|
|
private void field(String andOr,String field,String condition,String value,JSONArray jsonArray){
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("andOr",andOr);
|
|
|
json.put("field",field);
|
|
|
json.put("condition",condition);
|
|
|
json.put("value",value);
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 排序[{"key1":{"order":"asc|desc"}},{"key2":{"order":"asc|desc"}}]
|
|
|
* @param jsonArray
|
|
|
* @param key
|
|
|
* @param order
|
|
|
*/
|
|
|
private void sort(JSONArray jsonArray,String key,String order){
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("order",order);
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(key,json);
|
|
|
jsonArray.add(json);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询单条
|
|
@ -209,11 +284,10 @@ public class IotDeviceService {
|
|
|
*/
|
|
|
public String getById(String rid){
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("andOr","and");
|
|
|
json.put("filed","rid");
|
|
|
json.put("condition","=");
|
|
|
json.put("value",rid);
|
|
|
String url = baseUrl+"/getById";
|
|
|
JSONArray filters = new JSONArray();
|
|
|
field("and","rid","=",rid,filters);
|
|
|
json.put("filter",filters);
|
|
|
String url = baseUrl+"/dataSearch/getById";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
return response;
|
|
|
}
|
|
@ -221,15 +295,17 @@ public class IotDeviceService {
|
|
|
/**
|
|
|
* 查询
|
|
|
* filter
|
|
|
* - 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<filed>","value":"<value>"},<{...}>]
|
|
|
* - 参数格式:[{"andOr":"and|or","condition":">|=|<|>=|<=|?","field":"<field>","value":"<value>"},<{...}>]
|
|
|
* - 参数说明:andOr跟数据库的中的AND和OR相似;condition指条件匹配程度,?相当于数据库中的like;filed指检索的字段;value为检索的值
|
|
|
* page - 参数说明:页码
|
|
|
* size - 参数说明:分页大小
|
|
|
* sort - 参数格式:排序,key要排序的字段,order固定,取值asc或desc,不需要排序,传""
|
|
|
* 排序[{"key1":{"order":"asc|desc"}},{"key2":{"order":"asc|desc"}}]
|
|
|
* @param json
|
|
|
* @return
|
|
|
*/
|
|
|
public String searchList(JSONObject json){
|
|
|
String url = baseUrl+"/searchList";
|
|
|
String url = baseUrl+"/dataSearch/searchList";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
return response;
|
|
|
}
|
|
@ -240,7 +316,7 @@ public class IotDeviceService {
|
|
|
* @return
|
|
|
*/
|
|
|
public String listPage(JSONObject json){
|
|
|
String url = baseUrl+"/listPage";
|
|
|
String url = baseUrl+"/dataSearch/listPage";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
return response;
|
|
|
}
|
|
@ -254,7 +330,7 @@ public class IotDeviceService {
|
|
|
public String recent5(JSONObject json,JSONObject sort){
|
|
|
json.put("access_token",accessToken);
|
|
|
|
|
|
String url = baseUrl+"/recent5";
|
|
|
String url = baseUrl+"/dataSearch/recent5";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
return response;
|
|
|
}
|
|
@ -268,7 +344,7 @@ public class IotDeviceService {
|
|
|
public String recent1(JSONObject json,JSONObject sort){
|
|
|
json.put("access_token",accessToken);
|
|
|
|
|
|
String url = baseUrl+"/recent1";
|
|
|
String url = baseUrl+"/dataSearch/recent1";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
return response;
|
|
|
}
|
|
@ -313,14 +389,14 @@ public class IotDeviceService {
|
|
|
list.stream().forEach(one->{
|
|
|
String response = initUpload(one);
|
|
|
JSONObject re = JSONObject.parseObject(response);
|
|
|
String errorMsg = re.getString("errorMsg");//错误信息(请求失败才有错误消息)
|
|
|
if(StringUtils.isNotBlank(errorMsg)){
|
|
|
logger.error("id:"+one.getInteger("id")+" "+errorMsg);
|
|
|
if(re.getInteger("status")!=200){
|
|
|
logger.error("id:"+one.getInteger("id")+" "+re.getString("errorMsg"));
|
|
|
}else {
|
|
|
//保存映射关系
|
|
|
DeviceHealthyInfoMapping info = new DeviceHealthyInfoMapping();
|
|
|
info.setCreateTime(new Date());
|
|
|
info.setIndexId(one.getLong("id"));
|
|
|
info.setRid(one.getJSONObject("obj").getJSONArray("rid").getString(0));
|
|
|
infos.add(info);
|
|
|
}
|
|
|
});
|
|
@ -356,7 +432,8 @@ public class IotDeviceService {
|
|
|
// js.put("id",String.valueOf(jsonObject.getInteger("id")));
|
|
|
js.put("measure_time",subStringTime(jsonObject.getString("record_date")));
|
|
|
js.put("del",StringUtils.trimToEmpty(jsonObject.getString("del")));
|
|
|
js.put("status",StringUtils.trimToEmpty(jsonObject.getString("status")));
|
|
|
js.put("status",getStatus(jsonObject.getString("status")));
|
|
|
js.put("type",String.valueOf(type));
|
|
|
switch (type){
|
|
|
case 1:
|
|
|
//血糖
|
|
@ -405,14 +482,17 @@ public class IotDeviceService {
|
|
|
* 更新状态
|
|
|
* @param id
|
|
|
*/
|
|
|
public void updateStatus(Long id){
|
|
|
public void updateStatus(Long id,String status){
|
|
|
DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByIndexId(id,id);
|
|
|
if(mapping == null){
|
|
|
logger.info("未找到映射关系,id:"+id);
|
|
|
logger.error("未找到映射关系,id:"+id);
|
|
|
}else {
|
|
|
JSONObject json = new JSONObject();
|
|
|
String url = baseUrl+"/dataInput/updateRecord";
|
|
|
json.put("rid",mapping.getRid());
|
|
|
json.put("status",status);
|
|
|
String url = baseUrl+"/dataSearch/update";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
JSONObject res = JSONObject.parseObject(response);
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -424,13 +504,62 @@ public class IotDeviceService {
|
|
|
public DevicePatientHealthIndex getById(Long id){
|
|
|
DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByIndexId(id,id);
|
|
|
if(mapping == null){
|
|
|
logger.info("未找到映射关系,id:"+id);
|
|
|
logger.error("未找到映射关系,id:"+id);
|
|
|
return null;
|
|
|
}else {
|
|
|
return transforOne(getById(mapping.getRid()),id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 更新
|
|
|
* @param obj
|
|
|
* @return
|
|
|
*/
|
|
|
public DevicePatientHealthIndex update(DevicePatientHealthIndex obj){
|
|
|
|
|
|
DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByIndexId(obj.getId(),obj.getId());
|
|
|
if(mapping == null){
|
|
|
logger.error("未找到映射关系,id:"+obj.getId());
|
|
|
}else {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("rid",mapping.getRid());
|
|
|
json.put("del",obj.getDel());
|
|
|
transforIot(obj,json);
|
|
|
String url = baseUrl+"/dataSearch/update";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
JSONObject res = JSONObject.parseObject(response);
|
|
|
}
|
|
|
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除
|
|
|
* @param id
|
|
|
*/
|
|
|
public void delete(Long id){
|
|
|
DeviceHealthyInfoMapping mapping = deviceHealthyInfoMappingDao.findByIndexId(id,id);
|
|
|
if(mapping == null){
|
|
|
logger.error("未找到映射关系,id:"+id);
|
|
|
}else {
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("rid",mapping.getRid());
|
|
|
json.put("del","0");
|
|
|
String url = baseUrl+"/dataSearch/delete";
|
|
|
String response = httpClientUtil.iotPostBody(url, json.toString());
|
|
|
|
|
|
JSONObject res = JSONObject.parseObject(response);
|
|
|
if("true".equals(res.getString("obj"))){
|
|
|
logger.info("删除成功!");
|
|
|
}else {
|
|
|
logger.error("删除失败,id="+id+",rid="+mapping.getRid()+",msg="+res.getString("errorMsg"));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 体征上传
|
|
|
* @param obj
|
|
@ -457,43 +586,11 @@ public class IotDeviceService {
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
JSONObject js = new JSONObject();
|
|
|
js.put("measure_time",obj.getRecordDate());
|
|
|
switch (obj.getType()){
|
|
|
case 1:
|
|
|
//血糖
|
|
|
js.put("blood_sugar",obj.getValue1());
|
|
|
js.put("blood_sugar_unit",bloodSugarUnit);
|
|
|
js.put("blood_sugar_result",obj.getValue2());
|
|
|
break;
|
|
|
case 2:
|
|
|
//血压
|
|
|
js.put("systolic",obj.getValue1());
|
|
|
js.put("systolic_unit",bloodPressureUnit);
|
|
|
js.put("diastolic",obj.getValue2());
|
|
|
js.put("diastolic_unit",bloodPressureUnit);
|
|
|
if(StringUtils.isNotBlank(obj.getValue3())){
|
|
|
js.put("pulse",obj.getValue3());
|
|
|
js.put("pulse_unit",pulseUnit);
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
|
//体重/身高/BMI
|
|
|
js.put("height",obj.getValue1());
|
|
|
js.put("height_unit",heightUnit);
|
|
|
js.put("weight",obj.getValue2());
|
|
|
js.put("weight_unit",weightUnit);
|
|
|
if(StringUtils.isNotBlank(obj.getValue3())){
|
|
|
js.put("bmi",obj.getValue3());
|
|
|
js.put("bmi_unit",bmiUnit);
|
|
|
}
|
|
|
break;
|
|
|
case 4:
|
|
|
//腰围
|
|
|
js.put("waist",obj.getValue1());
|
|
|
js.put("waist_unit",waistUnit);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
transforIot(obj,js);
|
|
|
js.put("status","0");
|
|
|
js.put("del","1");
|
|
|
js.put("type",String.valueOf(obj.getType()));
|
|
|
jsonArray.add(js);
|
|
|
json.put("data",jsonArray);
|
|
|
//上传
|
|
@ -514,15 +611,6 @@ public class IotDeviceService {
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新
|
|
|
* @param obj
|
|
|
* @return
|
|
|
*/
|
|
|
public DevicePatientHealthIndex update(DevicePatientHealthIndex obj){
|
|
|
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
/************************************i健康业务相关 end ************************************************************/
|
|
|
|
|
@ -537,7 +625,7 @@ public class IotDeviceService {
|
|
|
return null;
|
|
|
}
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
if(jsonObject.getString("errorMsg")!=null){
|
|
|
if(jsonObject.getInteger("status")!=200||jsonObject.getJSONArray("obj").size()==0){
|
|
|
logger.error(jsonObject.getString("errorMsg"));
|
|
|
return null;
|
|
|
}
|
|
@ -547,25 +635,34 @@ public class IotDeviceService {
|
|
|
index.setDeviceSn(obj.getString("sn"));
|
|
|
index.setUser(obj.getString("usercode"));
|
|
|
index.setIdcard(obj.getString("idcard"));
|
|
|
index.setRecordDate(DateUtil.strToDate(obj.getString("measure_time")));
|
|
|
|
|
|
//{"errorCode":null,"errorMsg":null,"successMsg":"search success","status":200,"pageSize":10,"currPage":0,"totalPage":0,"totalCount":0,"detailModelList":null,
|
|
|
// "obj":[{"access_token":"test","data_source":"iHealth","sn":"867967022337804","ext_code":"","device_name":"","device_model":"",
|
|
|
// "data":[{"rid":"lwKBG349zj/XBIJOP8CpyoFxFKl0xyxLLzxpN/l9+1U=","del":1,"measure_time":"2016-08-26 12:32:04","systolic":"115.00","systolic_unit":"mmHg","diastolic":"105.00","pulse":"105.00","pulse_unit":"bpm"}],
|
|
|
// "idCard":"350122198601145513","username":"谢挺盛","usercode":"443a196ef8744536a531260eb26c05d7"}]}
|
|
|
|
|
|
JSONObject data = obj.getJSONArray("data").getJSONObject(0);
|
|
|
index.setRecordDate(DateUtil.strToDate(data.getString("measure_time")));
|
|
|
index.setSortDate(index.getRecordDate());
|
|
|
if(obj.getString("blood_sugar")==null){
|
|
|
index.setDel(data.getString("del"));
|
|
|
index.setStatus(data.getInteger("status"));
|
|
|
if(data.getString("blood_sugar")!=null){
|
|
|
index.setType(1);
|
|
|
index.setValue1(obj.getString("blood_sugar"));
|
|
|
index.setValue2(obj.getString("blood_sugar_result"));
|
|
|
}else if(obj.getString("systolic")==null){
|
|
|
index.setValue1(data.getString("blood_sugar"));
|
|
|
index.setValue2(data.getString("blood_sugar_result"));
|
|
|
}else if(data.getString("systolic")!=null){
|
|
|
index.setType(2);
|
|
|
index.setValue1(obj.getString("systolic"));
|
|
|
index.setValue2(obj.getString("diastolic"));
|
|
|
index.setValue3(obj.getString("pulse"));
|
|
|
}else if(obj.getString("height")==null){
|
|
|
index.setValue1(data.getString("systolic"));
|
|
|
index.setValue2(data.getString("diastolic"));
|
|
|
index.setValue3(data.getString("pulse"));
|
|
|
}else if(data.getString("height")!=null){
|
|
|
index.setType(3);
|
|
|
index.setValue1(obj.getString("height"));
|
|
|
index.setValue2(obj.getString("weight"));
|
|
|
index.setValue3(obj.getString("bmi"));
|
|
|
}else if(obj.getString("waist")==null){
|
|
|
index.setValue1(data.getString("height"));
|
|
|
index.setValue2(data.getString("weight"));
|
|
|
index.setValue3(data.getString("bmi"));
|
|
|
}else if(data.getString("waist")!=null){
|
|
|
index.setType(4);
|
|
|
index.setValue1(obj.getString("waist"));
|
|
|
index.setValue1(data.getString("waist"));
|
|
|
}
|
|
|
return index;
|
|
|
}
|
|
@ -605,6 +702,62 @@ public class IotDeviceService {
|
|
|
return StringUtils.isBlank(time)? "":time.substring(0,19);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 状态默认值
|
|
|
* @param status
|
|
|
* @return
|
|
|
*/
|
|
|
private String getStatus(String status){
|
|
|
return StringUtils.isBlank(status)?"0":status;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 转化成物联网格式
|
|
|
* @param obj
|
|
|
* @param json
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject transforIot(DevicePatientHealthIndex obj,JSONObject json){
|
|
|
switch (obj.getType()){
|
|
|
case 1:
|
|
|
//血糖
|
|
|
json.put("blood_sugar",obj.getValue1());
|
|
|
json.put("blood_sugar_unit",bloodSugarUnit);
|
|
|
json.put("blood_sugar_result",obj.getValue2());
|
|
|
break;
|
|
|
case 2:
|
|
|
//血压
|
|
|
json.put("systolic",obj.getValue1());
|
|
|
json.put("systolic_unit",bloodPressureUnit);
|
|
|
json.put("diastolic",obj.getValue2());
|
|
|
json.put("diastolic_unit",bloodPressureUnit);
|
|
|
if(StringUtils.isNotBlank(obj.getValue3())){
|
|
|
json.put("pulse",obj.getValue3());
|
|
|
json.put("pulse_unit",pulseUnit);
|
|
|
}
|
|
|
break;
|
|
|
case 3:
|
|
|
//体重/身高/BMI
|
|
|
json.put("height",obj.getValue1());
|
|
|
json.put("height_unit",heightUnit);
|
|
|
json.put("weight",obj.getValue2());
|
|
|
json.put("weight_unit",weightUnit);
|
|
|
if(StringUtils.isNotBlank(obj.getValue3())){
|
|
|
json.put("bmi",obj.getValue3());
|
|
|
json.put("bmi_unit",bmiUnit);
|
|
|
}
|
|
|
break;
|
|
|
case 4:
|
|
|
//腰围
|
|
|
json.put("waist",obj.getValue1());
|
|
|
json.put("waist_unit",waistUnit);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
/*****************************************工具方法 end ************************************************************/
|
|
|
|
|
|
}
|