main
黄海 2 years ago
parent 34deb60ce4
commit 2bfb74a5d4

@ -331,10 +331,11 @@ public class CollectController extends Controller {
*/
@Before({POST.class})
@IsLoginInterface({})
public void importData(int job_id) throws URISyntaxException, IOException, ParseException {
public void importData() throws URISyntaxException, IOException, ParseException {
// 延迟解析比率
ZipSecureFile.setMinInflateRatio(-1.0d);
UploadFile excelFile = getFile();//得到文件对象
int job_id = getInt("job_id");
//操作人员
String person_id = SessionKit.get(getRequest(), getResponse(), "person_id");
//根据人员ID获取人员所在的单位ID
@ -358,20 +359,20 @@ public class CollectController extends Controller {
return;
}
String basePath = CommonUtil.getClassPath() + File.separator + "Excel";
String user_excel_filename = UUID.randomUUID().toString().toLowerCase() + ".xlsx";
String upload_excel_filename_user = UUID.randomUUID().toString().toLowerCase() + ".xlsx";
//判断目录是不是存在
File file = new File(basePath);
if (!file.exists()) {
file.mkdirs();// 创建文件夹
}
excelFile.getFile().renameTo(new File(basePath + File.separator + user_excel_filename));
excelFile.getFile().renameTo(new File(basePath + File.separator + upload_excel_filename_user));
Record jobRecord = cm.getJob(job_id);
String upload_excel_filename = jobRecord.getStr("upload_excel_filename_finish");//原始模板文件
//我提供的模板文件
String f1 = basePath + File.separator + upload_excel_filename;
//用户上传的填充完的EXCEL文件
String f2 = basePath + File.separator + user_excel_filename;
String f2 = basePath + File.separator + upload_excel_filename_user;
//对比两个EXCEL文件 是不是格式一致,也就是是不是上传了正确的模板文件
int sheetCnt = cm.getSheetCount(upload_excel_filename);
@ -471,7 +472,7 @@ public class CollectController extends Controller {
Kv kv = Kv.create();
kv.set("success", false);
kv.set("message", "检查到输入的文件中存在不合法情况,请下载文件后查看处理后,重新上传!");
kv.set("user_excel_filename", "/Excel/" + user_excel_filename);
kv.set("upload_excel_filename_user", "/Excel/" + upload_excel_filename_user);
renderJson(kv);
//关闭Excel
wb.close();
@ -481,6 +482,9 @@ public class CollectController extends Controller {
for (int i = 0; i < sheetCnt; i++)
cm.importData(upload_excel_filename, wb, i, bureau_id, person_id);
//回写完成标记
cm.writeJobFinish(job_id,bureau_id,upload_excel_filename_user);
//关闭Excel
wb.close();
Kv kv = Kv.create();

@ -680,6 +680,17 @@ public class CollectModel {
return list;
}
//回写完成标记
/**
* @param job_id
* @param bureau_id
* @param upload_excel_filename_user
*/
public void writeJobFinish(int job_id, String bureau_id, String upload_excel_filename_user) {
String sql = "update t_collect_job_bureau set is_finish=1,upload_excel_filename_user=? where job_id=? and bureau_id=?";
Db.update(sql, upload_excel_filename_user, job_id, bureau_id);
}
/**
* Cell(*)

Loading…
Cancel
Save