caozixuan 4 年之前
父节点
当前提交
403394493d

+ 16 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/ExaminationResult.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.bean.result;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.annotation.ExcelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 /**
@@ -13,50 +14,65 @@ public class ExaminationResult {
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "examDetailId")
+    @ExcelProperty(name = "考务场次主键", width = 30, index = 1)
     private Long id;
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "学校id")
+    @ExcelProperty(name = "学校主键", width = 30, index = 2)
     private Long schoolId;
 
     @ApiModelProperty(value = "印刷计划id")
+    @ExcelProperty(name = "印刷计划主键", width = 30, index = 3)
     private Long printPlanId;
 
     @ApiModelProperty(value = "印刷计划名称")
+    @ExcelProperty(name = "印刷计划名称", width = 30, index = 4)
     private String printPlanName;
 
     @ApiModelProperty(value = "考试开始时间")
+    @ExcelProperty(name = "考试开始时间", width = 30, index = 5)
     private Long examStartTime;
 
     @ApiModelProperty(value = "考试结束时间")
+    @ExcelProperty(name = "考试结束时间", width = 30, index = 6)
     private Long examEndTime;
 
     @ApiModelProperty(value = "考点")
+    @ExcelProperty(name = "考点", width = 30, index = 7)
     private String examPlace;
 
     @ApiModelProperty(value = "考场")
+    @ExcelProperty(name = "考场", width = 30, index = 8)
     private String examRoom;
 
     @ApiModelProperty(value = "卷袋号")
+    @ExcelProperty(name = "卷袋号", width = 30, index = 9)
     private String packageCode;
 
     @ApiModelProperty(value = "课程(代码)")
+    @ExcelProperty(name = "课程(代码)", width = 30, index = 10)
     private String courseNameCode;
 
     @ApiModelProperty(value = "试卷编号")
+    @ExcelProperty(name = "试卷编号", width = 30, index = 11)
     private String paperNumber;
 
     @ApiModelProperty(value = "科次")
+    @ExcelProperty(name = "科次", width = 30, index = 12)
     private int totalSubjects;
 
     @JsonSerialize(using = ToStringSerializer.class)
     @ApiModelProperty(value = "创建人id")
+    @ExcelProperty(name = "创建人id", width = 30, index = 13)
     private Long createId;
 
     @ApiModelProperty(value = "创建时间")
+    @ExcelProperty(name = "创建时间", width = 30, index = 14)
     private Long createTime;
 
     @ApiModelProperty(value = "考务课程表主键组‘,’隔开")
+    @ExcelProperty(name = "考务课程表主键组‘,’隔开", width = 30, index = 15)
     private String examDetailCourseIds;
 
     public Long getId() {

+ 6 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamDetailService.java

@@ -124,4 +124,10 @@ public interface ExamDetailService extends IService<ExamDetail> {
     boolean taskCancel(ExamDetail examDetail);
 
     boolean resubmitTask(ExamDetail examDetail);
+
+    void disposeExamDetailByExaminationExcel(List<Map<String, Object>> dataList, Long userId);
+
+    void disposeExamDetailCourseByExaminationExcel(List<Map<String, Object>> dataList,Long userId);
+
+    void disposeExamStudentByExaminationExcel(List<Map<String, Object>> dataList,Long userId);
 }

+ 161 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamDetailServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -17,6 +18,7 @@ import com.qmth.distributed.print.business.entity.BasicAttachment;
 import com.qmth.distributed.print.business.entity.BasicExamRule;
 import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.ExamDetailCourse;
+import com.qmth.distributed.print.business.entity.ExamStudent;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.mapper.ExamDetailMapper;
 import com.qmth.distributed.print.business.service.*;
@@ -37,8 +39,11 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.net.URLEncoder;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -58,6 +63,8 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
     private ExamDetailMapper examDetailMapper;
     @Resource
     private CacheService cacheService;
+    @Resource
+    private ExamStudentService examStudentService;
 
     @Autowired
     private BasicAttachmentService basicAttachmentService;
@@ -317,4 +324,158 @@ public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailMapper, ExamDet
         // todo 调用生成pdf方法
         return false;
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void disposeExamDetailByExaminationExcel(List<Map<String, Object>> dataList, Long userId){
+        List<Map<String, Object>> examDetailKeyList = dataList.stream().flatMap(e -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put("schoolId",e.get("schoolId"));
+            map.put("printPlanId",e.get("printPlanId"));
+            map.put("printPlanName",e.get("printPlanName"));
+            map.put("examPlace",e.get("examPlace"));
+            map.put("examRoom",e.get("examRoom"));
+            map.put("examDate",e.get("examDate"));
+            map.put("examTime",e.get("examTime"));
+            return Stream.of(map);
+        }).distinct().collect(Collectors.toList());
+
+        System.out.println("examDetailKeyList = " + JSON.toJSONString(examDetailKeyList));
+
+        List<ExamDetail> examDetailList = new ArrayList<>();
+        for (Map<String, Object> map : examDetailKeyList) {
+            String examPlace = String.valueOf(map.get("examPlace"));
+            String examRoom = String.valueOf(map.get("examRoom"));
+            String examDate = String.valueOf(map.get("examDate"));
+            String examTime = String.valueOf(map.get("examTime"));
+            System.out.println("dataList : " + JSON.toJSONString(dataList));
+            System.out.println(examPlace + examRoom + examDate + examTime);
+            long totalSubjects = dataList.stream()
+                    .filter(e -> String.valueOf(e.get("examPlace")).equals(examPlace) &&
+                            String.valueOf(e.get("examRoom")).equals(examRoom) &&
+                            String.valueOf(e.get("examDate")).equals(examDate) &&
+                            String.valueOf(e.get("examTime")).equals(examTime)).count();
+
+            System.out.println("totalSubjects" + totalSubjects);
+            ExamDetail examDetail = new ExamDetail();
+            examDetail.setId(SystemConstant.getDbUuid());
+            examDetail.setExamName("");
+            examDetail.setSchoolId(Long.valueOf(String.valueOf(map.get("schoolId"))));
+            examDetail.setPrintPlanId(Long.valueOf(String.valueOf(map.get("printPlanId"))));
+            examDetail.setPrintPlanName(String.valueOf(map.get("printPlanName")));
+            examDetail.setExamPlace(examPlace);
+            examDetail.setExamRoom(examRoom);
+            examDetail.setTotalSubjects(Math.toIntExact(totalSubjects));
+            // TODO: 2021/4/9 解析日期和时间
+            examDetail.setExamStartTime(1L);
+            examDetail.setExamEndTime(2L);
+            examDetail.setCreateId(userId);
+            examDetail.setUpdateId(userId);
+            examDetailList.add(examDetail);
+        }
+        this.saveBatch(examDetailList);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void disposeExamDetailCourseByExaminationExcel(List<Map<String, Object>> dataList,Long userId){
+
+        List<Map<String, Object>> examDetailKeyList = dataList.stream().flatMap(e -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put("schoolId",e.get("schoolId"));
+            map.put("printPlanId",e.get("printPlanId"));
+            map.put("examPlace",e.get("examPlace"));
+            map.put("examRoom",e.get("examRoom"));
+            map.put("examDate",e.get("examDate"));
+            map.put("examTime",e.get("examTime"));
+            map.put("courseCode",e.get("courseCode"));
+            map.put("courseName",e.get("courseName"));
+            map.put("paperNumber",e.get("paperNumber"));
+            return Stream.of(map);
+        }).distinct().collect(Collectors.toList());
+
+        List<ExamDetailCourse> examDetailCourseList = new ArrayList<>();
+        for (Map<String, Object> map : examDetailKeyList) {
+            Long schoolId = Long.valueOf(String.valueOf(map.get("schoolId")));
+            Long printPlanId = Long.valueOf(String.valueOf(map.get("printPlanId")));
+            String examPlace = String.valueOf(map.get("examPlace"));
+            String examRoom = String.valueOf(map.get("examRoom"));
+            Long examStartTime = 1L;
+            Long examEndTime = 2L;
+            String courseCode = String.valueOf(map.get("courseCode"));
+            String courseName = String.valueOf(map.get("courseName"));
+            String paperNumber = String.valueOf(map.get("paperNumber"));
+            List<ExamDetail> examDetailList = this.list(new QueryWrapper<ExamDetail>().lambda()
+                    .eq(ExamDetail::getPrintPlanId,printPlanId)
+                    .eq(ExamDetail::getExamPlace,examPlace)
+                    .eq(ExamDetail::getExamRoom,examRoom)
+                    .eq(ExamDetail::getExamStartTime,examStartTime)
+                    .eq(ExamDetail::getExamEndTime,examEndTime));
+            if (examDetailList.size() != 1){
+                throw ExceptionResultEnum.ERROR.exception("无法找到新增的考务场次数据");
+            }
+            Long examDetailId = examDetailList.get(0).getId();
+            ExamDetailCourse examDetailCourse = new ExamDetailCourse();
+            examDetailCourse.setId(SystemConstant.getDbUuid());
+            examDetailCourse.setSchoolId(schoolId);
+            examDetailCourse.setExamDetailId(examDetailId);
+            examDetailCourse.setCourseCode(courseCode);
+            examDetailCourse.setCourseName(courseName);
+            examDetailCourse.setPaperNumber(paperNumber);
+            examDetailCourse.setCreateId(userId);
+            examDetailCourse.setUpdateId(userId);
+            examDetailCourseList.add(examDetailCourse);
+        }
+        examDetailCourseService.saveBatch(examDetailCourseList);
+    }
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void disposeExamStudentByExaminationExcel(List<Map<String, Object>> dataList,Long userId){
+        List<ExamStudent> examStudentList = new ArrayList<>();
+        for (Map<String, Object> map : dataList) {
+            Long schoolId = Long.valueOf(String.valueOf(map.get("schoolId")));
+            Long printPlanId = Long.valueOf(String.valueOf(map.get("printPlanId")));
+            String examPlace = String.valueOf(map.get("examPlace"));
+            String examRoom = String.valueOf(map.get("examRoom"));
+            Long examStartTime = 1L;
+            Long examEndTime = 2L;
+            String courseCode = String.valueOf(map.get("courseCode"));
+            String courseName = String.valueOf(map.get("courseName"));
+            String paperNumber = String.valueOf(map.get("paperNumber"));
+            String studentName = String.valueOf(map.get("studentName"));
+            String studentCode = String.valueOf(map.get("studentCode"));
+            List<ExamDetail> examDetailList = this.list(new QueryWrapper<ExamDetail>().lambda()
+                    .eq(ExamDetail::getPrintPlanId,printPlanId)
+                    .eq(ExamDetail::getExamPlace,examPlace)
+                    .eq(ExamDetail::getExamRoom,examRoom)
+                    .eq(ExamDetail::getExamStartTime,examStartTime)
+                    .eq(ExamDetail::getExamEndTime,examEndTime));
+            if (examDetailList.size() != 1){
+                throw ExceptionResultEnum.ERROR.exception("无法找到新增的考务场次数据");
+            }
+            Long examDetailId = examDetailList.get(0).getId();
+            List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.list(new QueryWrapper<ExamDetailCourse>().lambda()
+                    .eq(ExamDetailCourse::getExamDetailId,examDetailId)
+                    .eq(ExamDetailCourse::getCourseCode,courseCode)
+                    .eq(ExamDetailCourse::getCourseName,courseName)
+                    .eq(ExamDetailCourse::getPaperNumber,paperNumber));
+            if (examDetailCourseList.size() != 1){
+                throw ExceptionResultEnum.ERROR.exception("无法找到新增的考务科目数据");
+            }
+            Long examDetailCourseId = examDetailCourseList.get(0).getId();
+
+            ExamStudent examStudent = new ExamStudent();
+            examStudent.setId(SystemConstant.getDbUuid());
+            examStudent.setSchoolId(schoolId);
+            examStudent.setExamDetailCourseId(examDetailCourseId);
+            examStudent.setStudentName(studentName);
+            examStudent.setStudentCode(studentCode);
+            examStudent.setTicketNumber("");
+            examStudent.setSiteNumber("");
+            examStudent.setCreateId(userId);
+            examStudent.setUpdateId(userId);
+            examStudentList.add(examStudent);
+        }
+        examStudentService.saveBatch(examStudentList);
+    }
 }

+ 12 - 14
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationExportTemplateService.java

@@ -1,26 +1,22 @@
 package com.qmth.distributed.print.business.templete.execute;
 
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.distributed.print.business.bean.result.ExaminationResult;
-import com.qmth.distributed.print.business.entity.ExamDetail;
 import com.qmth.distributed.print.business.entity.TBTask;
 import com.qmth.distributed.print.business.enums.TaskResultEnum;
 import com.qmth.distributed.print.business.enums.TaskStatusEnum;
 import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.templete.export.AsyncExportTaskTemplete;
-import com.qmth.distributed.print.business.util.ExcelUtil;
-import com.qmth.distributed.print.business.util.ServletUtil;
+import com.qmth.distributed.print.business.templete.service.TaskLogicService;
+import com.qmth.distributed.print.business.util.OssUtil;
 import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.util.Result;
 import com.qmth.distributed.print.common.util.ResultUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.text.MessageFormat;
-import java.util.List;
 import java.util.Map;
 import java.util.StringJoiner;
 
@@ -32,14 +28,17 @@ import java.util.StringJoiner;
 @Service
 public class AsyncExaminationExportTemplateService extends AsyncExportTaskTemplete {
     @Resource
-    private ExamDetailService examDetailService;
+    ExamDetailService examDetailService;
+    @Resource
+    OssUtil ossUtil;
+    @Resource
+    TaskLogicService taskLogicService;
 
     public static final String OBJ_TITLE = "考务数据";
     private final static Logger log = LoggerFactory.getLogger(AsyncExaminationExportTemplateService.class);
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Result exportTask(Map<String, Object> map, Long printPlanId, String courseCode, String paperNumber, String examPlace, String examRoom, String packageCode) throws Exception {
+    public Result exportTask(Map<String, Object> map) throws Exception {
         TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
         Long userId = tbTask.getCreateId();
         Long schoolId = tbTask.getSchoolId();
@@ -48,11 +47,9 @@ public class AsyncExaminationExportTemplateService extends AsyncExportTaskTemple
                 .add(MessageFormat.format("{0}{1}{2}", FORMAT_TIME, BEGIN_TITLE, OBJ_TITLE));
         tbTask.setStatus(TaskStatusEnum.RUNNING);
 
-        List<ExaminationResult> examinationResultList = examDetailService.findExaminationBriefPage(schoolId,
-                printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode,
-                SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE).getRecords();
+
         try {
-            ExcelUtil.excelExport("考务信息查询", ExaminationResult.class, examinationResultList, ServletUtil.getResponse());
+            taskLogicService.executeExaminationLogic(map);
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", FORMAT_TIME, FINISH_TITLE, 111, FINISH_SIZE));
             tbTask.setResult(TaskResultEnum.SUCCESS);
         } catch (Exception e) {
@@ -66,7 +63,8 @@ public class AsyncExaminationExportTemplateService extends AsyncExportTaskTemple
             }
         } finally {//生成txt文件
             tbTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbTask);
         }
-        return ResultUtil.ok(map);
+        return ResultUtil.ok();
     }
 }

+ 8 - 323
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncExaminationImportTemplateService.java

@@ -1,28 +1,14 @@
 package com.qmth.distributed.print.business.templete.execute;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.api.exception.ApiException;
-import com.qmth.distributed.print.business.bean.dto.FieldsDto;
-import com.qmth.distributed.print.business.entity.*;
+import com.qmth.distributed.print.business.entity.TBTask;
 import com.qmth.distributed.print.business.enums.TaskResultEnum;
 import com.qmth.distributed.print.business.enums.TaskStatusEnum;
-import com.qmth.distributed.print.business.service.ExamDetailCourseService;
-import com.qmth.distributed.print.business.service.ExamDetailService;
-import com.qmth.distributed.print.business.service.ExamPrintPlanService;
-import com.qmth.distributed.print.business.service.ExamStudentService;
 import com.qmth.distributed.print.business.templete.importData.AsyncImportTaskTemplete;
+import com.qmth.distributed.print.business.templete.service.TaskLogicService;
 import com.qmth.distributed.print.common.contant.SystemConstant;
-import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import com.qmth.distributed.print.common.util.Result;
 import com.qmth.distributed.print.common.util.ResultUtil;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.CellType;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -31,9 +17,8 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.io.InputStream;
 import java.text.MessageFormat;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+import java.util.Map;
+import java.util.StringJoiner;
 
 /**
  * @Description: 考务数据导入模板
@@ -43,13 +28,7 @@ import java.util.stream.Stream;
 @Service
 public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemplete {
     @Resource
-    private ExamDetailService examDetailService;
-    @Resource
-    private ExamPrintPlanService examPrintPlanService;
-    @Resource
-    private ExamDetailCourseService examDetailCourseService;
-    @Resource
-    private ExamStudentService examStudentService;
+    private TaskLogicService taskLogicService;
 
     private final static Logger log = LoggerFactory.getLogger(AsyncExaminationImportTemplateService.class);
 
@@ -59,160 +38,15 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
     @Override
     public Result importTask(Map<String, Object> map) throws Exception {
         TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
-        Long printPlanId = tbTask.getPrintPlanId();
-        Long userId = tbTask.getCreateId();
-        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
-
-        if (examPrintPlan == null){
-            throw ExceptionResultEnum.ERROR.exception("印刷计划不存在printPlanId : " + printPlanId);
-        }
-        String printPlanName = examPrintPlan.getName();
-        Long schoolId = tbTask.getSchoolId();
-
-        System.out.println("------开始----------");
         InputStream inputStream = super.getUploadFileInputStream(tbTask);
-        System.out.println("------结束----------");
+        map.put("inputStream",inputStream);
+
         StringJoiner stringJoinerSummary = new StringJoiner("\n")
                 .add(MessageFormat.format("{0}{1}{2}", FORMAT_TIME, BEGIN_TITLE, OBJ_TITLE));
         tbTask.setStatus(TaskStatusEnum.RUNNING);
 
-
-        // 该学校有效考务数据
-        List<FieldsDto> fieldsDtoList = examDetailService.findExaminationFields(schoolId);
-        if (fieldsDtoList.size() == 0) {
-            throw ExceptionResultEnum.ERROR.exception("该学校没有设置考务数据");
-        }
-
         try {
-            String importFilePath = tbTask.getImportFilePath();
-            Map importFilePathMap = JSONObject.parseObject(importFilePath);
-            String path = String.valueOf(importFilePathMap.get("path"));
-            System.out.println("path = " + path);
-            Workbook workbook = null;
-            if (path.endsWith(SystemConstant.XLSX)) {
-                workbook = new XSSFWorkbook(inputStream);
-            } else if (path.endsWith("xls")) {
-                workbook = new HSSFWorkbook(inputStream);
-            } else {
-                throw ExceptionResultEnum.ERROR.exception("文件格式异常");
-            }
-            // 读取第一个工作表
-            Sheet sheet = workbook.getSheetAt(0);
-            // 获取sheet行数
-            int totalRows = sheet.getPhysicalNumberOfRows();
-            // 获取sheet列数
-            int totalCells = 0;
-            if (totalRows > 1 && sheet.getRow(0) != null) {
-                totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
-            }
-            System.out.println("行 : " + totalRows + "\n列 : " + totalCells);
-            Row head = sheet.getRow(0);
-            List<String> headList = new ArrayList<>();
-            // 将必填字段匹配excel解析的表头索引
-            for (int i = 0; i < totalCells; i++) {
-                String cellValue = head.getCell(i).getStringCellValue();
-                for (FieldsDto fieldsDto : fieldsDtoList) {
-                    if (cellValue.equals(fieldsDto.getName())) {
-                        fieldsDto.setIndex(i);
-                    }
-                }
-                headList.add(cellValue);
-            }
-
-            // 搜索所有有效字段 excel中的表头是否包含
-            for (FieldsDto fieldsDto : fieldsDtoList) {
-                if (!headList.contains(fieldsDto.getName())) {
-                    System.out.println("exception " + fieldsDto.getName());
-                    throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
-                }
-            }
-
-            System.out.println("headList : " + headList);
-            System.out.println("fieldsDtoList : " + JSONObject.toJSONString(fieldsDtoList));
-
-            List<Map<String, Object>> dataList = new ArrayList<>();
-
-            for (int r = 1; r < totalRows; r++) {
-                Row row = sheet.getRow(r);
-
-                String studentCode = null;
-                String studentName = null;
-                String courseCode = null;
-                String courseName = null;
-                String examPlace = null;
-                String examRoom = null;
-                String examDate = null;
-                String examTime = null;
-                String paperNumber = null;
-                List<FieldsDto> secondaryFieldList = new ArrayList<>();
-                for (FieldsDto fieldsDto : fieldsDtoList) {
-                    String name = fieldsDto.getName();
-                    String code = fieldsDto.getCode();
-                    int index = fieldsDto.getIndex();
-                    String level = fieldsDto.getLevel();
-                    if ("学号".equals(name)) {
-                        studentCode = row.getCell(index).getStringCellValue();
-                    } else if ("姓名".equals(name)) {
-                        studentName = row.getCell(index).getStringCellValue();
-                    } else if ("课程代码".equals(name)) {
-                        courseCode = row.getCell(index).getStringCellValue();
-                    } else if ("课程名称".equals(name)) {
-                        courseName = row.getCell(index).getStringCellValue();
-                    } else if ("考点".equals(name)) {
-                        examPlace = row.getCell(index).getStringCellValue();
-                    } else if ("考场".equals(name)) {
-                        examRoom = row.getCell(index).getStringCellValue();
-                    } else if ("考试日期".equals(name)) {
-                        row.getCell(index).setCellType(CellType.STRING);
-                        examDate = row.getCell(index).getStringCellValue();
-                    } else if ("考试时间".equals(name)) {
-                        row.getCell(index).setCellType(CellType.STRING);
-                        examTime = row.getCell(index).getStringCellValue();
-                    } else if ("试卷编号".equals(name)) {
-                        paperNumber = row.getCell(index).getStringCellValue();
-                    } else {
-                        if ("primary".equals(level)) {
-                            throw ExceptionResultEnum.ERROR.exception("有数据库不需要的必选字段 : " + name);
-                        }
-                        if ("secondary".equals(level)) {
-                            // 备选字段处理
-                            FieldsDto secondaryField = new FieldsDto();
-                            secondaryField.setLevel(level);
-                            secondaryField.setCode(code);
-                            secondaryField.setName(name);
-                            secondaryField.setEnable(true);
-                            secondaryField.setValue(row.getCell(index).getStringCellValue());
-                            secondaryFieldList.add(secondaryField);
-                        }
-                    }
-                }
-                Map<String, Object> dataMap = new HashMap<>();
-                dataMap.put("studentCode", studentCode);
-                dataMap.put("studentName", studentName);
-                // TODO: 2021/4/9 校验课程
-                dataMap.put("courseCode", courseCode);
-                dataMap.put("courseName", courseName);
-                dataMap.put("examPlace", examPlace);
-                dataMap.put("examRoom", examRoom);
-                // TODO: 2021/4/9 解析时间
-                dataMap.put("examDate", examDate);
-                dataMap.put("examTime", examTime);
-                dataMap.put("paperNumber", paperNumber);
-                dataMap.put("secondaryFieldList", secondaryFieldList);
-                dataMap.put("schoolId", schoolId);
-                dataMap.put("printPlanId", printPlanId);
-                dataMap.put("printPlanName", printPlanName);
-                dataList.add(dataMap);
-            }
-            System.out.println("dataList = " + JSON.toJSONString(dataList));
-
-
-            // 组装exam_detail数据
-            this.disposeExamDetailByExaminationExcel(dataList,userId);
-            // 组装exam_detail_course数据
-            this.disposeExamDetailCourseByExaminationExcel(dataList,userId);
-            // 组装exam_student数据
-            this.disposeExamStudentByExaminationExcel(dataList,userId);
+            taskLogicService.executeImportExaminationLogic(map);
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", FORMAT_TIME, FINISH_TITLE, 111, FINISH_SIZE));
             tbTask.setResult(TaskResultEnum.SUCCESS);
         }catch (Exception e){
@@ -230,153 +64,4 @@ public class AsyncExaminationImportTemplateService extends AsyncImportTaskTemple
         }
         return ResultUtil.ok(map);
     }
-
-    private void disposeExamDetailByExaminationExcel(List<Map<String, Object>> dataList,Long userId){
-        List<Map<String, Object>> examDetailKeyList = dataList.stream().flatMap(e -> {
-            Map<String, Object> map = new HashMap<>();
-            map.put("schoolId",e.get("schoolId"));
-            map.put("printPlanId",e.get("printPlanId"));
-            map.put("printPlanName",e.get("printPlanName"));
-            map.put("examPlace",e.get("examPlace"));
-            map.put("examRoom",e.get("examRoom"));
-            map.put("examDate",e.get("examDate"));
-            map.put("examTime",e.get("examTime"));
-            return Stream.of(map);
-        }).distinct().collect(Collectors.toList());
-
-        System.out.println("examDetailKeyList = " + JSON.toJSONString(examDetailKeyList));
-
-        List<ExamDetail> examDetailList = new ArrayList<>();
-        for (Map<String, Object> map : examDetailKeyList) {
-            String examPlace = String.valueOf(map.get("examPlace"));
-            String examRoom = String.valueOf(map.get("examRoom"));
-            String examDate = String.valueOf(map.get("examDate"));
-            String examTime = String.valueOf(map.get("examTime"));
-            System.out.println("dataList : " + JSON.toJSONString(dataList));
-            System.out.println(examPlace + examRoom + examDate + examTime);
-            long totalSubjects = dataList.stream()
-                    .filter(e -> String.valueOf(e.get("examPlace")).equals(examPlace) &&
-                            String.valueOf(e.get("examRoom")).equals(examRoom) &&
-                            String.valueOf(e.get("examDate")).equals(examDate) &&
-                            String.valueOf(e.get("examTime")).equals(examTime)).count();
-
-            System.out.println("totalSubjects" + totalSubjects);
-            ExamDetail examDetail = new ExamDetail();
-            examDetail.setId(SystemConstant.getDbUuid());
-            examDetail.setExamName("");
-            examDetail.setSchoolId(Long.valueOf(String.valueOf(map.get("schoolId"))));
-            examDetail.setPrintPlanId(Long.valueOf(String.valueOf(map.get("printPlanId"))));
-            examDetail.setPrintPlanName(String.valueOf(map.get("printPlanName")));
-            examDetail.setExamPlace(examPlace);
-            examDetail.setExamRoom(examRoom);
-            examDetail.setTotalSubjects(Math.toIntExact(totalSubjects));
-            // TODO: 2021/4/9 解析日期和时间
-            examDetail.setExamStartTime(1L);
-            examDetail.setExamEndTime(2L);
-            examDetail.setCreateId(userId);
-            examDetail.setUpdateId(userId);
-            examDetailList.add(examDetail);
-        }
-        examDetailService.saveBatch(examDetailList);
-    }
-
-    private void disposeExamDetailCourseByExaminationExcel(List<Map<String, Object>> dataList,Long userId){
-
-        List<Map<String, Object>> examDetailKeyList = dataList.stream().flatMap(e -> {
-            Map<String, Object> map = new HashMap<>();
-            map.put("schoolId",e.get("schoolId"));
-            map.put("printPlanId",e.get("printPlanId"));
-            map.put("examPlace",e.get("examPlace"));
-            map.put("examRoom",e.get("examRoom"));
-            map.put("examDate",e.get("examDate"));
-            map.put("examTime",e.get("examTime"));
-            map.put("courseCode",e.get("courseCode"));
-            map.put("courseName",e.get("courseName"));
-            map.put("paperNumber",e.get("paperNumber"));
-            return Stream.of(map);
-        }).distinct().collect(Collectors.toList());
-
-        List<ExamDetailCourse> examDetailCourseList = new ArrayList<>();
-        for (Map<String, Object> map : examDetailKeyList) {
-            Long schoolId = Long.valueOf(String.valueOf(map.get("schoolId")));
-            Long printPlanId = Long.valueOf(String.valueOf(map.get("printPlanId")));
-            String examPlace = String.valueOf(map.get("examPlace"));
-            String examRoom = String.valueOf(map.get("examRoom"));
-            Long examStartTime = 1L;
-            Long examEndTime = 2L;
-            String courseCode = String.valueOf(map.get("courseCode"));
-            String courseName = String.valueOf(map.get("courseName"));
-            String paperNumber = String.valueOf(map.get("paperNumber"));
-            List<ExamDetail> examDetailList = examDetailService.list(new QueryWrapper<ExamDetail>().lambda()
-                    .eq(ExamDetail::getPrintPlanId,printPlanId)
-                    .eq(ExamDetail::getExamPlace,examPlace)
-                    .eq(ExamDetail::getExamRoom,examRoom)
-                    .eq(ExamDetail::getExamStartTime,examStartTime)
-                    .eq(ExamDetail::getExamEndTime,examEndTime));
-            if (examDetailList.size() != 1){
-                throw ExceptionResultEnum.ERROR.exception("无法找到新增的考务场次数据");
-            }
-            Long examDetailId = examDetailList.get(0).getId();
-            ExamDetailCourse examDetailCourse = new ExamDetailCourse();
-            examDetailCourse.setId(SystemConstant.getDbUuid());
-            examDetailCourse.setSchoolId(schoolId);
-            examDetailCourse.setExamDetailId(examDetailId);
-            examDetailCourse.setCourseCode(courseCode);
-            examDetailCourse.setCourseName(courseName);
-            examDetailCourse.setPaperNumber(paperNumber);
-            examDetailCourse.setCreateId(userId);
-            examDetailCourse.setUpdateId(userId);
-            examDetailCourseList.add(examDetailCourse);
-        }
-        examDetailCourseService.saveBatch(examDetailCourseList);
-    }
-
-    private void disposeExamStudentByExaminationExcel(List<Map<String, Object>> dataList,Long userId){
-        List<ExamStudent> examStudentList = new ArrayList<>();
-        for (Map<String, Object> map : dataList) {
-            Long schoolId = Long.valueOf(String.valueOf(map.get("schoolId")));
-            Long printPlanId = Long.valueOf(String.valueOf(map.get("printPlanId")));
-            String examPlace = String.valueOf(map.get("examPlace"));
-            String examRoom = String.valueOf(map.get("examRoom"));
-            Long examStartTime = 1L;
-            Long examEndTime = 2L;
-            String courseCode = String.valueOf(map.get("courseCode"));
-            String courseName = String.valueOf(map.get("courseName"));
-            String paperNumber = String.valueOf(map.get("paperNumber"));
-            String studentName = String.valueOf(map.get("studentName"));
-            String studentCode = String.valueOf(map.get("studentCode"));
-            List<ExamDetail> examDetailList = examDetailService.list(new QueryWrapper<ExamDetail>().lambda()
-                    .eq(ExamDetail::getPrintPlanId,printPlanId)
-                    .eq(ExamDetail::getExamPlace,examPlace)
-                    .eq(ExamDetail::getExamRoom,examRoom)
-                    .eq(ExamDetail::getExamStartTime,examStartTime)
-                    .eq(ExamDetail::getExamEndTime,examEndTime));
-            if (examDetailList.size() != 1){
-                throw ExceptionResultEnum.ERROR.exception("无法找到新增的考务场次数据");
-            }
-            Long examDetailId = examDetailList.get(0).getId();
-            List<ExamDetailCourse> examDetailCourseList = examDetailCourseService.list(new QueryWrapper<ExamDetailCourse>().lambda()
-                    .eq(ExamDetailCourse::getExamDetailId,examDetailId)
-                    .eq(ExamDetailCourse::getCourseCode,courseCode)
-                    .eq(ExamDetailCourse::getCourseName,courseName)
-                    .eq(ExamDetailCourse::getPaperNumber,paperNumber));
-            if (examDetailCourseList.size() != 1){
-                throw ExceptionResultEnum.ERROR.exception("无法找到新增的考务科目数据");
-            }
-            Long examDetailCourseId = examDetailCourseList.get(0).getId();
-
-            ExamStudent examStudent = new ExamStudent();
-            examStudent.setId(SystemConstant.getDbUuid());
-            examStudent.setSchoolId(schoolId);
-            examStudent.setExamDetailCourseId(examDetailCourseId);
-            examStudent.setStudentName(studentName);
-            examStudent.setStudentCode(studentCode);
-            examStudent.setTicketNumber("");
-            examStudent.setSiteNumber("");
-            examStudent.setCreateId(userId);
-            examStudent.setUpdateId(userId);
-            examStudentList.add(examStudent);
-        }
-        examStudentService.saveBatch(examStudentList);
-    }
 }

+ 2 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/export/AsyncExportTaskTemplete.java

@@ -19,6 +19,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.annotation.Async;
 
+import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.nio.charset.StandardCharsets;
 import java.text.MessageFormat;
@@ -52,12 +53,7 @@ public abstract class AsyncExportTaskTemplete {
      * @return
      */
     @Async
