|  | @ -559,48 +559,50 @@ public class DeviceService {
 | 
	
		
			
				|  |  |                 if (devicePatientDeviceDos.size()>0){
 | 
	
		
			
				|  |  |                     if ("1".equals(is_warn)){//触发安防工单
 | 
	
		
			
				|  |  |                         BasePatientDO patientDO = patientDao.findById(devicePatientDeviceDos.get(0).getUser());
 | 
	
		
			
				|  |  |                         if(null==patientDO){
 | 
	
		
			
				|  |  |                         if(null!=patientDO){
 | 
	
		
			
				|  |  |                             String sql ="select DISTINCT pack.org_code,pack.org_name\n" +
 | 
	
		
			
				|  |  |                                     " from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
 | 
	
		
			
				|  |  |                                     "where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand  item.`code`='preventOutOfBed'  and item.service_package_id = pack.id \n" +
 | 
	
		
			
				|  |  |                                     "  and pack.del=1";
 | 
	
		
			
				|  |  |                             List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |                             Map<String, String> json = null;
 | 
	
		
			
				|  |  |                             String address= devicePatientDeviceDos.get(0).getSosAddress();
 | 
	
		
			
				|  |  |                             if (StringUtils.isNotBlank(devicePatientDeviceDos.get(0).getSosAddress())) {
 | 
	
		
			
				|  |  |                                  json = LatitudeUtils.getGeocoderLatitude(address.replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                             String lat=null;
 | 
	
		
			
				|  |  |                             String lng=null;
 | 
	
		
			
				|  |  |                              if (json != null) {
 | 
	
		
			
				|  |  |                                   lat= json.get("lat".toString());
 | 
	
		
			
				|  |  |                                   lng = json.get("lng".toString());
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                             Map<String,Object> map = new HashMap();
 | 
	
		
			
				|  |  |                             String url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
 | 
	
		
			
				|  |  |                             JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |                             jsonObject.put("patient",patientDO.getId());
 | 
	
		
			
				|  |  |                             jsonObject.put("patientName",patientDO.getName());
 | 
	
		
			
				|  |  |                             jsonObject.put("patientPhone",patientDO.getMobile());
 | 
	
		
			
				|  |  |                             jsonObject.put("serveDesc","疑似发生意外");
 | 
	
		
			
				|  |  |                             jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
 | 
	
		
			
				|  |  |                             jsonObject.put("serveAddress",address.replace(" ",""));
 | 
	
		
			
				|  |  |                             jsonObject.put("serveLat",lat);
 | 
	
		
			
				|  |  |                             jsonObject.put("serveLon",lng);
 | 
	
		
			
				|  |  |                             jsonObject.put("topicItem","preventOutOfBed");
 | 
	
		
			
				|  |  |                             jsonObject.put("deviceSn",device);
 | 
	
		
			
				|  |  |                             JSONObject jsonObjectParam = new JSONObject();
 | 
	
		
			
				|  |  |                             jsonObjectParam.put("order", jsonObject);
 | 
	
		
			
				|  |  |                             map.put("jsonData", jsonObjectParam.toJSONString());
 | 
	
		
			
				|  |  |                             map.put("orderSource", 5);
 | 
	
		
			
				|  |  |                             map.put("warnStr", "疑似发生意外");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                            String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
 | 
	
		
			
				|  |  |                            String postParams = AesEncryptUtils.agEncrypt(content);
 | 
	
		
			
				|  |  |                            String response = httpClientUtil.postBodyRawForm(url,postParams);
 | 
	
		
			
				|  |  |                            JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |                            JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
 | 
	
		
			
				|  |  |                             System.out.println(jsonObjectData.toJSONString());
 | 
	
		
			
				|  |  |                             if (sqlResult.size()>0){
 | 
	
		
			
				|  |  |                                 Map<String, String> json = null;
 | 
	
		
			
				|  |  |                                 String address= devicePatientDeviceDos.get(0).getSosAddress();
 | 
	
		
			
				|  |  |                                 if (StringUtils.isNotBlank(devicePatientDeviceDos.get(0).getSosAddress())) {
 | 
	
		
			
				|  |  |                                     json = LatitudeUtils.getGeocoderLatitude(address.replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 String lat=null;
 | 
	
		
			
				|  |  |                                 String lng=null;
 | 
	
		
			
				|  |  |                                 if (json != null) {
 | 
	
		
			
				|  |  |                                     lat= json.get("lat".toString());
 | 
	
		
			
				|  |  |                                     lng = json.get("lng".toString());
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                                 Map<String,Object> map = new HashMap();
 | 
	
		
			
				|  |  |                                 String url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
 | 
	
		
			
				|  |  |                                 JSONObject jsonObject = new JSONObject();
 | 
	
		
			
				|  |  |                                 jsonObject.put("patient",patientDO.getId());
 | 
	
		
			
				|  |  |                                 jsonObject.put("patientName",patientDO.getName());
 | 
	
		
			
				|  |  |                                 jsonObject.put("patientPhone",patientDO.getMobile());
 | 
	
		
			
				|  |  |                                 jsonObject.put("serveDesc","疑似发生意外");
 | 
	
		
			
				|  |  |                                 jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
 | 
	
		
			
				|  |  |                                 jsonObject.put("serveAddress",address.replace(" ",""));
 | 
	
		
			
				|  |  |                                 jsonObject.put("serveLat",lat);
 | 
	
		
			
				|  |  |                                 jsonObject.put("serveLon",lng);
 | 
	
		
			
				|  |  |                                 jsonObject.put("topicItem","preventOutOfBed");
 | 
	
		
			
				|  |  |                                 jsonObject.put("deviceSn",device);
 | 
	
		
			
				|  |  |                                 JSONObject jsonObjectParam = new JSONObject();
 | 
	
		
			
				|  |  |                                 jsonObjectParam.put("order", jsonObject);
 | 
	
		
			
				|  |  |                                 map.put("jsonData", jsonObjectParam.toJSONString());
 | 
	
		
			
				|  |  |                                 map.put("orderSource", 5);
 | 
	
		
			
				|  |  |                                 map.put("warnStr", "疑似发生意外");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                 String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
 | 
	
		
			
				|  |  |                                 String postParams = AesEncryptUtils.agEncrypt(content);
 | 
	
		
			
				|  |  |                                 String response = httpClientUtil.postBodyRawForm(url,postParams);
 | 
	
		
			
				|  |  |                                 JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
 | 
	
		
			
				|  |  |                                 JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
 | 
	
		
			
				|  |  |                                 System.out.println(jsonObjectData.toJSONString());
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 |