src/main/java/org/springblade/modules/apply/controller/ApplyController.java
@@ -72,13 +72,48 @@ } /** * 新增 * 新增报名 * @param apply 考试报名信息对象 */ @PostMapping("/save") @ApiOperation(value = "新增", notes = "传入apply") public R save(@RequestBody Apply apply) { return R.status(applyService.save(apply)); //查询人员是否已报名 User user = userService.getById(apply.getUserId()); if (null==user.getIsApply()){ //默认通过 apply.setApplyStatus(2); //默认为未考试状态 apply.setIsExam(1); apply.setApplyTime(new Date()); //报名 applyService.save(apply); //修改保安报名状态 User user1 = new User(); user1.setId(apply.getUserId()); user1.setIsApply(1); userService.updateById(user1); return R.data(200,"报名成功"); }else { if (1==user.getIsApply()){ return R.data(201,"已报名,不能重复报名"); } if (2==user.getIsApply()){ //默认通过 apply.setApplyStatus(2); //默认为未考试状态 apply.setIsExam(1); apply.setApplyTime(new Date()); applyService.save(apply); //修改保安报名状态 User user1 = new User(); user1.setId(apply.getUserId()); user1.setIsApply(1); userService.updateById(user1); return R.data(200,"报名成功"); } } return R.data(202,"报名失败"); } @@ -96,66 +131,8 @@ * @param apply 考试报名信息对象 */ @PostMapping("/submit") public R submit(@RequestBody Apply apply) throws Exception { if (null==apply.getId()){ //查询人员是否已报名 User user = userService.getById(apply.getUserId()); if (null==user.getIsApply()){ //默认通过 apply.setApplyStatus(2); //默认为未考试状态 apply.setIsExam(1); apply.setApplyTime(new Date()); //修改保安报名状态 User user1 = new User(); user1.setId(apply.getUserId()); user1.setIsApply(1); userService.updateById(user1); return R.data(200,"报名成功"); }else { if (1==user.getIsApply()){ return R.data(201,"已报名,不能重复报名"); } if (2==user.getIsApply()){ //默认通过 apply.setApplyStatus(2); //默认为未考试状态 apply.setIsExam(1); apply.setApplyTime(new Date()); //修改保安报名状态 User user1 = new User(); user1.setId(apply.getUserId()); user1.setIsApply(1); userService.updateById(user1); return R.data(200,"报名成功"); } } //去生成准考证号码 // apply.setCandidateNo(getCandidateNo(apply)); //去生成考试编号 // apply.setApplyCode(getApplyCode(apply)); }else { //修改保安报名状态 User user = new User(); user.setId(apply.getUserId()); user.setIsApply(2); userService.updateById(user); } apply.setApplyStatus(4); boolean status = applyService.saveOrUpdate(apply); if (status){ //内网新增 // arg.test01(arg.url+"/apply/save",apply); return R.data(200,"取消报名成功"); } // //内网修改 // if(null!=apply.getId()){ // //修改 // arg.test01(arg.url+"/apply/update",apply); // } return R.data(202,"报名失败"); public R submit(@RequestBody Apply apply){ return R.data(applyService.saveOrUpdate(apply)); } @@ -353,6 +330,19 @@ } /** * 查询用户详情 * @param user */ @GetMapping("/userDetail") @ApiOperation(value = "详情", notes = "传入apply") public R<User> details(User user) { //用户详情 User user1 = userService.getById(user.getId()); //返回 return R.data(user1); } /** * 详情 * @param apply 考试报名信息对象 */ @@ -389,6 +379,7 @@ public R cancelApply(@RequestBody Apply apply){ //查询人员是否已报名 User user = userService.getById(apply.getUserId()); System.out.println("user = " + user); if(null==user.getIsApply()){ apply.setApplyStatus(4); boolean status = applyService.updateById(apply); @@ -538,4 +529,15 @@ return applyService.getApplyDetailList(apply); } /** * 查询保安员个人报名信息 * @param apply 报名信息,包含userId * @return */ @GetMapping("/getSecurityApplyDetail") public ApplyVO getSecurityApplyDetail(ApplyVO apply){ return applyService.getSecurityApplyDetail(apply); } } src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.java
@@ -1,5 +1,6 @@ package org.springblade.modules.apply.mapper; import com.baomidou.mybatisplus.annotation.SqlParser; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Param; @@ -102,4 +103,12 @@ * @return */ List<ApplyVO> getApplyDetailList(Long id); /** * 查询保安员个人报名信息 * @param apply 报名信息,包含userId * @return */ @SqlParser(filter = true) ApplyVO getSecurityApplyDetail(@Param("apply") ApplyVO apply); } src/main/java/org/springblade/modules/apply/mapper/ApplyMapper.xml
@@ -274,4 +274,24 @@ and sa.exam_id is not null </select> <!--查询保安员个人报名信息--> <select id="getSecurityApplyDetail" resultType="org.springblade.modules.apply.vo.ApplyVO"> select bu.id userId,bu.real_name realName,bu.sex,bu.is_apply isApply, MAX(sa.id) id from blade_user bu left join sys_apply sa on sa.user_id = bu.id where 1=1 <if test="apply.userId!=null and apply.userId!=''"> and bu.id = #{apply.userId} </if> <if test="apply.id!=null and apply.id!=''"> and sa.id = #{apply.id} </if> </select> </mapper> src/main/java/org/springblade/modules/apply/service/ApplyService.java
@@ -95,4 +95,11 @@ * @return */ Map<String,Object> getApplyDetailList(ApplyVO apply); /** * 查询保安员个人报名信息 * @param apply 报名信息,包含userId * @return */ ApplyVO getSecurityApplyDetail(ApplyVO apply); } src/main/java/org/springblade/modules/apply/service/impl/ApplyServiceImpl.java
@@ -370,4 +370,14 @@ //返回数据 return map; } /** * 查询保安员个人报名信息 * @param apply 报名信息,包含userId * @return */ @Override public ApplyVO getSecurityApplyDetail(ApplyVO apply) { return baseMapper.getSecurityApplyDetail(apply); } } src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -14,12 +14,17 @@ import org.springblade.modules.exam.excel.ExamScoreExcel; import org.springblade.modules.exam.excel.ExamScoreImporter; 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.User; import org.springblade.modules.system.service.IUserService; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Random; /** * @author zhongrj @@ -32,6 +37,8 @@ public class ExamScoreController { private final ExamScoreService examScoreService; private final IUserService userService; /** * 自定义分页 @@ -90,13 +97,33 @@ @PostMapping("/updateExamScore") public R updateExamScore(@RequestBody ExamScore examScore) throws Exception { if (null!=examScore.getLearnGrade() && null!=examScore.getTheoryGrade()){ ExamScore examScore1 = examScoreService.getById(examScore.getId()); if (examScore.getTheoryGrade()>=60 && examScore.getLearnGrade()>=60){ //合格 examScore.setQualified(0); //去生成保安证编号 //查询当前保安信息 User user = userService.getById(examScore1.getUserId()); String pre = SecurityPaperUtil.getSecurityPaper(); //查询当前年份已有的保安证编号 int count = userService.getSecurityPaperCount(pre); String result = null; if (count==0){ result = pre + "00000"; }else { //格式化 DecimalFormat decimalFormat = new DecimalFormat("00000"); result = pre + (decimalFormat.format(count++)); } user.setSecuritynumber(result); //更新保安数据 userService.updateById(user); }else { //不合格 examScore.setQualified(1); } //总成绩 examScore.setAllGrade(Math.round((examScore.getLearnGrade()+examScore1.getTheoryGrade())/2)); } //内网修改 //arg.test01(arg.url+"/examScore/update",examScore); src/main/java/org/springblade/modules/exam/mapper/ExamScoreMapper.xml
@@ -5,9 +5,9 @@ <!--考试成绩分页信息--> <select id="selectExamScorePage" resultType="org.springblade.modules.exam.vo.ExamScoreVO"> SELECT es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade, es.id,es.theory_grade theoryGrade,ifnull(learn_grade,-1) learnGrade,es.user_id userId, exam_name examName,bu.real_name securityName,company,exam_time examTime, all_score allScore,exam_end_time examEndTime,qualified, all_grade allGrade,exam_end_time examEndTime,qualified, bd.dept_name companyName FROM exam_score es src/main/java/org/springblade/modules/exam/service/impl/ExamScoreServiceImpl.java
@@ -14,11 +14,15 @@ import org.springblade.modules.exam.service.ExamPaperService; import org.springblade.modules.exam.service.ExamScoreService; import org.springblade.modules.exam.service.ExamSubjectChoicesService; import org.springblade.modules.exam.util.SecurityPaperUtil; import org.springblade.modules.exam.vo.ExamResultVO; import org.springblade.modules.exam.vo.ExamScoreVO; import org.springblade.modules.system.entity.User; import org.springblade.modules.system.service.IUserService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.text.DecimalFormat; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -33,7 +37,7 @@ @AllArgsConstructor public class ExamScoreServiceImpl extends ServiceImpl<ExamScoreMapper, ExamScore> implements ExamScoreService { private final ExamPaperService examPaperService; private final IUserService userService; private final ExamSubjectChoicesService examSubjectChoicesService; @@ -148,10 +152,29 @@ if (examScore.getTheoryGrade() >= 60 && examScore.getLearnGrade() >= 60) { //合格 examScore.setQualified(0); //去生成保安证编号 //查询当前保安信息 User user = userService.getById(examScore.getUserId()); String pre = SecurityPaperUtil.getSecurityPaper(); //查询当前年份已有的保安证编号 int count = userService.getSecurityPaperCount(pre); String result = null; if (count==0){ result = pre + "00000"; }else { //格式化 DecimalFormat decimalFormat = new DecimalFormat("00000"); result = pre + (decimalFormat.format(count++)); } user.setSecuritynumber(result); //更新保安数据 userService.updateById(user); } else { //不合格 examScore.setQualified(1); } //总成绩 examScore.setAllGrade(Math.round((examScore.getTheoryGrade()+examScoreExcel.getLearnGrade())/2)); //更新成绩数据 baseMapper.updateById(examScore); } src/main/java/org/springblade/modules/exam/util/SecurityPaperUtil.java
New file @@ -0,0 +1,24 @@ package org.springblade.modules.exam.util; import java.util.Calendar; import java.util.Date; /** * 保安证编号生成 * @author zhongrj * @since 2021-08-11 */ public class SecurityPaperUtil { private final static String pre = "赣洪"; public static String getSecurityPaper(){ //获取当前时间 Date date = new Date(); Calendar instance = Calendar.getInstance(); instance.setTime(date); //获取年份 int year = instance.get(Calendar.YEAR); return pre+year; } } src/main/java/org/springblade/modules/system/mapper/UserMapper.java
@@ -95,4 +95,11 @@ @SqlParser(filter=true) Map<Long, TreeNode> getSecurityApplyTree(@Param("user") UserVO user); List<Map<Object,Object>> selectInr(String deptid); /** * 查询当前年份已有的保安证编号 * @param pre 前缀 * @return */ int getSecurityPaperCount(@Param("pre") String pre); } src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -303,4 +303,10 @@ and dept_id=#{deptid} </if> </select> <!--查询当前年份已有的保安证编号--> <select id="getSecurityPaperCount" resultType="java.lang.Integer"> select count(*) from blade_user where securitynumber like concat('%', #{pre},'%') </select> </mapper> src/main/java/org/springblade/modules/system/service/IUserService.java
@@ -244,4 +244,12 @@ List<TreeNode> getSecurityApplyTree(UserVO user); List<Map<Object,Object>> selectInr(String deptid); /** * 查询当前年份已有的保安证编号 * @param pre 前缀 * @return */ int getSecurityPaperCount(String pre); } src/main/java/org/springblade/modules/system/service/impl/UserServiceImpl.java
@@ -466,4 +466,14 @@ public List<Map<Object, Object>> selectInr(String deptid) { return baseMapper.selectInr(deptid); } /** * 查询当前年份已有的保安证编号 * @param pre 前缀 * @return */ @Override public int getSecurityPaperCount(String pre) { return baseMapper.getSecurityPaperCount(pre); } }