更新火点的街道编号数据
This commit is contained in:
parent
aa3e6b86e9
commit
b4a5f74a06
@ -69,6 +69,11 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.GET,"/getCityList").permitAll()//根据省编号获取市列表
|
||||
.antMatchers(HttpMethod.GET,"/getCountyList").permitAll()//根据市编号获取区县列表
|
||||
.antMatchers(HttpMethod.GET,"/getStreetList").permitAll()//根据区县编号获取街道列表
|
||||
.antMatchers(HttpMethod.GET,"/api/adm/getProvinceList").permitAll()//获取省列表
|
||||
.antMatchers(HttpMethod.GET,"/api/adm/getCityList").permitAll()//根据省编号获取市列表
|
||||
.antMatchers(HttpMethod.GET,"/api/adm/getCountyList").permitAll()//根据市编号获取区县列表
|
||||
.antMatchers(HttpMethod.GET,"/api/adm/getStreetList").permitAll()//根据区县编号获取街道列表
|
||||
.antMatchers(HttpMethod.GET,"/updateFirePointStreetCode").permitAll()
|
||||
// 所有其它请求需要身份认证
|
||||
.anyRequest().authenticated()
|
||||
.and()
|
||||
|
@ -8,6 +8,8 @@ import com.xkrs.dao.StreetDao;
|
||||
import com.xkrs.model.entity.CityEntity;
|
||||
import com.xkrs.model.entity.CountyEntity;
|
||||
import com.xkrs.model.entity.StreetEntity;
|
||||
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
|
||||
import com.xkrs.utils.GaoDeApiUtil;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -17,6 +19,7 @@ import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -137,4 +140,37 @@ public class StreetController {
|
||||
return "666";
|
||||
}
|
||||
|
||||
@GetMapping("/formatStreetData2")
|
||||
public String formatStreetData2() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
File file = new File("/Users/liuchengqian/Desktop/20200601-20220510火点统计.csv");
|
||||
FileInputStream fileInputStream = IoUtil.toStream(file);
|
||||
BufferedReader reader = IoUtil.getReader(fileInputStream, "UTF-8");
|
||||
Stream<String> lines = reader.lines();
|
||||
// AtomicInteger count = new AtomicInteger();
|
||||
lines.forEach(content -> {
|
||||
try {
|
||||
content = content.replace("\"", "");
|
||||
String[] split = content.split(",");
|
||||
List<String> locationList = new ArrayList<>();
|
||||
locationList.add(split[0]+ "," +split[1]);
|
||||
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
|
||||
String formattedAddress= geocode.getRegeocodes().get(0).getFormatted_address();//getAddressComponent().get(0).getTowncode();
|
||||
stringBuilder.append(content).append(",").append(formattedAddress).append("\n");
|
||||
// if (townCode.length() > 9) {
|
||||
// townCode = townCode.substring(0, 9);
|
||||
// }
|
||||
// System.out.println(townCode);
|
||||
// count.getAndIncrement();
|
||||
// System.out.println(content + " >>> " + count);
|
||||
// stringBuilder.append(content).append(",").append()
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("格式化街道数据时发生异常:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
142
src/main/java/com/xkrs/controller/StreettController.java
Normal file
142
src/main/java/com/xkrs/controller/StreettController.java
Normal file
@ -0,0 +1,142 @@
|
||||
package com.xkrs.controller;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.dao.CityDao;
|
||||
import com.xkrs.dao.CountyDao;
|
||||
import com.xkrs.dao.StreetDao;
|
||||
import com.xkrs.model.entity.CityEntity;
|
||||
import com.xkrs.model.entity.CountyEntity;
|
||||
import com.xkrs.model.entity.StreetEntity;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/adm")
|
||||
public class StreettController {
|
||||
|
||||
@Resource
|
||||
private CityDao cityDao;
|
||||
|
||||
@Resource
|
||||
private CountyDao countyDao;
|
||||
|
||||
@Resource
|
||||
private StreetDao streetDao;
|
||||
|
||||
/**
|
||||
* 获取省列表
|
||||
*/
|
||||
@GetMapping("/getProvinceList")
|
||||
public String getProvinceList() {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<Map<String, String>> provinceList = streetDao.selectProvinceList();
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, provinceList, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据省编号获取市列表
|
||||
*
|
||||
* @param provinceCode 省编号
|
||||
* @return 市列表
|
||||
*/
|
||||
@GetMapping("/getCityList")
|
||||
public String getCityList(@RequestParam("provinceCode") String provinceCode) {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<Map<String, String>> cityList = streetDao.selectCityList(provinceCode);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, cityList, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据市编号获取区县列表
|
||||
*
|
||||
* @param cityCode 市编号
|
||||
* @return 区县列表
|
||||
*/
|
||||
@GetMapping("/getCountyList")
|
||||
public String getCountyList(@RequestParam("cityCode") String cityCode) {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<Map<String, String>> countyList = streetDao.selectCountyList(cityCode);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, countyList, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据区县编号获取街道列表
|
||||
*
|
||||
* @param countyCode 区县编号
|
||||
* @return 街道列表
|
||||
*/
|
||||
@GetMapping("/getStreetList")
|
||||
public String getStreetList(@RequestParam("countyCode") String countyCode) {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<Map<String, String>> streetList = streetDao.selectStreetList(countyCode);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, streetList, locale);
|
||||
}
|
||||
|
||||
@GetMapping("/formatStreetData")
|
||||
public String formatStreetData() {
|
||||
File file = new File("/Users/liuchengqian/Downloads/Administrative-divisions-of-China-master/dist/streets2.csv");
|
||||
FileInputStream fileInputStream = IoUtil.toStream(file);
|
||||
BufferedReader reader = IoUtil.getReader(fileInputStream, "UTF-8");
|
||||
Stream<String> lines = reader.lines();
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
lines.forEach(content -> {
|
||||
try {
|
||||
content = content.replace("\"", "");
|
||||
String[] split = content.split(",");
|
||||
StreetEntity streetEntity = new StreetEntity();
|
||||
streetEntity.setProCode(split[3] + "0000");
|
||||
List<CityEntity> byProCode1 = cityDao.findByProCode(streetEntity.getProCode());
|
||||
if (byProCode1 == null || byProCode1.isEmpty()) {
|
||||
streetEntity.setProName("");
|
||||
} else {
|
||||
streetEntity.setProName(byProCode1.get(0).getProName());
|
||||
}
|
||||
streetEntity.setCityCode(split[4] + "00");
|
||||
List<CountyEntity> byCityCode1 = countyDao.findByCityCode(streetEntity.getCityCode());
|
||||
if (byCityCode1 == null || byCityCode1.isEmpty()) {
|
||||
streetEntity.setCityName("");
|
||||
} else {
|
||||
streetEntity.setCityName(byCityCode1.get(0).getCityName());
|
||||
}
|
||||
streetEntity.setCountyCode(split[2]);
|
||||
List<CountyEntity> byCountyCode = countyDao.findByCountyCode(streetEntity.getCountyCode());
|
||||
if (byCountyCode == null || byCountyCode.isEmpty()) {
|
||||
streetEntity.setCountyName("");
|
||||
} else {
|
||||
streetEntity.setCountyName(byCountyCode.get(0).getCountyName());
|
||||
}
|
||||
streetEntity.setStreetCode(split[0]);
|
||||
streetEntity.setStreetName(split[1]);
|
||||
streetDao.save(streetEntity);
|
||||
count.getAndIncrement();
|
||||
System.out.println(content + " >>> " + count);
|
||||
System.out.println(streetEntity.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("格式化街道数据时发生异常:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
return "666";
|
||||
}
|
||||
|
||||
}
|
@ -153,10 +153,10 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
sysUserEntity.setActiveFlag(0);
|
||||
sysUserEntity.setAccountType("县级");
|
||||
}
|
||||
if (9 == countyCode.length()) {//街道账号5天后过期
|
||||
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
|
||||
} else {//省市区县账号3天后过期
|
||||
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(3L)));
|
||||
if (9 == countyCode.length()) {//街道账号14天后过期
|
||||
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(14L)));
|
||||
} else {//省市区县账号7天后过期
|
||||
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(7L)));
|
||||
}
|
||||
sysUserEntity.setStatusCode(0);
|
||||
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
|
||||
|
@ -5,7 +5,6 @@ spring.datasource.url = jdbc:postgresql://118.24.27.47:5432/fire_point
|
||||
spring.datasource.userName = fire_manage
|
||||
spring.datasource.password = fire456
|
||||
spring.datasource.driverClassName = org.postgresql.Driver
|
||||
|
||||
server.tomcat.uri-encoding=UTF-8
|
||||
|
||||
# 关闭spring data 的redis仓库
|
||||
|
Loading…
Reference in New Issue
Block a user