智慧保安后台管理-外网项目备份
zengh
2021-08-19 8b464ee379c5b35ac8b22b4e5dde25c4f6fb75cf
src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -18,8 +18,11 @@
import org.springblade.modules.exam.service.ExamScoreService;
import org.springblade.modules.exam.util.SecurityPaperUtil;
import org.springblade.modules.exam.vo.ExamScoreVO;
import org.springblade.modules.system.entity.Role;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IRoleService;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.system.vo.UserVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
@@ -43,6 +46,8 @@
   private final IUserService userService;
   private final ExamPaperService examPaperService;
   private final IRoleService roleService;
   /**
    * 自定义分页
@@ -102,6 +107,8 @@
   public R updateExamScore(@RequestBody ExamScore examScore){
      if (null!=examScore.getLearnGrade() && null!=examScore.getTheoryGrade()){
         ExamScore examScore1 = examScoreService.getById(examScore.getId());
         //查询当前保安信息
         UserVO user = userService.getUserAgeById(Long.parseLong(examScore1.getUserId()));
         if (examScore.getTheoryGrade()>=60 && examScore.getLearnGrade()>=60){
            //合格
            examScore.setQualified(0);
@@ -109,8 +116,6 @@
            ExamPaper paper = examPaperService.getById(examScore.getExamId());
            if (paper.getExamType()==1) {
               //去生成保安证编号
               //查询当前保安信息
               User user = userService.getById(examScore1.getUserId());
               String pre = SecurityPaperUtil.getSecurityPaper();
               //查询当前年份已有的保安证编号
               int count = userService.getSecurityPaperCount(pre);
@@ -123,6 +128,13 @@
                  result = pre + (decimalFormat.format(count++));
               }
               user.setSecuritynumber(result);
               //修改为持证保安
               user.setHold("1");
               //分配保安角色
               Role role = new Role();
               role.setRoleAlias("保安");
               Role oneRole = roleService.getOne(Condition.getQueryWrapper(role));
               user.setRoleId(oneRole.getId().toString());
               //更新保安数据
               userService.updateById(user);
            }
@@ -131,10 +143,14 @@
            examScore.setQualified(1);
         }
         //总成绩
         examScore.setAllGrade(Math.round((examScore.getLearnGrade()+examScore1.getTheoryGrade())/2));
         if (user.getAge()<=50) {
            examScore.setAllGrade(Math.round((examScore.getLearnGrade() + examScore1.getTheoryGrade()) / 2));
         }
         if (user.getAge()>50) {
            examScore.setAllGrade(Integer.parseInt(String.valueOf(Math.round(examScore1.getTheoryGrade()*0.3)))
               + Integer.parseInt(String.valueOf(Math.round(examScore1.getLearnGrade()*0.7))));
         }
      }
      //内网修改
      //arg.test01(arg.url+"/examScore/update",examScore);
      //本地修改
      return R.status(examScoreService.updateById(examScore));
   }