-    Result exportTask(Map<String, Object> map) {
-        return null;
-    }
-
-    @Async
-    public abstract Result exportTask(Map<String, Object> map,Long printPlanId,String courseCode,String paperNumber,String examPlace,String examRoom,String packageCode) throws Exception;
+    public abstract Result exportTask(Map<String, Object> map) throws Exception;
 
     /**
      * 创建txt文件

+ 10 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.templete.service;
 
+import com.qmth.distributed.print.business.entity.TBTask;
 import org.springframework.util.LinkedMultiValueMap;
 
 import java.io.IOException;
@@ -31,4 +32,13 @@ public interface TaskLogicService {
      * @return
      */
     public Map<String, Object> executeCreatePdfLogic(Map<String, Object> map) throws IOException;
+
+    /**
+     * 处理考务数据逻辑
+     * @param map 参数
+     * @return 要导出的考务数据
+     */
+    public Map<String,Object> executeExaminationLogic(Map<String, Object> map) throws Exception;
+
+    public Map<String,Object> executeImportExaminationLogic(Map<String, Object> map) throws IOException, Exception;
 }

+ 211 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.templete.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.oss.common.utils.BinaryUtil;
@@ -7,7 +8,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.Gson;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.distributed.print.business.bean.dto.ExamStudentDto;
+import com.qmth.distributed.print.business.bean.dto.FieldsDto;
 import com.qmth.distributed.print.business.bean.dto.excel.UserImportDto;
