更新配置

This commit is contained in:
liuchengqian 2023-03-10 11:58:07 +08:00
parent abd12055f9
commit a87056e2d4
3 changed files with 61 additions and 2 deletions

View File

@ -1,18 +1,31 @@
package com.xkrs.controller; package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.FirePointOrdinaryDao;
import com.xkrs.dao.FirePointPreciseDao;
import com.xkrs.dao.StreetDao;
import com.xkrs.dao.SysUserDao; import com.xkrs.dao.SysUserDao;
import com.xkrs.helper.FirePointSubscribeManager; import com.xkrs.helper.FirePointSubscribeManager;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.qo.AllFirePointQo; import com.xkrs.model.qo.AllFirePointQo;
import com.xkrs.service.DispatchFirePointService; import com.xkrs.service.DispatchFirePointService;
import com.xkrs.service.impl.FirePointServiceImpl; import com.xkrs.service.impl.FirePointServiceImpl;
import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
@RestController @RestController
public class DispatchFirePointController { public class DispatchFirePointController {
@ -24,9 +37,17 @@ public class DispatchFirePointController {
private DispatchFirePointService firePointService; private DispatchFirePointService firePointService;
@Resource @Resource
private FirePointSubscribeManager firePointSubscribeManager; private FirePointSubscribeManager firePointSubscribeManager;
@Resource
private FirePointOrdinaryDao firePointOrdinaryDao;
@Resource
private FirePointPreciseDao firePointPreciseDao;
@Resource
private StreetDao streetDao;
private final Locale locale = LocaleContextHolder.getLocale();
@GetMapping("/debug") @GetMapping("/debug")
public String debug() { public String debug() {
// List<SysUserEntity> sysUserEntityList = sysUserDao.findAll(); // List<SysUserEntity> sysUserEntityList = sysUserDao.findAll();
// for (SysUserEntity sysUserEntity : sysUserEntityList) { // for (SysUserEntity sysUserEntity : sysUserEntityList) {
// String addTime = sysUserEntity.getAddTime(); // String addTime = sysUserEntity.getAddTime();
@ -49,7 +70,42 @@ public class DispatchFirePointController {
// sysUserEntity.setVipTimeRangeJson(serialize); // sysUserEntity.setVipTimeRangeJson(serialize);
// sysUserDao.save(sysUserEntity); // sysUserDao.save(sysUserEntity);
// } // }
return "OKkkkkkkk";
List<Map<String, String>> maps = streetDao.selectProCityPair();
List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.findAll();
List<String> errorList = new ArrayList<>();
for (FirePointOrdinaryEntity firePointOrdinaryEntity : firePointOrdinaryEntityList) {
String countyCode = firePointOrdinaryEntity.getCountyCode();
String proCode = countyCode.substring(0, 2) + "0000";
firePointOrdinaryEntity.setProCode(proCode);
firePointOrdinaryEntity.setProName(obtainProName(maps, proCode));
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.saveAll(firePointOrdinaryEntityList);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, errorList, locale);
}
private String obtainProName(List<Map<String, String>> maps, String proCode) {
for (Map<String, String> map : maps) {
if (map.get("pro_code").equals(proCode)) {
return map.get("pro_name");
}
}
return null;
}
private String obtainCityName(List<Map<String, String>> maps, String cityCode) {
for (Map<String, String> map : maps) {
if (map.get("city_code").equals(cityCode)) {
return map.get("city_name");
}
}
return null;
} }
@GetMapping("/autoSync") @GetMapping("/autoSync")

View File

@ -39,4 +39,7 @@ public interface StreetDao extends JpaRepository<StreetEntity, Integer>, JpaSpec
@Query(value = "SELECT DISTINCT t.street_code AS code, t.street_name AS name FROM street AS t WHERE t.county_code = ?1", nativeQuery = true) @Query(value = "SELECT DISTINCT t.street_code AS code, t.street_name AS name FROM street AS t WHERE t.county_code = ?1", nativeQuery = true)
List<Map<String, String>> selectStreetList(String countyCode); List<Map<String, String>> selectStreetList(String countyCode);
@Query(value = "SELECT t.pro_code, t.pro_name, t.city_code, t.city_name FROM street AS t group by pro_code, pro_name, city_code, city_name", nativeQuery = true)
List<Map<String, String>> selectProCityPair();
} }

View File

@ -23,7 +23,7 @@ spring.datasource.hikari.validation-timeout = 3000
## Spring Data JPA 配置 ## Spring Data JPA 配置
spring.jpa.database = POSTGRESQL spring.jpa.database = POSTGRESQL
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql = true spring.jpa.show-sql = false
# 指定 ddl mode (none, validate, create, create-drop, update) # 指定 ddl mode (none, validate, create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update spring.jpa.hibernate.ddl-auto = update
# 命名策略 # 命名策略