|
|
|
@ -80,6 +80,7 @@ public class CollectModel {
|
|
|
|
|
rSheet.set("end_column", end_column);
|
|
|
|
|
rSheet.set("data_start_row", data_start_row);
|
|
|
|
|
rSheet.set("column_num", column_num);
|
|
|
|
|
rSheet.set("upload_excel_filename",upload_excel_filename);
|
|
|
|
|
Db.save("t_collect_job_sheet", "job_id,sheet_index", rSheet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -221,7 +222,7 @@ public class CollectModel {
|
|
|
|
|
*/
|
|
|
|
|
public void saveJob(int job_id, String job_name, String upload_excel_filename_finish) {
|
|
|
|
|
String sql = "update t_collect_job set job_name=?,upload_excel_filename_finish=? where job_id=?";
|
|
|
|
|
Db.update(sql, job_name, job_id, upload_excel_filename_finish);
|
|
|
|
|
Db.update(sql, job_name, upload_excel_filename_finish, job_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -265,7 +266,7 @@ public class CollectModel {
|
|
|
|
|
//获取数据表结构
|
|
|
|
|
List<Record> list = getSheetStruct(job_id, sheet_index);
|
|
|
|
|
String sheetName = input.getStr("sheet_name");
|
|
|
|
|
String upload_excel_filename = input.getStr("upload_excel_filename");
|
|
|
|
|
String upload_excel_filename = getJob(job_id).getStr("upload_excel_filename");
|
|
|
|
|
String colSql = "", commentSql = "";
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
String column_name = record.getStr("column_name").toLowerCase();
|
|
|
|
@ -306,9 +307,9 @@ public class CollectModel {
|
|
|
|
|
record.set("table_name", table_name);
|
|
|
|
|
record.set("column_name", list.get(i).getStr("column_name"));
|
|
|
|
|
record.set("excel_column_idx", i);
|
|
|
|
|
record.set("memo", list.get(i).getStr("memo"));
|
|
|
|
|
record.set("original_name", list.get(i).getStr("original_name"));
|
|
|
|
|
record.set("allow_blank", list.get(i).getBoolean("allow_blank"));
|
|
|
|
|
record.set("column_type", convertDataType(list.get(i).getStr("column_type")));
|
|
|
|
|
record.set("column_type", convertDataType(list.get(i).getStr("data_type_id")));
|
|
|
|
|
record.set("upload_excel_filename", upload_excel_filename);
|
|
|
|
|
record.set("sheet_index", sheet_index);
|
|
|
|
|
record.set("sheet_name", sheet_name);
|
|
|
|
@ -318,29 +319,9 @@ public class CollectModel {
|
|
|
|
|
Db.batchSave("t_collect_mapping", writeList, 100);
|
|
|
|
|
|
|
|
|
|
//记录模板文件的头文件位置,开始行,结束行,开始列,结束列
|
|
|
|
|
sql = "delete from t_collect_config where upload_excel_filename=? and table_name=?";
|
|
|
|
|
sql = "delete from t_collect_job_sheet where upload_excel_filename=? and table_name=?";
|
|
|
|
|
Db.update(sql, upload_excel_filename, table_name);
|
|
|
|
|
|
|
|
|
|
int start_row = input.getInt("start_row");
|
|
|
|
|
int end_row = input.getInt("end_row");
|
|
|
|
|
int start_column = input.getInt("start_column");
|
|
|
|
|
int end_column = input.getInt("end_column");
|
|
|
|
|
int data_start_row = input.getInt("data_start_row");
|
|
|
|
|
int column_num = input.getInt("column_num");
|
|
|
|
|
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("upload_excel_filename", upload_excel_filename);
|
|
|
|
|
record.set("table_name", table_name);
|
|
|
|
|
record.set("start_row", start_row);
|
|
|
|
|
record.set("end_row", end_row);
|
|
|
|
|
record.set("start_column", start_column);
|
|
|
|
|
record.set("end_column", end_column);
|
|
|
|
|
record.set("sheet_index", sheet_index);
|
|
|
|
|
record.set("sheet_name", sheet_name);
|
|
|
|
|
record.set("data_start_row", data_start_row);
|
|
|
|
|
record.set("column_num", column_num);
|
|
|
|
|
Db.save("t_collect_config", "id", record);
|
|
|
|
|
|
|
|
|
|
Kv kv = Kv.create();
|
|
|
|
|
kv.set("success", true);
|
|
|
|
|
kv.set("message", "表结构创建成功!");
|
|
|
|
@ -381,7 +362,7 @@ public class CollectModel {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Record getSheetConfig(String upload_excel_filename, int sheet_index) {
|
|
|
|
|
String sql = "select * from t_collect_config where upload_excel_filename=? and sheet_index=?";
|
|
|
|
|
String sql = "select * from t_collect_job_sheet where upload_excel_filename=? and sheet_index=?";
|
|
|
|
|
return Db.findFirst(sql, upload_excel_filename, sheet_index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -392,7 +373,7 @@ public class CollectModel {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public int getSheetCount(String upload_excel_filename) {
|
|
|
|
|
String sql = "select * from t_collect_config where upload_excel_filename=?";
|
|
|
|
|
String sql = "select * from t_collect_job_sheet where upload_excel_filename=?";
|
|
|
|
|
List<Record> list = Db.find(sql, upload_excel_filename);
|
|
|
|
|
return list.size();
|
|
|
|
|
}
|
|
|
|
@ -419,7 +400,7 @@ public class CollectModel {
|
|
|
|
|
//读取sheet页
|
|
|
|
|
XSSFSheet sheet = wb.getSheetAt(sheetIdx);
|
|
|
|
|
//通过表名获取到它的读取起始行,终止列
|
|
|
|
|
String sql = "select * from t_collect_config where upload_excel_filename=? and sheet_index=?";
|
|
|
|
|
String sql = "select * from t_collect_job_sheet where upload_excel_filename=? and sheet_index=?";
|
|
|
|
|
Record record = Db.findFirst(sql, upload_excel_filename, sheetIdx);
|
|
|
|
|
String table_name = record.getStr("table_name");
|
|
|
|
|
|
|
|
|
@ -516,24 +497,24 @@ public class CollectModel {
|
|
|
|
|
Row ed = sheet.getRow(_list.get(_list.size() - 1) - 1);//下标从0开始
|
|
|
|
|
List<Record> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
String column_name, memo;
|
|
|
|
|
String column_name, original_name;
|
|
|
|
|
for (int colNum = 0; colNum < ed.getLastCellNum(); colNum++) {
|
|
|
|
|
if (StrKit.isBlank(ed.getCell(colNum).toString())) {
|
|
|
|
|
memo = CommonUtil.removeKuoHao(st.getCell(colNum).toString().replace("\n", ""));
|
|
|
|
|
original_name = CommonUtil.removeKuoHao(st.getCell(colNum).toString().replace("\n", ""));
|
|
|
|
|
column_name = ChineseCharacterUtil.getColumnNameByMemo(CommonUtil.removeKuoHao(st.getCell(colNum).toString()));
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("memo", memo);
|
|
|
|
|
record.set("original_name", original_name);
|
|
|
|
|
record.set("column_name", column_name);
|
|
|
|
|
list.add(record);
|
|
|
|
|
} else {
|
|
|
|
|
int k = colNum;
|
|
|
|
|
while (StrKit.isBlank(st.getCell(k).toString())) k--;
|
|
|
|
|
memo = st.getCell(k).toString().replace("\n", "")
|
|
|
|
|
original_name = st.getCell(k).toString().replace("\n", "")
|
|
|
|
|
+ "_" + ed.getCell(colNum).toString().replace("\n", "");
|
|
|
|
|
column_name = ChineseCharacterUtil.getColumnNameByMemo(CommonUtil.removeKuoHao(st.getCell(k).toString()))
|
|
|
|
|
+ "_" + ChineseCharacterUtil.getColumnNameByMemo(CommonUtil.removeKuoHao(ed.getCell(colNum).toString()));
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("memo", memo);
|
|
|
|
|
record.set("original_name", original_name);
|
|
|
|
|
record.set("column_name", column_name.toLowerCase());
|
|
|
|
|
list.add(record);
|
|
|
|
|
}
|
|
|
|
|