+import com.qmth.distributed.print.business.bean.result.ExaminationResult;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.DrawRuleEnum;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
@@ -21,6 +24,12 @@ import com.qmth.distributed.print.common.util.Base64Util;
 import com.qmth.distributed.print.common.util.HexUtils;
 import com.qmth.distributed.print.common.util.ResultUtil;
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -32,6 +41,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
+import java.io.*;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -82,6 +92,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     @Resource
     BasicAttachmentService basicAttachmentService;
 
+    @Resource
+    ExamDetailService examDetailService;
+
     @Resource
     OssUtil ossUtil;
 
@@ -302,6 +315,204 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return map;
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Map<String,Object> executeExaminationLogic(Map<String, Object> map) throws Exception {
+//        printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode,
+        Long printPlanId = null;
+        if (map.get("printPlanId") != null){
+            printPlanId = SystemConstant.convertIdToLong(String.valueOf(map.get("printPlanId")));
+        }
+        String courseCode = null;
+        if (map.get("courseCode") != null){
+            courseCode = String.valueOf(map.get("courseCode"));
+        }
+        String paperNumber = null;
+        if (map.get("paperNumber") != null){
+            paperNumber = String.valueOf(map.get("paperNumber"));
+        }
+        String examPlace = null;
+        if (map.get("examPlace") != null){
+            examPlace = String.valueOf(map.get("examPlace"));
+        }
+        String examRoom = null;
+        if (map.get("examRoom") != null){
+            examRoom = String.valueOf(map.get("examRoom"));
+        }
+        String packageCode = null;
+        if (map.get("packageCode") != null){
+            packageCode = String.valueOf(map.get("packageCode"));
+        }
+
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        Long userId = tbTask.getCreateId();
+        Long schoolId = tbTask.getSchoolId();
+
+        List<ExaminationResult> examinationResultList = examDetailService.findExaminationBriefPage(schoolId,
+                printPlanId, courseCode, paperNumber, examPlace, examRoom, packageCode,
+                SystemConstant.PAGE_NUMBER, SystemConstant.PAGE_SIZE).getRecords();
+        System.out.println("examinationResultList = " + JSON.toJSONString(examinationResultList));
+
+        OutputStream outputStream = new ByteArrayOutputStream();
+        ExcelUtil.excelMake(ExaminationResult.class,examinationResultList,outputStream);
+
+        InputStream in = ConvertUtil.parse(outputStream);
+
+        ossUtil.ossUpload("考务数据", in, DigestUtils.md5Hex(in));
+        return map;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public Map<String, Object> executeImportExaminationLogic(Map<String, Object> map) throws Exception {
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        InputStream inputStream = (InputStream) map.get("inputStream");
+        Long printPlanId = tbTask.getPrintPlanId();
+        Long userId = tbTask.getCreateId();
+        ExamPrintPlan examPrintPlan = examPrintPlanService.getById(printPlanId);
+
+        if (examPrintPlan == null){
+            throw ExceptionResultEnum.ERROR.exception("印刷计划不存在printPlanId : " + printPlanId);
+        }
+        String printPlanName = examPrintPlan.getName();
+        Long schoolId = tbTask.getSchoolId();
+        // 该学校有效考务数据
+        List<FieldsDto> fieldsDtoList = examDetailService.findExaminationFields(schoolId);
+        if (fieldsDtoList.size() == 0) {
+            throw ExceptionResultEnum.ERROR.exception("该学校没有设置考务数据");
+        }
+        String importFilePath = tbTask.getImportFilePath();
+        Map importFilePathMap = JSONObject.parseObject(importFilePath);
+        String path = String.valueOf(importFilePathMap.get("path"));
+        System.out.println("path = " + path);
+        Workbook workbook = null;
+        if (path.endsWith(SystemConstant.XLSX)) {
+            workbook = new XSSFWorkbook(inputStream);
+        } else if (path.endsWith("xls")) {
+            workbook = new HSSFWorkbook(inputStream);
+        } else {
+            throw ExceptionResultEnum.ERROR.exception("文件格式异常");
+        }
+        // 读取第一个工作表
+        Sheet sheet = workbook.getSheetAt(0);
+        // 获取sheet行数
+        int totalRows = sheet.getPhysicalNumberOfRows();
+        // 获取sheet列数
+        int totalCells = 0;
+        if (totalRows > 1 && sheet.getRow(0) != null) {
+            totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
+        }
+        System.out.println("行 : " + totalRows + "\n列 : " + totalCells);
+        Row head = sheet.getRow(0);
+        List<String> headList = new ArrayList<>();
+        // 将必填字段匹配excel解析的表头索引
+        for (int i = 0; i < totalCells; i++) {
+            String cellValue = head.getCell(i).getStringCellValue();
+            for (FieldsDto fieldsDto : fieldsDtoList) {
+                if (cellValue.equals(fieldsDto.getName())) {
+                    fieldsDto.setIndex(i);
+                }
+            }
+            headList.add(cellValue);
+        }
+
+        // 搜索所有有效字段 excel中的表头是否包含
+        for (FieldsDto fieldsDto : fieldsDtoList) {
+            if (!headList.contains(fieldsDto.getName())) {
+                System.out.println("exception " + fieldsDto.getName());
+                throw ExceptionResultEnum.ERROR.exception("学校考务必填字段 :'" + fieldsDto.getName() + "' 不存在");
+            }
+        }
+
+        System.out.println("headList : " + headList);
+        System.out.println("fieldsDtoList : " + JSONObject.toJSONString(fieldsDtoList));
+
+        List<Map<String, Object>> dataList = new ArrayList<>();
+
+        for (int r = 1; r < totalRows; r++) {
+            Row row = sheet.getRow(r);
+
+            String studentCode = null;
+            String studentName = null;
+            String courseCode = null;
+            String courseName = null;
+            String examPlace = null;
+            String examRoom = null;
+            String examDate = null;
+            String examTime = null;
+            String paperNumber = null;
+            List<FieldsDto> secondaryFieldList = new ArrayList<>();
+            for (FieldsDto fieldsDto : fieldsDtoList) {
+                String name = fieldsDto.getName();
+                String code = fieldsDto.getCode();
+                int index = fieldsDto.getIndex();
+                String level = fieldsDto.getLevel();
+                if ("学号".equals(name)) {
+                    studentCode = row.getCell(index).getStringCellValue();
+                } else if ("姓名".equals(name)) {
+                    studentName = row.getCell(index).getStringCellValue();
+                } else if ("课程代码".equals(name)) {
+                    courseCode = row.getCell(index).getStringCellValue();
+                } else if ("课程名称".equals(name)) {
+                    courseName = row.getCell(index).getStringCellValue();
+                } else if ("考点".equals(name)) {
+                    examPlace = row.getCell(index).getStringCellValue();
+                } else if ("考场".equals(name)) {
+                    examRoom = row.getCell(index).getStringCellValue();
+                } else if ("考试日期".equals(name)) {
+                    row.getCell(index).setCellType(CellType.STRING);
+                    examDate = row.getCell(index).getStringCellValue();
+                } else if ("考试时间".equals(name)) {
+                    row.getCell(index).setCellType(CellType.STRING);
+                    examTime = row.getCell(index).getStringCellValue();
+                } else if ("试卷编号".equals(name)) {
+                    paperNumber = row.getCell(index).getStringCellValue();
+                } else {
+                    if ("primary".equals(level)) {
+                        throw ExceptionResultEnum.ERROR.exception("有数据库不需要的必选字段 : " + name);
+                    }
+                    if ("secondary".equals(level)) {
+                        // 备选字段处理
+                        FieldsDto secondaryField = new FieldsDto();
+                        secondaryField.setLevel(level);
+                        secondaryField.setCode(code);
+                        secondaryField.setName(name);
+                        secondaryField.setEnable(true);
+                        secondaryField.setValue(row.getCell(index).getStringCellValue());
+                        secondaryFieldList.add(secondaryField);
+                    }
+                }
+            }
+            Map<String, Object> dataMap = new HashMap<>();
+            dataMap.put("studentCode", studentCode);
+            dataMap.put("studentName", studentName);
+            // TODO: 2021/4/9 校验课程
+            dataMap.put("courseCode", courseCode);
+            dataMap.put("courseName", courseName);
+            dataMap.put("examPlace", examPlace);
+            dataMap.put("examRoom", examRoom);
+            // TODO: 2021/4/9 解析时间
+            dataMap.put("examDate", examDate);
+            dataMap.put("examTime", examTime);
+            dataMap.put("paperNumber", paperNumber);
+            dataMap.put("secondaryFieldList", secondaryFieldList);
+            dataMap.put("schoolId", schoolId);
+            dataMap.put("printPlanId", printPlanId);
+            dataMap.put("printPlanName", printPlanName);
+            dataList.add(dataMap);
+        }
+        System.out.println("dataList = " + JSON.toJSONString(dataList));
+
+
+        // 组装exam_detail数据
+        examDetailService.disposeExamDetailByExaminationExcel(dataList,userId);
+        // 组装exam_detail_course数据
+        examDetailService.disposeExamDetailCourseByExaminationExcel(dataList,userId);
+        // 组装exam_student数据
+        examDetailService.disposeExamStudentByExaminationExcel(dataList,userId);
+        return null;
+    }
+
     /**
      * 创建签到表
      *

+ 31 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/ConvertUtil.java

@@ -0,0 +1,31 @@
+package com.qmth.distributed.print.business.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author: CaoZixuan
+ * @Date:
+ */
+public class ConvertUtil {
+    // inputStream转outputStream
+    public static ByteArrayOutputStream parse(final InputStream in) throws Exception {
+        final ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
+        int ch;
+        while ((ch = in.read()) != -1) {
+            swapStream.write(ch);
+        }
+        return swapStream;
+    }
+
+    // outputStream转inputStream
+    public static ByteArrayInputStream parse(final OutputStream out) {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        baos = (ByteArrayOutputStream) out;
+        return new ByteArrayInputStream(baos.toByteArray());
+    }
+}

+ 12 - 9
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamDetailController.java

@@ -4,30 +4,26 @@ package com.qmth.distributed.print.api;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.distributed.print.business.bean.dto.excel.UserExportDto;
-import com.qmth.distributed.print.business.bean.params.ArraysParams;
 import com.qmth.distributed.print.business.bean.result.EditResult;
-import com.qmth.distributed.print.business.bean.result.ExaminationResult;
 import com.qmth.distributed.print.business.entity.TBTask;
 import com.qmth.distributed.print.business.enums.TaskTypeEnum;
 import com.qmth.distributed.print.business.service.ExamDetailService;
 import com.qmth.distributed.print.business.service.TBTaskService;
 import com.qmth.distributed.print.business.templete.execute.AsyncExaminationExportTemplateService;
 import com.qmth.distributed.print.business.templete.execute.AsyncExaminationImportTemplateService;
-import com.qmth.distributed.print.business.util.ExcelUtil;
 import com.qmth.distributed.print.business.util.ServletUtil;
 import com.qmth.distributed.print.common.contant.SystemConstant;
 import com.qmth.distributed.print.common.util.Result;
 import com.qmth.distributed.print.common.util.ResultUtil;
 import io.swagger.annotations.*;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import javax.validation.Valid;
 import java.io.IOException;
-import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -155,8 +151,15 @@ public class ExamDetailController {
                            @ApiParam(value = "考场") @RequestParam(required = false) String examRoom,
                            @ApiParam(value = "卷袋号") @RequestParam(required = false) String packageCode) throws Exception {
         Map<String, Object> map = tbTaskService.saveTask(TaskTypeEnum.EXAMINATION_EXPORT);
+        map.put("printPlanId",printPlanId);
+        map.put("courseCode",courseCode);
+        map.put("paperNumber",paperNumber);
+        map.put("examPlace",examPlace);
+        map.put("examRoom",examRoom);
+        map.put("packageCode",packageCode);
         asyncExaminationExportTemplateService
-                .exportTask(map,SystemConstant.convertIdToLong(printPlanId),courseCode,paperNumber,examPlace,examRoom,packageCode);
+                .exportTask(map);
+        TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;
     }
 }