From 60aae894f78fd8e47959c185cbafd72bf23b7269 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Mon, 2 Dec 2024 17:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=A4=A9=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E5=8F=8D=E6=9F=A5=E5=A1=AB=E8=A1=A5=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= 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 | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 374cd60..14595df 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -35,6 +35,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.OPTIONS).permitAll() .antMatchers("/global/configuration/**").permitAll() .antMatchers("/push/**").permitAll() + .antMatchers("/debug").permitAll() .antMatchers("/queryFirePoint").permitAll() .antMatchers("/queryNotice").permitAll()//查询通知 .antMatchers(HttpMethod.POST, "/api/user/updateSysUser").permitAll() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index a5114c4..59a00c1 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -11,14 +11,17 @@ import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.AuditFireTypeQo; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo; +import com.xkrs.model.vo.TianDiTuGeocodeVo; import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; import com.xkrs.service.impl.FirePointServiceImpl; import com.xkrs.utils.FirePointQueryHelper; +import com.xkrs.utils.TianDiTuApiUtil; import org.apache.hc.core5.util.TextUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.web.bind.annotation.*; @@ -94,6 +97,50 @@ public class FirePointController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale); } + @GetMapping("/debug") + public String debug() { + //使用天地图反查填补历史数据-start + System.out.println("开始解析"); + while (true) { + //查询未审核的普通火点 + Specification specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> { + List predicateList = new ArrayList<>(); + predicateList.add(criteriaBuilder.isNull(root.get("streetCode").as(String.class))); + predicateList.add(criteriaBuilder.equal(root.get("streetCode").as(String.class), "")); + predicateList.add(criteriaBuilder.isNull(root.get("streetName").as(String.class))); + predicateList.add(criteriaBuilder.equal(root.get("streetName").as(String.class), "")); + predicateList.add(criteriaBuilder.isNull(root.get("firePointAddress").as(String.class))); + predicateList.add(criteriaBuilder.equal(root.get("firePointAddress").as(String.class), "")); + return criteriaBuilder.or(predicateList.toArray(new Predicate[predicateList.size()])); + }; + //未审核的普通火点列表 + PageRequest pageRequest = PageRequest.of(1, 1000, Sort.by(Sort.Direction.DESC, "satelliteTime")); + List list = firePointDao.findAll(specificationOrdinary, pageRequest).getContent(); + if (list.isEmpty()) { + break; + } + for (FirePointEntity item : list) { + try { + TianDiTuGeocodeVo geocode = TianDiTuApiUtil.geocode(item.getLongitude(), item.getLatitude()); + TianDiTuGeocodeVo.ResultDTO.AddressComponentDTO addressComponent = geocode.result.addressComponent; + item.setFirePointAddress(geocode.result.formattedAddress); + item.setCountyCode(addressComponent.countyCode.substring(3, 9)); + item.setCountyName(addressComponent.county); + item.setStreetCode(addressComponent.townCode.substring(3, 12)); + item.setStreetName(addressComponent.town); + firePointDao.saveAndFlush(item); + System.out.println("解析成功"); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("解析失败" + item.getId()); + } + } + } + //使用天地图反查填补历史数据-end + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OKKKK", locale); + } + + /** * 添加火点数据 *