|
@@ -1,10 +1,13 @@
|
|
|
package cn.com.qmth.examcloud.exchange.outer.api.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
-
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
+import cn.com.qmth.examcloud.exchange.base.response.FailureBaseResponse;
|
|
|
+import cn.com.qmth.examcloud.exchange.base.response.SuccessBaseResponse;
|
|
|
+import cn.com.qmth.examcloud.exchange.outer.service.OutletScoreService;
|
|
|
+import cn.com.qmth.examcloud.exchange.outer.service.bean.OutletScore;
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -14,140 +17,161 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.response.FailureBaseResponse;
|
|
|
-import cn.com.qmth.examcloud.exchange.base.response.SuccessBaseResponse;
|
|
|
-import cn.com.qmth.examcloud.exchange.outer.service.OutletScoreService;
|
|
|
-import cn.com.qmth.examcloud.exchange.outer.service.bean.OutletScore;
|
|
|
-import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 获取成绩接口
|
|
|
- * @author chenken
|
|
|
- * @date 2018年4月3日 下午3:57:26
|
|
|
- * @company QMTH
|
|
|
+ *
|
|
|
+ * @author chenken
|
|
|
+ * @date 2018年4月3日 下午3:57:26
|
|
|
+ * @company QMTH
|
|
|
* @description ScoreController.java
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/api/ecs_outlet/score")
|
|
|
-public class CommonGainScoreController extends ControllerSupport{
|
|
|
+public class CommonGainScoreController extends ControllerSupport {
|
|
|
|
|
|
@Autowired
|
|
|
private OutletScoreService outletScoreService;
|
|
|
|
|
|
- @ApiOperation(value = "查询成绩:根据考试名称、机构ID和学生考试方式查询")
|
|
|
+ @ApiOperation(value = "查询成绩:根据考试名称(不推荐)/考试代码(推荐)、机构ID和学生考试方式查询")
|
|
|
+ @Deprecated
|
|
|
@GetMapping
|
|
|
- public ResponseEntity<?> query(@RequestParam(name = "examName") String examName,
|
|
|
- @RequestParam(name = "examStuRemark",required=false) String examStuRemark,
|
|
|
+ public ResponseEntity<?> query(@RequestParam(name = "examCode", required = false) String examCode,
|
|
|
+ @RequestParam(name = "examName") @Deprecated String examName,
|
|
|
+ @RequestParam(name = "examStuRemark", required = false) String examStuRemark,
|
|
|
HttpServletRequest request) {
|
|
|
- try{
|
|
|
- User accessUser = getAccessUser();
|
|
|
- if(accessUser == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(examName)) {
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("考试名称不能为空"),HttpStatus.BAD_REQUEST);
|
|
|
+ try {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ if (accessUser == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(examName)) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("考试名称不能为空"), HttpStatus.BAD_REQUEST);
|
|
|
}
|
|
|
Long orgId = accessUser.getRootOrgId();
|
|
|
- List<OutletScore> outletScoreList = outletScoreService.queryExamScore(examName, examStuRemark, orgId);
|
|
|
- return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功",outletScoreList), HttpStatus.OK);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- log.error("查询失败",e);
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请求失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
-
|
|
|
+ //如果examCode为空,则将examName作为examCode
|
|
|
+ final String finalExamCode;
|
|
|
+ if (StringUtils.isEmpty(examCode)) {
|
|
|
+ finalExamCode = examName;
|
|
|
+ } else {
|
|
|
+ finalExamCode = examCode;
|
|
|
+ }
|
|
|
+ List<OutletScore> outletScoreList = outletScoreService.queryExamScore(finalExamCode, examStuRemark, orgId);
|
|
|
+ return new ResponseEntity<>(new SuccessBaseResponse("查询成功", outletScoreList), HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("查询失败", e);
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请求失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@ApiOperation(value = "查询成绩:按考试名称、考生身份证号、机构ID查询成绩")
|
|
|
@GetMapping("/examNameAndIdentityNumberList")
|
|
|
public ResponseEntity<?> queryByIdentityNumber(@RequestParam(name = "examName") String examName,
|
|
|
- @RequestParam(name = "identityNumberList") List<String> identityNumberList,
|
|
|
- HttpServletRequest request) {
|
|
|
- try{
|
|
|
- User accessUser = getAccessUser();
|
|
|
- if(accessUser == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(examName)) {
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("考试名称不能为空"),HttpStatus.BAD_REQUEST);
|
|
|
+ @RequestParam(name = "identityNumberList") List<String> identityNumberList,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ if (accessUser == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(examName)) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("考试名称不能为空"), HttpStatus.BAD_REQUEST);
|
|
|
}
|
|
|
- if (identityNumberList==null||identityNumberList.size()==0) {
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("身份证号不能为空"),HttpStatus.BAD_REQUEST);
|
|
|
+ if (identityNumberList == null || identityNumberList.size() == 0) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("身份证号不能为空"), HttpStatus.BAD_REQUEST);
|
|
|
}
|
|
|
- if(identityNumberList.size()>1000){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("单次查询,身份证号数量不能大于1000"),HttpStatus.BAD_REQUEST);
|
|
|
- }
|
|
|
- List<OutletScore> outletScoreList = outletScoreService.queryExamScoreByExamNameAndIdentityNumbers(examName,identityNumberList,accessUser.getRootOrgId());
|
|
|
- return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功",outletScoreList), HttpStatus.OK);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- log.error("查询失败",e);
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请求失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
+ if (identityNumberList.size() > 1000) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("单次查询,身份证号数量不能大于1000"), HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+ List<OutletScore> outletScoreList = outletScoreService.queryExamScoreByExamNameAndIdentityNumbers(examName, identityNumberList, accessUser.getRootOrgId());
|
|
|
+ return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功", outletScoreList), HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("查询失败", e);
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请求失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- @ApiOperation(value = "查询成绩:按考试名称、机构ID、学号、课程code查询成绩")
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询成绩:按考试名称/考试代码、机构ID、学号、课程code查询成绩")
|
|
|
@GetMapping("/batchNameAndCourseCodeAndStudentCodes")
|
|
|
public ResponseEntity<?> queryExamScores(
|
|
|
- @RequestParam(name = "batchName") String batchName,
|
|
|
- @RequestParam(name = "courseCode") String courseCode,
|
|
|
- @RequestParam(name = "studentCodes") List<String> studentCodes,
|
|
|
- HttpServletRequest request){
|
|
|
- try{
|
|
|
- User accessUser = getAccessUser();
|
|
|
- if(accessUser == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- if(StringUtils.isEmpty(batchName)){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("考试名称不能为空"),HttpStatus.BAD_REQUEST);
|
|
|
- }
|
|
|
- if(StringUtils.isEmpty(courseCode)){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("课程不能为空"),HttpStatus.BAD_REQUEST);
|
|
|
- }
|
|
|
- if(studentCodes == null || studentCodes.size()==0){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("学号不能为空"),HttpStatus.BAD_REQUEST);
|
|
|
- }
|
|
|
- if(studentCodes.size()>1000){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("单次查询,学号数量不能大于1000"),HttpStatus.BAD_REQUEST);
|
|
|
- }
|
|
|
- List<OutletScore> outletScoreList = outletScoreService.queryExamScoreBy(accessUser.getRootOrgId(),batchName,courseCode,studentCodes);
|
|
|
- return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功",outletScoreList), HttpStatus.OK);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- log.error("查询失败",e);
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请求失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
+ @RequestParam(name = "examCode",required = false) @ApiParam("考试代码") String examCode,
|
|
|
+ @RequestParam(name = "batchName") @Deprecated @ApiParam("考试名称,已废弃,推荐使用examCode") String batchName,
|
|
|
+ @RequestParam(name = "courseCode") String courseCode,
|
|
|
+ @RequestParam(name = "studentCodes") List<String> studentCodes,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ if (accessUser == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(batchName)) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("考试名称不能为空"), HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(courseCode)) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("课程不能为空"), HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+ if (studentCodes == null || studentCodes.size() == 0) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("学号不能为空"), HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+ if (studentCodes.size() > 1000) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("单次查询,学号数量不能大于1000"), HttpStatus.BAD_REQUEST);
|
|
|
+ }
|
|
|
+ //如果考试代码为空,则将考试名称作为考试代码
|
|
|
+ final String finalExamCode;
|
|
|
+ if (StringUtils.isEmpty(courseCode)) {
|
|
|
+ finalExamCode = batchName;
|
|
|
+ } else {
|
|
|
+ finalExamCode = examCode;
|
|
|
+ }
|
|
|
+ List<OutletScore> outletScoreList = outletScoreService.queryExamScoreBy(accessUser.getRootOrgId(),
|
|
|
+ finalExamCode, courseCode, studentCodes);
|
|
|
+ return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功", outletScoreList), HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("查询失败", e);
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请求失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- @ApiOperation(value = "查询成绩明细:按考试名称、机构ID、学号、课程code查询成绩")
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询成绩明细:按考试名称/考试代码、机构ID、学号、课程code查询成绩")
|
|
|
@GetMapping("/batchQueryScoreDetail")
|
|
|
- public ResponseEntity<?> batchQueryScoreDetail(@RequestParam(name = "examName")String examName,
|
|
|
- @RequestParam(name = "studentCode")String studentCode,
|
|
|
- @RequestParam(name = "courseCode")String courseCode,
|
|
|
- HttpServletRequest request){
|
|
|
- User accessUser = getAccessUser();
|
|
|
- if(accessUser == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- if(examName == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("examName is not null"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- if(studentCode == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("studentCode is not null"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- if(courseCode == null){
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("courseCode is not null"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
- try {
|
|
|
- List<OutletScore> outletScores = outletScoreService.queryExamScoreBy(accessUser.getRootOrgId(), examName, studentCode, courseCode);
|
|
|
- return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功",outletScores), HttpStatus.OK);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("查询失败",e);
|
|
|
- return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("查询失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
- }
|
|
|
+ public ResponseEntity<?> batchQueryScoreDetail(@RequestParam(name = "examCode",required = false) @ApiParam("考试代码") String examCode,
|
|
|
+ @RequestParam(name = "examName") @Deprecated @ApiParam("考试名称,已弃用,推荐使用examCode") String examName,
|
|
|
+ @RequestParam(name = "studentCode") String studentCode,
|
|
|
+ @RequestParam(name = "courseCode") String courseCode,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ if (accessUser == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("请先登录"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ if (examName == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("examName is not null"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ if (studentCode == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("studentCode is not null"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ if (courseCode == null) {
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("courseCode is not null"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ final String finalExamCode;
|
|
|
+ if (StringUtils.isEmpty(examCode)){
|
|
|
+ finalExamCode=examName;
|
|
|
+ }else {
|
|
|
+ finalExamCode=examCode;
|
|
|
+ }
|
|
|
+ List<OutletScore> outletScores = outletScoreService.queryExamScoreBy(accessUser.getRootOrgId(), finalExamCode, studentCode, courseCode);
|
|
|
+ return new ResponseEntity<SuccessBaseResponse>(new SuccessBaseResponse("查询成功", outletScores), HttpStatus.OK);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error("查询失败", e);
|
|
|
+ return new ResponseEntity<FailureBaseResponse>(new FailureBaseResponse("查询失败"), HttpStatus.INTERNAL_SERVER_ERROR);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|