|  | @ -13,6 +13,7 @@ import com.yihu.jw.care.service.contacts.ContactsService;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.util.ConcealUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.util.CountDistance;
 | 
	
		
			
				|  |  | import com.yihu.jw.care.util.MyJdbcTemplate;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
	
		
			
				|  | @ -25,6 +26,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.ResponseContant;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.GpsUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.LatitudeUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.entity.ServiceException;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.healthIndex.HealthIndexUtil;
 | 
	
	
		
			
				|  | @ -115,7 +117,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
 | 
	
		
			
				|  |  |     private EmergencyAssistanceService emergencyAssistanceService;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private SecurityMonitoringOrderService securityMonitoringOrderService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private CountDistance countDistance;
 | 
	
		
			
				|  |  |     @PostConstruct
 | 
	
		
			
				|  |  |     public void init() {
 | 
	
		
			
				|  |  |         relations.put(0, "其他");
 | 
	
	
		
			
				|  | @ -1002,6 +1005,47 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
 | 
	
		
			
				|  |  |                     devInfoObj.put("safeAreaGz", securityMonitoringOrderService.getElectronicFence(deviceSn));
 | 
	
		
			
				|  |  |                     // 行动轨迹
 | 
	
		
			
				|  |  |                     devInfoObj.put("actionTrack", securityMonitoringOrderService.getActionTrack(deviceSn));
 | 
	
		
			
				|  |  |                     //当前定位
 | 
	
		
			
				|  |  |                     List<Map<String , Object>> newList = securityMonitoringOrderService.getNewList(deviceSn,day);
 | 
	
		
			
				|  |  |                     String lat = "";
 | 
	
		
			
				|  |  |                     String lon = "";
 | 
	
		
			
				|  |  |                     if (newList.size() > 0) {
 | 
	
		
			
				|  |  |                         lat = (String) newList.get(0).get("lat");
 | 
	
		
			
				|  |  |                         lon = (String) newList.get(0).get("lon");
 | 
	
		
			
				|  |  |                         devInfoObj.put("currentPositioning", LatitudeUtils.getLocationAddress(lat,lon));    //当前定位
 | 
	
		
			
				|  |  |                     } else {  //当前地址为null,则获取居民坐标
 | 
	
		
			
				|  |  |                         newList = securityMonitoringOrderService.getPatientLatLon(deviceSn);
 | 
	
		
			
				|  |  |                         String safeArea = (String) newList.get(0).get("lat_lon");
 | 
	
		
			
				|  |  |                         String[] safeAreas = safeArea.split(";");
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  |                         for (String area:safeAreas){
 | 
	
		
			
				|  |  |                             String[] areaPoint = area.split(",");
 | 
	
		
			
				|  |  |                             lat = areaPoint[0];
 | 
	
		
			
				|  |  |                             lon = areaPoint[1];
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     devInfoObj.put("currentPositioning",LatitudeUtils.getLocationAddress(lat,lon));       //当前定位
 | 
	
		
			
				|  |  |                     double dulat =Double.parseDouble(lat);
 | 
	
		
			
				|  |  |                     double dulon = Double.parseDouble(lon);
 | 
	
		
			
				|  |  |                     String safeArea = device.getSafeAreaGz();
 | 
	
		
			
				|  |  |                     String[] safeAreas = safeArea.split(";");
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  |                     for (String area:safeAreas){
 | 
	
		
			
				|  |  |                         String[] areaPoint = area.split(",");
 | 
	
		
			
				|  |  |                         com.alibaba.fastjson.JSONObject positionTmp = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |                         Double areaLon = Double.parseDouble( areaPoint[0]);
 | 
	
		
			
				|  |  |                         Double areaLat = Double.parseDouble( areaPoint[1]);
 | 
	
		
			
				|  |  | //                                com.alibaba.fastjson.JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
 | 
	
		
			
				|  |  |                         positionTmp.put("lat",areaLat);
 | 
	
		
			
				|  |  |                         positionTmp.put("lon",areaLon);
 | 
	
		
			
				|  |  |                         fenceLocation.add(positionTmp);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (!countDistance.isInPolygon(dulon,dulat,fenceLocation)){
 | 
	
		
			
				|  |  | //                        orderUtil.createSecurityOrder(sn,null,null,8,"1","yslkaqqy",null);
 | 
	
		
			
				|  |  |                         devInfoObj.put("isTrueFalse","已超出围栏范围");
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         devInfoObj.put("isTrueFalse","未超出围栏范围");
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     break;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | //        }
 |