|  | @ -60,40 +60,60 @@ public class KitService extends BaseService {
 | 
												
													
														
															|  |     public void kitBinding(String deviceSn,String type,String patientCode) throws Exception{
 |  |     public void kitBinding(String deviceSn,String type,String patientCode) throws Exception{
 | 
												
													
														
															|  |         Patient patient = patientService.findByCode(patientCode);
 |  |         Patient patient = patientService.findByCode(patientCode);
 | 
												
													
														
															|  |         JSONObject dataJSONStr = jyKitService.kitBinding(deviceSn,patient.getMobile(),type);
 |  |         JSONObject dataJSONStr = jyKitService.kitBinding(deviceSn,patient.getMobile(),type);
 | 
												
													
														
															|  |         //绑定成功,设备添加到device库
 |  | 
 | 
												
													
														
															|  |         String sn = dataJSONStr.getString("device_sn");//设备编码
 |  | 
 | 
												
													
														
															|  |         String deviceType = dataJSONStr.getString("device_type");//设备型号
 |  | 
 | 
												
													
														
															|  |         String maxAlarm = dataJSONStr.getString("max_alarm");//设备闹钟数
 |  | 
 | 
												
													
														
															|  |         String maxDrugs = dataJSONStr.getString("max_drugs");//设备药格数
 |  | 
 | 
												
													
														
															|  | 
 |  |         PatientDevice patientDevice = null;
 | 
												
													
														
															|  | 
 |  |         if("1".equals(type)){
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         System.out.println("sn:"+sn+",deviceType:"+deviceType+",maxAlarm:"+maxAlarm+",maxDrugs:"+maxDrugs);
 |  | 
 | 
												
													
														
															|  | 
 |  |             //绑定成功,设备添加到device库
 | 
												
													
														
															|  | 
 |  |             String sn = dataJSONStr.getString("device_sn");//设备编码
 | 
												
													
														
															|  | 
 |  |             String deviceType = dataJSONStr.getString("device_type");//设备型号
 | 
												
													
														
															|  | 
 |  |             String maxAlarm = dataJSONStr.getString("max_alarm");//设备闹钟数
 | 
												
													
														
															|  | 
 |  |             String maxDrugs = dataJSONStr.getString("max_drugs");//设备药格数
 | 
												
													
														
															|  | 
 |  |             System.out.println("sn:"+sn+",deviceType:"+deviceType+",maxAlarm:"+maxAlarm+",maxDrugs:"+maxDrugs);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //添加设备
 |  | 
 | 
												
													
														
															|  |         DeviceDetail deviceDetail = new DeviceDetail();
 |  | 
 | 
												
													
														
															|  |         deviceDetail.setDeviceModel(deviceType);//设备型号
 |  | 
 | 
												
													
														
															|  |         deviceDetail.setDeviceName("");
 |  | 
 | 
												
													
														
															|  |         deviceDetail.setDeviceCode(sn);
 |  | 
 | 
												
													
														
															|  |         deviceDetail.setLinkman(patient.getName());
 |  | 
 | 
												
													
														
															|  |         String sql = " select f.* from wlyy_sign_family f where f.patient='' and p.status=1 ";
 |  | 
 | 
												
													
														
															|  |         List<Map<String, Object>> signFamilys1 = jdbcTemplate.queryForList(sql);
 |  | 
 | 
												
													
														
															|  |         if(signFamilys1.size()>0){
 |  | 
 | 
												
													
														
															|  |             deviceDetail.setOrgName(signFamilys1.get(0).get("hospital_name")+"");
 |  | 
 | 
												
													
														
															|  |             deviceDetail.setTel(patient.getMobile());
 |  | 
 | 
												
													
														
															|  |             deviceDetail.setGrantAdminTeam(signFamilys1.get(0).get("admin_team_code")+"");
 |  | 
 | 
												
													
														
															|  |             deviceDetail.setGrantOrgCode(signFamilys1.get(0).get("hospital")+"");
 |  | 
 | 
												
													
														
															|  |             deviceDetail.setGrantTime(new Date());
 |  | 
 | 
												
													
														
															|  | 
 |  |             //添加设备
 | 
												
													
														
															|  | 
 |  |             DeviceDetail deviceDetail = new DeviceDetail();
 | 
												
													
														
															|  | 
 |  |             deviceDetail.setDeviceModel(deviceType);//设备型号
 | 
												
													
														
															|  | 
 |  |             deviceDetail.setDeviceName("巨烨科技智能药盒");
 | 
												
													
														
															|  | 
 |  |             deviceDetail.setDeviceCode(sn);
 | 
												
													
														
															|  | 
 |  |             deviceDetail.setLinkman(patient.getName());
 | 
												
													
														
															|  | 
 |  |             String sql = " select f.* from wlyy_sign_family f where f.patient='"+patientCode+"' and f.status=1 ";
 | 
												
													
														
															|  | 
 |  |             List<Map<String, Object>> signFamilys1 = jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  | 
 |  |             if(signFamilys1.size()>0){
 | 
												
													
														
															|  | 
 |  |                 deviceDetail.setOrgName(signFamilys1.get(0).get("hospital_name")+"");
 | 
												
													
														
															|  | 
 |  |                 deviceDetail.setTel(patient.getMobile());
 | 
												
													
														
															|  | 
 |  |                 deviceDetail.setGrantAdminTeam(signFamilys1.get(0).get("admin_team_code")+"");
 | 
												
													
														
															|  | 
 |  |                 deviceDetail.setGrantOrgCode(signFamilys1.get(0).get("hospital")+"");
 | 
												
													
														
															|  | 
 |  |                 deviceDetail.setGrantTime(new Date());
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             deviceDetail = deviceDetailDao.save(deviceDetail);
 | 
												
													
														
															|  | 
 |  |             patientDevice = new PatientDevice();
 | 
												
													
														
															|  | 
 |  |             patientDevice.setDeviceId(deviceDetail.getId());
 | 
												
													
														
															|  | 
 |  |             patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
 | 
												
													
														
															|  | 
 |  |             patientDevice.setDeviceName(deviceDetail.getDeviceName());
 | 
												
													
														
															|  | 
 |  |             patientDevice.setUser(patientCode);
 | 
												
													
														
															|  | 
 |  |             patientDevice.setCategoryCode("3");
 | 
												
													
														
															|  | 
 |  |             patientDevice.setUserType("-1");
 | 
												
													
														
															|  | 
 |  |             patientDevice.setUserIdcard(patient.getIdcard());
 | 
												
													
														
															|  | 
 |  |             patientDevice.setCzrq(new Date());
 | 
												
													
														
															|  | 
 |  |         }else {
 | 
												
													
														
															|  | 
 |  |             List<PatientDevice> list = patientDeviceDao.findByDeviceSn(deviceSn);
 | 
												
													
														
															|  | 
 |  |             if(list.size()>0){
 | 
												
													
														
															|  | 
 |  |                 patientDevice = list.get(0);
 | 
												
													
														
															|  | 
 |  |             }else{
 | 
												
													
														
															|  | 
 |  |                 throw new Exception(" 数据库中没有该设备!");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         deviceDetail = deviceDetailDao.save(deviceDetail);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         //添加绑定关系
 |  |         //添加绑定关系
 | 
												
													
														
															|  |         PatientDevice patientDevice = new PatientDevice();
 |  | 
 | 
												
													
														
															|  |         patientDevice.setDeviceId(deviceDetail.getId());
 |  | 
 | 
												
													
														
															|  |         patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
 |  | 
 | 
												
													
														
															|  |         patientDevice.setDeviceName(deviceDetail.getDeviceName());
 |  | 
 | 
												
													
														
															|  |         patientDevice.setUser(patientCode);
 |  | 
 | 
												
													
														
															|  |         patientDevice.setCategoryCode("3");
 |  | 
 | 
												
													
														
															|  |         patientDevice.setUserType("-1");
 |  | 
 | 
												
													
														
															|  |         patientDevice.setUserIdcard(patient.getIdcard());
 |  | 
 | 
												
													
														
															|  |         patientDevice.setCzrq(new Date());
 |  | 
 | 
												
													
														
															|  | 
 |  | //        PatientDevice patientDevice = new PatientDevice();
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setDeviceId(deviceDetail.getId());
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setDeviceSn(deviceDetail.getDeviceCode());
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setDeviceName(deviceDetail.getDeviceName());
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setUser(patientCode);
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setCategoryCode("3");
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setUserType("-1");
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setUserIdcard(patient.getIdcard());
 | 
												
													
														
															|  | 
 |  | //        patientDevice.setCzrq(new Date());
 | 
												
													
														
															|  |         if("1".equals(type)){
 |  |         if("1".equals(type)){
 | 
												
													
														
															|  |             type="0";
 |  |             type="0";
 | 
												
													
														
															|  |         }else if("2".equals(type)){
 |  |         }else if("2".equals(type)){
 | 
												
											
												
													
														
															|  | @ -122,7 +142,8 @@ public class KitService extends BaseService {
 | 
												
													
														
															|  |         kitUseRemindRecord.setRemindType(Integer.valueOf(remindType));
 |  |         kitUseRemindRecord.setRemindType(Integer.valueOf(remindType));
 | 
												
													
														
															|  |         kitUseRemindRecord.setInsertTime(currentTime);
 |  |         kitUseRemindRecord.setInsertTime(currentTime);
 | 
												
													
														
															|  |         kitUseRemindRecord.setKitAccountId(kitAccountId);
 |  |         kitUseRemindRecord.setKitAccountId(kitAccountId);
 | 
												
													
														
															|  | //        kitUseRemindRecord.setDeviveModel();//药盒型号
 |  | 
 | 
												
													
														
															|  | 
 |  |         DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviveSn);
 | 
												
													
														
															|  | 
 |  |         kitUseRemindRecord.setDeviceModel(deviceDetail!=null?deviceDetail.getDeviceModel():null);//药盒型号
 | 
												
													
														
															|  |         kitUseRemindRecord.setDeviceSn(deviveSn);
 |  |         kitUseRemindRecord.setDeviceSn(deviveSn);
 | 
												
													
														
															|  |         //根据药盒sn码和居民的绑定关系表,获取居民信息
 |  |         //根据药盒sn码和居民的绑定关系表,获取居民信息
 | 
												
													
														
															|  |         List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(deviveSn);
 |  |         List<PatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(deviveSn);
 |