|  | @ -1098,7 +1098,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
 | 
												
													
														
															|  |         return result;
 |  |         return result;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     public JSONObject patientMonitoringInfo(String patient){
 |  | 
 | 
												
													
														
															|  | 
 |  |     public JSONObject patientMonitoringInfo(String patient,String topicItem){
 | 
												
													
														
															|  |         JSONObject result = new JSONObject();
 |  |         JSONObject result = new JSONObject();
 | 
												
													
														
															|  |         result.put("location",null);
 |  |         result.put("location",null);
 | 
												
													
														
															|  |         result.put("fences",null);
 |  |         result.put("fences",null);
 | 
												
											
												
													
														
															|  | @ -1106,74 +1106,79 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
 | 
												
													
														
															|  |         result.put("fire",null);
 |  |         result.put("fire",null);
 | 
												
													
														
															|  |         result.put("deviceSn",null);
 |  |         result.put("deviceSn",null);
 | 
												
													
														
															|  |         result.put("monitorInfo",null);
 |  |         result.put("monitorInfo",null);
 | 
												
													
														
															|  |         List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
 |  | 
 | 
												
													
														
															|  |         if (devicePatientDeviceDos.size()==0){
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |         else {
 |  | 
 | 
												
													
														
															|  |             DevicePatientDevice device = devicePatientDeviceDos.get(0);
 |  | 
 | 
												
													
														
															|  |             result.put("deviceSn",device.getDeviceSn());
 |  | 
 | 
												
													
														
															|  |             try {
 |  | 
 | 
												
													
														
															|  |              JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
 |  | 
 | 
												
													
														
															|  |              if (response!=null){
 |  | 
 | 
												
													
														
															|  |                  //定位信息
 |  | 
 | 
												
													
														
															|  |                 if (response.containsKey("last_location")&&response.get("last_location")!=null){
 |  | 
 | 
												
													
														
															|  |                     JSONObject locationTmp = response.getJSONObject("last_location");
 |  | 
 | 
												
													
														
															|  |                     Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
 |  | 
 | 
												
													
														
															|  |                     Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
 |  | 
 | 
												
													
														
															|  |                     JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
 |  | 
 | 
												
													
														
															|  |                     tmp.put("city",response.getString("last_city"));
 |  | 
 | 
												
													
														
															|  |                     tmp.put("province",response.getString("last_province"));
 |  | 
 | 
												
													
														
															|  |                     tmp.put("address",response.getString("last_address"));
 |  | 
 | 
												
													
														
															|  |                     result.put("location",tmp);
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |                 //围栏信息
 |  | 
 | 
												
													
														
															|  |                  if (response.containsKey("fences")&&response.get("fences")!=null){
 |  | 
 | 
												
													
														
															|  |                      JSONArray fencesArr = response.getJSONArray("fences");
 |  | 
 | 
												
													
														
															|  |                      JSONArray fencesEnables = new JSONArray();
 |  | 
 | 
												
													
														
															|  |                      for (int i=0;i<fencesArr.size();i++){
 |  | 
 | 
												
													
														
															|  |                          JSONObject tmp = fencesArr.getJSONObject(i);
 |  | 
 | 
												
													
														
															|  |                          if (tmp.getBooleanValue("enable")){//围栏生效
 |  | 
 | 
												
													
														
															|  |                             JSONObject fenceTmp = new JSONObject();
 |  | 
 | 
												
													
														
															|  |                             fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
 |  | 
 | 
												
													
														
															|  |                             fenceTmp.put("name",tmp.getString("name"));
 |  | 
 | 
												
													
														
															|  |                             JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
 |  | 
 | 
												
													
														
															|  |                             JSONArray fenceLocation = new JSONArray();
 |  | 
 | 
												
													
														
															|  |                             for (int j=0;j<fenceLocationTmp.size();j++){
 |  | 
 | 
												
													
														
															|  |                                 Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
 |  | 
 | 
												
													
														
															|  |                                 Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
 |  | 
 | 
												
													
														
															|  |                                 JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
 |  | 
 | 
												
													
														
															|  |                                 fenceLocation.add(positionTmp);
 |  | 
 | 
												
													
														
															|  | 
 |  |         if ((StringUtils.isNotBlank(topicItem)&&"preventLost".equals(topicItem))||null==topicItem){
 | 
												
													
														
															|  | 
 |  |             List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
 | 
												
													
														
															|  | 
 |  |             if (devicePatientDeviceDos.size()==0){
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             else {
 | 
												
													
														
															|  | 
 |  |                 DevicePatientDevice device = devicePatientDeviceDos.get(0);
 | 
												
													
														
															|  | 
 |  |                 result.put("deviceSn",device.getDeviceSn());
 | 
												
													
														
															|  | 
 |  |                 try {
 | 
												
													
														
															|  | 
 |  |                     JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
 | 
												
													
														
															|  | 
 |  |                     if (response!=null){
 | 
												
													
														
															|  | 
 |  |                         //定位信息
 | 
												
													
														
															|  | 
 |  |                         if (response.containsKey("last_location")&&response.get("last_location")!=null){
 | 
												
													
														
															|  | 
 |  |                             JSONObject locationTmp = response.getJSONObject("last_location");
 | 
												
													
														
															|  | 
 |  |                             Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
 | 
												
													
														
															|  | 
 |  |                             Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
 | 
												
													
														
															|  | 
 |  |                             JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
 | 
												
													
														
															|  | 
 |  |                             tmp.put("city",response.getString("last_city"));
 | 
												
													
														
															|  | 
 |  |                             tmp.put("province",response.getString("last_province"));
 | 
												
													
														
															|  | 
 |  |                             tmp.put("address",response.getString("last_address"));
 | 
												
													
														
															|  | 
 |  |                             result.put("location",tmp);
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         //围栏信息
 | 
												
													
														
															|  | 
 |  |                         if (response.containsKey("fences")&&response.get("fences")!=null){
 | 
												
													
														
															|  | 
 |  |                             JSONArray fencesArr = response.getJSONArray("fences");
 | 
												
													
														
															|  | 
 |  |                             JSONArray fencesEnables = new JSONArray();
 | 
												
													
														
															|  | 
 |  |                             for (int i=0;i<fencesArr.size();i++){
 | 
												
													
														
															|  | 
 |  |                                 JSONObject tmp = fencesArr.getJSONObject(i);
 | 
												
													
														
															|  | 
 |  |                                 if (tmp.getBooleanValue("enable")){//围栏生效
 | 
												
													
														
															|  | 
 |  |                                     JSONObject fenceTmp = new JSONObject();
 | 
												
													
														
															|  | 
 |  |                                     fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
 | 
												
													
														
															|  | 
 |  |                                     fenceTmp.put("name",tmp.getString("name"));
 | 
												
													
														
															|  | 
 |  |                                     JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
 | 
												
													
														
															|  | 
 |  |                                     JSONArray fenceLocation = new JSONArray();
 | 
												
													
														
															|  | 
 |  |                                     for (int j=0;j<fenceLocationTmp.size();j++){
 | 
												
													
														
															|  | 
 |  |                                         Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
 | 
												
													
														
															|  | 
 |  |                                         Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
 | 
												
													
														
															|  | 
 |  |                                         JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
 | 
												
													
														
															|  | 
 |  |                                         fenceLocation.add(positionTmp);
 | 
												
													
														
															|  | 
 |  |                                     }
 | 
												
													
														
															|  | 
 |  |                                     fenceTmp.put("location",fenceLocation);
 | 
												
													
														
															|  | 
 |  |                                     fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
 | 
												
													
														
															|  | 
 |  |                                     fencesEnables.add(fenceTmp);
 | 
												
													
														
															|  | 
 |  |                                 }
 | 
												
													
														
															|  |                             }
 |  |                             }
 | 
												
													
														
															|  |                             fenceTmp.put("location",fenceLocation);
 |  | 
 | 
												
													
														
															|  |                             fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
 |  | 
 | 
												
													
														
															|  |                             fencesEnables.add(fenceTmp);
 |  | 
 | 
												
													
														
															|  |                          }
 |  | 
 | 
												
													
														
															|  |                      }
 |  | 
 | 
												
													
														
															|  |                      if (fencesEnables.size()>0){
 |  | 
 | 
												
													
														
															|  |                          result.put("fences",fencesEnables);
 |  | 
 | 
												
													
														
															|  |                      }
 |  | 
 | 
												
													
														
															|  |                  }
 |  | 
 | 
												
													
														
															|  |              }
 |  | 
 | 
												
													
														
															|  |             }catch (Exception e){
 |  | 
 | 
												
													
														
															|  |                 e.printStackTrace();
 |  | 
 | 
												
													
														
															|  |                 result.put("location",null);
 |  | 
 | 
												
													
														
															|  | 
 |  |                             if (fencesEnables.size()>0){
 | 
												
													
														
															|  | 
 |  |                                 result.put("fences",fencesEnables);
 | 
												
													
														
															|  | 
 |  |                             }
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }catch (Exception e){
 | 
												
													
														
															|  | 
 |  |                     e.printStackTrace();
 | 
												
													
														
															|  | 
 |  |                     result.put("location",null);
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
 |  | 
 | 
												
													
														
															|  |         if (devicePatientDeviceDos.size()==0){
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |         else{
 |  | 
 | 
												
													
														
															|  |             try {
 |  | 
 | 
												
													
														
															|  |                 JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,devicePatientDeviceDos.get(0).getDeviceSn(),1,null);
 |  | 
 | 
												
													
														
															|  |                 result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
 |  | 
 | 
												
													
														
															|  |                 if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
 |  | 
 | 
												
													
														
															|  |                     result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |                 else {
 |  | 
 | 
												
													
														
															|  |                     result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
 |  | 
 | 
												
													
														
															|  | 
 |  |         if ((StringUtils.isNotBlank(topicItem)&&"preventFall".equals(topicItem))||null==topicItem){
 | 
												
													
														
															|  | 
 |  |             List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
 | 
												
													
														
															|  | 
 |  |             if (devicePatientDeviceDos.size()==0){
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             else{
 | 
												
													
														
															|  | 
 |  |                 try {
 | 
												
													
														
															|  | 
 |  |                     JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,devicePatientDeviceDos.get(0).getDeviceSn(),1,null);
 | 
												
													
														
															|  | 
 |  |                     result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
 | 
												
													
														
															|  | 
 |  |                     result.put("patientAddress",devicePatientDeviceDos.get(0).getSosAddress());
 | 
												
													
														
															|  | 
 |  |                     if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
 | 
												
													
														
															|  | 
 |  |                         result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                     else {
 | 
												
													
														
															|  | 
 |  |                         result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }catch (Exception e){
 | 
												
													
														
															|  | 
 |  |                     e.printStackTrace();
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |             }catch (Exception e){
 |  | 
 | 
												
													
														
															|  |                 e.printStackTrace();
 |  | 
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 |