|
@@ -33,9 +33,11 @@ public class ReadFileNameTest {
|
|
|
@Autowired
|
|
|
private IExamInfoService examInfoService;
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 用于通过文件夹导出考场下的视频信息
|
|
|
+ */
|
|
|
@Test
|
|
|
- public void test() {
|
|
|
+ public void test() {
|
|
|
String folderPath = "H:/河南省"; // 替换为你的文件夹路径
|
|
|
String excelFilePath = "H:/file.xlsx"; // 替换为你的Excel文件路径
|
|
|
|
|
@@ -84,167 +86,139 @@ public class ReadFileNameTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void traverseFolders(File folder, Sheet sheet, int rowIndex) {
|
|
|
- String province = folder.getName();
|
|
|
- String provinceId = "41";
|
|
|
- String city = null;
|
|
|
- String cityId = null;
|
|
|
- String county = null;
|
|
|
- String countyId = null;
|
|
|
- String exam = null;
|
|
|
-
|
|
|
- String video = null;
|
|
|
- if (folder.isDirectory()) {
|
|
|
- File[] files = folder.listFiles();
|
|
|
- for (int i = 0; i < files.length; i++) { //市级
|
|
|
- // System.out.println(files[i].getName());
|
|
|
- city = files[i].getName();
|
|
|
- List<DictCity> dictCityList = dictCityService.getDictCityByName(city);
|
|
|
-
|
|
|
- for (int j = 0; j < dictCityList.size(); j++) {
|
|
|
- cityId = dictCityList.get(j).getCode();
|
|
|
- if(cityId.startsWith("41")){
|
|
|
- break;
|
|
|
- }
|
|
|
+ private void traverseFolders(File folder, Sheet sheet, int rowIndex) {
|
|
|
+ String province = folder.getName();
|
|
|
+ String provinceId = "41";
|
|
|
+ String city = null;
|
|
|
+ String cityId = null;
|
|
|
+ String county = null;
|
|
|
+ String countyId = null;
|
|
|
+ String exam = null;
|
|
|
+
|
|
|
+ String video = null;
|
|
|
+ if (folder.isDirectory()) {
|
|
|
+ File[] files = folder.listFiles();
|
|
|
+ for (int i = 0; i < files.length; i++) { //市级
|
|
|
+ // System.out.println(files[i].getName());
|
|
|
+ city = files[i].getName();
|
|
|
+ List<DictCity> dictCityList = dictCityService.getDictCityByName(city);
|
|
|
+
|
|
|
+ for (int j = 0; j < dictCityList.size(); j++) {
|
|
|
+ cityId = dictCityList.get(j).getCode();
|
|
|
+ if (cityId.startsWith("41")) {
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- if(files[i].isDirectory()) {
|
|
|
- File[] files2 = files[i].listFiles();
|
|
|
- for (int j = 0; j < files2.length; j++) { //区级
|
|
|
- // System.out.println(" "+files2[j].getName());
|
|
|
- county = files2[j].getName();
|
|
|
- List<DictCity> dictCity2List = dictCityService.getDictCityByName(county);
|
|
|
+ if (files[i].isDirectory()) {
|
|
|
+ File[] files2 = files[i].listFiles();
|
|
|
+ for (int j = 0; j < files2.length; j++) { //区级
|
|
|
+ // System.out.println(" "+files2[j].getName());
|
|
|
+ county = files2[j].getName();
|
|
|
+ List<DictCity> dictCity2List = dictCityService.getDictCityByName(county);
|
|
|
|
|
|
- for (int x = 0; x < dictCity2List.size(); x++) {
|
|
|
- countyId = dictCity2List.get(x).getCode();
|
|
|
- if(countyId.startsWith(cityId)){
|
|
|
- break;
|
|
|
- }
|
|
|
+ for (int x = 0; x < dictCity2List.size(); x++) {
|
|
|
+ countyId = dictCity2List.get(x).getCode();
|
|
|
+ if (countyId.startsWith(cityId)) {
|
|
|
+ break;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if(files2[j].isDirectory()) {
|
|
|
- File[] files3 = files2[j].listFiles();
|
|
|
- for (int k = 0; k < files3.length; k++) { //考场
|
|
|
- // System.out.println(" "+files3[k].getName());
|
|
|
- exam = files3[k].getName();
|
|
|
- ExamInfo examInfo = new ExamInfo();
|
|
|
- examInfo.setName(exam);
|
|
|
- ExamInfo examInfo2 = null;
|
|
|
- List<ExamInfo> list = examInfoService.selectOldExamInfoList(examInfo);
|
|
|
- if(list!=null && list.size()>0) {
|
|
|
- examInfo2 = list.get(0);
|
|
|
- }
|
|
|
- if(files3[k].isDirectory()){
|
|
|
- File[] files4 = files3[k].listFiles();
|
|
|
- for (int l = 0; l < files4.length; l++) {
|
|
|
- // System.out.println(" "+files4[l].getName());
|
|
|
- video = files4[l].getName();
|
|
|
- video = video.substring(0,video.indexOf("."));
|
|
|
- //写入excel
|
|
|
- Row row = sheet.createRow(rowIndex);
|
|
|
- row.createCell(0).setCellValue("");
|
|
|
- row.createCell(1).setCellValue(video);
|
|
|
-
|
|
|
- if (video.indexOf("试看")>=0) {
|
|
|
- row.createCell(2).setCellValue(1);
|
|
|
- } else if (video.indexOf("1")>=0){
|
|
|
- row.createCell(2).setCellValue(1+1);
|
|
|
- } else if (video.indexOf("2")>=0) {
|
|
|
- row.createCell(2).setCellValue(2+1);
|
|
|
- } else if (video.indexOf("3")>=0) {
|
|
|
- row.createCell(2).setCellValue(3+1);
|
|
|
- } else if (video.indexOf("4")>=0) {
|
|
|
- row.createCell(2).setCellValue(4+1);
|
|
|
- } else if (video.indexOf("5")>=0) {
|
|
|
- row.createCell(2).setCellValue(5+1);
|
|
|
- } else if (video.indexOf("6")>=0) {
|
|
|
- row.createCell(2).setCellValue(6+1);
|
|
|
- } else if (video.indexOf("7")>=0) {
|
|
|
- row.createCell(2).setCellValue(7+1);
|
|
|
- } else if (video.indexOf("A")>=0) {
|
|
|
- row.createCell(2).setCellValue(1+1);
|
|
|
- } else if (video.indexOf("B")>=0) {
|
|
|
- row.createCell(2).setCellValue(2+1);
|
|
|
- } else if (video.indexOf("C")>=0) {
|
|
|
- row.createCell(2).setCellValue(3+1);
|
|
|
- } else if (video.indexOf("D")>=0) {
|
|
|
- row.createCell(2).setCellValue(4+1);
|
|
|
- } else if (video.indexOf("E")>=0) {
|
|
|
- row.createCell(2).setCellValue(5+1);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- row.createCell(3).setCellValue("");
|
|
|
- row.createCell(4).setCellValue("");
|
|
|
- row.createCell(5).setCellValue("3");
|
|
|
- row.createCell(6).setCellValue("1");
|
|
|
- row.createCell(7).setCellValue("1");
|
|
|
- row.createCell(8).setCellValue(provinceId);
|
|
|
- row.createCell(9).setCellValue(province);
|
|
|
- row.createCell(10).setCellValue(cityId);
|
|
|
- row.createCell(11).setCellValue(city);
|
|
|
- row.createCell(12).setCellValue(countyId);
|
|
|
- row.createCell(13).setCellValue(county);
|
|
|
- row.createCell(14).setCellValue("");
|
|
|
- row.createCell(15).setCellValue("");
|
|
|
- if(examInfo2!=null) {
|
|
|
- row.createCell(16).setCellValue(examInfo2.getId());
|
|
|
- row.createCell(17).setCellValue(examInfo2.getName());
|
|
|
- } else {
|
|
|
- row.createCell(16).setCellValue("");
|
|
|
- row.createCell(17).setCellValue("");
|
|
|
- }
|
|
|
- if (video.indexOf("试看")>=0) {
|
|
|
- row.createCell(18).setCellValue("1");
|
|
|
- } else {
|
|
|
- row.createCell(18).setCellValue("2");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- System.out.println(province+" "+city+" "+county+" "+exam+" "+video);
|
|
|
- rowIndex++;
|
|
|
+ if (files2[j].isDirectory()) {
|
|
|
+ File[] files3 = files2[j].listFiles();
|
|
|
+ for (int k = 0; k < files3.length; k++) { //考场
|
|
|
+ // System.out.println(" "+files3[k].getName());
|
|
|
+ exam = files3[k].getName();
|
|
|
+ ExamInfo examInfo = new ExamInfo();
|
|
|
+ examInfo.setName(exam);
|
|
|
+ ExamInfo examInfo2 = null;
|
|
|
+ List<ExamInfo> list = examInfoService.selectOldExamInfoList(examInfo);
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ examInfo2 = list.get(0);
|
|
|
+ }
|
|
|
+ if (files3[k].isDirectory()) {
|
|
|
+ File[] files4 = files3[k].listFiles();
|
|
|
+ for (int l = 0; l < files4.length; l++) {
|
|
|
+ // System.out.println(" "+files4[l].getName());
|
|
|
+ video = files4[l].getName();
|
|
|
+ video = video.substring(0, video.indexOf("."));
|
|
|
+ //写入excel
|
|
|
+ Row row = sheet.createRow(rowIndex);
|
|
|
+ row.createCell(0).setCellValue("");
|
|
|
+ row.createCell(1).setCellValue(video);
|
|
|
+
|
|
|
+ if (video.indexOf("试看") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(1);
|
|
|
+ } else if (video.indexOf("1") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(1 + 1);
|
|
|
+ } else if (video.indexOf("2") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(2 + 1);
|
|
|
+ } else if (video.indexOf("3") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(3 + 1);
|
|
|
+ } else if (video.indexOf("4") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(4 + 1);
|
|
|
+ } else if (video.indexOf("5") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(5 + 1);
|
|
|
+ } else if (video.indexOf("6") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(6 + 1);
|
|
|
+ } else if (video.indexOf("7") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(7 + 1);
|
|
|
+ } else if (video.indexOf("A") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(1 + 1);
|
|
|
+ } else if (video.indexOf("B") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(2 + 1);
|
|
|
+ } else if (video.indexOf("C") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(3 + 1);
|
|
|
+ } else if (video.indexOf("D") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(4 + 1);
|
|
|
+ } else if (video.indexOf("E") >= 0) {
|
|
|
+ row.createCell(2).setCellValue(5 + 1);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
+ row.createCell(3).setCellValue("");
|
|
|
+ row.createCell(4).setCellValue("");
|
|
|
+ row.createCell(5).setCellValue("3");
|
|
|
+ row.createCell(6).setCellValue("1");
|
|
|
+ row.createCell(7).setCellValue("1");
|
|
|
+ row.createCell(8).setCellValue(provinceId);
|
|
|
+ row.createCell(9).setCellValue(province);
|
|
|
+ row.createCell(10).setCellValue(cityId);
|
|
|
+ row.createCell(11).setCellValue(city);
|
|
|
+ row.createCell(12).setCellValue(countyId);
|
|
|
+ row.createCell(13).setCellValue(county);
|
|
|
+ row.createCell(14).setCellValue("");
|
|
|
+ row.createCell(15).setCellValue("");
|
|
|
+ if (examInfo2 != null) {
|
|
|
+ row.createCell(16).setCellValue(examInfo2.getId());
|
|
|
+ row.createCell(17).setCellValue(examInfo2.getName());
|
|
|
+ } else {
|
|
|
+ row.createCell(16).setCellValue("");
|
|
|
+ row.createCell(17).setCellValue("");
|
|
|
+ }
|
|
|
+ if (video.indexOf("试看") >= 0) {
|
|
|
+ row.createCell(18).setCellValue("1");
|
|
|
+ } else {
|
|
|
+ row.createCell(18).setCellValue("2");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ System.out.println(province + " " + city + " " + county + " " + exam + " " + video);
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-// if (files != null) {
|
|
|
-// for (File file : files) {
|
|
|
-// if (file.isDirectory()) {
|
|
|
-// // 获取文件夹路径
|
|
|
-// String folderPath = file.getPath();
|
|
|
-//
|
|
|
-// // 分割文件夹路径
|
|
|
-// String[] folderNames = folderPath.split("\\\\");
|
|
|
-// int numLevels = folderNames.length;
|
|
|
-//
|
|
|
-// // 创建新行
|
|
|
-// Row row = sheet.createRow(rowIndex);
|
|
|
-// for (int i = 0; i < numLevels; i++) {
|
|
|
-// row.createCell(i).setCellValue(folderNames[i]);
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 获取mp4文件
|
|
|
-// File[] mp4Files = file.listFiles((dir, name) -> name.toLowerCase().endsWith(".mp4"));
|
|
|
-// if (mp4Files != null && mp4Files.length > 0) {
|
|
|
-// String mp4FileName = mp4Files[0].getName();
|
|
|
-// row.createCell(numLevels).setCellValue(mp4FileName);
|
|
|
-// }
|
|
|
-//
|
|
|
-// rowIndex++;
|
|
|
-//
|
|
|
-// // 递归遍历下一级文件夹
|
|
|
-// traverseFolders(file, sheet, rowIndex);
|
|
|
-// }
|
|
|
-// }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|