|
|
|
@ -3,7 +3,7 @@ package UnitTest.ImportExcel;
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.aspose.cells.Workbook;
|
|
|
|
|
import com.dsideal.QingLong.Util.AsposeUtil;
|
|
|
|
|
import com.dsideal.QingLong.Util.GenericTemplateUtil;
|
|
|
|
|
import com.dsideal.QingLong.Util.ImportUtil;
|
|
|
|
|
import com.jfinal.kit.Kv;
|
|
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
@ -82,7 +82,7 @@ public class CreateTableAndTemplate {
|
|
|
|
|
List<Kv> kvList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < sheetCount; i++) {
|
|
|
|
|
try {
|
|
|
|
|
Kv kv = GenericTemplateUtil.getTableStruct(wb, i);
|
|
|
|
|
Kv kv = ImportUtil.getTableStruct(wb, i);
|
|
|
|
|
if (!kv.getBoolean("success")) {
|
|
|
|
|
System.out.println("发现错误:" + kv.getStr("message"));
|
|
|
|
|
return;
|
|
|
|
@ -104,13 +104,13 @@ public class CreateTableAndTemplate {
|
|
|
|
|
//开发时暴力删除掉原表,在正式上线前要注意:不能简单粗暴的删除!!
|
|
|
|
|
for (Kv kv : kvList) {
|
|
|
|
|
String tableName = kv.getStr("table_name");
|
|
|
|
|
GenericTemplateUtil.dropTable(tableName);
|
|
|
|
|
ImportUtil.dropTable(tableName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断表是不是已存在
|
|
|
|
|
for (Kv kv : kvList) {
|
|
|
|
|
String tableName = kv.getStr("table_name");
|
|
|
|
|
if (GenericTemplateUtil.isTableExist(tableName)) {
|
|
|
|
|
if (ImportUtil.isTableExist(tableName)) {
|
|
|
|
|
System.out.println("表" + tableName + "已存在,不能删除,程序无法继续!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -119,7 +119,7 @@ public class CreateTableAndTemplate {
|
|
|
|
|
//检查通过,处理建表逻辑
|
|
|
|
|
for (Kv kv : kvList) {
|
|
|
|
|
String tableName = kv.getStr("table_name");
|
|
|
|
|
GenericTemplateUtil.createTable(tableName, kv, upload_excel_filename);//创建表
|
|
|
|
|
ImportUtil.createTable(tableName, kv, upload_excel_filename);//创建表
|
|
|
|
|
}
|
|
|
|
|
//检查是不是需要对指定列进行加红星+Comment操作
|
|
|
|
|
int sheetIdx = 0;
|
|
|
|
@ -137,8 +137,8 @@ public class CreateTableAndTemplate {
|
|
|
|
|
if (StrKit.isBlank(cell.getStringCellValue())) {
|
|
|
|
|
cell = wb.getSheetAt(sheetIdx).getRow(start_row).getCell(colIdx);
|
|
|
|
|
}
|
|
|
|
|
GenericTemplateUtil.addStar(wb, cell);
|
|
|
|
|
GenericTemplateUtil.addComment(wb, cell, "此单元格内容必须输入!");
|
|
|
|
|
ImportUtil.addStar(wb, cell);
|
|
|
|
|
ImportUtil.addComment(wb, cell, "此单元格内容必须输入!");
|
|
|
|
|
}
|
|
|
|
|
colIdx++;
|
|
|
|
|
}
|
|
|
|
@ -154,7 +154,7 @@ public class CreateTableAndTemplate {
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
String options = record.getStr("options");
|
|
|
|
|
if (!StrKit.isBlank(options)) {
|
|
|
|
|
GenericTemplateUtil.addValidation(wb, sheetIdx, options, data_start_row, data_start_row + 20000, colIdx, colIdx);//范围
|
|
|
|
|
ImportUtil.addValidation(wb, sheetIdx, options, data_start_row, data_start_row + 20000, colIdx, colIdx);//范围
|
|
|
|
|
}
|
|
|
|
|
colIdx++;
|
|
|
|
|
}
|
|
|
|
|