|
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
+import com.qmth.boot.tools.excel.ExcelReader;
|
|
|
|
+import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
import com.qmth.distributed.print.business.bean.dto.*;
|
|
import com.qmth.distributed.print.business.bean.dto.approvalForm.*;
|
|
import com.qmth.distributed.print.business.bean.dto.approvalForm.*;
|
|
import com.qmth.distributed.print.business.bean.dto.examObject.ExamObjectDto;
|
|
import com.qmth.distributed.print.business.bean.dto.examObject.ExamObjectDto;
|
|
@@ -71,6 +73,7 @@ import java.io.InputStream;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
@@ -550,6 +553,132 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
return examTaskImportResultDto;
|
|
return examTaskImportResultDto;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public ExamTaskImportResultDto importFile1(MultipartFile file) throws IOException {
|
|
|
|
+ Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
|
+
|
|
|
|
+ ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 1);
|
|
|
|
+ List<ExamTaskTemp> examTaskImportDtoList;
|
|
|
|
+ try {
|
|
|
|
+ examTaskImportDtoList = excelReader.getObjectList(ExamTaskTemp.class);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("读取excel内容失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AtomicInteger i = new AtomicInteger(3);
|
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.getSecondOrg(schoolId, null);
|
|
|
|
+ if (CollectionUtils.isEmpty(sysOrgList)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请先导入机构数据");
|
|
|
|
+ }
|
|
|
|
+ List<BasicCourse> basicCourseList = basicCourseService.listBySchoolId(schoolId);
|
|
|
|
+ if (CollectionUtils.isEmpty(basicCourseList)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请先导入课程数据");
|
|
|
|
+ }
|
|
|
|
+ List<SysUserResult> sysUserList = sysUserService.listBySchoolId(schoolId);
|
|
|
|
+ if (CollectionUtils.isEmpty(sysUserList)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请先导入用户数据");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 课程与名称map
|
|
|
|
+ Map<String, String> courseCodeAndNameMap = new HashMap<>();
|
|
|
|
+ // 试卷编号与课程代码map
|
|
|
|
+ Map<String, String> paperNumberAndCourseCodeMap = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ ExamTaskImportResultDto examTaskImportResultDto = new ExamTaskImportResultDto();
|
|
|
|
+ examTaskImportResultDto.setBatchNo(String.valueOf(System.nanoTime()));
|
|
|
|
+ List<ExamTaskTemp> examTaskTempList = new ArrayList<>();
|
|
|
|
+ List<ExamTaskDto> examTaskDtos = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (ExamTaskTemp examTaskTemp : examTaskImportDtoList) {
|
|
|
|
+ StringJoiner errorMsg = new StringJoiner("");
|
|
|
|
+ errorMsg.add("第" + i.getAndIncrement() + "行");
|
|
|
|
+ String courseCode = examTaskTemp.getCourseCode();
|
|
|
|
+ String courseName = examTaskTemp.getCourseName();
|
|
|
|
+ String teachingRoomName = examTaskTemp.getTeachingRoomName();
|
|
|
|
+ String paperNumber = examTaskTemp.getPaperNumber();
|
|
|
|
+ String userAccount = examTaskTemp.getUserAccount();
|
|
|
|
+ String userName = examTaskTemp.getUserName();
|
|
|
|
+ if (StringUtils.isBlank(courseCode)) {
|
|
|
|
+ errorMsg.add("课程代码" + courseCode + "不能为空");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(courseName)) {
|
|
|
|
+ errorMsg.add("课程名称[" + courseName + "]不能为空");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(teachingRoomName)) {
|
|
|
|
+ errorMsg.add("开课学院[" + teachingRoomName + "]不能为空");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ SysOrg sysOrg = sysOrgList.stream().filter(m -> m.getName().equals(teachingRoomName)).findFirst().orElse(null);
|
|
|
|
+ if (sysOrg == null) {
|
|
|
|
+ errorMsg.add("开课学院[" + teachingRoomName + "]不存在");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ BasicCourse basicCourse = basicCourseList.stream().filter(m -> m.getTeachingRoomId().equals(sysOrg.getId()) && m.getCode().equals(courseCode)).findFirst().orElse(null);
|
|
|
|
+ if (basicCourse == null) {
|
|
|
|
+ errorMsg.add("开课学院[" + teachingRoomName + "]未找到课程代码[" + courseCode + "]");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ // 课程是否重复
|
|
|
|
+ if (courseCodeAndNameMap.containsKey(courseCode + teachingRoomName)) {
|
|
|
|
+ if (courseCodeAndNameMap.get(courseCode + teachingRoomName).equals(paperNumber)) {
|
|
|
|
+ errorMsg.add("课程代码[" + courseCode + "]、开课学院[" + teachingRoomName + "]有重复数据");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ courseCodeAndNameMap.put(courseCode + teachingRoomName, paperNumber);
|
|
|
|
+ }
|
|
|
|
+ // 试卷编号是否重复
|
|
|
|
+ if (StringUtils.isNotBlank(paperNumber)) {
|
|
|
|
+ if (paperNumberAndCourseCodeMap.containsKey(paperNumber)) {
|
|
|
|
+ errorMsg.add("试卷编号[" + paperNumber + "]有重复数据");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ } else {
|
|
|
|
+ courseCodeAndNameMap.put(paperNumber, "1");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ((StringUtils.isNotBlank(userAccount) && StringUtils.isBlank(userName)) ||
|
|
|
|
+ (StringUtils.isBlank(userAccount) && StringUtils.isNotBlank(userName))) {
|
|
|
|
+ errorMsg.add("命题老师工号、命题老师姓名必须都为空或都不为空");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ SysUserResult sysUser = null;
|
|
|
|
+ if (!StringUtils.isAllBlank(userAccount, userName)) {
|
|
|
|
+ // 校验命题老师
|
|
|
|
+ sysUser = sysUserList.stream().filter(m -> m.getLoginName().equals(userAccount)).findFirst().orElse(null);
|
|
|
|
+ if (sysUser != null && !userName.equals(sysUser.getRealName())) {
|
|
|
|
+ errorMsg.add("命题老师姓名[" + userName + "]与用户管理中不一致");
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(errorMsg.toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ examTaskTemp.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examTaskTemp.setSchoolId(schoolId);
|
|
|
|
+ examTaskTemp.setBatchNo(examTaskImportResultDto.getBatchNo());
|
|
|
|
+ examTaskTemp.setCourseId(basicCourse.getId());
|
|
|
|
+ examTaskTempList.add(examTaskTemp);
|
|
|
|
+
|
|
|
|
+ ExamTaskDto examTaskDto = new ExamTaskDto();
|
|
|
|
+ examTaskDto.setCourseId(basicCourse.getId());
|
|
|
|
+ examTaskDto.setCourseCode(examTaskTemp.getCourseCode());
|
|
|
|
+ examTaskDto.setCourseName(examTaskTemp.getCourseName());
|
|
|
|
+ examTaskDto.setPaperNumber(examTaskTemp.getPaperNumber());
|
|
|
|
+ if (sysUser != null) {
|
|
|
|
+ examTaskDto.setUserId(String.valueOf(sysUser.getId()));
|
|
|
|
+ examTaskDto.setUserName(sysUser.getRealName());
|
|
|
|
+ }
|
|
|
|
+ examTaskDto.setUsers(sysUserList);
|
|
|
|
+ examTaskDtos.add(examTaskDto);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ examTaskImportResultDto.setTasks(examTaskDtos);
|
|
|
|
+ if (CollectionUtils.isNotEmpty(examTaskTempList)) {
|
|
|
|
+ examTaskTempService.saveBatch(examTaskTempList);
|
|
|
|
+ }
|
|
|
|
+ return examTaskImportResultDto;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public List<ExamTask> saveBatch(ExamTask task) {
|
|
public List<ExamTask> saveBatch(ExamTask task) {
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
@@ -734,7 +863,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
|
|
map.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
|
|
map.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
|
|
// map.computeIfAbsent(SystemConstant.PAPAER_ATTACHMENT_IDS, v -> examTaskDetail.getPaperAttachmentIds());
|
|
// map.computeIfAbsent(SystemConstant.PAPAER_ATTACHMENT_IDS, v -> examTaskDetail.getPaperAttachmentIds());
|
|
map.computeIfAbsent(SystemConstant.APPROVE_OPERATION, v -> FlowApprovePassEnum.PASS);
|
|
map.computeIfAbsent(SystemConstant.APPROVE_OPERATION, v -> FlowApprovePassEnum.PASS);
|
|
-// map.computeIfAbsent(SystemConstant.APPROVE_USER_IDS, v -> examTaskDetail.getApproveUserIds());
|
|
|
|
|
|
+ map.computeIfAbsent(SystemConstant.APPROVE_USER_IDS, v -> examTaskApplyPram.getApproveUserIds());
|
|
map = activitiService.taskApprove(map);
|
|
map = activitiService.taskApprove(map);
|
|
map.put(SystemConstant.SEND_FLOW_MQ, true);
|
|
map.put(SystemConstant.SEND_FLOW_MQ, true);
|
|
}
|
|
}
|