打表索引检查
parent
17751438fd
commit
c4e448cb1b
|
|
@ -14,7 +14,7 @@ public class ExcelUtils {
|
|||
private static Set<String> oldFileNames = new HashSet<>();
|
||||
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);
|
||||
String[] list = oldfile.list();
|
||||
oldFileNames.addAll(Arrays.asList(list));
|
||||
|
|
@ -96,7 +96,7 @@ public class ExcelUtils {
|
|||
System.out.println(getInfos);
|
||||
}
|
||||
|
||||
public static void readExcelData() throws IOException {
|
||||
public static void readExcelData() throws Exception {
|
||||
File file = new File(excelPath);
|
||||
if (file.exists()) {
|
||||
File[] files = file.listFiles();
|
||||
|
|
@ -144,7 +144,7 @@ public class ExcelUtils {
|
|||
return fieldInfo;
|
||||
}
|
||||
|
||||
private static void buildDataInfo(Workbook wb) throws IOException {
|
||||
private static void buildDataInfo(Workbook wb) throws Exception {
|
||||
Sheet sheet;
|
||||
Row row;
|
||||
Object cellData;
|
||||
|
|
@ -154,6 +154,7 @@ public class ExcelUtils {
|
|||
int rownum = sheet.getLastRowNum();
|
||||
FileWriter fw = new FileWriter(path + sheetName + ".txt");
|
||||
PrintWriter out = new PrintWriter(fw);
|
||||
Set<Integer> indexCheck = new HashSet<>();
|
||||
for (int i = 0; i <= rownum; i++) {
|
||||
if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){
|
||||
continue;
|
||||
|
|
@ -191,6 +192,17 @@ public class ExcelUtils {
|
|||
}else{
|
||||
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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue