From 8d43111bd0e598bc0b2014cbfa69a32e74959dff Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 15 Dec 2021 19:24:05 +0800
Subject: [PATCH] ftp sql 同步封装
---
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java | 35 ++++++++++++++++++++++++++++++-----
1 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java b/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
index 6635094..ec87cdb 100644
--- a/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
@@ -18,6 +18,7 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.common.utils.TimeSwitchUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.modules.apply.entity.Apply;
import org.springblade.modules.exam.entity.*;
@@ -32,9 +33,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
/**
* 服务实现类
@@ -82,6 +82,22 @@
//模拟考试
if (examPaperVO1.getExamType()==2) {
examPaperVO1.setNum(baseMapper.getTrainNumber(examPaperVO1));
+ examPaperVO1.setExamNum(baseMapper.getExamNumber(examPaperVO1));
+ //计算截止时间
+ long nowTime = System.currentTimeMillis();
+ long examStartTime = examPaperVO1.getStartTime().getTime();
+ long examEndTime = examPaperVO1.getEndTime().getTime();
+ //判断时间
+ if (nowTime-examEndTime>0){
+ //剩余时间大于1天
+ examPaperVO1.setDeadline("考试已结束");
+ }else if(nowTime-examStartTime>=0 && nowTime-examEndTime<=0){
+ //已到考试时间
+ examPaperVO1.setDeadline("已到考试时间");
+ }else {
+ long time = examStartTime - nowTime;
+ examPaperVO1.setDeadline(TimeSwitchUtil.secondToTime(time));
+ }
}
});
return examPaperVOIPage;
@@ -99,6 +115,8 @@
if (null!=paper.getScoreId()){
//随机分类信息
List<ExamSubjectChoicesVO> examSubjectChoicesVOS = baseMapper.queryRandomSubject(paper);
+// long before = System.currentTimeMillis();
+ List<ExamExaminationSubject> list = new ArrayList<>();
examSubjectChoicesVOS.forEach(examSubjectChoicesVO -> {
//新增个人对应每场考试成绩试卷
ExamExaminationSubject ksxtSginup = new ExamExaminationSubject();
@@ -106,8 +124,15 @@
ksxtSginup.setCategoryId(examSubjectChoicesVO.getChoicesType());
ksxtSginup.setSubjectId(examSubjectChoicesVO.getId());
//新增
- examExaminationSubjectService.save(ksxtSginup);
+// examExaminationSubjectService.save(ksxtSginup);
+ list.add(ksxtSginup);
+ //将题目答案设置为空字符串,不让前端看到
+ examSubjectChoicesVO.setAnswer("");
});
+ //批量新增
+ baseMapper.insertBatch(list);
+// long after = System.currentTimeMillis();
+// System.out.println("时间差"+(after-before));
//新增试卷关联信息
return examSubjectChoicesVOS;
}
@@ -174,7 +199,7 @@
* @return
*/
@Override
- public ExamPaper getExamInfoByExamName(String examName) {
+ public List<ExamPaper> getExamInfoByExamName(String examName) {
return baseMapper.getExamInfoByExamName(examName);
}
--
Gitblit v1.9.3