|
@ -152,14 +152,17 @@ public class IotDeviceService {
|
|
|
* 设备绑定
|
|
|
* @param patientDevice
|
|
|
* @param address
|
|
|
* @param name
|
|
|
* @param diseaseCondition 病情:0绿标,1黄标,2红标
|
|
|
* @return
|
|
|
*/
|
|
|
public String saveDevice(PatientDevice patientDevice,String address,String name){
|
|
|
public String saveDevice(PatientDevice patientDevice,String address,String name,Integer diseaseCondition){
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("categoryCode",patientDevice.getCategoryCode());
|
|
|
json.put("address",address);
|
|
|
json.put("patient",patientDevice.getUser());
|
|
|
json.put("patientName",name);
|
|
|
json.put("diseaseCondition",diseaseCondition);
|
|
|
json.put("idcard",patientDevice.getUserIdcard());
|
|
|
json.put("deviceId",patientDevice.getDeviceId());
|
|
|
json.put("deviceName",patientDevice.getDeviceName());
|
|
@ -169,7 +172,7 @@ public class IotDeviceService {
|
|
|
json.put("agent",patientDevice.getAgent());
|
|
|
json.put("doctor",patientDevice.getDoctor());
|
|
|
|
|
|
String url = baseUrl+"/patientDevice/addPatientDevice";
|
|
|
String url = baseUrl+"wg/patientDevice/addPatientDevice";
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
params.add(new BasicNameValuePair("jsonData",json.toString()));
|
|
|
String response = httpClientUtil.post(url, params, "UTF-8");
|
|
@ -404,7 +407,7 @@ public class IotDeviceService {
|
|
|
List<PatientDevice> list = patientDeviceDao.findAll();
|
|
|
list.forEach(patientDevice -> {
|
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
|
String response = saveDevice(patientDevice,patient.getAddress(),patient.getName());
|
|
|
String response = saveDevice(patientDevice,patient.getAddress(),patient.getName(),patient.getDiseaseCondition());
|
|
|
JSONObject re = JSONObject.parseObject(response);
|
|
|
if(re.getInteger("status")!=200){
|
|
|
logger.error("id:"+patientDevice.getId()+" "+re.getString("errorMsg"));
|
|
@ -412,6 +415,18 @@ public class IotDeviceService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 测试设备绑定
|
|
|
* @return
|
|
|
*/
|
|
|
public String testSaveDevice(){
|
|
|
List<PatientDevice> list = patientDeviceDao.findAll();
|
|
|
PatientDevice patientDevice = list.get(0);
|
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
|
String response = saveDevice(patientDevice,patient.getAddress(),patient.getName(),patient.getDiseaseCondition());
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化迁移数据
|
|
|
* @return
|