|
@@ -6,6 +6,7 @@ import com.qmth.boot.api.annotation.BOOL;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
import com.qmth.teachcloud.common.SignatureEntityTest;
|
|
|
import com.qmth.teachcloud.common.bean.params.BasicSemesterParams;
|
|
|
+import com.qmth.teachcloud.common.bean.params.CalculateParams;
|
|
|
import com.qmth.teachcloud.common.config.DictionaryConfig;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
@@ -17,6 +18,7 @@ import com.qmth.teachcloud.report.business.bean.params.CourseParam;
|
|
|
import com.qmth.teachcloud.report.business.bean.params.TBExamParam;
|
|
|
import com.qmth.teachcloud.report.business.service.TBExamCourseService;
|
|
|
import com.qmth.teachcloud.report.business.service.TBExamService;
|
|
|
+import com.qmth.teachcloud.report.business.templete.strategy.CourseCodeSyncTaskService;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.MessageFormat;
|
|
@@ -65,6 +68,9 @@ public class OpenApiController {
|
|
|
@Resource
|
|
|
DictionaryConfig dictionaryConfig;
|
|
|
|
|
|
+ @Resource
|
|
|
+ CourseCodeSyncTaskService courseCodeSyncTaskService;
|
|
|
+
|
|
|
@ApiOperation(value = "学期创建/更新接口")
|
|
|
@ApiResponses({@ApiResponse(code = 200, message = "学期创建/更新接口", response = Object.class)})
|
|
|
@RequestMapping(value = "/semester_edit", method = RequestMethod.POST)
|
|
@@ -121,23 +127,28 @@ public class OpenApiController {
|
|
|
Optional.ofNullable(result).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("数据为空"));
|
|
|
String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
log.info("calculate进来了,result:{}", decodeJson);
|
|
|
- CourseParam courseParam = JacksonUtil.readJson(decodeJson, CourseParam.class);
|
|
|
- courseParam.validParamsExamIdAndCourseCode();
|
|
|
+ CalculateParams calculateParams = JacksonUtil.readJson(decodeJson, CalculateParams.class);
|
|
|
+ calculateParams.validParams();
|
|
|
AuthThirdUtil.hasPermission();
|
|
|
|
|
|
String callbackPwd = dictionaryConfig.printOpenDomain().getCallbackPwd();
|
|
|
Optional.ofNullable(callbackPwd).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("配置文件回调密码为空"));
|
|
|
|
|
|
+ courseCodeSyncTaskService.start(calculateParams);
|
|
|
+
|
|
|
try {
|
|
|
- Double progress = 0D;
|
|
|
- for (int i = 0; i < 11; i++) {
|
|
|
- progress += 10D;
|
|
|
+ //TODO 这里加入前置校验数据环节
|
|
|
+
|
|
|
+ BigDecimal progress = new BigDecimal(0);
|
|
|
+ BigDecimal finished = new BigDecimal(1);
|
|
|
+ for (int i = 0; i < calculateParams.getCourseCode().size(); i++) {
|
|
|
+ progress = new BigDecimal(i).divide(new BigDecimal(calculateParams.getCourseCode().size() - 1), 2, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
Long time = System.currentTimeMillis();
|
|
|
JSONObject dataObjectJson = new JSONObject();
|
|
|
- dataObjectJson.put("examId", courseParam.getExamId());
|
|
|
- dataObjectJson.put("courseCode", courseParam.getCourseCode());
|
|
|
+ dataObjectJson.put("examId", calculateParams.getExamId());
|
|
|
+ dataObjectJson.put("courseCode", calculateParams.getCourseCode().get(i));
|
|
|
dataObjectJson.put("progress", progress);
|
|
|
- if (progress == 100D) {
|
|
|
+ if (progress.compareTo(finished) == 0) {
|
|
|
dataObjectJson.put("status", "FINISHED");
|
|
|
} else {
|
|
|
dataObjectJson.put("status", "RUNNING");
|
|
@@ -149,10 +160,10 @@ public class OpenApiController {
|
|
|
if (Objects.nonNull(callbackResult)) {
|
|
|
log.info("callbackResult:{}", JacksonUtil.parseJson(callbackResult));
|
|
|
}
|
|
|
- if (progress == 100D) {
|
|
|
+ if (progress.compareTo(finished) == 0) {
|
|
|
break;
|
|
|
}
|
|
|
- Thread.sleep(5000);
|
|
|
+// Thread.sleep(5000);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|