|
@@ -1,18 +1,25 @@
|
|
|
package com.qmth.distributed.print.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.distributed.print.business.bean.result.CalculateNotifyResult;
|
|
|
+import com.qmth.distributed.print.business.entity.GradeBatch;
|
|
|
+import com.qmth.distributed.print.business.entity.GradeBatchPaper;
|
|
|
+import com.qmth.distributed.print.business.service.GradeBatchPaperService;
|
|
|
+import com.qmth.distributed.print.business.service.GradeBatchService;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.enums.GradeAnalyzePaperStatusEnum;
|
|
|
import com.qmth.teachcloud.common.util.*;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -43,10 +50,17 @@ public class NotifyApiController {
|
|
|
@Resource
|
|
|
DictionaryConfig dictionaryConfig;
|
|
|
|
|
|
+ @Resource
|
|
|
+ GradeBatchService gradeBatchService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ GradeBatchPaperService gradeBatchPaperService;
|
|
|
+
|
|
|
@ApiOperation(value = "教研分析进度回调")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "教研分析进度回调", response = CalculateNotifyResult.class)})
|
|
|
@RequestMapping(value = "/analysis/progress", method = RequestMethod.POST)
|
|
|
@Aac(auth = BOOL.FALSE)
|
|
|
+ @Transactional
|
|
|
public Result analysisProgress(@ApiParam(value = "接收教研分析回调数据", required = true) @RequestBody String result) throws UnsupportedEncodingException {
|
|
|
try {
|
|
|
log.info("analysis_progress,result:{}", result);
|
|
@@ -66,6 +80,7 @@ public class NotifyApiController {
|
|
|
if (!Objects.equals(localSign, sign)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("签名不匹配");
|
|
|
}
|
|
|
+
|
|
|
CalculateNotifyResult calculateNotifyResult = JSONObject.toJavaObject(JSONObject.parseObject(decodeJson), CalculateNotifyResult.class);
|
|
|
List<String> courseCodeList = new ArrayList<>();
|
|
|
courseCodeList.addAll(calculateNotifyResult.getCourseCode().keySet());
|
|
@@ -73,7 +88,39 @@ public class NotifyApiController {
|
|
|
|
|
|
String source = Base64Util.encode(ShaUtils.sha1(calculateNotifyResult.getExamId() + courseCodeList.toString()));
|
|
|
log.info("source:{}", source);
|
|
|
- //TODO 更新grade_batch(状态和进度)和grade_batch_paper(状态)
|
|
|
+
|
|
|
+ QueryWrapper<GradeBatch> gradeBatchQueryWrapper = new QueryWrapper<>();
|
|
|
+ gradeBatchQueryWrapper.lambda().eq(GradeBatch::getThirdExamId, calculateNotifyResult.getExamId())
|
|
|
+ .eq(GradeBatch::getSource, source);
|
|
|
+ GradeBatch gradeBatch = gradeBatchService.getOne(gradeBatchQueryWrapper);
|
|
|
+ Optional.ofNullable(gradeBatch).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("批次数据为空"));
|
|
|
+
|
|
|
+ if (Objects.isNull(gradeBatch.getNotifyTime()) ||
|
|
|
+ (Objects.nonNull(gradeBatch.getNotifyTime())
|
|
|
+ && gradeBatch.getNotifyTime().longValue() >= calculateNotifyResult.getTime().longValue())) {
|
|
|
+ if (Objects.nonNull(calculateNotifyResult.getStatus())) {
|
|
|
+ gradeBatch.setStatus(GradeAnalyzePaperStatusEnum.valueOf(calculateNotifyResult.getStatus()));
|
|
|
+ }
|
|
|
+ gradeBatch.setProgress(calculateNotifyResult.getProgress());
|
|
|
+ gradeBatch.setNotifyTime(System.currentTimeMillis());
|
|
|
+ gradeBatchService.updateById(gradeBatch);
|
|
|
+
|
|
|
+ QueryWrapper<GradeBatchPaper> gradeBatchPaperQueryWrapper = new QueryWrapper<>();
|
|
|
+ gradeBatchPaperQueryWrapper.lambda().eq(GradeBatchPaper::getBatchId, gradeBatch.getId());
|
|
|
+
|
|
|
+ List<GradeBatchPaper> gradeBatchPaperList = new ArrayList<>();
|
|
|
+ calculateNotifyResult.getCourseCode().forEach((k, v) -> {
|
|
|
+ gradeBatchPaperQueryWrapper.lambda().eq(GradeBatchPaper::getPaperNumber, k)
|
|
|
+ .eq(GradeBatchPaper::getEnable, true);
|
|
|
+ GradeBatchPaper gradeBatchPaper = gradeBatchPaperService.getOne(gradeBatchPaperQueryWrapper);
|
|
|
+ Optional.ofNullable(gradeBatchPaper).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("批次科目[" + k + "]数据为空"));
|
|
|
+
|
|
|
+ gradeBatchPaper.setStatus(v);
|
|
|
+ gradeBatchPaper.setUpdateTime(System.currentTimeMillis());
|
|
|
+ gradeBatchPaperList.add(gradeBatchPaper);
|
|
|
+ });
|
|
|
+ gradeBatchPaperService.updateBatchById(gradeBatchPaperList);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
|
if (e instanceof ApiException) {
|