From cd54841e88ccea2f36f4b691de9110ee0d968238 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Thu, 5 Jan 2023 08:47:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AB=E7=82=B9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 - .../xkrs/controller/FirePointController.java | 61 ------------------- .../service/impl/FirePointServiceImpl.java | 20 ++---- 3 files changed, 5 insertions(+), 77 deletions(-) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index d0970dc..9cd0285 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -38,7 +38,6 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers("/queryFirePoint").permitAll() .antMatchers(HttpMethod.POST, "/api/user/updateSysUser").permitAll() .antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll() - .antMatchers(HttpMethod.GET, "/importThree").permitAll() .antMatchers(HttpMethod.GET, "/selectGlobalConfigValue").permitAll() .antMatchers(HttpMethod.GET, "/selectGlobalConfig").permitAll() .antMatchers(HttpMethod.POST, "/globalConfig").permitAll() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index c6e11ac..c5e7d24 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -66,67 +66,6 @@ public class FirePointController { @Resource private FirePointQueryHelper firePointQueryHelper; - @GetMapping("/importThree") - public String importThree() throws Exception { - String rootDir = "/Users/liuchengqian/Desktop/source_three/"; - ExcelImportUtil importUtil = new ExcelImportUtil(new File(rootDir+"1023.xlsx")); - List> excelMapList = importUtil.readExcelContent(); - //20221024084045098124080 - for (int i = 0; i < excelMapList.size(); i++) { - Map excelMap = excelMapList.get(i); - String 火点监测时间 = excelMap.get("火点监测时间"); - String 经度 = excelMap.get("经度"); - String 纬度 = excelMap.get("纬度"); - String 区县名称 = excelMap.get("区县名称"); - String 地表类型 = excelMap.get("地表类型"); - String 卫星源 = excelMap.get("卫星源"); - String 置信度 = excelMap.get("置信度"); - - FirePointEntity firePointEntity = new FirePointEntity(); - firePointEntity.setFireCode(String.valueOf(System.currentTimeMillis())); - firePointEntity.setSatelliteTime(火点监测时间); - firePointEntity.setLongitude(Double.parseDouble(经度)); - firePointEntity.setLatitude(Double.parseDouble(纬度)); - firePointEntity.setSatelliteType(卫星源); - firePointEntity.setLandType(地表类型); - firePointEntity.setConfidence(置信度); - firePointEntity.setAddTime(火点监测时间); - firePointEntity.setFireType("0"); - firePointEntity.setFireImage(null); - firePointEntity.setSatelliteImage(null); - firePointEntity.setAuditFireType("0");//初始化火点为未审核状态 - try { - bindAddress(firePointEntity); - } catch (Exception e) { - e.printStackTrace(); - log.info("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage()); - } - firePointDao.save(firePointEntity); - Thread.sleep(20); - System.out.println("已完成" + (i) + "/" + excelMapList.size()); - } - - Locale locale = LocaleContextHolder.getLocale(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OKK", locale); - } - private void bindAddress(FirePointEntity firePointEntity) throws Exception { - List locationList = new ArrayList<>(); - locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude()); - GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList); - GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0); - String formattedAddress = reGeoCode.getFormatted_address(); - firePointEntity.setFirePointAddress(formattedAddress); - GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0); - firePointEntity.setCountyCode(addressComponent.getAdcode()); - firePointEntity.setCountyName(addressComponent.getDistrict()); - String townCode = addressComponent.getTowncode(); - String fixedTownCode = townCode.length() > 9 ? townCode.substring(0, 9) : townCode; - firePointEntity.setStreetCode(fixedTownCode); - firePointEntity.setStreetName(addressComponent.getTownship()); - } - - - @GetMapping("/queryzzhd") public String queryzzhd() { List firePointEntities1 = firePointQueryHelper.queryZZHD("371482", "2022-01-01 00:00:10", "2022-06-26 00:00:10"); diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index bb9fc6c..6b9f794 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -115,13 +115,7 @@ public class FirePointServiceImpl implements FirePointService { firePointEntity.setFireImage(firePointQo.getFireImage()); firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage()); firePointEntity.setAuditFireType("0");//初始化火点为未审核状态 - try { - bindAddress(firePointEntity); - } catch (Exception e) { - e.printStackTrace(); - log.info("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage()); - return false; - } + bindAddress(firePointEntity); if (checkDuplicatedData(firePointEntity)) { return false; @@ -234,12 +228,8 @@ public class FirePointServiceImpl implements FirePointService { shanDongFirePoint.setFireImage(firePointQo.getFireImage()); shanDongFirePoint.setSatelliteImage(firePointQo.getSatelliteImage()); shanDongFirePoint.setVerifyState("0"); - try { - bindAddress(shanDongFirePoint); - } catch (Exception e) { - e.printStackTrace(); - System.out.println("添加山东火点信息 逆地理编码请求街道编号失败:" + e.getMessage()); - } + bindAddress(shanDongFirePoint); + if (checkDuplicatedDataX(shanDongFirePoint) || checkDuplicatedData(shanDongFirePoint)) { return false; } @@ -341,7 +331,7 @@ public class FirePointServiceImpl implements FirePointService { /** * 为实体类绑定地址、编号、名称 */ - private void bindAddress(FirePointEntity firePointEntity) throws Exception { + private void bindAddress(FirePointEntity firePointEntity) { List locationList = new ArrayList<>(); locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude()); GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList); @@ -360,7 +350,7 @@ public class FirePointServiceImpl implements FirePointService { /** * 为实体类绑定地址、编号、名称 */ - private void bindAddress(ShanDongFirePointEntity firePointEntity) throws Exception { + private void bindAddress(ShanDongFirePointEntity firePointEntity) { List locationList = new ArrayList<>(); locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude()); GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);