|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.EmptyInterface;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.IsLoginInterface;
|
|
|
|
|
import com.dsideal.QingLong.Interceptor.IsNumericInterface;
|
|
|
|
|
import com.dsideal.QingLong.Util.ImportExcelKit;
|
|
|
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
import com.jfinal.ext.interceptor.GET;
|
|
|
|
|
import com.jfinal.ext.interceptor.POST;
|
|
|
|
@ -127,6 +128,17 @@ public class CollectModel {
|
|
|
|
|
return Db.find(sql, job_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定JOB_ID下的所有Sheet表的相关信息,准备用这些信息创建数据库表
|
|
|
|
|
*
|
|
|
|
|
* @param job_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<Record> getJobSheet(int job_id) {
|
|
|
|
|
String sql = "select * from t_collect_job_sheet where job_id=?";
|
|
|
|
|
return Db.find(sql, job_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定任务+指定 Sheet_index的Sheet相关信息
|
|
|
|
|
*
|
|
|
|
@ -156,25 +168,16 @@ public class CollectModel {
|
|
|
|
|
*
|
|
|
|
|
* @param writeList
|
|
|
|
|
*/
|
|
|
|
|
public void saveSheet(List<Record> writeList) {
|
|
|
|
|
public void saveSheet(int job_id, int sheet_index, List<Record> writeList, String table_name) {
|
|
|
|
|
if (writeList.size() == 0) return;
|
|
|
|
|
int job_id = writeList.get(0).getInt("job_id");
|
|
|
|
|
int sheet_index = writeList.get(0).getInt("sheet_index");
|
|
|
|
|
String sql = "delete from t_collect_job_sheet_col where job_id=? and sheet_index=?";
|
|
|
|
|
Db.update(sql, job_id, sheet_index);
|
|
|
|
|
Db.batchSave("t_collect_job_sheet_col", writeList, 100);
|
|
|
|
|
//确认job_id+sheet_index完成
|
|
|
|
|
sql = "update t_collect_job_sheet set table_name=?,is_check=1,check_time=? where job_id=? and sheet_index=?";
|
|
|
|
|
Db.update(sql, table_name, DateTime.now(), job_id, sheet_index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:确认job_id+sheet_index完成
|
|
|
|
|
*
|
|
|
|
|
* @param job_id
|
|
|
|
|
* @param sheet_index
|
|
|
|
|
*/
|
|
|
|
|
public void checkSheet(int job_id, int sheet_index) {
|
|
|
|
|
String sql = "update t_collect_job_sheet set is_check=1,check_time=? where job_id=? and sheet_index=?";
|
|
|
|
|
Db.update(sql, DateTime.now(), job_id, sheet_index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:检查当前登录人员是不是有发布任务的角色
|
|
|
|
@ -209,16 +212,6 @@ public class CollectModel {
|
|
|
|
|
Db.update(sql, job_name, job_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定JOB_ID下的所有Sheet表的相关信息,准备用这些信息创建数据库表
|
|
|
|
|
*
|
|
|
|
|
* @param job_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<Record> getJobSheet(int job_id) {
|
|
|
|
|
String sql = "select * from t_collect_job_sheet where job_id=?";
|
|
|
|
|
return Db.find(sql, job_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:是不是指定任务的所有Sheet全部都确认通过
|
|
|
|
@ -238,4 +231,94 @@ public class CollectModel {
|
|
|
|
|
kv.set("success", true);
|
|
|
|
|
return kv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:创建表
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static Kv createTable(int job_id, int sheet_index) {
|
|
|
|
|
// Record input = List < Record > list = (List<Record>) input.get("list");
|
|
|
|
|
// String sheetName = input.getStr("sheet_name");
|
|
|
|
|
// String upload_excel_filename = input.getStr("upload_excel_filename");
|
|
|
|
|
// String colSql = "", commentSql = "";
|
|
|
|
|
// for (Record record : list) {
|
|
|
|
|
// String column_name = record.getStr("column_name").toLowerCase();
|
|
|
|
|
// colSql += column_name + " " + record.getStr("column_type");//varchar(2048)
|
|
|
|
|
// String memo = record.getStr("memo");
|
|
|
|
|
// if (record.getBoolean("allow_blank") == null || !record.getBoolean("allow_blank")) colSql += " NOT NULL ";
|
|
|
|
|
// colSql += ",";
|
|
|
|
|
// commentSql += "COMMENT ON COLUMN \"public\".\"" + tableName + "\".\"" + column_name + "\" IS '" + memo + "';\n";
|
|
|
|
|
// }
|
|
|
|
|
// String finalSql = "CREATE TABLE \"public\".\"" + tableName + "\" (";
|
|
|
|
|
// finalSql += "\"id\" serial4,";
|
|
|
|
|
// finalSql += "\"bureau_id\" char(36) NOT NULL,";
|
|
|
|
|
// finalSql += "\"person_id\" char(36) NOT NULL,";
|
|
|
|
|
// finalSql += colSql;
|
|
|
|
|
// finalSql += "PRIMARY KEY (\"id\")";
|
|
|
|
|
// finalSql += ");\n";
|
|
|
|
|
//
|
|
|
|
|
// finalSql += "COMMENT ON COLUMN \"public\".\"" + tableName + "\".\"id\" IS '主键,自增长ID';\n";
|
|
|
|
|
// finalSql += "COMMENT ON COLUMN \"public\".\"" + tableName + "\".\"bureau_id\" IS '单位ID';\n";
|
|
|
|
|
// finalSql += "COMMENT ON COLUMN \"public\".\"" + tableName + "\".\"person_id\" IS '上传人员ID';\n";
|
|
|
|
|
// finalSql += commentSql;
|
|
|
|
|
// finalSql += "COMMENT ON TABLE \"public\".\"" + tableName + "\" IS '" + sheetName + "';";
|
|
|
|
|
// //添加索引
|
|
|
|
|
// finalSql += "CREATE INDEX ON \"public\".\"" + tableName + "\" (\"bureau_id\");";
|
|
|
|
|
// finalSql += "CREATE INDEX ON \"public\".\"" + tableName + "\" (\"person_id\");";
|
|
|
|
|
// Db.update(finalSql);
|
|
|
|
|
//
|
|
|
|
|
// //写入模板与表结构的关系t_collect_mapping
|
|
|
|
|
// String sql = "delete from t_collect_mapping where table_name=?";
|
|
|
|
|
// Db.update(sql, tableName);
|
|
|
|
|
//
|
|
|
|
|
// int sheet_index = input.getInt("sheet_index");
|
|
|
|
|
// String sheet_name = input.getStr("sheet_name");
|
|
|
|
|
// List<Record> writeList = new ArrayList<>();
|
|
|
|
|
// for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
// Record record = new Record();
|
|
|
|
|
// record.set("table_name", tableName);
|
|
|
|
|
// 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("allow_blank", list.get(i).getBoolean("allow_blank"));
|
|
|
|
|
// record.set("column_type", ImportExcelKit.convertDataType(list.get(i).getStr("column_type")));
|
|
|
|
|
// record.set("upload_excel_filename", upload_excel_filename);
|
|
|
|
|
// record.set("sheet_index", sheet_index);
|
|
|
|
|
// record.set("sheet_name", sheet_name);
|
|
|
|
|
// record.set("options", list.get(i).getStr("options"));
|
|
|
|
|
// writeList.add(record);
|
|
|
|
|
// }
|
|
|
|
|
// Db.batchSave("t_collect_mapping", writeList, 100);
|
|
|
|
|
//
|
|
|
|
|
// //记录模板文件的头文件位置,开始行,结束行,开始列,结束列
|
|
|
|
|
// sql = "delete from t_collect_config where upload_excel_filename=? and table_name=?";
|
|
|
|
|
// Db.update(sql, upload_excel_filename, tableName);
|
|
|
|
|
//
|
|
|
|
|
// 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", tableName);
|
|
|
|
|
// 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", "表结构创建成功!");
|
|
|
|
|
return kv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|