更新脚本

This commit is contained in:
liuchengqian 2023-03-11 11:23:03 +08:00
parent 0d55683533
commit 482dd8243d
2 changed files with 8 additions and 13 deletions

View File

@ -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<Map<String, String>> maps = streetDao.selectProCityPair();
// List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.findAll();
List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.finghjhgfdhjk();
List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime"));
int size = firePointOrdinaryEntityList.size();
List<String> 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);
}

View File

@ -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<FirePointOrdinaryEntity, Long>, JpaSpecificationExecutor<FirePointOrdinaryEntity> {
@Query(value = "SELECT * FROM fire_point_ordinary ORDER BY satellite_time DESC LIMIT 10000", nativeQuery = true)
List<FirePointOrdinaryEntity> finghjhgfdhjk();
}