|
@ -104,6 +104,7 @@ public class PatientDeviceController extends BaseController {
|
|
@RequestParam(required = false) String afterDinnerEnd,
|
|
@RequestParam(required = false) String afterDinnerEnd,
|
|
@RequestParam(required = false) String beforeSleepStart,
|
|
@RequestParam(required = false) String beforeSleepStart,
|
|
@RequestParam(required = false) String beforeSleepEnd,
|
|
@RequestParam(required = false) String beforeSleepEnd,
|
|
|
|
@RequestParam(required = false) String sim,
|
|
@RequestParam String deviceSN,
|
|
@RequestParam String deviceSN,
|
|
@RequestParam String categoryCode,
|
|
@RequestParam String categoryCode,
|
|
@RequestParam String userType,
|
|
@RequestParam String userType,
|
|
@ -115,43 +116,48 @@ public class PatientDeviceController extends BaseController {
|
|
|
|
|
|
if (StringUtils.isNotEmpty(newDeviceSN)) {
|
|
if (StringUtils.isNotEmpty(newDeviceSN)) {
|
|
// 校验新的sn码 1.是否被占用 2.是否是真的设备码
|
|
// 校验新的sn码 1.是否被占用 2.是否是真的设备码
|
|
PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(newDeviceSN, userType);
|
|
|
|
if (device != null) {
|
|
|
|
throw new Exception("sn码" + newDeviceSN + "已被使用!");
|
|
|
|
}
|
|
|
|
|
|
if(!newDeviceSN.equals(deviceSN)){
|
|
|
|
//有改sn码
|
|
|
|
PatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(newDeviceSN, userType);
|
|
|
|
if (device != null) {
|
|
|
|
throw new Exception("sn码" + newDeviceSN + "已被使用!");
|
|
|
|
}
|
|
|
|
|
|
|
|
//注册设备
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
params.put("deviceSn", newDeviceSN);
|
|
|
|
|
|
//注册设备
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
params.put("deviceSn", newDeviceSN);
|
|
|
|
|
|
//调用服务
|
|
|
|
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)) {
|
|
|
|
|
|
//调用服务
|
|
|
|
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)) {
|
|
|
|
if ("1".equals(categoryCode)) {
|
|
|
|
|
|
} else {
|
|
|
|
String message = json.get("Message").toString();
|
|
|
|
return error(-1,message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ("1".equals(categoryCode)) {
|
|
// 先修改患者设备绑定表
|
|
// 先修改患者设备绑定表
|
|
int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType);
|
|
|
|
if (rows != 0) {
|
|
|
|
// 只更换设备编码,不更改时间值
|
|
|
|
|
|
int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType,sim);
|
|
|
|
if (rows != 0) {
|
|
|
|
// 只更换设备编码,不更改时间值
|
|
// 1.先查询是否自定义时间段,没有则新增,有则修改
|
|
// 1.先查询是否自定义时间段,没有则新增,有则修改
|
|
PatientHealthTime healthTime = patientHealthTimeDao.findByUserAndSN(user, deviceSN);
|
|
|
|
if (healthTime == null) {
|
|
|
|
patientDeviceService.setBloodTime(user, newDeviceSN, "null", "null", "null", "null", "null", "null",
|
|
|
|
"null", "null", "null", "null", "null", "null", "null", "null");
|
|
|
|
} else {
|
|
|
|
patientDeviceService.updateDeviceSN(user, deviceSN, newDeviceSN);
|
|
|
|
}
|
|
|
|
|
|
PatientHealthTime healthTime = patientHealthTimeDao.findByUserAndSN(user, deviceSN);
|
|
|
|
if (healthTime == null) {
|
|
|
|
patientDeviceService.setBloodTime(user, newDeviceSN, "null", "null", "null", "null", "null", "null",
|
|
|
|
"null", "null", "null", "null", "null", "null", "null", "null");
|
|
|
|
} else {
|
|
|
|
patientDeviceService.updateDeviceSN(user, deviceSN, newDeviceSN);
|
|
}
|
|
}
|
|
}else {
|
|
|
|
int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType);
|
|
|
|
}
|
|
}
|
|
} else {
|
|
|
|
String message = json.get("Message").toString();
|
|
|
|
throw new Exception(message);
|
|
|
|
|
|
}else {
|
|
|
|
int rows = patientDeviceService.updatePatientDevice(user, deviceSN, newDeviceSN,userType,sim);
|
|
}
|
|
}
|
|
|
|
|
|
return write(200, "更改sv码成功!");
|
|
return write(200, "更改sv码成功!");
|
|
}
|
|
}
|
|
patientDeviceService.setBloodTime(user, deviceSN, fastingStart, fastingEnd, afterBreakfastStart, afterBreakfastEnd, beforeLunchStart, beforeLunchEnd,
|
|
patientDeviceService.setBloodTime(user, deviceSN, fastingStart, fastingEnd, afterBreakfastStart, afterBreakfastEnd, beforeLunchStart, beforeLunchEnd,
|