|
@@ -148,7 +148,7 @@ public class OpenApiController {
|
|
|
public Result calculate(@ApiParam(value = "接收分析课程(试卷)数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
|
|
|
Optional.ofNullable(result).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("数据为空"));
|
|
|
String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
- log.info("calculate进来了进来了,result:{}", decodeJson);
|
|
|
+ log.info("calculate进来了,result:{}", decodeJson);
|
|
|
CourseParam courseParam = JacksonUtil.readJson(decodeJson, CourseParam.class);
|
|
|
courseParam.validParamsExamIdAndCourseCode();
|
|
|
AuthThirdUtil.hasPermission();
|
|
@@ -157,58 +157,34 @@ public class OpenApiController {
|
|
|
Optional.ofNullable(callbackPwd).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("配置文件回调密码为空"));
|
|
|
|
|
|
try {
|
|
|
- Long time = System.currentTimeMillis();
|
|
|
- JSONObject dataObjectJson = new JSONObject();
|
|
|
- dataObjectJson.put("examId", courseParam.getExamId());
|
|
|
- dataObjectJson.put("courseCode", courseParam.getCourseCode());
|
|
|
- dataObjectJson.put("progress", 0d);
|
|
|
- dataObjectJson.put("status", "RUNNING");
|
|
|
- dataObjectJson.put("time", time);
|
|
|
- String pattern = "{0}{1}{2}";
|
|
|
- String sign = URLEncoder.encode(MessageFormat.format(pattern, callbackPwd, SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(dataObjectJson.toJSONString())), SystemConstant.CHARSET_NAME);
|
|
|
- String callbackResult = HttpUtil.postJson(dictionaryConfig.printOpenDomain().getHostUrl() + dictionaryConfig.printOpenDomain().getCallbackUrlApi(), dataObjectJson.toJSONString(), sign, time);
|
|
|
- if (Objects.nonNull(callbackResult)) {
|
|
|
- log.info("callbackResult:{}", JacksonUtil.parseJson(callbackResult));
|
|
|
+ Double progress = 0D;
|
|
|
+ for (int i = 0; i < 11; i++) {
|
|
|
+ progress += 10D;
|
|
|
+ Long time = System.currentTimeMillis();
|
|
|
+ JSONObject dataObjectJson = new JSONObject();
|
|
|
+ dataObjectJson.put("examId", courseParam.getExamId());
|
|
|
+ dataObjectJson.put("courseCode", courseParam.getCourseCode());
|
|
|
+ dataObjectJson.put("progress", progress);
|
|
|
+ if (progress == 100D) {
|
|
|
+ dataObjectJson.put("status", "FINISHED");
|
|
|
+ } else {
|
|
|
+ dataObjectJson.put("status", "RUNNING");
|
|
|
+ }
|
|
|
+ dataObjectJson.put("time", time);
|
|
|
+ String pattern = "{0}{1}{2}";
|
|
|
+ String sign = URLEncoder.encode(MessageFormat.format(pattern, Base64Util.encode(ShaUtils.sha1(callbackPwd)), SignatureEntityTest.FIELD_JOINER, SignatureEntityTest.encrypt(dataObjectJson.toJSONString())), SystemConstant.CHARSET_NAME);
|
|
|
+ String callbackResult = HttpUtil.postJson(dictionaryConfig.printOpenDomain().getHostUrl() + dictionaryConfig.printOpenDomain().getCallbackUrlApi(), dataObjectJson.toJSONString(), sign, time);
|
|
|
+ if (Objects.nonNull(callbackResult)) {
|
|
|
+ log.info("callbackResult:{}", JacksonUtil.parseJson(callbackResult));
|
|
|
+ }
|
|
|
+ if (progress == 100D) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ Thread.sleep(5000);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
|
}
|
|
|
return ResultUtil.ok(true);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|