删除无用代码
This commit is contained in:
parent
d9e1536c2d
commit
13e81b0a80
10
attach.txt
Normal file
10
attach.txt
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
//调用封装好的工具
|
||||
ExcelImportUtil importUtil = new ExcelImportUtil(file);
|
||||
//调用导入的方法,获取sheet表的内容
|
||||
List<Map<String, String>> maps = importUtil.readExcelContent();
|
||||
|
||||
|
||||
FileInputStream fileInputStream = IoUtil.toStream(file);
|
||||
BufferedReader reader = IoUtil.getReader(fileInputStream, "UTF-8");
|
||||
Stream<String> lines = reader.lines();
|
@ -2,7 +2,6 @@ package com.xkrs.common.account;
|
||||
|
||||
import com.xkrs.common.encapsulation.OutputEncapsulation;
|
||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.model.entity.SysUserEntity;
|
||||
import com.xkrs.model.vo.SysUserVo;
|
||||
import com.xkrs.utils.DateTimeUtil;
|
||||
import io.jsonwebtoken.Claims;
|
||||
@ -26,6 +25,7 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
* token认证服务
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
public class TokenAuthenticationService {
|
||||
@ -35,9 +35,7 @@ public class TokenAuthenticationService {
|
||||
/**
|
||||
* 加密密钥
|
||||
*/
|
||||
static public final String SECRET_KEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U303" +
|
||||
"45HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXU" +
|
||||
"JOI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8";
|
||||
static public final String SECRET_KEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U303" + "45HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXU" + "JOI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8";
|
||||
/**
|
||||
* Token前缀
|
||||
*/
|
||||
@ -51,12 +49,12 @@ public class TokenAuthenticationService {
|
||||
|
||||
/**
|
||||
* JWT生成方法
|
||||
*
|
||||
* @param response
|
||||
* @param userName
|
||||
* @param authorities
|
||||
*/
|
||||
static void addAuthentication(HttpServletResponse response, String userName,
|
||||
Collection<? extends GrantedAuthority> authorities, SysUserVo sysUserEntity, Map map1) {
|
||||
static void addAuthentication(HttpServletResponse response, String userName, Collection<? extends GrantedAuthority> authorities, SysUserVo sysUserEntity, Map map1) {
|
||||
|
||||
Locale locale = new Locale("zh", "CN");
|
||||
Map map = new HashMap(3);
|
||||
@ -67,7 +65,7 @@ public class TokenAuthenticationService {
|
||||
}
|
||||
authsList = auths.toString();
|
||||
if (authsList.length() > 1) {
|
||||
authsList=authsList.substring(1,authsList.length());
|
||||
authsList = authsList.substring(1);
|
||||
} else {
|
||||
logger.warn(userName + " has no permission!");
|
||||
}
|
||||
@ -82,17 +80,13 @@ public class TokenAuthenticationService {
|
||||
final long EXPIRATIONTIME = 60 * 60 * (duration.toDays() + 1) * 24_000;
|
||||
|
||||
// 生成JWT
|
||||
String jwt = Jwts.builder()
|
||||
.setSubject(userName)
|
||||
.setIssuer("https://www.microservice.com")
|
||||
.setAudience(userName)
|
||||
String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName)
|
||||
// 保存权限
|
||||
.claim("auths", authsList)
|
||||
// 有效期设置
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||
// 签名设置
|
||||
.signWith(key)
|
||||
.compact();
|
||||
.signWith(key).compact();
|
||||
map.put("token", jwt);
|
||||
map.put("user", sysUserEntity);
|
||||
map.put("cityAndCounty", map1);
|
||||
@ -103,17 +97,13 @@ public class TokenAuthenticationService {
|
||||
final long EXPIRATIONTIME = 21_600_000;
|
||||
|
||||
// 生成JWT
|
||||
String jwt = Jwts.builder()
|
||||
.setSubject(userName)
|
||||
.setIssuer("https://www.microservice.com")
|
||||
.setAudience(userName)
|
||||
String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName)
|
||||
// 保存权限
|
||||
.claim("auths", authsList)
|
||||
// 有效期设置
|
||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||
// 签名设置
|
||||
.signWith(key)
|
||||
.compact();
|
||||
.signWith(key).compact();
|
||||
map.put("token", jwt);
|
||||
map.put("user", sysUserEntity);
|
||||
map.put("cityAndCounty", map1);
|
||||
@ -122,8 +112,7 @@ public class TokenAuthenticationService {
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = response.getWriter();
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
@ -132,6 +121,7 @@ public class TokenAuthenticationService {
|
||||
|
||||
/**
|
||||
* JWT验证方法
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ -141,11 +131,9 @@ public class TokenAuthenticationService {
|
||||
if (token != null) {
|
||||
try {
|
||||
// 解析 Token
|
||||
Claims claims = Jwts.parserBuilder()
|
||||
.setSigningKey(key).build()
|
||||
Claims claims = Jwts.parserBuilder().setSigningKey(key).build()
|
||||
// 去掉 Bearer
|
||||
.parseClaimsJws(token.replace(TOKEN_PREFIX, ""))
|
||||
.getBody();
|
||||
.parseClaimsJws(token.replace(TOKEN_PREFIX, "")).getBody();
|
||||
// 获取用户名
|
||||
String userName = claims.getSubject();
|
||||
// 获取权限
|
||||
|
@ -58,7 +58,6 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
.antMatchers(HttpMethod.GET, "/api/user/verificationCode").permitAll()
|
||||
.antMatchers(HttpMethod.POST, "/uploadFileMore").permitAll()
|
||||
.antMatchers(HttpMethod.POST, "/uploadFile").permitAll()
|
||||
.antMatchers(HttpMethod.POST, "/importCityExcel").permitAll()
|
||||
.antMatchers(HttpMethod.POST, "/deleteShuiTi").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/selectBeijing").permitAll()
|
||||
.antMatchers(HttpMethod.GET, "/api/user/verificationCodeUpdate").permitAll()
|
||||
|
@ -372,21 +372,6 @@ public class FirePointController {
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入全国省市区
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/importCityExcel")
|
||||
public String importCityExcel(MultipartFile file) throws Exception {
|
||||
// 获取区域信息
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
firePointService.importCityExcel(file);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "导入成功", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除水体类型的火点信息
|
||||
*
|
||||
|
@ -1,30 +1,18 @@
|
||||
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 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;
|
||||
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.ArrayList;
|
||||
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;
|
||||
|
||||
@ -93,84 +81,4 @@ public class StreetController {
|
||||
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";
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -122,14 +122,6 @@ public interface FirePointService {
|
||||
*/
|
||||
List<Map<String, Object>> selectCountyName(String code);
|
||||
|
||||
/**
|
||||
* 导入全国省市区
|
||||
*
|
||||
* @param file
|
||||
* @throws Exception
|
||||
*/
|
||||
void importCityExcel(MultipartFile file) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新火点的街道编号数据
|
||||
*
|
||||
|
@ -32,7 +32,6 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
import static com.xkrs.utils.DateTimeUtil.dateTimeToString;
|
||||
@ -767,34 +766,6 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
return countyDao.selectCountyName(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入全国省市区
|
||||
*
|
||||
* @param file
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(rollbackOn = Exception.class)
|
||||
@Override
|
||||
public void importCityExcel(MultipartFile file) throws Exception {
|
||||
//调用封装好的工具
|
||||
ExcelImportUtil importUtil = new ExcelImportUtil(file);
|
||||
//调用导入的方法,获取sheet表的内容
|
||||
List<Map<String, String>> maps = importUtil.readExcelContent();
|
||||
//导入订单详情表
|
||||
List<Nationwide> orderDetails = maps.stream().filter(Objects::nonNull).map(map -> {
|
||||
Nationwide nationwide = new Nationwide();
|
||||
nationwide.setProName(map.get("pro_name"));
|
||||
nationwide.setProCode(map.get("pro_code"));
|
||||
nationwide.setCityName(map.get("city_name"));
|
||||
nationwide.setCityCode(map.get("city_code"));
|
||||
nationwide.setCountyName(map.get("town_name"));
|
||||
nationwide.setCountyCode(map.get("town_code"));
|
||||
return nationwide;
|
||||
}).collect(Collectors.toList());
|
||||
//批量添加到订单详情
|
||||
nationwideDao.saveAll(orderDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新火点的街道编号数据
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user