| 
					
				 | 
			
			
				@ -4,10 +4,7 @@ package com.yihu.jw.care.service.device; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.serializer.SerializerFeature; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.config.AqgConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.BaseSleepPlanDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.DeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.DeviceDetailDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.PatientDeviceDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.dao.device.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.assistance.EmergencyAssistanceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.contacts.ContactsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.care.service.security.SecurityMonitoringOrderService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -18,10 +15,7 @@ import com.yihu.jw.care.util.MyJdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.doctor.dao.BaseDoctorDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.doctor.BaseDoctorDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.base.patient.BasePatientDO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.BaseSleepPlan; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.Device; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DeviceDetail; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.DevicePatientDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.entity.care.device.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.patient.dao.BasePatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.restmodel.ResponseContant; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.jw.util.common.GpsUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -119,6 +113,9 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private SecurityMonitoringOrderService securityMonitoringOrderService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private CountDistance countDistance; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PatientSafeAreaDao safeAreaDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @PostConstruct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        relations.put(0, "其他"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -391,7 +388,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String , Object>> findDeviceFromAdmin(String patientName, int page, int pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public List<Map<String , Object>> findDeviceFromAdmin(String doctor,String patientName, int page, int pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "select Distinct p.id,p.`name`,dd.photo,pd.device_id deviceId,pd.category_code categoryCode,pd.device_name deviceName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " pd.device_sn deviceSn,pd.czrq,pd.doctor,pd.doctor_name doctorName,pd.agent,pd.agent_name agentName " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " from wlyy_patient_device pd,wlyy_devices wd,base_patient p,dm_device dd where p.id = pd.`user`  and pd.del = 0 " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -399,6 +396,12 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(patientName)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " AND (p.`name` LIKE '%" + patientName +"%' or  p.idcard LIKE '%" + patientName + "%') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(doctor)){//著老远查看时之查看签约居民的绑定 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sql += " and EXISTS (SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r,base_team_member m " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " WHERE sr.patient = p.id and sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    " and m.doctor_code = '"+doctor+"' and m.del = '1') "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        sql += " ORDER BY pd.czrq DESC LIMIT "+ (page-1)*pageSize +" , " + pageSize + " "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return list; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1005,7 +1008,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        day = DateUtil.getStringDateShort(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 电子围栏 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    devInfoObj.put("safeAreaGz", securityMonitoringOrderService.getElectronicFence(deviceSn)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    devInfoObj.put("safeAreaGz", securityMonitoringOrderService.getElectronicFence(device.getUser())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 行动轨迹 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    devInfoObj.put("actionTrack", securityMonitoringOrderService.getActionTrack(deviceSn,day)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //当前定位 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1032,7 +1035,11 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    devInfoObj.put("currentLon",lon);       //当前定位 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    double dulat =Double.parseDouble(lat); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    double dulon = Double.parseDouble(lon); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String safeArea = device.getSafeAreaGz(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(device.getUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String safeArea=null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (safeAreaDOS.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        safeArea = safeAreaDOS.get(0).getSafeAreaGz(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String[] safeAreas = safeArea.split(";"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (String area:safeAreas){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1068,9 +1075,9 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param deviceSn 设备sn码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONObject getPatientDeviceData(String patient,String deviceSn,Integer page,Integer pageSize)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getPatientDeviceData(String patient,String deviceSn,Integer page,Integer pageSize)throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = page>0?page-1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        com.alibaba.fastjson.JSONObject result = new com.alibaba.fastjson.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (devices.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DevicePatientDevice device = devices.get(0); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1097,7 +1104,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONObject getHealthIndex(com.alibaba.fastjson.JSONObject result,Integer type,String deviceSn,String patient,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getHealthIndex(JSONObject result,Integer type,String deviceSn,String patient,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        page = page>0?page-1:0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Long count =0l; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PageRequest pageRequest = new PageRequest(page, pageSize); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1188,7 +1195,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                re.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    re.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            result.put("dataList",re); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1199,7 +1206,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONObject getEmeWarn(com.alibaba.fastjson.JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public JSONObject getEmeWarn(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sqlCount = "select SUM(total) from( \n" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "select count(ord.id) as total from base_emergency_assistance_order ord  where ord.device_sn='"+deviceSn+"' " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1351,54 +1358,89 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONObject updateDeviceFenceArea(String deviceSn,Integer fenceNO,String enable,String name,String freq, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String updateDeviceFenceArea(String patient,String deviceSn,Integer fenceNO,String enable,String name,String freq, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                 String time_begin,String time_end,String safe_area ,String clear) throws Exception{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String url =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("16".equals(devices.get(0).getCategoryCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DevicePatientDevice patientDevice = devices.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(safe_area)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientDevice.setSafeAreaGz(safe_area); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientDeviceDao.save(patientDevice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                object.put("success",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return object; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (devices.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                DevicePatientDevice deviceTmp = devices.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("4".equals(deviceTmp.getCategoryCode())||"16".equals(deviceTmp.getCategoryCode())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patient = deviceTmp.getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if ("4".equals(devices.get(0).getCategoryCode())){//手表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Device device = deviceDao.findOne(devices.get(0).getDeviceId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (device!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if ("X1".equals(device.getModel())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    url = MessageFormat.format(AqgConfig.X1fence_area, deviceSn,fenceNO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DevicePatientDevice> devices = patientDeviceDao.findAllByUserAndCategoryCode(patient,"4"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientSafeAreaDO safeAreaDO = new PatientSafeAreaDO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 1删除 空修改或删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (safeAreaDOS.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO = safeAreaDOS.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setSuccessFlag(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(clear)) {//删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDao.deleteByPatient(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            else{//新增或修改 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setSafeAreaGz(safe_area); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setUpdateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setSuccessFlag(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            url = MessageFormat.format(AqgConfig.S3fence_area, deviceSn,fenceNO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        MultiValueMap<String, String> param = new LinkedMultiValueMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(StringUtils.isBlank(clear)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isNotBlank(safe_area)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String[] position = safe_area.split(";"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safe_area = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (String tmp:position){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String[] point = tmp.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    safe_area+= gpsUtil.bd09_To_Gcj02_str(Double.parseDouble(point[1]),Double.parseDouble(point[0]))+";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (devices.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DevicePatientDevice patientDevice = devices.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String deviceSnTmp = patientDevice.getDeviceSn(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String url =""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("4".equals(devices.get(0).getCategoryCode())){//手表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Device device = deviceDao.findOne(devices.get(0).getDeviceId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (device!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if ("X1".equals(device.getModel())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        url = MessageFormat.format(AqgConfig.X1fence_area, deviceSnTmp,fenceNO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                url = MessageFormat.format(AqgConfig.S3fence_area, deviceSnTmp,fenceNO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            MultiValueMap<String, String> param = new LinkedMultiValueMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(StringUtils.isBlank(clear)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotBlank(safe_area)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    String[] position = safe_area.split(";"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    safe_area = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (String tmp:position){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        String[] point = tmp.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        safe_area+= gpsUtil.bd09_To_Gcj02_str(Double.parseDouble(point[1]),Double.parseDouble(point[0]))+";"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("name", name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("freq", freq); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("enable",enable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("time_begin", time_begin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("time_end", time_end); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("safe_area", safe_area); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                param.add("clear",clear); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject responseObj = response.getBody(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (responseObj.getBoolean("success")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDO.setSuccessFlag(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new Exception("安全区域设置失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isBlank(clear)&&StringUtils.isNotBlank(patient)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                safeAreaDao.save(safeAreaDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("name", name); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("freq", freq); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("enable",enable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("time_begin", time_begin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("time_end", time_end); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("safe_area", safe_area); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            param.add("clear",clear); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return response.getBody(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "success"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 |