智慧保安后台管理-外网项目备份
Administrator
2021-12-15 8d43111bd0e598bc0b2014cbfa69a32e74959dff
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,6 +33,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@@ -80,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;
@@ -108,6 +126,8 @@
            //新增
//            examExaminationSubjectService.save(ksxtSginup);
            list.add(ksxtSginup);
            //将题目答案设置为空字符串,不让前端看到
            examSubjectChoicesVO.setAnswer("");
         });
         //批量新增
         baseMapper.insertBatch(list);
@@ -179,7 +199,7 @@
    * @return
    */
   @Override
   public ExamPaper getExamInfoByExamName(String examName) {
   public List<ExamPaper> getExamInfoByExamName(String examName) {
      return baseMapper.getExamInfoByExamName(examName);
   }