wangliang 3 yıl önce
ebeveyn
işleme
15331cb93f

+ 26 - 8
teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/TeachCloudReportTaskUtils.java

@@ -20,10 +20,7 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * 同步教研分析接口工具类
@@ -54,6 +51,11 @@ public class TeachCloudReportTaskUtils {
      */
     public Long syncSemester(Long schoolId, Long thirdSemesterId, String semesterName, Long startTime, Long endTime, Boolean enable) {
         String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
+        Optional.ofNullable(hostUrl).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置教研分析host"));
+        BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
+        if (hostUrl.contains("*")) {
+            hostUrl = hostUrl.replace("*", basicSchool.getCode());
+        }
         String saveUrl = dictionaryConfig.reportOpenDomain().getSemesterApi();
         validUrl(hostUrl, saveUrl);
         String postUrl = hostUrl.concat(saveUrl);
@@ -99,6 +101,11 @@ public class TeachCloudReportTaskUtils {
      */
     public Long syncExam(Long schoolId, Long id, String examName, Long examTime, String semesterId, Boolean enable) {
         String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
+        Optional.ofNullable(hostUrl).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置教研分析host"));
+        BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
+        if (hostUrl.contains("*")) {
+            hostUrl = hostUrl.replace("*", basicSchool.getCode());
+        }
         String saveUrl = dictionaryConfig.reportOpenDomain().getExamApi();
         validUrl(hostUrl, saveUrl);
         String postUrl = hostUrl.concat(saveUrl);
@@ -142,6 +149,11 @@ public class TeachCloudReportTaskUtils {
     public boolean syncCourse(Long schoolId, String examId, String courseCode, String courseName,
                               String paperType, String teachCollegeName, Boolean enable) {
         String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
+        Optional.ofNullable(hostUrl).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置教研分析host"));
+        BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
+        if (hostUrl.contains("*")) {
+            hostUrl = hostUrl.replace("*", basicSchool.getCode());
+        }
         String saveUrl = dictionaryConfig.reportOpenDomain().getCourseEditApi();
         validUrl(hostUrl, saveUrl);
         String postUrl = hostUrl.concat(saveUrl);
@@ -182,6 +194,11 @@ public class TeachCloudReportTaskUtils {
      */
     public boolean startCalc(Long schoolId, Long examId, List<String> courseCodes) {
         String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
+        Optional.ofNullable(hostUrl).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置教研分析host"));
+        BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
+        if (hostUrl.contains("*")) {
+            hostUrl = hostUrl.replace("*", basicSchool.getCode());
+        }
         String saveUrl = dictionaryConfig.reportOpenDomain().getCalculateApi();
         validUrl(hostUrl, saveUrl);
         String postUrl = hostUrl.concat(saveUrl);
@@ -222,6 +239,11 @@ public class TeachCloudReportTaskUtils {
      */
     public boolean publish(Long schoolId, Long thirdExamId, String gradeCourseCode, boolean publishStatus) {
         String hostUrl = dictionaryConfig.reportOpenDomain().getHostUrl();
+        Optional.ofNullable(hostUrl).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置教研分析host"));
+        BasicSchool basicSchool = commonCacheService.schoolCache(schoolId);
+        if (hostUrl.contains("*")) {
+            hostUrl = hostUrl.replace("*", basicSchool.getCode());
+        }
         String saveUrl = dictionaryConfig.reportOpenDomain().getPublishApi();
         validUrl(hostUrl, saveUrl);
         String postUrl = hostUrl.concat(saveUrl);
@@ -278,7 +300,6 @@ public class TeachCloudReportTaskUtils {
         if (!basicSchool.getEnable()) {
             throw ExceptionResultEnum.ERROR.exception("学校已禁用");
         }
-
         return SignatureEntityTest.build(SignatureType.SECRET, POST_METHOD, url, time, basicSchool.getAccessKey(), basicSchool.getAccessSecret());
     }
 
@@ -311,7 +332,6 @@ public class TeachCloudReportTaskUtils {
             throw ExceptionResultEnum.ERROR.exception((StringUtils.isBlank(name) ? "" : name) + "值必填");
         }
         return Objects.isNull(value) ? defaultValue : value;
-
     }
 
     /**
@@ -327,7 +347,6 @@ public class TeachCloudReportTaskUtils {
             throw ExceptionResultEnum.ERROR.exception((StringUtils.isBlank(name) ? "" : name) + "值必填");
         }
         return value == null ? defaultValue : value;
-
     }
 
     /**
@@ -340,5 +359,4 @@ public class TeachCloudReportTaskUtils {
             throw ExceptionResultEnum.ERROR.exception("云阅卷同步接口未正确配置");
         }
     }
-
 }