From 482dd8243d15b6aa51a9760f84a074e1b17fb7f4 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Sat, 11 Mar 2023 11:23:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DispatchFirePointController.java | 15 ++++++++------- .../java/com/xkrs/dao/FirePointOrdinaryDao.java | 6 ------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/xkrs/controller/DispatchFirePointController.java b/src/main/java/com/xkrs/controller/DispatchFirePointController.java index 33573db..6d5af0a 100644 --- a/src/main/java/com/xkrs/controller/DispatchFirePointController.java +++ b/src/main/java/com/xkrs/controller/DispatchFirePointController.java @@ -10,10 +10,10 @@ import com.xkrs.model.entity.FirePointOrdinaryEntity; import com.xkrs.model.qo.AllFirePointQo; import com.xkrs.service.DispatchFirePointService; import com.xkrs.service.impl.FirePointServiceImpl; -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.Sort; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -72,10 +72,11 @@ public class DispatchFirePointController { // } List> maps = streetDao.selectProCityPair(); -// List firePointOrdinaryEntityList = firePointOrdinaryDao.findAll(); - List firePointOrdinaryEntityList = firePointOrdinaryDao.finghjhgfdhjk(); + List firePointOrdinaryEntityList = firePointOrdinaryDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime")); + int size = firePointOrdinaryEntityList.size(); List errorList = new ArrayList<>(); - for (FirePointOrdinaryEntity firePointOrdinaryEntity : firePointOrdinaryEntityList) { + for (int i = 0; i < size; i++) { + FirePointOrdinaryEntity firePointOrdinaryEntity = firePointOrdinaryEntityList.get(i); String countyCode = firePointOrdinaryEntity.getCountyCode(); String proCode = countyCode.substring(0, 2) + "0000"; firePointOrdinaryEntity.setProCode(proCode); @@ -83,11 +84,11 @@ public class DispatchFirePointController { String cityCode = countyCode.substring(0, 4) + "00"; firePointOrdinaryEntity.setCityCode(cityCode); firePointOrdinaryEntity.setCityName(obtainCityName(maps, cityCode)); - if (TextUtils.isEmpty(firePointOrdinaryEntity.getCountyCode()) || TextUtils.isEmpty(firePointOrdinaryEntity.getCountyName()) || TextUtils.isEmpty(firePointOrdinaryEntity.getCityCode()) || TextUtils.isEmpty(firePointOrdinaryEntity.getCityName()) || TextUtils.isEmpty(firePointOrdinaryEntity.getProCode()) || TextUtils.isEmpty(firePointOrdinaryEntity.getProName())) { - errorList.add(firePointOrdinaryEntity.getFireCode()); + firePointOrdinaryDao.save(firePointOrdinaryEntity); + if (i % 100 == 0) { + System.out.println(i + "/" + size); } } - firePointOrdinaryDao.saveAll(firePointOrdinaryEntityList); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, errorList, locale); } diff --git a/src/main/java/com/xkrs/dao/FirePointOrdinaryDao.java b/src/main/java/com/xkrs/dao/FirePointOrdinaryDao.java index 517c83a..8b449d4 100644 --- a/src/main/java/com/xkrs/dao/FirePointOrdinaryDao.java +++ b/src/main/java/com/xkrs/dao/FirePointOrdinaryDao.java @@ -3,14 +3,8 @@ package com.xkrs.dao; import com.xkrs.model.entity.FirePointOrdinaryEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; -import java.util.List; - @Component public interface FirePointOrdinaryDao extends JpaRepository, JpaSpecificationExecutor { - - @Query(value = "SELECT * FROM fire_point_ordinary ORDER BY satellite_time DESC LIMIT 10000", nativeQuery = true) - List finghjhgfdhjk(); }