|  | @ -3,8 +3,10 @@ package com.yihu.wlyy.web.doctor.health;
 | 
												
													
														
															|  | import com.yihu.device.entity.DevicePatientHealthIndex;
 |  | import com.yihu.device.entity.DevicePatientHealthIndex;
 | 
												
													
														
															|  | import com.yihu.wlyy.aop.ObserverRequired;
 |  | import com.yihu.wlyy.aop.ObserverRequired;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
 |  | import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.entity.patient.Patient;
 | 
												
													
														
															|  | import com.yihu.wlyy.entity.patient.PatientHealthStandard;
 |  | import com.yihu.wlyy.entity.patient.PatientHealthStandard;
 | 
												
													
														
															|  | import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
 |  | import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.wlyy.service.common.account.PatientService;
 | 
												
													
														
															|  | import com.yihu.wlyy.util.SystemConf;
 |  | import com.yihu.wlyy.util.SystemConf;
 | 
												
													
														
															|  | import com.yihu.wlyy.web.BaseController;
 |  | import com.yihu.wlyy.web.BaseController;
 | 
												
													
														
															|  | import io.swagger.annotations.Api;
 |  | import io.swagger.annotations.Api;
 | 
												
											
												
													
														
															|  | @ -31,6 +33,8 @@ public class DoctorHealthController extends BaseController {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 	@Autowired
 |  | 	@Autowired
 | 
												
													
														
															|  | 	private PatientHealthIndexService healthIndexService;
 |  | 	private PatientHealthIndexService healthIndexService;
 | 
												
													
														
															|  | 
 |  | 	@Autowired
 | 
												
													
														
															|  | 
 |  | 	private PatientService patientService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 	@RequestMapping(value = "recent",method = RequestMethod.GET)
 |  | 	@RequestMapping(value = "recent",method = RequestMethod.GET)
 | 
												
													
														
															|  | 	@ResponseBody
 |  | 	@ResponseBody
 | 
												
											
												
													
														
															|  | @ -239,17 +243,6 @@ public class DoctorHealthController extends BaseController {
 | 
												
													
														
															|  | 							standard.setCzrq(new Date());
 |  | 							standard.setCzrq(new Date());
 | 
												
													
														
															|  | 							list.add(standard);
 |  | 							list.add(standard);
 | 
												
													
														
															|  | 						}
 |  | 						}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 						DoctorHealthStandard doctorHealthStandard = new DoctorHealthStandard();
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setDoctor(getUID());
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setType(obj.getInt("type"));
 |  | 
 | 
												
													
														
															|  | 						doctorHealthStandard.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  | 						doclist.add(doctorHealthStandard);
 |  | 
 | 
												
													
														
															|  | 					}
 |  | 					}
 | 
												
													
														
															|  | 					if (list.size() == 0) {
 |  | 					if (list.size() == 0) {
 | 
												
													
														
															|  | 						return error(-1, "保存失败!");
 |  | 						return error(-1, "保存失败!");
 | 
												
											
												
													
														
															|  | @ -259,12 +252,6 @@ public class DoctorHealthController extends BaseController {
 | 
												
													
														
															|  | 					if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
 |  | 					if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
 | 
												
													
														
															|  | 						return error(-1, "保存失败!");
 |  | 						return error(-1, "保存失败!");
 | 
												
													
														
															|  | 					}
 |  | 					}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 					Iterable<DoctorHealthStandard> dociterable = healthIndexService.saveDocStandard(doclist, getUID());
 |  | 
 | 
												
													
														
															|  | 					if (dociterable == null || dociterable.iterator() == null || !dociterable.iterator().hasNext()) {
 |  | 
 | 
												
													
														
															|  | 						return error(-1, "保存失败!");
 |  | 
 | 
												
													
														
															|  | 					}
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 				}
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 			return write(200, "保存成功");
 |  | 			return write(200, "保存成功");
 | 
												
											
												
													
														
															|  | @ -391,4 +378,80 @@ public class DoctorHealthController extends BaseController {
 | 
												
													
														
															|  | 		}
 |  | 		}
 | 
												
													
														
															|  | 	}
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "savastandbyteamcode",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ResponseBody
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("医生保存团队下所有居民的预警方案")
 | 
												
													
														
															|  | 
 |  | 	public String doctorSaveStandardByTeamCode(
 | 
												
													
														
															|  | 
 |  | 			@ApiParam("团队代码") @RequestParam String teamcode,
 | 
												
													
														
															|  | 
 |  | 			@ApiParam("预警值Json") @RequestParam String json) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			JSONArray array = new JSONArray(json);
 | 
												
													
														
															|  | 
 |  | 			if (StringUtils.isEmpty(teamcode) || array == null || array.length() == 0) {
 | 
												
													
														
															|  | 
 |  | 				return error(-1, "保存失败!");
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			List<Patient> patients = patientService.findAllSignPatientTeamcode(teamcode);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			if(!patients.isEmpty()){
 | 
												
													
														
															|  | 
 |  | 				// 生成数据对象
 | 
												
													
														
															|  | 
 |  | 				List<PatientHealthStandard> list = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 				//保存患者的数据时,同时医生的预警值方案
 | 
												
													
														
															|  | 
 |  | 				List<DoctorHealthStandard> doclist = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 				for (int i = 0; i < array.length(); i++) {
 | 
												
													
														
															|  | 
 |  | 					JSONObject obj = array.getJSONObject(i);
 | 
												
													
														
															|  | 
 |  | 					if (obj == null) {
 | 
												
													
														
															|  | 
 |  | 						continue;
 | 
												
													
														
															|  | 
 |  | 					}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 					for (Patient patient: patients) {
 | 
												
													
														
															|  | 
 |  | 						PatientHealthStandard standard = new PatientHealthStandard();
 | 
												
													
														
															|  | 
 |  | 						standard.setDoctor(getUID());
 | 
												
													
														
															|  | 
 |  | 						standard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 						standard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 						standard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 						standard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 						standard.setType(obj.getInt("type"));
 | 
												
													
														
															|  | 
 |  | 						standard.setPatient(patient.getCode());
 | 
												
													
														
															|  | 
 |  | 						standard.setCzrq(new Date());
 | 
												
													
														
															|  | 
 |  | 						list.add(standard);
 | 
												
													
														
															|  | 
 |  | 					}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 					DoctorHealthStandard doctorHealthStandard = new DoctorHealthStandard();
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setDoctor(getUID());
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setMaxValue1(obj.has("max_value1") ? NumberUtils.toDouble(obj.getString("max_value1"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setMaxValue2(obj.has("max_value2") ? NumberUtils.toDouble(obj.getString("max_value2"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setMinValue1(obj.has("min_value1") ? NumberUtils.toDouble(obj.getString("min_value1"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setMinValue2(obj.has("min_value2") ? NumberUtils.toDouble(obj.getString("min_value2"), 0) : 0);
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setType(obj.getInt("type"));
 | 
												
													
														
															|  | 
 |  | 					doctorHealthStandard.setCzrq(new Date());
 | 
												
													
														
															|  | 
 |  | 					doclist.add(doctorHealthStandard);
 | 
												
													
														
															|  | 
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 				if (list.size() == 0) {
 | 
												
													
														
															|  | 
 |  | 					return error(-1, "保存失败!");
 | 
												
													
														
															|  | 
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 				// 保存数据库
 | 
												
													
														
															|  | 
 |  | 				Iterable<PatientHealthStandard> iterable = healthIndexService.saveStandardPatients(list, patients);
 | 
												
													
														
															|  | 
 |  | 				if (iterable == null || iterable.iterator() == null || !iterable.iterator().hasNext()) {
 | 
												
													
														
															|  | 
 |  | 					return error(-1, "保存失败!");
 | 
												
													
														
															|  | 
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 				Iterable<DoctorHealthStandard> dociterable = healthIndexService.saveDocStandard(doclist, getUID());
 | 
												
													
														
															|  | 
 |  | 				if (dociterable == null || dociterable.iterator() == null || !dociterable.iterator().hasNext()) {
 | 
												
													
														
															|  | 
 |  | 					return error(-1, "保存失败!");
 | 
												
													
														
															|  | 
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			return write(200, "保存成功");
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | 			error(e);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(e, -1, "操作失败!");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | }
 |  | }
 |