From e810bb568064ff87f0462daafe86e4c39579647b Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 16 Aug 2021 19:38:48 +0800
Subject: [PATCH] 1.工作汇报查询修改 2.考试成绩查询接口修改

---
 src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java b/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
index c417eb2..abbff05 100644
--- a/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
+++ b/src/main/java/org/springblade/modules/exam/controller/ExamScoreController.java
@@ -10,16 +10,23 @@
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+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.exam.excel.ExamScoreImporter;
+import org.springblade.modules.exam.service.ExamPaperService;
 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 +39,10 @@
 public class ExamScoreController {
 
 	private final ExamScoreService examScoreService;
+
+	private final IUserService userService;
+
+	private final ExamPaperService examPaperService;
 
 	/**
 	 * 自定义分页
@@ -88,18 +99,42 @@
 	 * @param examScore 考试成绩信息对象
 	 */
 	@PostMapping("/updateExamScore")
-	public R updateExamScore(@RequestBody ExamScore examScore) throws Exception {
+	public R updateExamScore(@RequestBody ExamScore examScore){
 		if (null!=examScore.getLearnGrade() && null!=examScore.getTheoryGrade()){
+			ExamScore examScore1 = examScoreService.getById(examScore.getId());
 			if (examScore.getTheoryGrade()>=60 && examScore.getLearnGrade()>=60){
 				//合格
 				examScore.setQualified(0);
+				//正式考试通过生成保安证编号
+				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);
+					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);
+		//arg.test01(arg.url+"/examScore/update",examScore);
 		//本地修改
 		return R.status(examScoreService.updateById(examScore));
 	}
@@ -135,6 +170,20 @@
 		return R.data(detail);
 	}
 
+
+	/**
+	 * 详情
+	 * @param examScore 考试成绩信息对象
+	 */
+	@GetMapping("/details")
+	@ApiOperation(value = "详情", notes = "传入examScore")
+	public R<ExamScore> detail(ExamScore examScore) {
+		//查询考试成绩详情
+		ExamScore detail = examScoreService.getOne(Condition.getQueryWrapper(examScore));
+		//返回
+		return R.data(detail);
+	}
+
 	/**
 	 * 导入实操成绩
 	 * @param isCovered 1 覆盖  0不覆盖

--
Gitblit v1.9.3