|
|
|
@ -1,11 +1,13 @@
|
|
|
|
|
package net.educoder.schedule;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import net.educoder.config.PropertiesConfig;
|
|
|
|
|
import net.educoder.model.AutoEvaParamConfig;
|
|
|
|
|
import net.educoder.service.AutoEvaParamConfigService;
|
|
|
|
|
import net.educoder.util.SignatureUtil;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
@ -35,6 +37,10 @@ public class EvaCheckWarningTask {
|
|
|
|
|
@Autowired
|
|
|
|
|
private AutoEvaParamConfigService autoEvaParamConfigService;
|
|
|
|
|
|
|
|
|
|
@Value("${bridge.sign.accessKeySecret}")
|
|
|
|
|
private String accessKeySecret;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
|
@Scheduled(cron = "${task.cron.evalCheck}")
|
|
|
|
|
public void check() {
|
|
|
|
@ -75,7 +81,7 @@ public class EvaCheckWarningTask {
|
|
|
|
|
private void postEvaluation(AutoEvaParamConfig autoEvaParamConfig) {
|
|
|
|
|
JSONObject extrasObject = JSONObject.parseObject(autoEvaParamConfig.getExtras());
|
|
|
|
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
|
Map<String, Object> param = new HashMap<>(32);
|
|
|
|
|
param.put("isPublished", extrasObject.getInteger("isPublished"));
|
|
|
|
|
param.put("trimBlank", extrasObject.getInteger("trimBlank"));
|
|
|
|
|
param.put("containers", extrasObject.getString("containers"));
|
|
|
|
@ -92,6 +98,14 @@ public class EvaCheckWarningTask {
|
|
|
|
|
param.put("buildID", autoEvaParamConfig.getBuildId());
|
|
|
|
|
param.put("sec_key", UUID.randomUUID().toString());
|
|
|
|
|
param.put("callBackUrl", propertiesConfig.getCallbackUrl());
|
|
|
|
|
param.put("ak", RandomUtil.randomString(16));
|
|
|
|
|
param.put("nonce", RandomUtil.randomString(16));
|
|
|
|
|
|
|
|
|
|
String sign = SignatureUtil.genSignature(accessKeySecret, param);
|
|
|
|
|
log.info("postEvaluation---------签名值sign:{}", sign);
|
|
|
|
|
|
|
|
|
|
param.put("sign", sign);
|
|
|
|
|
|
|
|
|
|
String result = HttpUtil.post(propertiesConfig.getGameEvaluationUrl(), param);
|
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
|
|
log.info("实训评测接口返回:{},tpiId:{}", jsonResult, autoEvaParamConfig.getTpiId());
|
|
|
|
@ -103,12 +117,20 @@ public class EvaCheckWarningTask {
|
|
|
|
|
* @param autoEvaParamConfig 配置
|
|
|
|
|
*/
|
|
|
|
|
private void postOjEvaluation(AutoEvaParamConfig autoEvaParamConfig) {
|
|
|
|
|
Map<String, Object> param = new HashMap<>(8);
|
|
|
|
|
Map<String, Object> param = new HashMap<>(16);
|
|
|
|
|
param.put("tpiID", autoEvaParamConfig.getTpiId());
|
|
|
|
|
param.put("testCases", autoEvaParamConfig.getTestCases());
|
|
|
|
|
param.put("codeFileContent", autoEvaParamConfig.getCodeFileContent());
|
|
|
|
|
param.put("sec_key", UUID.randomUUID().toString());
|
|
|
|
|
param.put("callBackUrl", propertiesConfig.getCallbackUrl());
|
|
|
|
|
param.put("ak", RandomUtil.randomString(16));
|
|
|
|
|
param.put("nonce", RandomUtil.randomString(16));
|
|
|
|
|
|
|
|
|
|
String sign = SignatureUtil.genSignature(accessKeySecret, param);
|
|
|
|
|
log.info("postEvaluation---------签名值:{}", sign);
|
|
|
|
|
param.put("sign", sign);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String result = HttpUtil.post(propertiesConfig.getOjEvaluationUrl(), param);
|
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
|
|
log.info("Oj评测接口返回:{},tpiId:{}", jsonResult, autoEvaParamConfig.getTpiId());
|
|
|
|
|