提交 778e1fe9 authored 作者: zhoushaopan's avatar zhoushaopan

feat(培训人次): 导入excel查询错误的数据

导入excel查询错误的数据
上级 76681b84
...@@ -78,4 +78,9 @@ public class transferController { ...@@ -78,4 +78,9 @@ public class transferController {
biz088DcBranchTrainStatisticsService.fromExcel(filePath); biz088DcBranchTrainStatisticsService.fromExcel(filePath);
return "success"; return "success";
} }
@GetMapping("/queryContent")
public String fromExcelList(String filePath,String id) {
return biz088DcBranchTrainStatisticsService.queryContent(filePath,id);
}
} }
...@@ -9,4 +9,12 @@ public interface Biz088DcBranchTrainStatisticsService { ...@@ -9,4 +9,12 @@ public interface Biz088DcBranchTrainStatisticsService {
* @param filePath * @param filePath
*/ */
void fromExcel(String filePath); void fromExcel(String filePath);
/**
* 查询ID对应的内容
* @param filePath
* @param id
* @return
*/
String queryContent(String filePath, String id);
} }
...@@ -32,9 +32,8 @@ import java.io.IOException; ...@@ -32,9 +32,8 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Date; import java.util.function.Function;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -168,6 +167,43 @@ public class Biz088DcBranchTrainStatisticsImpl implements Biz088DcBranchTrainSta ...@@ -168,6 +167,43 @@ public class Biz088DcBranchTrainStatisticsImpl implements Biz088DcBranchTrainSta
} }
} }
@Override
public String queryContent(String filePath, String id) {
Map<String, BranchTrainStatExcelVO> voMap = new HashMap<>();
//根据文件路径获取文件夹下面的所有的文件
File file = new File(filePath);
File[] files = file.listFiles();
//输出文件数量
log.info("文件数量:{}", files.length);
File newFile ;
//最后统一输出到文件中
try {
newFile = new File(System.getProperty("user.dir")+ File.separator+"error.txt");
if (!newFile.exists()){
newFile.createNewFile();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
for (File file1 : files) {
boolean b = file1.getName().startsWith(".");
if (!b) {
ImportParams importParams = new ImportParams();
importParams.setTitleRows(0);
importParams.setHeadRows(1);
List<BranchTrainStatExcelVO> importedExcel = ExcelImportUtil.importExcel(file1, BranchTrainStatExcelVO.class, importParams);
Map<String, BranchTrainStatExcelVO> map = importedExcel.stream()
.collect(Collectors.toMap(BranchTrainStatExcelVO::getId, Function.identity())
);
voMap.putAll(map);
}
}
log.info("voMap的长度:{}", voMap.size());
return JSON.toJSONString(voMap.get(id));
}
public static void main(String[] args) { public static void main(String[] args) {
String input = "这是一段包含手机号码13512345678的文本,还有另一个号码13998765432。"; String input = "这是一段包含手机号码13512345678的文本,还有另一个号码13998765432。";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论