| 
					
				 | 
			
			
				@ -0,0 +1,137 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.jw.care.endpoint.third.device; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.fasterxml.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.PatientDeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.endpoint.BaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.DeviceDetailService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.device.PatientHealthIndexService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DevicePatientDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.web.ListEnvelop; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiOperation; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.ApiParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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 java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 患者端:设备管理控制类 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 * @author George 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RestController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@RequestMapping(value = "/cloudCare/noLogin/device") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				@Api(value = "患者设备管理", description = "患者设备管理") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				public class PDeviceController extends BaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private static Logger logger = LoggerFactory.getLogger(PDeviceController.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientDeviceService patientDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation("获取居民的设备任务信息") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "getPatientDeviceTaskInfo",method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getPatientDeviceTaskInfo(@ApiParam(name = "patientCode",value = "患者code")@RequestParam(value = "patientCode",required = true)String patientCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200,"执行成功","data",patientDeviceService.getPatientDeviceTaskInfo(patientCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(-1,"执行失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation("获取居民的爱牵挂设备亲情号码") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "getAqgDeviceInfo",method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getAqgDeviceInfo(@ApiParam(name = "deviceSn",value = "设备sn码") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                               @RequestParam(value = "deviceSn",required = true)String deviceSn){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200,"获取成功","data",patientDeviceService.getAqgDeviceInfo(deviceSn)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(-1,"获取失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation("修改删除 爱牵挂亲情号码") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "updAqgDeviceSosInfo",method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String updAqgDeviceSosInfo(@ApiParam(name = "deviceSn",value = "设备id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @RequestParam(value = "deviceSn",required = true)String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @ApiParam(name = "seqid",value = "亲情号码id") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @RequestParam(value = "seqid",required = false)String seqid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @ApiParam(name = "name",value = "亲情号码昵称",required = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @RequestParam(value = "name",required = false)String name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @ApiParam(name = "num",value = "号码",required = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @RequestParam(value = "num",required = false)String num, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @ApiParam(name = "dial_flag",value = "0不设置为紧急呼叫号码,1设置为紧急呼叫号码",required = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @RequestParam(value = "dial_flag",required = false)String dial_flag, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @ApiParam(name = "clear",value = "删除标志,删除传1",required = false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                   @RequestParam(value = "clear",required = false)String clear){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject json = patientDeviceService.updAqgDeviceSosInfo(deviceSn, seqid, name, num, dial_flag, clear); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(json.getBoolean("success")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return success("操作成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1,json.getString("error_desc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(-1,"操作失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation("获取设备最新位置数据") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "getDeviceLastLocation",method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String getDeviceLastLocation(@ApiParam(name = "deviceSn",value = "设备sn码") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "deviceSn",required = true)String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "type",value = "type 0:Gps定位; 1:基站定位 (非必填)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "type",required = false)String type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200,"获取成功","data",patientDeviceService.getDeviceLastLocation(deviceSn,type)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(-1,"获取失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation("更新智能手环设备安全区域") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "updateDeviceFenceArea",method = RequestMethod.GET) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String updateDeviceFenceArea(@ApiParam(name = "deviceSn",value = "设备sn码") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "deviceSn",required = true)String deviceSn, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "fenceNO",value = "安全区编号") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "fenceNO",required = false)Integer fenceNO, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "enable",value = "0,1 是否启用") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "enable",required = false)String enable, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "name",value = "安全区名称") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "name",required = false)String name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "freq",value = "0,触发一天;1,每日触发 ") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "freq",required = false)String freq, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "time_begin",value = "目标时间与当日0点之间相差的秒数 ") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "time_begin",required = false)String time_begin, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "time_end",value = "同上 ") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "time_end",required = false)String time_end, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "safe_area",value = "lon1,lat1;lon2,lat2; 5个坐标 形成一个封闭区域  A;B;C;D;A ") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "safe_area",required = false)String safe_area, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @ApiParam(name = "clear",value = "删除标志,删除传1") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        @RequestParam(value = "clear",required = false)String clear 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200,"获取成功","data",patientDeviceService.updateDeviceFenceArea(deviceSn, fenceNO, enable, name, freq, time_begin, time_end, safe_area, clear)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(-1,"获取失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |