|
@ -14,6 +14,7 @@ import com.yihu.wlyy.repository.patient.PatientDeviceDao;
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
|
import com.yihu.wlyy.util.MyJdbcTemplate;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.NameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
@ -62,6 +63,8 @@ public class IotDeviceService {
|
|
@Autowired
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
private MyJdbcTemplate myJdbcTemplate;
|
|
|
|
@Autowired
|
|
private PatientDeviceDao patientDeviceDao;
|
|
private PatientDeviceDao patientDeviceDao;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientDao patientDao;
|
|
private PatientDao patientDao;
|
|
@ -162,10 +165,11 @@ public class IotDeviceService {
|
|
* @param diseaseCondition 病情:0绿标,1黄标,2红标
|
|
* @param diseaseCondition 病情:0绿标,1黄标,2红标
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public String saveDevice(PatientDevice patientDevice,String address,String name,Integer diseaseCondition){
|
|
|
|
|
|
public String saveDevice(PatientDevice patientDevice,String address,String name,Integer diseaseCondition,String hospitalName){
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
json.put("categoryCode",patientDevice.getCategoryCode());
|
|
json.put("categoryCode",patientDevice.getCategoryCode());
|
|
json.put("address",address);
|
|
json.put("address",address);
|
|
|
|
json.put("hospitalName",hospitalName);
|
|
json.put("patient",patientDevice.getUser());
|
|
json.put("patient",patientDevice.getUser());
|
|
json.put("patientName",name);
|
|
json.put("patientName",name);
|
|
json.put("diseaseCondition",diseaseCondition);
|
|
json.put("diseaseCondition",diseaseCondition);
|
|
@ -178,9 +182,13 @@ public class IotDeviceService {
|
|
json.put("agent",patientDevice.getAgent());
|
|
json.put("agent",patientDevice.getAgent());
|
|
json.put("doctor",patientDevice.getDoctor());
|
|
json.put("doctor",patientDevice.getDoctor());
|
|
|
|
|
|
|
|
return saveDevice(json.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
private String saveDevice(String json){
|
|
String url = baseUrl+"wg/patientDevice/addPatientDevice";
|
|
String url = baseUrl+"wg/patientDevice/addPatientDevice";
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
params.add(new BasicNameValuePair("jsonData",json.toString()));
|
|
|
|
|
|
params.add(new BasicNameValuePair("jsonData",json));
|
|
String response = httpClientUtil.post(url, params, "UTF-8");
|
|
String response = httpClientUtil.post(url, params, "UTF-8");
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
@ -415,14 +423,15 @@ public class IotDeviceService {
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
if(patient!=null){
|
|
if(patient!=null){
|
|
String address = patient.getAddress();
|
|
String address = patient.getAddress();
|
|
|
|
String hospital = null;
|
|
if(StringUtils.isBlank(address)){
|
|
if(StringUtils.isBlank(address)){
|
|
//居民地址为空,默认取居民的社区,如果社区为空默认填写签约的社区医院
|
|
//居民地址为空,默认取居民的社区,如果社区为空默认填写签约的社区医院
|
|
SignFamily signFamily = signFamilyDao.findByPatient(patientDevice.getUser());
|
|
SignFamily signFamily = signFamilyDao.findByPatient(patientDevice.getUser());
|
|
if(signFamily!=null){
|
|
if(signFamily!=null){
|
|
address = StringUtils.isBlank(signFamily.getSickVillageName())?signFamily.getHospitalName():signFamily.getSickVillageName();
|
|
|
|
|
|
hospital = StringUtils.isBlank(signFamily.getSickVillageName())?signFamily.getHospitalName():signFamily.getSickVillageName();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
String response = saveDevice(patientDevice,address,patient.getName(),patient.getDiseaseCondition());
|
|
|
|
|
|
String response = saveDevice(patientDevice,address,patient.getName(),patient.getDiseaseCondition(),hospital);
|
|
if(StringUtils.isNotBlank(response)){
|
|
if(StringUtils.isNotBlank(response)){
|
|
JSONObject re = JSONObject.parseObject(response);
|
|
JSONObject re = JSONObject.parseObject(response);
|
|
if(re.getInteger("status")!=200){
|
|
if(re.getInteger("status")!=200){
|
|
@ -433,6 +442,33 @@ public class IotDeviceService {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导入正式环境的坐标信息
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public void exportNormalPatientDevice(){
|
|
|
|
String sql = "SELECT * from wlyy_device_location_tmp";
|
|
|
|
List<JSONObject> list = myJdbcTemplate.queryJson(sql);
|
|
|
|
list.forEach(device -> {
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("categoryCode",device.getString("category_code"));
|
|
|
|
json.put("hospitalName",device.getString("hospital_name"));
|
|
|
|
json.put("address",device.getString("address"));
|
|
|
|
json.put("patient",device.getString("user"));
|
|
|
|
json.put("patientName",device.getString("name"));
|
|
|
|
json.put("diseaseCondition",device.getString("disease_condition"));
|
|
|
|
json.put("idcard",device.getString("user_idcard"));
|
|
|
|
json.put("deviceId",device.getString("device_id"));
|
|
|
|
json.put("deviceName",device.getString("device_name"));
|
|
|
|
json.put("deviceSn",device.getString("device_sn"));
|
|
|
|
json.put("userType",device.getString(""));
|
|
|
|
json.put("sim",device.getString("sim"));
|
|
|
|
json.put("agent",device.getString("agent"));
|
|
|
|
json.put("doctor",device.getString("doctor"));
|
|
|
|
saveDevice(json.toString());
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 测试设备绑定
|
|
* 测试设备绑定
|
|
* @return
|
|
* @return
|
|
@ -441,7 +477,12 @@ public class IotDeviceService {
|
|
List<PatientDevice> list = patientDeviceDao.findAll();
|
|
List<PatientDevice> list = patientDeviceDao.findAll();
|
|
PatientDevice patientDevice = list.get(0);
|
|
PatientDevice patientDevice = list.get(0);
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
String response = saveDevice(patientDevice,patient.getAddress(),patient.getName(),patient.getDiseaseCondition());
|
|
|
|
|
|
SignFamily signFamily = signFamilyDao.findByPatient(patientDevice.getUser());
|
|
|
|
String hospital = null;
|
|
|
|
if(signFamily!=null){
|
|
|
|
hospital = StringUtils.isBlank(signFamily.getSickVillageName())?signFamily.getHospitalName():signFamily.getSickVillageName();
|
|
|
|
}
|
|
|
|
String response = saveDevice(patientDevice,patient.getAddress(),patient.getName(),patient.getDiseaseCondition(),hospital);
|
|
return response;
|
|
return response;
|
|
}
|
|
}
|
|
|
|
|