|
@@ -1,9 +1,14 @@
|
|
package com.qmth.teachcloud.report.api;
|
|
package com.qmth.teachcloud.report.api;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
import com.qmth.boot.api.annotation.Aac;
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
import com.qmth.boot.api.annotation.BOOL;
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
|
+import com.qmth.boot.tools.signature.SignatureEntity;
|
|
|
|
+import com.qmth.boot.tools.signature.SignatureType;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.teachcloud.common.util.HttpUtil;
|
|
|
|
+import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
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 io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
@@ -15,8 +20,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -37,10 +43,36 @@ public class OpenApiController {
|
|
@ApiOperation(value = "接收基础考务数据")
|
|
@ApiOperation(value = "接收基础考务数据")
|
|
@ApiResponses({@ApiResponse(code = 200, message = "推送基础考务数据", response = Object.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "推送基础考务数据", response = Object.class)})
|
|
@RequestMapping(value = "/basic/examination/data", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/basic/examination/data", method = RequestMethod.POST)
|
|
- public Result basicExaminationData(@ApiParam(value = "接收基础考务数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
|
|
|
|
|
|
+ public Result basicExaminationData(@ApiParam(value = "接收基础考务数据信息", required = true) @RequestBody String result) throws IOException, InterruptedException {
|
|
log.info("basicExaminationData进来了,result:{}", result);
|
|
log.info("basicExaminationData进来了,result:{}", result);
|
|
String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
log.info("decodeJson:{}", decodeJson);
|
|
log.info("decodeJson:{}", decodeJson);
|
|
|
|
+ if (Objects.nonNull(decodeJson)) {
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(decodeJson);
|
|
|
|
+ String callbackUrl = jsonObject.getString("callbackUrl");
|
|
|
|
+ String accessKey = jsonObject.getString("accessKey");
|
|
|
|
+ String accessSecret = jsonObject.getString("accessSecret");
|
|
|
|
+ if (Objects.nonNull(callbackUrl)) {
|
|
|
|
+ Double progress = 0D;
|
|
|
|
+ for (int i = 0; i < 11; i++) {
|
|
|
|
+ progress += 10D;
|
|
|
|
+ JSONObject dataObjectJson = new JSONObject();
|
|
|
|
+ dataObjectJson.put("progress", progress);
|
|
|
|
+ if (progress == 100D) {
|
|
|
|
+ dataObjectJson.put("status", "FINISHED");
|
|
|
|
+ } else {
|
|
|
|
+ dataObjectJson.put("status", "RUNNING");
|
|
|
|
+ }
|
|
|
|
+ Long timestamp = System.currentTimeMillis();
|
|
|
|
+ String accessToken = SignatureEntity.build(SignatureType.SECRET, SystemConstant.METHOD, callbackUrl, timestamp, accessKey, accessSecret);
|
|
|
|
+ String callbackResult = HttpUtil.postJson("http://127.0.0.1:7001" + callbackUrl, dataObjectJson.toJSONString(), accessToken, timestamp);
|
|
|
|
+ if (Objects.nonNull(callbackResult)) {
|
|
|
|
+ log.info("callbackResult:{}", JacksonUtil.parseJson(callbackResult));
|
|
|
|
+ }
|
|
|
|
+ Thread.sleep(5000);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return ResultUtil.ok(true);
|
|
return ResultUtil.ok(true);
|
|
}
|
|
}
|
|
}
|
|
}
|