|
@@ -5,16 +5,20 @@ import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.distributed.print.business.bean.result.EditResult;
|
|
import com.qmth.distributed.print.business.bean.result.EditResult;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.FieldUniqueEnum;
|
|
import com.qmth.teachcloud.common.enums.FieldUniqueEnum;
|
|
import com.qmth.teachcloud.common.util.Result;
|
|
import com.qmth.teachcloud.common.util.Result;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
-import com.qmth.teachcloud.mark.bean.ai.MarkAiQuestionParamResult;
|
|
|
|
|
|
+import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
|
+import com.qmth.teachcloud.mark.entity.MarkAiQuestionLevel;
|
|
import com.qmth.teachcloud.mark.entity.MarkAiQuestionParam;
|
|
import com.qmth.teachcloud.mark.entity.MarkAiQuestionParam;
|
|
|
|
+import com.qmth.teachcloud.mark.entity.MarkAiQuestionPoint;
|
|
import com.qmth.teachcloud.mark.service.MarkAiQuestionLevelService;
|
|
import com.qmth.teachcloud.mark.service.MarkAiQuestionLevelService;
|
|
import com.qmth.teachcloud.mark.service.MarkAiQuestionParamService;
|
|
import com.qmth.teachcloud.mark.service.MarkAiQuestionParamService;
|
|
import com.qmth.teachcloud.mark.service.MarkAiQuestionPointService;
|
|
import com.qmth.teachcloud.mark.service.MarkAiQuestionPointService;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
@@ -24,6 +28,9 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -56,8 +63,59 @@ public class MarkAiQuestionParamController {
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
}
|
|
}
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
try {
|
|
try {
|
|
-
|
|
|
|
|
|
+ switch (markAiQuestionParam.getMode()) {
|
|
|
|
+ case POINT://按得分点
|
|
|
|
+ if (CollectionUtils.isEmpty(markAiQuestionParam.getPointList())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("得分点信息为空");
|
|
|
|
+ }
|
|
|
|
+ markAiQuestionParam.getPointList().stream().peek(s -> s.setAiQuestionId(markAiQuestionParam.getId())).collect(Collectors.toList());
|
|
|
|
+ if (Objects.isNull(markAiQuestionParam.getId())) {//新增
|
|
|
|
+ markAiQuestionParam.insertInfo(sysUser.getId());
|
|
|
|
+ markAiQuestionPointService.saveBatch(markAiQuestionParam.getPointList());
|
|
|
|
+ } else {//修改
|
|
|
|
+ List<MarkAiQuestionPoint> markAiQuestionPointDbList = markAiQuestionPointService.listByAiQuestionId(markAiQuestionParam.getId());
|
|
|
|
+ List<MarkAiQuestionLevel> markAiQuestionLevelDbList = markAiQuestionLevelService.listByAiQuestionId(markAiQuestionParam.getId());
|
|
|
|
+ //删除档次的数据
|
|
|
|
+ if (CollectionUtils.isNotEmpty(markAiQuestionLevelDbList)) {
|
|
|
|
+ markAiQuestionLevelService.removeByIds(markAiQuestionLevelDbList.stream().map(MarkAiQuestionLevel::getId).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ //全删point数据全增
|
|
|
|
+ if (CollectionUtils.isNotEmpty(markAiQuestionPointDbList)) {
|
|
|
|
+ markAiQuestionPointService.removeByIds(markAiQuestionPointDbList.stream().map(MarkAiQuestionPoint::getId).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ markAiQuestionPointService.saveBatch(markAiQuestionParam.getPointList());
|
|
|
|
+ markAiQuestionParam.updateInfo(sysUser.getId());
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case LEVEL://按档次
|
|
|
|
+ if (CollectionUtils.isEmpty(markAiQuestionParam.getLevelList())) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("档次信息为空");
|
|
|
|
+ }
|
|
|
|
+ markAiQuestionParam.getLevelList().stream().peek(s -> s.setAiQuestionId(markAiQuestionParam.getId())).collect(Collectors.toList());
|
|
|
|
+ if (Objects.isNull(markAiQuestionParam.getId())) {//新增
|
|
|
|
+ markAiQuestionParam.insertInfo(sysUser.getId());
|
|
|
|
+ markAiQuestionLevelService.saveBatch(markAiQuestionParam.getLevelList());
|
|
|
|
+ } else {
|
|
|
|
+ List<MarkAiQuestionPoint> markAiQuestionPointDbList = markAiQuestionPointService.listByAiQuestionId(markAiQuestionParam.getId());
|
|
|
|
+ List<MarkAiQuestionLevel> markAiQuestionLevelDbList = markAiQuestionLevelService.listByAiQuestionId(markAiQuestionParam.getId());
|
|
|
|
+ //删除得分点的数据
|
|
|
|
+ if (CollectionUtils.isNotEmpty(markAiQuestionPointDbList)) {
|
|
|
|
+ markAiQuestionPointService.removeByIds(markAiQuestionPointDbList.stream().map(MarkAiQuestionPoint::getId).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ //全删level数据全增
|
|
|
|
+ if (CollectionUtils.isNotEmpty(markAiQuestionLevelDbList)) {
|
|
|
|
+ markAiQuestionLevelService.removeByIds(markAiQuestionLevelDbList.stream().map(MarkAiQuestionLevel::getId).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ markAiQuestionLevelService.saveBatch(markAiQuestionParam.getLevelList());
|
|
|
|
+ markAiQuestionParam.updateInfo(sysUser.getId());
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ markAiQuestionParamService.saveOrUpdate(markAiQuestionParam);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
if (e instanceof DuplicateKeyException) {
|
|
if (e instanceof DuplicateKeyException) {
|
|
@@ -75,8 +133,13 @@ public class MarkAiQuestionParamController {
|
|
|
|
|
|
@ApiOperation(value = "AI评卷参数查询")
|
|
@ApiOperation(value = "AI评卷参数查询")
|
|
@RequestMapping(value = "/info", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/info", method = RequestMethod.POST)
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "AI评卷参数查询", response = MarkAiQuestionParamResult.class)})
|
|
|
|
- public Result info(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
|
|
|
|
- return ResultUtil.ok();
|
|
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "AI评卷参数查询", response = MarkAiQuestionParam.class)})
|
|
|
|
+ public Result info(@ApiParam(value = "题目id", required = true) @RequestParam Long questionId) {
|
|
|
|
+ MarkAiQuestionParam markAiQuestionParam = markAiQuestionParamService.getByExamIdAndPaperNumberAndQuestionId(null, null, questionId);
|
|
|
|
+ Objects.requireNonNull(markAiQuestionParam, "AI评卷参数信息为空");
|
|
|
|
+ List<MarkAiQuestionPoint> markAiQuestionPointDbList = markAiQuestionPointService.listByAiQuestionId(markAiQuestionParam.getId());
|
|
|
|
+ List<MarkAiQuestionLevel> markAiQuestionLevelDbList = markAiQuestionLevelService.listByAiQuestionId(markAiQuestionParam.getId());
|
|
|
|
+ markAiQuestionParam.setListInfo(markAiQuestionPointDbList, markAiQuestionLevelDbList);
|
|
|
|
+ return ResultUtil.ok(markAiQuestionParam);
|
|
}
|
|
}
|
|
}
|
|
}
|