| 
					
				 | 
			
			
				@ -9,6 +9,7 @@ import com.yihu.jw.care.service.common.PermissionService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.contacts.ContactsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.DeviceManageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientHealthIndexService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.useragent.UserAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DevicePatientDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.patient.BaseDeviceRepairEntity; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -17,15 +18,13 @@ import com.yihu.jw.restmodel.web.PageEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.http.MediaType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestMethod; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RequestParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -51,6 +50,8 @@ public class DoctorDeviceController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private ContactsService contactsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					UserAgent userAgent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private PatientHealthIndexService healthIndexService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					private ObjectMapper  objectMapper=new ObjectMapper(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -314,4 +315,156 @@ public class DoctorDeviceController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@GetMapping(value = "getHealthIndexInfoWithAvg") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ApiOperation("获取居民心率波动和呼吸频率--带平均值(医生端)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String getHealthIndexInfoWithAvg(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@RequestParam(value="patient",required = false) String patient, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@ApiParam(name="type",value="健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率,6体温,7呼吸)",defaultValue = "1") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@RequestParam(value="type",required = true) Integer type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@ApiParam(name="gi_type",value="就餐类型",defaultValue = "0") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@RequestParam(value = "gi_type",required = false,defaultValue = "0") Integer gi_type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@ApiParam(name="begin",value="开始时间",defaultValue = "2021-10-20 00:00:00") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@RequestParam(value="begin",required = true) String begin, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@ApiParam(name="end",value="结束时间",defaultValue = "2021-10-21 00:00:00") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@RequestParam(value="end",required = true) String end, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@ApiParam(name = "deviceSn",required = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
															@RequestParam(value = "deviceSn",required = false) String deviceSn){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//医生端登录鉴权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							jsonObject.put("doctorId",permissionService.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (permissionService.noPermission(1, jsonObject)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"该操作没有权限"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200,"查询成功","data",healthIndexService.findChartByPatientWithAvg(patient,type,gi_type,begin,end,deviceSn)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return errorResult(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ApiOperation("获取睡眠带睡眠报告") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value ="getSleepReport",method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String getSleepReport(@ApiParam(name="patient")@RequestParam(value = "patient",required = false)String patient, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
												 @ApiParam(name="deviceSn")@RequestParam(value = "deviceSn",required = false)String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
												 @ApiParam(name="day")@RequestParam(value = "day",required = false)String day){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//医生端登录鉴权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							jsonObject.put("doctorId",permissionService.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (permissionService.noPermission(1, jsonObject)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"该操作没有权限"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isBlank(patient)&&StringUtils.isBlank(deviceSn)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"请求参数"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							org.json.JSONObject result = patientDeviceService.getSleepReport(patient,deviceSn,day); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (ResponseContant.success==result.getInt(ResponseContant.resultFlag)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(200,"获取成功","data",result.get(ResponseContant.resultMsg)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							}else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,result.getString(ResponseContant.resultMsg)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return errorResult(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ApiOperation("获取患者手表睡眠质量(医生端)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "getX1SleepInfo", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String getX1SleepInfo(@ApiParam(name = "patient") @RequestParam(value = "patient", required = false) String patient, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
												 @ApiParam(name = "deviceSn") @RequestParam(value = "deviceSn", required = false) String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
												 @ApiParam(name = "day") @RequestParam(value = "day", required = false) String day) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//医生端登录鉴权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							jsonObject.put("doctorId",permissionService.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (permissionService.noPermission(1, jsonObject)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"该操作没有权限"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isBlank(patient) && StringUtils.isBlank(deviceSn)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(-1,"请求参数"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							org.json.JSONObject result = patientDeviceService.getX1SleepInfo(patient, deviceSn, day); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (ResponseContant.success == result.getInt(ResponseContant.resultFlag)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(200,"获取成功","data", result.get(ResponseContant.resultMsg)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(-1,result.getString(ResponseContant.resultMsg)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return errorResult(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ApiOperation("获取患者手表步数数据(医生端)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "getPatientStep", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String getPatientStep(@ApiParam(name = "patient") @RequestParam(value = "patient", required = false) String patient, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
												 @ApiParam(name = "deviceSn") @RequestParam(value = "deviceSn", required = false) String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
												 @ApiParam(name = "day") @RequestParam(value = "day", required = false) String day) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//医生端登录鉴权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							jsonObject.put("doctorId",permissionService.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (permissionService.noPermission(1, jsonObject)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"该操作没有权限"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isBlank(patient) && StringUtils.isBlank(deviceSn)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(-1,"请求参数"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							org.json.JSONObject result = patientDeviceService.getPatientStep(patient, deviceSn, day); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (ResponseContant.success == result.getInt(ResponseContant.resultFlag)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(200,"获取成功","data", result.get(ResponseContant.resultMsg)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return write(-1,result.getString(ResponseContant.resultMsg)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return errorResult(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ApiOperation("获取烟雾/燃气浓度列表(医生端)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "getSmokeOrGasList", method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String getSmokeOrGasList(@ApiParam(name = "deviceSn") @RequestParam(value = "deviceSn", required = true) String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														 @ApiParam(name = "day", value = "yyyy-MM-dd") @RequestParam(value = "day", required = false) String day) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//医生端登录鉴权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							jsonObject.put("doctorId",permissionService.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (permissionService.noPermission(1, jsonObject)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"该操作没有权限"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200,"获取成功","list", patientDeviceService.getSmokeOrGasList(deviceSn, day)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return errorResult(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@ApiOperation("获取设备详情数据 --设备可多人绑定查询数据时与patient无关-医生端") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					@RequestMapping(value = "getPatientDeviceDataNew",method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String getPatientDeviceDataNew(@ApiParam(name="patient") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @RequestParam(value = "patient")String patient, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @ApiParam(name="deviceSn") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @RequestParam(value = "deviceSn")String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @ApiParam(name="page") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @RequestParam(value = "page")Integer page, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @ApiParam(name="pageSize") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @RequestParam(value = "pageSize")Integer pageSize, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
														  @ApiParam(name = "type", value = "0全部 1日常监护 2预警记录(工单列表)") @RequestParam(value = "type", required = false) String type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							//医生端登录鉴权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							JSONObject jsonObject = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							jsonObject.put("doctorId",permissionService.getUID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (permissionService.noPermission(1, jsonObject)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return error(-1,"该操作没有权限"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return write(200,"获取成功","data",patientDeviceService.getPatientDeviceData(patient,type,deviceSn,page,pageSize)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						}catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return errorResult(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |