智慧保安后台管理-外网
Administrator
2021-08-13 317330666d95595c9b7aa72f83bbc43a6121fe30
src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -409,27 +409,16 @@
   /**
    * 批量报名
    * @param apply 考试报名信息对象
    * @param ids userIds 人员
    */
   @PostMapping("/batchApply")
   public R batchApply(@RequestBody ApplyVO apply){
      List<String> list = Arrays.asList(apply.getUserIds().split(","));
      list.forEach(userId ->{
         User user = userService.getById(userId);
         //未报名的新增,已报名的不做处理
         if (null==user.getIsApply()) {
            Apply apply1 = new Apply();
            apply1.setApplyStatus(2);
            //默认为未考试状态
            apply1.setIsExam(1);
            apply1.setApplyTime(new Date());
            apply1.setUserId(Long.parseLong(userId));
            applyService.save(apply1);
            //修改保安报名状态
            user.setIsApply(1);
            userService.updateById(user);
         }else {
            if (user.getIsApply()==2) {
   public R batchApply(@RequestParam String ids,@RequestParam String deptId){
      if (!ids.equals("")) {
         List<String> list = Arrays.asList(ids.split(","));
         list.forEach(userId -> {
            User user = userService.getById(userId);
            //未报名的新增,已报名的不做处理
            if (null == user.getIsApply()) {
               Apply apply1 = new Apply();
               apply1.setApplyStatus(2);
               //默认为未考试状态
@@ -440,9 +429,55 @@
               //修改保安报名状态
               user.setIsApply(1);
               userService.updateById(user);
            } else {
               if (user.getIsApply() == 2) {
                  Apply apply1 = new Apply();
                  apply1.setApplyStatus(2);
                  //默认为未考试状态
                  apply1.setIsExam(1);
                  apply1.setApplyTime(new Date());
                  apply1.setUserId(Long.parseLong(userId));
                  applyService.save(apply1);
                  //修改保安报名状态
                  user.setIsApply(1);
                  userService.updateById(user);
               }
            }
         });
      }else {
         //查询所有未报名的人员
         List<User> users = userService.getNotApplyIdList(deptId);
         if (users.size()>0){
            users.forEach(user ->{
               //未报名的新增,已报名的不做处理
               if (null == user.getIsApply()) {
                  Apply apply1 = new Apply();
                  apply1.setApplyStatus(2);
                  //默认为未考试状态
                  apply1.setIsExam(1);
                  apply1.setApplyTime(new Date());
                  apply1.setUserId(user.getId());
                  applyService.save(apply1);
                  //修改保安报名状态
                  user.setIsApply(1);
                  userService.updateById(user);
               } else {
                  if (user.getIsApply() == 2) {
                     Apply apply1 = new Apply();
                     apply1.setApplyStatus(2);
                     //默认为未考试状态
                     apply1.setIsExam(1);
                     apply1.setApplyTime(new Date());
                     apply1.setUserId(user.getId());
                     applyService.save(apply1);
                     //修改保安报名状态
                     user.setIsApply(1);
                     userService.updateById(user);
                  }
               }
            });
         }
      });
      }
      return R.data(200,"报名成功");
   }