|
@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -96,8 +97,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
Map<String, Object> finalMap = new HashMap<>();
|
|
|
ExamDetail examDetail = examDetailService.getById(examDetailId);
|
|
|
// 撤回提示
|
|
|
- if(ExamDetailStatusEnum.NEW.name().equals(examDetail.getStatus())
|
|
|
- || ExamDetailStatusEnum.READY.name().equals(examDetail.getStatus())){
|
|
|
+ if (ExamDetailStatusEnum.NEW.name().equals(examDetail.getStatus())
|
|
|
+ || ExamDetailStatusEnum.READY.name().equals(examDetail.getStatus())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("该任务已被撤回");
|
|
|
}
|
|
|
// 取试卷
|
|
@@ -149,8 +150,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
public Map<String, Object> getPrintData(Long examDetailId, String machineCode, Boolean isPrint, String printUser) {
|
|
|
ExamDetail examDetail = examDetailService.getById(examDetailId);
|
|
|
// 撤回提示
|
|
|
- if(ExamDetailStatusEnum.NEW.name().equals(examDetail.getStatus())
|
|
|
- || ExamDetailStatusEnum.READY.name().equals(examDetail.getStatus())){
|
|
|
+ if (ExamDetailStatusEnum.NEW.name().equals(examDetail.getStatus())
|
|
|
+ || ExamDetailStatusEnum.READY.name().equals(examDetail.getStatus())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("该任务已被撤回");
|
|
|
}
|
|
|
if (isPrint && StringUtils.isBlank(printUser)) {
|
|
@@ -167,7 +168,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
// 2.取生成的完整的pdf
|
|
|
String printContent = examPrintPlan.getPrintContent();
|
|
|
// 是否包含试卷、题卡
|
|
|
- if(StringUtils.isNotBlank(printContent)) {
|
|
|
+ if (StringUtils.isNotBlank(printContent)) {
|
|
|
// 试卷、题卡map
|
|
|
Map<String, Object> detailMap = new HashMap<>();
|
|
|
// 备用试卷、备用题卡map
|
|
@@ -176,7 +177,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
int backupCount = examPrintPlan.getBackupCount().intValue();
|
|
|
// 取考生列表
|
|
|
List<Map> studentList = examDetailService.listStudentByExamDetailId(schoolId, examDetailId, "1", "1");
|
|
|
- if(printContent.contains("PAPER")){
|
|
|
+ if (printContent.contains("PAPER")) {
|
|
|
if (examDetail.getAttachmentId() == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("考场pdf未生成");
|
|
|
}
|
|
@@ -224,7 +225,7 @@ public class ClientServiceImpl implements ClientService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if(printContent.contains("CARD")){
|
|
|
+ if (printContent.contains("CARD")) {
|
|
|
// 生成题卡List
|
|
|
detailMap.put("card", spliceCardContent(studentList));
|
|
|
|
|
@@ -232,6 +233,9 @@ public class ClientServiceImpl implements ClientService {
|
|
|
List<ClientPrintBackupDataDto> cardBackupList = new ArrayList<>();
|
|
|
for (Map<String, Object> examDetailCours : examDetailCourses) {
|
|
|
String attachmentIds = examDetailCours.get("cardAttachmentIds").toString();
|
|
|
+ if (StringUtils.isBlank(attachmentIds)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("备用题卡未生成");
|
|
|
+ }
|
|
|
JSONObject jsonObject = JSONObject.parseObject(attachmentIds);
|
|
|
List<Map> backupCards = JSONObject.parseArray(JSONObject.toJSONString(jsonObject.get("card")), Map.class);
|
|
|
for (Map backupCard : backupCards) {
|
|
@@ -331,8 +335,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
return m.getExamDetailId();
|
|
|
}
|
|
|
return null;
|
|
|
- }).filter(m->StringUtils.isNotBlank(m)).count();
|
|
|
- if(count > 0){
|
|
|
+ }).filter(m -> StringUtils.isNotBlank(m)).count();
|
|
|
+ if (count > 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("有任务被撤回,请刷新列表后再试");
|
|
|
}
|
|
|
List<Map<String, Object>> finalList = new ArrayList<>();
|
|
@@ -394,8 +398,8 @@ public class ClientServiceImpl implements ClientService {
|
|
|
}
|
|
|
|
|
|
// 撤回提示
|
|
|
- if(ExamDetailStatusEnum.NEW.name().equals(examDetail.getStatus())
|
|
|
- || ExamDetailStatusEnum.READY.name().equals(examDetail.getStatus())){
|
|
|
+ if (ExamDetailStatusEnum.NEW.name().equals(examDetail.getStatus())
|
|
|
+ || ExamDetailStatusEnum.READY.name().equals(examDetail.getStatus())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("该任务已被撤回");
|
|
|
}
|
|
|
|
|
@@ -405,57 +409,77 @@ public class ClientServiceImpl implements ClientService {
|
|
|
if (!packageCode.equals(examDetail.getPackageCode())) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("卷袋编号与系统数据不一致");
|
|
|
}
|
|
|
- // 取最后一张备卡
|
|
|
- QueryWrapper<ExamDetailCourse> courseQueryWrapper = new QueryWrapper<>();
|
|
|
- courseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetailId).orderByDesc(ExamDetailCourse::getPaperNumber);
|
|
|
- List<ExamDetailCourse> examDetailCourses = examDetailCourseService.list(courseQueryWrapper);
|
|
|
- if (examDetailCourses.isEmpty()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("考场下课程数据异常");
|
|
|
- }
|
|
|
- ExamDetailCourse examDetailCourse = examDetailCourses.get(0);
|
|
|
|
|
|
- QueryWrapper<ExamTask> taskQueryWrapper = new QueryWrapper<>();
|
|
|
- taskQueryWrapper.lambda().eq(ExamTask::getSchoolId, schoolId).eq(ExamTask::getCourseCode, examDetailCourse.getCourseCode()).eq(ExamTask::getPaperNumber, examDetailCourse.getPaperNumber());
|
|
|
- ExamTask examTask = examTaskService.getOne(taskQueryWrapper);
|
|
|
- if (examTask == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
|
|
|
+ ExamPrintPlan examPrintPlan = examPrintPlanService.getById(examDetail.getPrintPlanId());
|
|
|
+ String printContent = examPrintPlan.getPrintContent();
|
|
|
+ if (StringUtils.isBlank(printContent)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("打印内容没有包含试卷、题卡,无需校验");
|
|
|
}
|
|
|
+ Integer backupCount = examPrintPlan.getBackupCount();
|
|
|
+ // 有备用题卡
|
|
|
+ if (printContent.contains("CARD")) {
|
|
|
+ QueryWrapper<ExamDetailCourse> courseQueryWrapper = new QueryWrapper<>();
|
|
|
+ courseQueryWrapper.lambda().eq(ExamDetailCourse::getExamDetailId, examDetailId).orderByDesc(ExamDetailCourse::getPaperNumber);
|
|
|
+ List<ExamDetailCourse> examDetailCourses = examDetailCourseService.list(courseQueryWrapper);
|
|
|
+ if (examDetailCourses.isEmpty()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考场下课程数据异常");
|
|
|
+ }
|
|
|
|
|
|
- QueryWrapper<ExamTaskDetail> taskDetailQueryWrapper = new QueryWrapper<>();
|
|
|
- taskDetailQueryWrapper.lambda().eq(ExamTaskDetail::getExamTaskId, examTask.getId());
|
|
|
- ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(taskDetailQueryWrapper);
|
|
|
- if (examTaskDetail == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("命题任务数据异常");
|
|
|
- }
|
|
|
- ExamCardDetail examCardDetail = examCardDetailService.getByCardId(examTaskDetail.getCardId());
|
|
|
- if (examCardDetail == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡数据异常");
|
|
|
- }
|
|
|
- String attachmentIds = examCardDetail.getAttachmentId();
|
|
|
- if (StringUtils.isBlank(attachmentIds)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("备卡数据异常");
|
|
|
- }
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(attachmentIds);
|
|
|
- String backupAttachmentIds = JSONObject.toJSONString(jsonObject.get("card"));
|
|
|
- List<Map> list = JSONObject.parseArray(backupAttachmentIds, Map.class);
|
|
|
- Map map = list.get(list.size() - 1);
|
|
|
- String backupPackageCode = map.get("packageCode").toString();
|
|
|
- if (StringUtils.isBlank(lastCode)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("最后一张备卡数据异常");
|
|
|
- }
|
|
|
- if (!lastCode.equals(backupPackageCode)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码与系统数据不一致");
|
|
|
- }
|
|
|
+ if (backupCount > 0) {
|
|
|
+ if (StringUtils.isBlank(lastCode)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码数据异常");
|
|
|
+ }
|
|
|
|
|
|
- String lastCodeSub = lastCode.substring(0, lastCode.length() - 2);
|
|
|
- if (!packageCode.equals(lastCodeSub)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码与试卷编号不一致");
|
|
|
- }
|
|
|
+ // 取最后一个课程数据(包含最后一张备卡条码信息)
|
|
|
+ ExamDetailCourse examDetailCourselast = examDetailCourses.get(examDetailCourses.size() - 1);
|
|
|
+ if (examDetailCourselast == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡数据异常");
|
|
|
+ }
|
|
|
+ String attachmentIds = examDetailCourselast.getAttachmentId();
|
|
|
+ if (StringUtils.isBlank(attachmentIds)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("备卡数据异常");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(attachmentIds);
|
|
|
+ String backupAttachmentIds = JSONObject.toJSONString(jsonObject.get("card"));
|
|
|
+ List<Map> list = JSONObject.parseArray(backupAttachmentIds, Map.class);
|
|
|
+ Map map = list.get(list.size() - 1);
|
|
|
+ String backupPackageCode = map.get("packageCode").toString();
|
|
|
+
|
|
|
+ if (!lastCode.equals(backupPackageCode)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码与系统数据不匹配");
|
|
|
+ }
|
|
|
|
|
|
- UpdateWrapper<ExamDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.lambda().set(ExamDetail::getValidate, true).eq(ExamDetail::getId, examDetailId);
|
|
|
+ String lastCodeSub = lastCode.substring(0, lastCode.length() - 2);
|
|
|
+ if (!packageCode.equals(lastCodeSub)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("最后一张备卡条码与试卷编号不属于同一考场");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 无备卡,取最后一个考生考号
|
|
|
+ if (StringUtils.isBlank(lastCode)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("最后一张题卡条码数据异常");
|
|
|
+ }
|
|
|
+ List<Long> examDetailCourseIds = examDetailCourses.stream().map(m -> m.getId()).collect(Collectors.toList());
|
|
|
+ QueryWrapper<ExamStudent> studentQueryWrapper = new QueryWrapper<>();
|
|
|
+ studentQueryWrapper.lambda().in(ExamStudent::getExamDetailCourseId, examDetailCourseIds);
|
|
|
+ List<ExamStudent> examStudents = examStudentService.list(studentQueryWrapper);
|
|
|
+ if (CollectionUtils.isEmpty(examStudents)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考生数据异常");
|
|
|
+ }
|
|
|
+ examStudents.sort(Comparator.comparing(ExamStudent::getSiteNumber));
|
|
|
+ ExamStudent examStudent = examStudents.get(examStudents.size() - 1);
|
|
|
+ if (StringUtils.isBlank(examStudent.getTicketNumber())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考生考号异常");
|
|
|
+ }
|
|
|
+ if (lastCode.equals(examStudent.getTicketNumber())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("最后一张题卡条码与系统数据不匹配");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- return examDetailService.update(updateWrapper);
|
|
|
+ UpdateWrapper<ExamDetail> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.lambda().set(ExamDetail::getValidate, true).eq(ExamDetail::getId, examDetailId);
|
|
|
+ examDetailService.update(updateWrapper);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|