|
@ -16,6 +16,7 @@ import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@ -72,6 +73,8 @@ public class DeviceService {
|
|
|
private DoctorSwitchDao doctorSwitchDao;
|
|
|
@Autowired
|
|
|
private TrackPatientDao trackPatientDao;
|
|
|
@Value("${systemConfig.server_url}")
|
|
|
private String wlyyService;
|
|
|
|
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
|
private Integer aStart;
|
|
@ -1150,4 +1153,96 @@ public class DeviceService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/******************************体征上传 start**************************************************/
|
|
|
private String bloodSugarUnit = "mmol/L";
|
|
|
private String bloodPressureUnit = "mmHg";
|
|
|
private String pulseUnit = "bpm";
|
|
|
private String heightUnit = "cm";
|
|
|
private String weightUnit = "kg";
|
|
|
private String bmiUnit = "kg/m^2";
|
|
|
private String waistUnit = "cm";
|
|
|
|
|
|
public void upload(PatientDevice patientDevice,PatientHealthIndex obj,String userType){
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
if(patientDevice!=null){
|
|
|
//未绑定居民
|
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
|
json.put("idcard",patient.getIdcard());
|
|
|
json.put("username",patient.getName());
|
|
|
json.put("usercode",patient.getCode());
|
|
|
json.put("device_name",patientDevice.getDeviceName());
|
|
|
json.put("device_model",patientDevice.getDeviceName());
|
|
|
}
|
|
|
json.put("sn",obj.getDeviceSn());
|
|
|
json.put("ext_code",userType);
|
|
|
|
|
|
|
|
|
com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
|
|
|
com.alibaba.fastjson.JSONObject js = new com.alibaba.fastjson.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;
|
|
|
}
|
|
|
jsonArray.add(js);
|
|
|
json.put("data",jsonArray);
|
|
|
|
|
|
try {
|
|
|
String url = wlyyService + "/iot/upload";
|
|
|
|
|
|
Map<String, Object> params = new HashedMap();
|
|
|
params.put("jsonStr", json.toString());
|
|
|
|
|
|
HttpResponse response = httpHelper.post(url, params);
|
|
|
|
|
|
if (response != null && response.getStatusCode() == 200) {
|
|
|
JSONObject jsonObject = JSONObject.fromObject(response.getBody());
|
|
|
if (!"200".equals(jsonObject.optString("status"))) {
|
|
|
throw new Exception(jsonObject.optString("msg"));
|
|
|
}
|
|
|
} else {
|
|
|
throw new Exception("接口调用错误!" + response.getBody());
|
|
|
}
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************体征上传 end****************************************************/
|
|
|
}
|