|
@@ -1,8 +1,11 @@
|
|
|
package com.qmth.distributed.print.api;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
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.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
@@ -42,29 +45,42 @@ public class NotifyApiController {
|
|
|
DictionaryConfig dictionaryConfig;
|
|
|
|
|
|
@ApiOperation(value = "教研分析进度回调")
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "教研分析进度回调", response = Object.class)})
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "教研分析进度回调", response = CalculateNotifyResult.class)})
|
|
|
@RequestMapping(value = "/analysis/progress", method = RequestMethod.POST)
|
|
|
@Aac(auth = BOOL.FALSE)
|
|
|
public Result analysisProgress(@ApiParam(value = "接收教研分析回调数据", required = true) @RequestBody String result) throws UnsupportedEncodingException {
|
|
|
- log.info("analysis_progress,result:{}", result);
|
|
|
- String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
- log.info("analysis_progress decodeJson:{}", decodeJson);
|
|
|
+ try {
|
|
|
+ log.info("analysis_progress,result:{}", result);
|
|
|
+ String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
+ log.info("analysis_progress decodeJson:{}", decodeJson);
|
|
|
|
|
|
- String callbackPwd = dictionaryConfig.printOpenDomain().getCallbackPwd();
|
|
|
- Optional.ofNullable(callbackPwd).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("配置文件回调密码为空"));
|
|
|
+ String callbackPwd = dictionaryConfig.printOpenDomain().getCallbackPwd();
|
|
|
+ Optional.ofNullable(callbackPwd).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("配置文件回调密码为空"));
|
|
|
|
|
|
- String sign = ServletUtil.getRequestAuthorization();
|
|
|
- Optional.ofNullable(sign).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("签名为空"));
|
|
|
- log.info("sign:{}", sign);
|
|
|
+ String sign = ServletUtil.getRequestAuthorization();
|
|
|
+ Optional.ofNullable(sign).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("签名为空"));
|
|
|
+ log.info("sign:{}", sign);
|
|
|
|
|
|
- String localSign = URLEncoder.encode(Base64Util.encode(ShaUtils.sha1(callbackPwd + decodeJson)), SystemConstant.CHARSET_NAME);
|
|
|
- log.info("localSign:{}", localSign);
|
|
|
+ String localSign = URLEncoder.encode(Base64Util.encode(ShaUtils.sha1(callbackPwd + decodeJson)), SystemConstant.CHARSET_NAME);
|
|
|
+ log.info("localSign:{}", localSign);
|
|
|
|
|
|
- if (!Objects.equals(localSign, sign)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("签名不匹配");
|
|
|
+ if (!Objects.equals(localSign, sign)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("签名不匹配");
|
|
|
+ }
|
|
|
+ CalculateNotifyResult calculateNotifyResult = JSONObject.toJavaObject(JSONObject.parseObject(decodeJson), CalculateNotifyResult.class);
|
|
|
+ String source = Base64Util.encode(ShaUtils.sha1(calculateNotifyResult.getExamId() + calculateNotifyResult.getCourseCode().toString()));
|
|
|
+ log.info("source:{}", source);
|
|
|
+ //TODO 此处加批次数据状态更新service方法
|
|
|
+ //更新grade_batch(状态和进度)和grade_batch_paper(状态)
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
+ //todo 生成txt文件
|
|
|
+ if (e instanceof ApiException) {
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- //TODO 此处加批次数据状态更新service方法
|
|
|
return ResultUtil.ok(System.currentTimeMillis());
|
|
|
}
|
|
|
}
|