| | |
| | | package org.springblade.modules.exam.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.FTP.Monitor; |
| | | import org.springblade.modules.FTP.Result; |
| | | import org.springblade.modules.exam.entity.ExamPaper; |
| | | import org.springblade.modules.exam.entity.ExamScore; |
| | | import org.springblade.modules.exam.excel.ExamScoreExcel; |
| | |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.system.service.MyAsyncService; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | private final SecurityPaperService securityPaperService; |
| | | |
| | | private final MyAsyncService myAsyncService; |
| | | |
| | | private final RedisTemplate redisTemplate; |
| | | |
| | | /** |
| | | * 自定义分页 |
| | |
| | | if (null != examScore.getLearnGrade() && null != examScore.getTheoryGrade()) { |
| | | ExamScore examScore1 = examScoreService.getById(examScore.getId()); |
| | | //查询当前保安信息 |
| | | UserVO user = userService.getUserAgeById(Long.parseLong(examScore1.getUserId())); |
| | | UserVO user1 = userService.getUserAgeById(Long.parseLong(examScore1.getUserId())); |
| | | //再根据身份证号查询用户,方式用户考了试,被删除,又新建的情况,修改最新用户的状态信息 |
| | | User user1 = userService.getUserInfoByIdCardNo(user.getCardid()); |
| | | // User user1 = userService.getUserInfoByIdCardNo(user.getCardid()); |
| | | //考试合格 |
| | | if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) { |
| | | //合格 |
| | |
| | | //去生成保安证编号 |
| | | String pre = SecurityPaperUtil.getSecurityPaper(); |
| | | //查询当前年份已有的保安证编号 |
| | | int max = userService.getSecurityPaperCount(pre); |
| | | // int max = userService.getSecurityPaperCount(pre); |
| | | //需调用内网查询 |
| | | //生成随机数 |
| | | String uuid = UUID.randomUUID().toString(); |
| | | |
| | | //数据推送 |
| | | Map<String, Object> map = new HashMap<>(1); |
| | | map.put(uuid,pre); |
| | | myAsyncService.FTPSecurityNumberBit(map); |
| | | |
| | | int count = 0; |
| | | Result result0 = new Result(); |
| | | //调用ftp获取返回数据 |
| | | while (true){ |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //调用ftp获取返回数据 |
| | | result0 = Monitor.getSecurityNumberBit(uuid); |
| | | //如果返回true,就退处 |
| | | if (result0.getCode()==200){ |
| | | break; |
| | | }else{ |
| | | //计数 |
| | | count++; |
| | | //如果超过100s 没有读取到,则退出 |
| | | if (count == 100) { |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | int max = Integer.parseInt(result0.getMsg()); |
| | | String result = null; |
| | | if (max == 0) { |
| | | result = pre + "00001"; |
| | |
| | | securityPaper.setUserId(user1.getId()); |
| | | securityPaper.setNumber(result); |
| | | securityPaper.setCreateTime(new Date()); |
| | | securityPaper.setIdCardNo(user.getCardid()); |
| | | securityPaper.setIdCardNo(user1.getCardid()); |
| | | securityPaper.setPeopleName(user1.getRealName()); |
| | | securityPaper.setExamId(Long.parseLong(examScore1.getExamId())); |
| | | securityPaper.setApplyId(examScore1.getApplyId()); |
| | |
| | | examScore.setQualified(1); |
| | | } |
| | | //总成绩 |
| | | if (user.getAge() <= 50) { |
| | | if (user1.getAge() <= 50) { |
| | | if (null != examScore1.getTheoryGrade()) { |
| | | examScore.setAllGrade(Math.round((examScore.getLearnGrade() + examScore1.getTheoryGrade()) / 2)); |
| | | } else { |
| | | examScore.setAllGrade(Math.round(examScore.getLearnGrade() / 2)); |
| | | } |
| | | } |
| | | if (user.getAge() > 50) { |
| | | if (user1.getAge() > 50) { |
| | | if (null != examScore1.getTheoryGrade()) { |
| | | examScore.setAllGrade(Integer.parseInt(String.valueOf(Math.round(examScore1.getTheoryGrade() * 0.5))) |
| | | + Integer.parseInt(String.valueOf(Math.round(examScore.getLearnGrade() * 0.5)))); |