打表索引检查

back_recharge
zhangshanxue 2020-05-09 07:06:01 +08:00
parent 17751438fd
commit c4e448cb1b
1 changed files with 15 additions and 3 deletions

View File

@ -14,7 +14,7 @@ public class ExcelUtils {
private static Set<String> oldFileNames = new HashSet<>(); private static Set<String> oldFileNames = new HashSet<>();
private static String javaFilePath = "tablemanager/src/main/java/config/"; private static String javaFilePath = "tablemanager/src/main/java/config/";
public static void main(String[] args) throws IOException { public static void main(String[] args) throws Exception {
File oldfile = new File(path); File oldfile = new File(path);
String[] list = oldfile.list(); String[] list = oldfile.list();
oldFileNames.addAll(Arrays.asList(list)); oldFileNames.addAll(Arrays.asList(list));
@ -96,7 +96,7 @@ public class ExcelUtils {
System.out.println(getInfos); System.out.println(getInfos);
} }
public static void readExcelData() throws IOException { public static void readExcelData() throws Exception {
File file = new File(excelPath); File file = new File(excelPath);
if (file.exists()) { if (file.exists()) {
File[] files = file.listFiles(); File[] files = file.listFiles();
@ -144,7 +144,7 @@ public class ExcelUtils {
return fieldInfo; return fieldInfo;
} }
private static void buildDataInfo(Workbook wb) throws IOException { private static void buildDataInfo(Workbook wb) throws Exception {
Sheet sheet; Sheet sheet;
Row row; Row row;
Object cellData; Object cellData;
@ -154,6 +154,7 @@ public class ExcelUtils {
int rownum = sheet.getLastRowNum(); int rownum = sheet.getLastRowNum();
FileWriter fw = new FileWriter(path + sheetName + ".txt"); FileWriter fw = new FileWriter(path + sheetName + ".txt");
PrintWriter out = new PrintWriter(fw); PrintWriter out = new PrintWriter(fw);
Set<Integer> indexCheck = new HashSet<>();
for (int i = 0; i <= rownum; i++) { for (int i = 0; i <= rownum; i++) {
if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){ if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){
continue; continue;
@ -191,6 +192,17 @@ public class ExcelUtils {
}else{ }else{
info.append("\t").append(cellData); info.append("\t").append(cellData);
} }
if(i>2&&j==1){
try {
if(indexCheck.contains(cellData)){
throw new Exception("\r\ncollection:="+sheetName+" 重复\r\n :index: "+cellData+"\r\n :row:"+(i+1));
}
indexCheck.add(Integer.valueOf(cellData.toString()));
}catch (ClassCastException e){
System.out.println("wb = [" + e + "]");
}
}
} }
} }
out.write(info.toString()); out.write(info.toString());