更新配置
This commit is contained in:
parent
abd12055f9
commit
a87056e2d4
@ -1,18 +1,31 @@
|
||||
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.helper.FirePointSubscribeManager;
|
||||
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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
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
|
||||
public class DispatchFirePointController {
|
||||
@ -24,9 +37,17 @@ public class DispatchFirePointController {
|
||||
private DispatchFirePointService firePointService;
|
||||
@Resource
|
||||
private FirePointSubscribeManager firePointSubscribeManager;
|
||||
@Resource
|
||||
private FirePointOrdinaryDao firePointOrdinaryDao;
|
||||
@Resource
|
||||
private FirePointPreciseDao firePointPreciseDao;
|
||||
@Resource
|
||||
private StreetDao streetDao;
|
||||
private final Locale locale = LocaleContextHolder.getLocale();
|
||||
|
||||
@GetMapping("/debug")
|
||||
public String debug() {
|
||||
|
||||
// List<SysUserEntity> sysUserEntityList = sysUserDao.findAll();
|
||||
// for (SysUserEntity sysUserEntity : sysUserEntityList) {
|
||||
// String addTime = sysUserEntity.getAddTime();
|
||||
@ -49,7 +70,42 @@ public class DispatchFirePointController {
|
||||
// sysUserEntity.setVipTimeRangeJson(serialize);
|
||||
// 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")
|
||||
|
@ -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)
|
||||
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();
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ spring.datasource.hikari.validation-timeout = 3000
|
||||
## Spring Data JPA 配置
|
||||
spring.jpa.database = POSTGRESQL
|
||||
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)
|
||||
spring.jpa.hibernate.ddl-auto = update
|
||||
# 命名策略
|
||||
|
Loading…
Reference in New Issue
Block a user