|
@ -1,21 +1,20 @@
|
|
|
package com.yihu.wlyy.service.app.device;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
import com.yihu.wlyy.entity.device.Device;
|
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.repository.deviece.DeviceDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
@ -29,9 +28,7 @@ import org.springside.modules.persistence.SearchFilter;
|
|
|
import org.springside.modules.persistence.SearchFilter.Operator;
|
|
|
import org.springside.modules.utils.Clock;
|
|
|
|
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Component
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@ -54,6 +51,12 @@ public class PatientDeviceService extends BaseService {
|
|
|
@Autowired
|
|
|
private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
|
|
|
|
|
|
private String url = SystemConf.getInstance().getYihuOpenPlatformUrl();
|
|
|
private String appid = SystemConf.getInstance().getYihuOpenPlatformAppId();
|
|
|
private String secret = SystemConf.getInstance().getYihuOpenPlatformSecret();
|
|
|
|
|
|
private String registerDevice = "DeviceGateway/DeviceApi/registerDevice";//注册设备
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 保存患者设备
|
|
@ -98,11 +101,73 @@ public class PatientDeviceService extends BaseService {
|
|
|
//当前用户的身份证
|
|
|
Patient patient = patientDao.findByCode(patientDevice.getUser());
|
|
|
patientDevice.setUserIdcard(patient.getIdcard());
|
|
|
patientDeviceDao.save(patientDevice);
|
|
|
|
|
|
//注册设备
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("deviceSn", sn);
|
|
|
|
|
|
//调用服务
|
|
|
String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
|
|
|
System.out.println("注册设备="+response);
|
|
|
JSONObject json = new JSONObject(response);
|
|
|
String code = json.get("Code").toString();
|
|
|
//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
|
|
|
if("10000".equals(code)||"10001".equals(code))
|
|
|
{
|
|
|
patientDeviceDao.save(patientDevice);
|
|
|
}else{
|
|
|
String message = json.get("Message").toString();
|
|
|
throw new Exception(message);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 注册设备
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String registerSnInit() throws Exception{
|
|
|
String re = "";
|
|
|
Iterable<PatientDevice> iterable = patientDeviceDao.findAll();
|
|
|
if(iterable!=null){
|
|
|
for (PatientDevice patientDevice:iterable){
|
|
|
String deviceSn = patientDevice.getDeviceSn();
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("deviceSn", deviceSn);
|
|
|
|
|
|
String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
|
|
|
System.out.println("注册设备="+response);
|
|
|
JSONObject json = new JSONObject(response);
|
|
|
String code = json.get("Code").toString();
|
|
|
//10000注册成功 10001已注册 -10000参数不通过(没传参数) -10001设备不存在 -10002设备未出库
|
|
|
if("10000".equals(code)||"10001".equals(code))
|
|
|
{
|
|
|
|
|
|
}else{
|
|
|
String message = json.get("Message").toString();
|
|
|
re+= deviceSn + message +";";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 单个注册
|
|
|
* @param deviceSn
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String registerSn(String deviceSn) throws Exception{
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("deviceSn", deviceSn);
|
|
|
|
|
|
String response = HttpClientUtil.httpPost(url + registerDevice,HttpClientUtil.getSecretParams(params,appid,secret));
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除患者设备
|
|
|
*/
|