|
@@ -10,7 +10,6 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
import com.qmth.teachcloud.common.entity.BasicSchool;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
-import com.qmth.teachcloud.common.util.HttpKit;
|
|
|
|
import com.qmth.teachcloud.common.util.HttpUtil;
|
|
import com.qmth.teachcloud.common.util.HttpUtil;
|
|
import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
@@ -48,10 +47,10 @@ public class TeachCloudReportTaskUtils {
|
|
* 学期创建/更新接口
|
|
* 学期创建/更新接口
|
|
*
|
|
*
|
|
* @param thirdSemesterId
|
|
* @param thirdSemesterId
|
|
- * @param semesterName 学期名称
|
|
|
|
- * @param startTime 学期开始时间
|
|
|
|
- * @param endTime 学期结束时间
|
|
|
|
- * @param enable 启用/禁用,ture:启用,false:禁用,默认启用
|
|
|
|
|
|
+ * @param semesterName 学期名称
|
|
|
|
+ * @param startTime 学期开始时间
|
|
|
|
+ * @param endTime 学期结束时间
|
|
|
|
+ * @param enable 启用/禁用,ture:启用,false:禁用,默认启用
|
|
*/
|
|
*/
|
|
public Long syncSemester(Long schoolId, Long thirdSemesterId, String semesterName, Long startTime, Long endTime, Boolean enable) {
|
|
public Long syncSemester(Long schoolId, Long thirdSemesterId, String semesterName, Long startTime, Long endTime, Boolean enable) {
|
|
String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
|
|
String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
|
|
@@ -74,7 +73,7 @@ public class TeachCloudReportTaskUtils {
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
if (jsonObject.containsKey("code")) {
|
|
if (jsonObject.containsKey("code")) {
|
|
String code = jsonObject.getString("code");
|
|
String code = jsonObject.getString("code");
|
|
- if("200".equals(code)) {
|
|
|
|
|
|
+ if ("200".equals(code)) {
|
|
return jsonObject.getLong("data");
|
|
return jsonObject.getLong("data");
|
|
} else {
|
|
} else {
|
|
throw ExceptionResultEnum.ERROR.exception(jsonObject.getString("error"));
|
|
throw ExceptionResultEnum.ERROR.exception(jsonObject.getString("error"));
|
|
@@ -118,7 +117,7 @@ public class TeachCloudReportTaskUtils {
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
if (jsonObject.containsKey("code")) {
|
|
if (jsonObject.containsKey("code")) {
|
|
String code = jsonObject.getString("code");
|
|
String code = jsonObject.getString("code");
|
|
- if("200".equals(code)) {
|
|
|
|
|
|
+ if ("200".equals(code)) {
|
|
return jsonObject.getLong("data");
|
|
return jsonObject.getLong("data");
|
|
} else {
|
|
} else {
|
|
throw ExceptionResultEnum.ERROR.exception(jsonObject.getString("error"));
|
|
throw ExceptionResultEnum.ERROR.exception(jsonObject.getString("error"));
|
|
@@ -162,7 +161,7 @@ public class TeachCloudReportTaskUtils {
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
if (jsonObject.containsKey("code")) {
|
|
if (jsonObject.containsKey("code")) {
|
|
String code = jsonObject.getString("code");
|
|
String code = jsonObject.getString("code");
|
|
- if("200".equals(code)) {
|
|
|
|
|
|
+ if ("200".equals(code)) {
|
|
JSONObject successJson = JSONObject.parseObject(jsonObject.getString("data"));
|
|
JSONObject successJson = JSONObject.parseObject(jsonObject.getString("data"));
|
|
return successJson.getBoolean("success");
|
|
return successJson.getBoolean("success");
|
|
} else {
|
|
} else {
|
|
@@ -212,6 +211,45 @@ public class TeachCloudReportTaskUtils {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 发布
|
|
|
|
+ *
|
|
|
|
+ * @param schoolId 学校ID
|
|
|
|
+ * @param thirdExamId 考试ID
|
|
|
|
+ * @param gradeCourseCode 课程
|
|
|
|
+ * @param publishStatus 发布状态
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean publish(Long schoolId, Long thirdExamId, String gradeCourseCode, boolean publishStatus) {
|
|
|
|
+ String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
|
|
|
|
+ String saveUrl = dictionaryConfig.reportOpenDomain().getPublishApi();
|
|
|
|
+ validUrl(hostUrl, saveUrl);
|
|
|
|
+ String postUrl = hostUrl.concat(saveUrl);
|
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
|
+ try {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.computeIfAbsent("examId", v -> thirdExamId);
|
|
|
|
+ map.computeIfAbsent("courseCode", v -> gradeCourseCode);//试卷编号+卷型
|
|
|
|
+ map.computeIfAbsent("publishStatus", v -> publishStatus);//发布(默认true)
|
|
|
|
+ String accessToken = createSign(schoolId, timestamp, saveUrl);
|
|
|
|
+ String result = HttpUtil.postJson(postUrl, JacksonUtil.parseJson(map), accessToken, timestamp);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
|
+ if (jsonObject.containsKey("code")) {
|
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
|
+ if ("200".equals(code)) {
|
|
|
|
+ JSONObject successJson = JSONObject.parseObject(jsonObject.getString("data"));
|
|
|
|
+ return successJson.getBoolean("success");
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(jsonObject.getString("error"));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("分析课程同步失败");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* http请求头
|
|
* http请求头
|