|
@@ -3,6 +3,7 @@ package com.qmth.distributed.print.business.templete.execute;
|
|
import com.alibaba.excel.ExcelReader;
|
|
import com.alibaba.excel.ExcelReader;
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
@@ -47,66 +48,55 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
|
|
public Result importTask(Map<String, Object> map) throws IOException {
|
|
public Result importTask(Map<String, Object> map) throws IOException {
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
System.out.println("printPlanId = " + tbTask.getPrintPlanId());
|
|
System.out.println("printPlanId = " + tbTask.getPrintPlanId());
|
|
|
|
+ System.out.println("------开始----------");
|
|
InputStream inputStream = super.getUploadFileInputStream(tbTask);
|
|
InputStream inputStream = super.getUploadFileInputStream(tbTask);
|
|
|
|
+ System.out.println("------结束----------");
|
|
StringJoiner stringJoinerSummary = new StringJoiner("\n")
|
|
StringJoiner stringJoinerSummary = new StringJoiner("\n")
|
|
.add(MessageFormat.format("{0}{1}{2}", FORMAT_TIME, BEGIN_TITLE, OBJ_TITLE));
|
|
.add(MessageFormat.format("{0}{1}{2}", FORMAT_TIME, BEGIN_TITLE, OBJ_TITLE));
|
|
tbTask.setStatus(TaskStatusEnum.RUNNING);
|
|
tbTask.setStatus(TaskStatusEnum.RUNNING);
|
|
- try {
|
|
|
|
- ExaminationListener listener = new ExaminationListener();
|
|
|
|
|
|
+ // try
|
|
|
|
+
|
|
|
|
+ String importFilePath = tbTask.getImportFilePath();
|
|
|
|
+ Map importFilePathMap = JSONObject.parseObject(importFilePath);
|
|
|
|
+ String path = String.valueOf(importFilePathMap.get("path"));
|
|
|
|
+ System.out.println("path = " + path);
|
|
|
|
+// // 该学校有效考务数据
|
|
|
|
+// List<FieldsDto> fieldsDtoList = examDetailService.findExaminationFields(tbTask.getSchoolId());
|
|
|
|
+// if (fieldsDtoList.size() == 0){
|
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("该学校没有设置考务数据");
|
|
|
|
+// }
|
|
|
|
+// for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
|
|
+// if (!headerList.contains(fieldsDto.getName())){
|
|
|
|
+// System.out.println("exception " + fieldsDto.getName());
|
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
|
|
+// String name = fieldsDto.getName();
|
|
|
|
+// String code = fieldsDto.getCode();
|
|
|
|
+// for (int i = 0;i < headerList.size();i++){
|
|
|
|
+// String headName = headerList.get(i);
|
|
|
|
+// if (name.equals(headName)){
|
|
|
|
+// fieldsDto.setIndex(i);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// // 组装exam_detail数据
|
|
|
|
+// Long schoolId = tbTask.getSchoolId();
|
|
|
|
+// Long printPlanId = tbTask.getPrintPlanId();
|
|
|
|
+// List<ExamPrintPlan> examPrintPlanList = examPrintPlanService.list(new QueryWrapper<ExamPrintPlan>().lambda().eq(ExamPrintPlan::getSchoolId,schoolId).eq(ExamPrintPlan::getId,printPlanId));
|
|
|
|
+// if (examPrintPlanList.size() != 1){
|
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("没有找到对应的考试计划");
|
|
|
|
+// }
|
|
|
|
+// String printPlanName = examPrintPlanList.get(0).getName();
|
|
|
|
+// int examPlaceIndex = fieldsDtoList.stream().filter(e -> "examPlace".equals(e.getCode())).map(FieldsDto::getIndex).collect(Collectors.toList()).get(0);
|
|
|
|
+//
|
|
|
|
+// // 组装exam_detail_course数据
|
|
|
|
+//
|
|
|
|
+// // 组装exam_student数据
|
|
|
|
|
|
- ExcelReader excelReader = new ExcelReader(inputStream, ExcelTypeEnum.XLSX, null, listener);
|
|
|
|
- excelReader.read();
|
|
|
|
- // 解析的excel数据
|
|
|
|
- List<Map<Integer, String>> dataList = listener.getDataList();
|
|
|
|
- System.out.println(JSON.toJSONString(dataList));
|
|
|
|
|
|
|
|
- // 表头列表
|
|
|
|
- List<String> headerList = (List<String>) dataList.get(0);
|
|
|
|
- // 该学校有效考务数据
|
|
|
|
- List<FieldsDto> fieldsDtoList = examDetailService.findExaminationFields(tbTask.getSchoolId());
|
|
|
|
- if (fieldsDtoList.size() == 0){
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该学校没有设置考务数据");
|
|
|
|
- }
|
|
|
|
- for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
|
|
- if (!headerList.contains(fieldsDto.getName())){
|
|
|
|
- System.out.println("exception " + fieldsDto.getName());
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- for (FieldsDto fieldsDto : fieldsDtoList) {
|
|
|
|
- String name = fieldsDto.getName();
|
|
|
|
- String code = fieldsDto.getCode();
|
|
|
|
- for (int i = 0;i < headerList.size();i++){
|
|
|
|
- String headName = headerList.get(i);
|
|
|
|
- if (name.equals(headName)){
|
|
|
|
- fieldsDto.setIndex(i);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 组装exam_detail数据
|
|
|
|
- Long schoolId = tbTask.getSchoolId();
|
|
|
|
- Long printPlanId = tbTask.getPrintPlanId();
|
|
|
|
- List<ExamPrintPlan> examPrintPlanList = examPrintPlanService.list(new QueryWrapper<ExamPrintPlan>().lambda().eq(ExamPrintPlan::getSchoolId,schoolId).eq(ExamPrintPlan::getId,printPlanId));
|
|
|
|
- if (examPrintPlanList.size() != 1){
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("没有找到对应的考试计划");
|
|
|
|
- }
|
|
|
|
- String printPlanName = examPrintPlanList.get(0).getName();
|
|
|
|
- int examPlaceIndex = fieldsDtoList.stream().filter(e -> "examPlace".equals(e.getCode())).map(FieldsDto::getIndex).collect(Collectors.toList()).get(0);
|
|
|
|
-
|
|
|
|
- // 组装exam_detail_course数据
|
|
|
|
-
|
|
|
|
- // 组装exam_student数据
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }catch (Exception e){
|
|
|
|
-
|
|
|
|
- }finally {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|