Administrator
2021-08-19 6bd7ffcfcb0b5fb8dd1a5e95e78b07d9bb161f19
src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -24,7 +24,9 @@
import org.springblade.modules.apply.vo.ApplyPaPerVO;
import org.springblade.modules.apply.vo.ApplyVO;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.entity.ExamScore;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.web.bind.annotation.*;
@@ -50,6 +52,8 @@
   private final ExamPaperService examPaperService;
   private final IUserService userService;
   private final ExamScoreService examScoreService;
   /**
    * 自定义分页
@@ -98,7 +102,7 @@
         if (1==user.getIsApply()){
            return R.data(201,"已报名,不能重复报名");
         }
         if (2==user.getIsApply()){
         if (2==user.getIsApply() || -1==user.getIsApply() || 3==user.getIsApply()){
            //默认通过
            apply.setApplyStatus(2);
            //默认为未考试状态
@@ -389,12 +393,49 @@
            return R.data(200,"取消报名成功");
         }
      }else {
         if(user.getIsApply()==1){
            apply.setApplyStatus(4);
            boolean status = applyService.updateById(apply);
            //修改保安报名状态
            user.setIsApply(2);
            userService.updateById(user);
            if (status){
               return R.data(200,"取消报名成功");
            }
         }else {
            return R.data(201,"尚未报名");
         }
      }
      return R.data(202,"取消报名失败");
   }
   /**
    * 公司报名列表取消报名,无applyId
    * @param apply 考试报名信息对象
    */
   @PostMapping("/cancelApplyNotApplyId")
   public R cancelApplyNotApplyId(@RequestBody Apply apply){
      //查询人员是否已报名
      User user = userService.getById(apply.getUserId());
      //查询报名信息,取最新的一条(即当前userId,)applyId最大的一条记录
      Apply apply1 = applyService.getMaxApplyIdByUserIdInfo(apply.getUserId());
      if(null==user.getIsApply()){
         apply1.setApplyStatus(4);
         boolean status = applyService.updateById(apply1);
         //修改保安报名状态
         user.setIsApply(2);
         userService.updateById(user);
         if (status){
            return R.data(200,"取消报名成功");
         }
      }else {
         if (user.getIsApply()==2) {
            return R.data(201,"尚未报名");
         }
         if(user.getIsApply()==1){
            apply.setApplyStatus(4);
            boolean status = applyService.updateById(apply);
            apply1.setApplyStatus(4);
            boolean status = applyService.updateById(apply1);
            //修改保安报名状态
            user.setIsApply(2);
            userService.updateById(user);
@@ -430,7 +471,7 @@
               user.setIsApply(1);
               userService.updateById(user);
            } else {
               if (user.getIsApply() == 2) {
               if (user.getIsApply() == 2 || -1==user.getIsApply() || 3==user.getIsApply()) {
                  Apply apply1 = new Apply();
                  apply1.setApplyStatus(2);
                  //默认为未考试状态
@@ -447,6 +488,7 @@
      }else {
         //查询所有未报名的人员
         List<User> users = userService.getNotApplyIdList(deptId);
         System.out.println("users = " + users.size());
         if (users.size()>0){
            users.forEach(user ->{
               //未报名的新增,已报名的不做处理
@@ -462,7 +504,7 @@
                  user.setIsApply(1);
                  userService.updateById(user);
               } else {
                  if (user.getIsApply() == 2) {
                  if (user.getIsApply() == 2 || -1==user.getIsApply() || 3==user.getIsApply()) {
                     Apply apply1 = new Apply();
                     apply1.setApplyStatus(2);
                     //默认为未考试状态
@@ -489,17 +531,17 @@
    */
   @PostMapping("/batchExam")
   public R batchExam(@RequestParam String ids,
                  @RequestParam String examTime,
                  String examTime,
                  @RequestParam Date startTime,
                  @RequestParam Date endTime){
                  Date endTime){
      if (!ids.equals("")){
         List<String> list = Arrays.asList(ids.split(","));
         if (list.size()>0){
            ExamPaper examPaper = new ExamPaper();
            examPaper.setExamTime(examTime);
//            examPaper.setExamTime(examTime);
            examPaper.setExamType(1);
            examPaper.setStartTime(startTime);
            examPaper.setEndTime(endTime);
//            examPaper.setEndTime(endTime);
            Calendar instance = Calendar.getInstance();
            instance.setTime(startTime);
            int year = instance.get(Calendar.YEAR);
@@ -525,10 +567,10 @@
         if (applyIds.size()>0){
            //生成考试
            ExamPaper examPaper = new ExamPaper();
            examPaper.setExamTime(examTime);
//            examPaper.setExamTime(examTime);
            examPaper.setExamType(1);
            examPaper.setStartTime(startTime);
            examPaper.setEndTime(endTime);
//            examPaper.setEndTime(endTime);
            Calendar instance = Calendar.getInstance();
            instance.setTime(startTime);
            int year = instance.get(Calendar.YEAR);
@@ -573,4 +615,24 @@
      return applyService.getSecurityApplyDetail(apply);
   }
   /**
    * 修改考试状态
    * @param apply 报名信息,包含userId,applyid
    * @return
    */
   @PostMapping("/updateApplyStatus")
   public ExamScore updateApplyStatus(@RequestBody ApplyVO apply){
      applyService.updateApplyStatus(apply);
      //新增考试成绩,没有成绩数据,待提交答题后更新数据
      ExamScore examScore = new ExamScore();
      examScore.setExamId(apply.getExamId().toString());
      examScore.setUserId(apply.getUserId().toString());
      examScore.setExamTime(new Date());
      //新增
      examScoreService.save(examScore);
      return examScore;
   }
}