|  | @ -122,61 +122,82 @@ public class WlyyDeviceController extends BaseController {
 | 
	
		
			
				|  |  |     private IotPatientDeviceService iotPatientDeviceService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 设备删除
 | 
	
		
			
				|  |  |      * 设备删除     屏蔽部分为患者端解绑设备
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @ApiOperation("设备删除")
 | 
	
		
			
				|  |  |     @RequestMapping(value = "DeletePatientDevice",method = {RequestMethod.GET,RequestMethod.POST})
 | 
	
		
			
				|  |  |     @RequestMapping(value = "deletePatientDevice",method = {RequestMethod.POST})
 | 
	
		
			
				|  |  |     @ResponseBody
 | 
	
		
			
				|  |  |     public String delete(@ApiParam(name = "id", value = "删除设备关联ID")
 | 
	
		
			
				|  |  |                          @RequestParam(value = "id", required = true) String id) {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             PatientDevice pd = iotPatientDeviceService.findId(id);
 | 
	
		
			
				|  |  |             if (pd != null) {
 | 
	
		
			
				|  |  |                 if (!StringUtils.equals(pd.getUser(), getRepUID())) {
 | 
	
		
			
				|  |  |                     return error(1,"只允许删除自己的设备!");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 iotPatientDeviceService.deleteDevice(id, getRepUID());
 | 
	
		
			
				|  |  |                 //居民自主解绑设备时发送消息给医生
 | 
	
		
			
				|  |  |                 Patient patient = iotPatientDeviceService.findByCode(pd.getUser());   //getRepUID()
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 SignFamily signFamily = iotPatientDeviceService.findDoctor(patient.getCode());
 | 
	
		
			
				|  |  |                 String messageContent =  "您的居民"+patient.getName()+"解绑了";
 | 
	
		
			
				|  |  |                 if ("1".equals(pd.getCategoryCode())){
 | 
	
		
			
				|  |  |                     messageContent +="血糖仪,点击下方查看居民详情";
 | 
	
		
			
				|  |  |                 }else if ("2".equals(pd.getCategoryCode())){
 | 
	
		
			
				|  |  |                     messageContent +="血压计,点击下方查看居民详情";
 | 
	
		
			
				|  |  |                 }else if ("4".equals(pd.getCategoryCode())){
 | 
	
		
			
				|  |  |                     messageContent +="智能手表,点击下方查看居民详情";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 Message message = new Message();
 | 
	
		
			
				|  |  |                 message.setCzrq(new Date());
 | 
	
		
			
				|  |  |                 message.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 message.setContent(messageContent);
 | 
	
		
			
				|  |  |                 message.setRead(1);//设置未读
 | 
	
		
			
				|  |  |                 message.setReceiver(signFamily.getDoctor());//设置接受医生的code
 | 
	
		
			
				|  |  |                 message.setSender("admin");//设置发送的用户
 | 
	
		
			
				|  |  |                 message.setSenderName("系统");
 | 
	
		
			
				|  |  |                 message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
 | 
	
		
			
				|  |  |                 message.setSenderPhoto("");
 | 
	
		
			
				|  |  |                 message.setTitle("解绑设备消息");
 | 
	
		
			
				|  |  |                 message.setType(301);//解绑设备消息
 | 
	
		
			
				|  |  |                 message.setReadonly(1);//是否只读消息
 | 
	
		
			
				|  |  |                 message.setSex(1);
 | 
	
		
			
				|  |  |                 message.setRelationCode(patient.getCode());
 | 
	
		
			
				|  |  |                 message.setOver("1");//未处理
 | 
	
		
			
				|  |  |                 message.setData("");
 | 
	
		
			
				|  |  |                 message.setDel("1");
 | 
	
		
			
				|  |  |                 iotPatientDeviceService.saveMessage(message);
 | 
	
		
			
				|  |  |                 //全部解绑后去判断就更新设备表中是否绑定字段
 | 
	
		
			
				|  |  |                 iotPatientDeviceService.savePatientDeviceLog(pd,pd.getDeviceSn(),2,2);
 | 
	
		
			
				|  |  |                 iotPatientDeviceService.unBindUpdateIsBinding(pd.getDeviceSn());
 | 
	
		
			
				|  |  |                 return success("设备已删除!");
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 return error(-1, "不存在该设备!");
 | 
	
		
			
				|  |  |     public String delete(
 | 
	
		
			
				|  |  |             @ApiParam(name="deviceSn",value="设备SN")
 | 
	
		
			
				|  |  |             @RequestParam(value="deviceSn",required = true) String deviceSn,
 | 
	
		
			
				|  |  |             @ApiParam(name="type",value="设备类型")
 | 
	
		
			
				|  |  |             @RequestParam(value="type",required = true) String type
 | 
	
		
			
				|  |  | //            @ApiParam(name = "id", value = "删除设备关联ID")
 | 
	
		
			
				|  |  | //                         @RequestParam(value = "id", required = true) String id
 | 
	
		
			
				|  |  |     ) {
 | 
	
		
			
				|  |  | //        try {
 | 
	
		
			
				|  |  | //            PatientDevice pd = iotPatientDeviceService.findId(id);
 | 
	
		
			
				|  |  | //            if (pd != null) {
 | 
	
		
			
				|  |  | //                if (!StringUtils.equals(pd.getDoctor(), getRepUID())) {//user:915f019b-5b1d-11e6-8344-fa163e8aee56
 | 
	
		
			
				|  |  | //                    return error(1,"只允许删除自己的设备!");
 | 
	
		
			
				|  |  | //                }
 | 
	
		
			
				|  |  | //                iotPatientDeviceService.deleteDevice(id, getRepUID());
 | 
	
		
			
				|  |  | //                //居民自主解绑设备时发送消息给医生
 | 
	
		
			
				|  |  | //                Patient patient = iotPatientDeviceService.findByCode(pd.getUser());   //getRepUID()
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //                SignFamily signFamily = iotPatientDeviceService.findDoctor(patient.getCode());
 | 
	
		
			
				|  |  | //                String messageContent =  "您的居民"+patient.getName()+"解绑了";
 | 
	
		
			
				|  |  | //                if ("1".equals(pd.getCategoryCode())){
 | 
	
		
			
				|  |  | //                    messageContent +="血糖仪,点击下方查看居民详情";
 | 
	
		
			
				|  |  | //                }else if ("2".equals(pd.getCategoryCode())){
 | 
	
		
			
				|  |  | //                    messageContent +="血压计,点击下方查看居民详情";
 | 
	
		
			
				|  |  | //                }else if ("4".equals(pd.getCategoryCode())){
 | 
	
		
			
				|  |  | //                    messageContent +="智能手表,点击下方查看居民详情";
 | 
	
		
			
				|  |  | //                }
 | 
	
		
			
				|  |  | //                Message message = new Message();
 | 
	
		
			
				|  |  | //                message.setCzrq(new Date());
 | 
	
		
			
				|  |  | //                message.setCreateTime(new Date());
 | 
	
		
			
				|  |  | //                message.setContent(messageContent);
 | 
	
		
			
				|  |  | //                message.setRead(1);//设置未读
 | 
	
		
			
				|  |  | //                message.setReceiver(signFamily.getDoctor());//设置接受医生的code
 | 
	
		
			
				|  |  | //                message.setSender("admin");//设置发送的用户
 | 
	
		
			
				|  |  | //                message.setSenderName("系统");
 | 
	
		
			
				|  |  | //                message.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
 | 
	
		
			
				|  |  | //                message.setSenderPhoto("");
 | 
	
		
			
				|  |  | //                message.setTitle("解绑设备消息");
 | 
	
		
			
				|  |  | //                message.setType(301);//解绑设备消息
 | 
	
		
			
				|  |  | //                message.setReadonly(1);//是否只读消息
 | 
	
		
			
				|  |  | //                message.setSex(1);
 | 
	
		
			
				|  |  | //                message.setRelationCode(patient.getCode());
 | 
	
		
			
				|  |  | //                message.setOver("1");//未处理
 | 
	
		
			
				|  |  | //                message.setData("");
 | 
	
		
			
				|  |  | //                message.setDel("1");
 | 
	
		
			
				|  |  | //                iotPatientDeviceService.saveMessage(message);
 | 
	
		
			
				|  |  | //                //全部解绑后去判断就更新设备表中是否绑定字段
 | 
	
		
			
				|  |  | //                iotPatientDeviceService.savePatientDeviceLog(pd,pd.getDeviceSn(),2,2);
 | 
	
		
			
				|  |  | //                iotPatientDeviceService.unBindUpdateIsBinding(pd.getDeviceSn());
 | 
	
		
			
				|  |  | //                return success("设备已删除!");
 | 
	
		
			
				|  |  | //            } else {
 | 
	
		
			
				|  |  | //                return error(-1, "不存在该设备!");
 | 
	
		
			
				|  |  | //            }
 | 
	
		
			
				|  |  | //        } catch (Exception ex) {
 | 
	
		
			
				|  |  | //            error(ex);
 | 
	
		
			
				|  |  | //            return invalidUserException(ex, -1, ex.getMessage());
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             List<PatientDevice> patientDevices = iotPatientDeviceService.findByDeviceSnAndCategory(deviceSn, type);
 | 
	
		
			
				|  |  |             PatientDevice patientDevice = new PatientDevice();
 | 
	
		
			
				|  |  |             if (patientDevices!=null && patientDevices.size()>0){
 | 
	
		
			
				|  |  |                 patientDevice = patientDevices.get(0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception ex) {
 | 
	
		
			
				|  |  |             error(ex);
 | 
	
		
			
				|  |  |             return invalidUserException(ex, -1, ex.getMessage());
 | 
	
		
			
				|  |  |             iotPatientDeviceService.deleteDevices(deviceSn,type);
 | 
	
		
			
				|  |  |             //全部解绑后去判断就更新设备表中是否绑定字段
 | 
	
		
			
				|  |  |             iotPatientDeviceService.savePatientDeviceLog(patientDevice,deviceSn,1,2);
 | 
	
		
			
				|  |  |             iotPatientDeviceService.unBindUpdateIsBinding(deviceSn);
 | 
	
		
			
				|  |  |             return write(200,"解绑成功!");
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             error(e);
 | 
	
		
			
				|  |  |             return write(-1,e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |