瀏覽代碼

Merge remote-tracking branch 'origin/dev' into dev

phoenix 1 年之前
父節點
當前提交
b379afcfab

+ 2 - 2
src/main/java/com/xjrsoft/module/courseTable/service/ICourseTableService.java

@@ -31,9 +31,9 @@ public interface ICourseTableService extends IService<CourseTable> {
 
     CourseTableVo getList(CourseTableDto dto);
 
-    List<CourseListVo> getAdjustList(Long teacherId, Date adjustDate);
+    List<CourseListVo> getAdjustList(String teacherId, String adjustDate);
 
-    String getPreCheck(String preCheckType, Long courseId, Long swapCourseId, Date swapDate, Long subTeacherId);
+    String getPreCheck(String preCheckType, String courseId, String swapCourseId, String swapDate, String subTeacherId);
 
     /**
      * 流程审批通过后,根据日期

+ 26 - 13
src/main/java/com/xjrsoft/module/courseTable/service/impl/CourseTableServiceImpl.java

@@ -57,6 +57,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.time.DayOfWeek;
 import java.time.Duration;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
@@ -242,27 +243,40 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
      * 调课顶课查询
      */
     @Override
-    public List<CourseListVo> getAdjustList(Long teacherId, Date adjustDate) {
+    public List<CourseListVo> getAdjustList(String teacherId, String adjustDate) {
         CourseTableAdjustDto dto = new CourseTableAdjustDto();
-        if(!ObjectUtil.isEmpty(adjustDate)){
-            LocalDateTime localDateTime = adjustDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+        if(adjustDate != null && !"".equals(adjustDate)){
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDate localDateTime = LocalDate.parse(adjustDate, formatter);
             DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
             dto.setWeek(dayOfWeek.getValue());
         }
-        dto.setTeacherId(teacherId);
+        dto.setTeacherId(Long.parseLong(teacherId));
+        List<CourseListVo> list = courseTableMapper.getAdjustList(dto);
+        for (CourseListVo courseListVo : list) {
+            if(courseListVo.getTimePeriod() == 1){
+                courseListVo.setTimePeriodCn("上午");
+            }else if(courseListVo.getTimePeriod() == 2){
+                courseListVo.setTimePeriodCn("下午");
+            }else if(courseListVo.getTimePeriod() == 3){
+                courseListVo.setTimePeriodCn("晚上");
+            }
+        }
 
-        return courseTableMapper.getAdjustList(dto);
+        return list;
     }
 
     @Override
-    public String getPreCheck(String preCheckType, Long courseId, Long swapCourseId, Date swapDate, Long subTeacherId) {
+    public String getPreCheck(String preCheckType, String courseId, String swapCourseId, String swapDate, String subTeacherId) {
         if(preCheckType != null && !"".equals(preCheckType)){
             if(CourseAdjustTypeEnum.courseExchange.getCode().equals(preCheckType)){
                 CourseTable courseTable = courseTableMapper.selectById(courseId);
                 CourseTable swapCourseTable = courseTableMapper.selectById(swapCourseId);
                 try {
-                    JsonObject preCheck = getExtendPreCheck(swapDate, courseTable, swapCourseTable);
-                    if(!preCheck.get("data").getAsBoolean() && !preCheck.get("msg").isJsonNull()){
+                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+                    LocalDate localDateTime = LocalDate.parse(swapDate, formatter);
+                    JsonObject preCheck = getExtendPreCheck(localDateTime, courseTable, swapCourseTable);
+                    if(preCheck.get("code").getAsInt() == -1 && !preCheck.get("msg").isJsonNull()){
                         return preCheck.get("msg").getAsString();
                     }
                 } catch (Exception e) {
@@ -273,7 +287,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
                 CourseTable courseTable = courseTableMapper.selectById(courseId);
                 try {
                     JsonObject jsonObject = substitutePreTestin(subTeacherId, courseTable);
-                    if(!jsonObject.get("data").getAsBoolean() && !jsonObject.get("msg").isJsonNull()){
+                    if(jsonObject.get("code").getAsInt() == -1 && !jsonObject.get("msg").isJsonNull()){
                         return jsonObject.get("msg").getAsString();
                     }
                 } catch (Exception e) {
@@ -345,7 +359,6 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
         //生成签名
         String sign = ScheduleUtil.createSign(timestamp);
         String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
-        System.out.println(result);
     }
 
     /**
@@ -379,7 +392,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
      * @param courseTable
      * @return 检查结果
      */
-    JsonObject substitutePreTestin(Long subTeacherId, CourseTable courseTable) throws Exception {
+    JsonObject substitutePreTestin(String subTeacherId, CourseTable courseTable) throws Exception {
         JsonParser jsonParser = new JsonParser();
         String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/Substitute/PreTesting";
         JsonObject jsonObject = new JsonObject();
@@ -406,7 +419,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
      * @param swapCourseTable 对调的课程
      * @return 检查结果
      */
-    JsonObject getExtendPreCheck(Date swapDate, CourseTable courseTable, CourseTable swapCourseTable) throws Exception {
+    JsonObject getExtendPreCheck(LocalDate swapDate, CourseTable courseTable, CourseTable swapCourseTable) throws Exception {
         JsonParser jsonParser = new JsonParser();
         String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/PreTesting";
         JsonObject jsonObject = new JsonObject();
@@ -417,7 +430,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
 //        jsonObject.addProperty("dayOfweek", 5);
         jsonObject.addProperty("numberOfday", swapCourseTable.getTimeNumber());
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        jsonObject.addProperty("date", swapDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter));
+        jsonObject.addProperty("date", swapDate.format(formatter));
         jsonObject.addProperty("reschduleId", courseTable.getJianyueId());
 
         //获取时间戳

+ 1 - 0
src/main/java/com/xjrsoft/module/job/JianyuekbBaseDataTask.java

@@ -8,6 +8,7 @@ import com.xjrsoft.common.utils.DatasourceUtil;
 import com.xjrsoft.module.schedule.entity.JianyueData;
 import com.xjrsoft.module.schedule.util.DataUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.ApplicationContext;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 

+ 20 - 22
src/main/java/com/xjrsoft/module/job/JianyuekbScheduleTask.java

@@ -1,12 +1,11 @@
 package com.xjrsoft.module.job;
 
-import cn.hutool.core.util.StrUtil;
 import cn.hutool.db.Db;
 import cn.hutool.extra.spring.SpringUtil;
 import com.google.gson.JsonArray;
 import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.utils.DatasourceUtil;
-import com.xjrsoft.module.base.entity.BaseSemester;
+import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
 import com.xjrsoft.module.schedule.entity.JianyueData;
 import com.xjrsoft.module.schedule.util.DataUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -14,6 +13,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.sql.DataSource;
+import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -27,22 +27,31 @@ import java.util.Set;
 @Component
 @Slf4j
 public class JianyuekbScheduleTask {
-
-    @Scheduled(cron = "0 */15 * * * ?")
-    public void RefreshConnectionPool() {
+    @Scheduled(cron = "0 */10 * * * ?")
+    public void RefreshConnectionPool() throws SQLException, InterruptedException {
         String active = SpringUtil.getActiveProfile();
         if(!"prod".equals(active)){
             log.info("非正式环境,无法执行获取课表数据");
             return;
         }
-        //doExecute();
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        Db use = Db.use(datasource);
+        String sql = "SELECT * FROM course_receive_msg WHERE delete_mark = 0 AND is_callback IS NULL";
+        List<CourseReceiveMsg> receiveMsgs = use.query(sql, CourseReceiveMsg.class);
+        for (CourseReceiveMsg receiveMsg : receiveMsgs) {
+            String updSql = "update course_receive_msg set is_callback = 0 where id = " + receiveMsg.getId();
+            use.execute(updSql, new HashMap<>());
+
+            doExecute(use, receiveMsg.getEduYearSerialNo(), receiveMsg.getStartDate(), receiveMsg.getEndDate());
+
+            updSql = "update course_receive_msg set is_callback = 1 where id = " + receiveMsg.getId();
+            use.execute(updSql, new HashMap<>());
+        }
     }
 
-    void doExecute(){
+    void doExecute(Db use, String eduYearSerialNo, String startDate, String endDate){
         log.info("开始获取课表数据");
-        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
         try {
-            Db use = Db.use(datasource);
             String sql = "SELECT distinct table_name FROM jianyue_data WHERE 1 = 1";
             List<JianyueData> query = use.query(sql, JianyueData.class);
             Set<String> tables = new HashSet<>();
@@ -65,7 +74,7 @@ public class JianyuekbScheduleTask {
             DataUtil dataUtil = new DataUtil();
             //获取年级
             String tableName = "base_grade";
-            Map<String, Long> gradeMap = dataMap.get(tableName);
+//            Map<String, Long> gradeMap = dataMap.get(tableName);
             //获取学期
             tableName = "base_semester";
             Map<String, Long> semesterMap = dataMap.get(tableName);
@@ -82,19 +91,8 @@ public class JianyuekbScheduleTask {
             tableName = "base_classroom";
             Map<String, Long> classroomMap = dataMap.get(tableName);
 
-            //查询当前学期id
-            String currenSemeter = dataUtil.getCurrenSemeter();
-            if(StrUtil.isEmpty(currenSemeter)){
-                return;
-            }
-            sql = "SELECT * FROM base_semester WHERE id = (select source_id from jianyue_data where jianyue_id = '" + currenSemeter + "')";
-            List<BaseSemester> semesters = use.query(sql, BaseSemester.class);
-            if(semesters.isEmpty()){
-                return;
-            }
-            BaseSemester baseSemester = semesters.get(0);
             //获取课表并存到数据库
-            JsonArray scheduleInfo = dataUtil.getScheduleInfoByClass(classMap, baseSemester.getStartDate(), baseSemester.getEndDate());
+            JsonArray scheduleInfo = dataUtil.getScheduleInfoByGrade(eduYearSerialNo, startDate, endDate);
             dataUtil.insertCourseTable(use, scheduleInfo, classroomMap, courseMap, semesterMap, teacherMap, classMap);
             dataUtil.insertClassTime(use, scheduleInfo);
             log.info("课表数据获取完成");

+ 1 - 49
src/main/java/com/xjrsoft/module/schedule/controller/ScheduleController.java

@@ -34,6 +34,7 @@ import com.xjrsoft.module.teacher.service.IBaseTeacherService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -84,55 +85,6 @@ public class ScheduleController {
         courseReceiveMsg.setDeleteMark(DeleteMark.NODELETE.getCode());
         courseReceiveMsg.setEnabledMark(EnabledMark.ENABLED.getCode());
         courseReceiveMsgService.save(courseReceiveMsg);
-        CompletableFuture.runAsync(() -> {
-            try {
-                DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
-                Db use = Db.use(datasource);
-                DataUtil dataUtil = new DataUtil();
-                JsonArray scheduleInfo = dataUtil.getScheduleInfoByGrade(eduYearSerialNo, startDate, endDate);
-                String sql = "SELECT distinct table_name FROM jianyue_data WHERE 1 = 1";
-                List<JianyueData> query = use.query(sql, JianyueData.class);
-                Set<String> tables = new HashSet<>();
-                for (JianyueData jianyueData : query) {
-                    tables.add(jianyueData.getTableName());
-                }
-                sql = "SELECT * FROM jianyue_data WHERE 0 = 0";
-                List<JianyueData> list = use.query(sql, JianyueData.class);
-                Map<String, Map<String, Long>> dataMap = new HashMap<>();
-                for (String table : tables) {
-                    Map<String, Long> tableData = new HashMap<>();
-                    for (JianyueData jianyueData : list) {
-                        if(!table.equals(jianyueData.getTableName())){
-                            continue;
-                        }
-                        tableData.put(jianyueData.getJianyueId(), jianyueData.getSourceId());
-                    }
-                    dataMap.put(table, tableData);
-                }
-
-                //获取学期
-                String tableName = "base_semester";
-                Map<String, Long> semesterMap = dataMap.get(tableName);
-                //获取课程
-                tableName = "base_course_subject";
-                Map<String, Long> courseMap = dataMap.get(tableName);
-                //获取教职工
-                tableName = "base_teacher";
-                Map<String, Long> teacherMap = dataMap.get(tableName);
-                //获取行政班
-                tableName = "base_class";
-                Map<String, Long> classMap = dataMap.get(tableName);
-
-                tableName = "base_classroom";
-                Map<String, Long> classroomMap = dataMap.get(tableName);
-                dataUtil.insertCourseTable(use, scheduleInfo, classroomMap, courseMap, semesterMap, teacherMap, classMap);
-                dataUtil.insertClassTime(use, scheduleInfo);
-            } catch (SQLException e) {
-                throw new RuntimeException(e);
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        });
 
         return RT.ok(courseReceiveMsg);
     }

+ 4 - 2
src/main/java/com/xjrsoft/module/schedule/util/DataUtil.java

@@ -199,7 +199,7 @@ public class DataUtil {
                 continue;
             }
             JsonObject paramJson = new JsonObject();
-            paramJson.addProperty("name", courseSubject.getName() + courseSubject.getCode());
+            paramJson.addProperty("name", courseSubject.getName());
             paramJson.addProperty("code", courseSubject.getCode());
             paramJson.addProperty("extendId", courseSubject.getId().toString());
             if(tagMap.get(courseSubject.getBaseLabelId()) != null){
@@ -263,6 +263,8 @@ public class DataUtil {
 
             if(semester.getStartDate() != null && semester.getEndDate() != null && semester.getEndDate().getTime() > timestamp && semester.getStartDate().getTime() < timestamp){
                 paramJson.addProperty("isCurrent", Boolean.TRUE);
+            }else if(semester.getStartDate() != null && semester.getEndDate() != null && semester.getEndDate().getTime() > timestamp && semester.getStartDate().getTime() > timestamp){
+                paramJson.addProperty("isCurrent", Boolean.TRUE);
             }else{
                 paramJson.addProperty("isCurrent", Boolean.FALSE);
             }
@@ -543,7 +545,7 @@ public class DataUtil {
             String sql = "INSERT INTO class_time(id,time_period,number,full_name,short_name,create_date,summer_start_time"
                     + ",summer_end_time,winter_start_time,winter_end_time) select " + id + String.format("%04d", count) + ","
                     + jsonObject.get("tmePeriod").getAsInt() + ","
-                    + jsonObject.get("numberOfDay").getAsInt() + ","
+                    + substring1 + ","
                     + "'" + fullName + "',"
                     + "'" + fullName + "',now(),"
                     + "'" + jsonObject.get("startTime").getAsString() + "',"

+ 4 - 4
src/main/java/com/xjrsoft/module/schedule/util/ScheduleUtil.java

@@ -23,9 +23,9 @@ import java.util.Map;
 @Slf4j
 public class ScheduleUtil {
     public static final String ALGORITHM = "HmacSHA256";
-    public static final String apiUrl = "https://live.jianyuekb.com/api/v1/ScheduleFlowV2/OpenApi/";
-    public static final String password = "Jh&NAbn6Rm#p@6ZZ";
-    public static final String secert = "UUFM5TID45X";
+    public static final String apiUrl = "http://219.153.208.33:20000/api/v1/ScheduleFlowV2/OpenApi/";
+    public static final String password = "@ak8To$xSHFoT6FoqsqYb3";
+    public static final String secert = "UUXQ8G4W9IU";
 //    private static JianyuekbConfig jianyuekbConfig;
 
 //    public ScheduleUtil(JianyuekbConfig jianyuekbConfig){
@@ -63,7 +63,7 @@ public class ScheduleUtil {
             URL url = new URL(httpUrl);
             // 通过远程url连接对象打开连接
             connection = (HttpURLConnection) url.openConnection();
-            connection.setRequestProperty("schoolId","UUFM5TID45X");
+            connection.setRequestProperty("schoolId",secert);
             connection.setRequestProperty("sign",sign);
             connection.setRequestProperty("timestamp",String.format("%d",timestamp));
             // 设置连接请求方式

+ 5 - 1
src/main/java/com/xjrsoft/module/schedule/vo/CourseListVo.java

@@ -20,7 +20,11 @@ public class CourseListVo {
     private String classroomName;
 
     @ApiModelProperty("时段(1=上午 2=下午 3=晚上)")
-    private String timePeriod;
+    private Integer timePeriod;
+
+    @ApiModelProperty("时段(1=上午 2=下午 3=晚上)")
+    private String timePeriodCn;
+
 
     @ApiModelProperty("节次")
     private String timeNumber;

+ 2 - 2
src/main/resources/mapper/courseTable/CourseTable.xml

@@ -38,8 +38,8 @@
         <if test="dto.startDate != null and dto.endDate != null">
             and t1.schedule_date between #{dto.startDate} and #{dto.endDate}
         </if>
-        <if test="dto.today != null">
-            and t1.schedule_date = #{dto.today}
+        <if test="dto.toDay != null">
+            and t1.schedule_date = #{dto.toDay}
         </if>
     </select>
     <select id="getAdjustList" parameterType="com.xjrsoft.module.schedule.dto.CourseTableAdjustDto" resultType="com.xjrsoft.module.schedule.vo.CourseListVo">

+ 2 - 2
src/main/resources/sqlScript/20240125_sql.sql

@@ -339,5 +339,5 @@ CREATE TABLE base_label
     PRIMARY KEY (`id`)
 ) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT '基础标签表';
 
-# ALTER TABLE `tl`.`base_course_subject`
-#   CHANGE `org_id` `base_label_id` BIGINT NULL   COMMENT '标签id(base_label)';
+ALTER TABLE `base_course_subject`
+   CHANGE `org_id` `base_label_id` BIGINT NULL   COMMENT '标签id(base_label)';

+ 11 - 11
src/test/java/com/xjrsoft/xjrsoftboot/ScheduleFlowTest.java

@@ -33,8 +33,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 // 简约课表测试
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = XjrSoftApplication.class)
+//@RunWith(SpringRunner.class)
+//@SpringBootTest(classes = XjrSoftApplication.class)
 public class ScheduleFlowTest {
 
     public static final String ALGORITHM = "HmacSHA256";
@@ -87,10 +87,10 @@ public class ScheduleFlowTest {
     public void ScheduleFlowTest() throws Exception {
         long timestamp = System.currentTimeMillis();
         System.out.println("timestamp:" + timestamp);
-        String md5Str = SaSecureUtil.md5("Jh&NAbn6Rm#p@6ZZ" + timestamp);
+        String md5Str = SaSecureUtil.md5("@ak8To$xSHFoT6FoqsqYb3" + timestamp);
 
 
-        String sign = calculateHMac("UUFM5TID45X", md5Str);
+        String sign = calculateHMac("UUXQ8G4W9IU", md5Str);
         System.out.println("sign:" + sign);
 
         //查询校区id
@@ -117,13 +117,13 @@ public class ScheduleFlowTest {
 //        List<String> classInfo = getClassInfo(sign, timestamp);
 //
 //        //查询课表信息
-        List<JianyueData> baseClass = jianyueDataMapper.selectList(new QueryWrapper<JianyueData>().lambda().eq(JianyueData::getTableName, "base_class"));
-        List<String> classInfo = new ArrayList<>();
-        for (JianyueData aClass : baseClass) {
-            classInfo.add(aClass.getJianyueId());
-        }
-        JsonArray scheduleInfo = getScheduleInfo(sign, timestamp, classInfo);
-        System.out.println(scheduleInfo);
+//        List<JianyueData> baseClass = jianyueDataMapper.selectList(new QueryWrapper<JianyueData>().lambda().eq(JianyueData::getTableName, "base_class"));
+//        List<String> classInfo = new ArrayList<>();
+//        for (JianyueData aClass : baseClass) {
+//            classInfo.add(aClass.getJianyueId());
+//        }
+//        JsonArray scheduleInfo = getScheduleInfo(sign, timestamp, classInfo);
+//        System.out.println(scheduleInfo);
 
 //
 

+ 861 - 0
src/test/java/com/xjrsoft/xjrsoftboot/ScheduleTest.java

@@ -0,0 +1,861 @@
+package com.xjrsoft.xjrsoftboot;
+
+import cn.dev33.satoken.secure.SaSecureUtil;
+import cn.hutool.db.Db;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.xjrsoft.XjrSoftApplication;
+import com.xjrsoft.common.constant.GlobalConstant;
+import com.xjrsoft.common.utils.DatasourceUtil;
+import com.xjrsoft.module.courseTable.service.ICourseTableService;
+import com.xjrsoft.module.schedule.entity.JianyueData;
+import com.xjrsoft.module.schedule.util.DataUtil;
+import com.xjrsoft.module.schedule.util.ScheduleUtil;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.sql.DataSource;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+// 简约课表测试
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = XjrSoftApplication.class)
+public class ScheduleTest {
+
+    public static final String ALGORITHM = "HmacSHA256";
+    public static final String apiUrl = "http://219.153.208.33:20000/api/v1/ScheduleFlowV2/OpenApi/";
+    @Autowired
+    private ICourseTableService courseTableService;
+
+    public static String calculateHMac(String key, String data) throws Exception {
+        Mac sha256_HMAC = Mac.getInstance(ALGORITHM);
+
+        SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), ALGORITHM);
+        sha256_HMAC.init(secret_key);
+
+        return byteArrayToHex(sha256_HMAC.doFinal(data.getBytes("UTF-8")));
+    }
+
+    public static String byteArrayToHex(byte[] a) {
+        StringBuilder sb = new StringBuilder(a.length * 2);
+        for (byte b : a)
+            sb.append(String.format("%02x", b));
+        return sb.toString();
+    }
+
+
+    /**
+     * 将加密后的字节数组转换成字符串
+     *
+     * @param b 字节数组
+     * @return 字符串
+     */
+    private static String byteArrayToHexString(byte[] b) {
+        StringBuilder hs = new StringBuilder();
+        String stmp;
+        for (int n = 0; b != null && n < b.length; n++) {
+            stmp = Integer.toHexString(b[n] & 0XFF);
+            if (stmp.length() == 1)
+                hs.append('0');
+            hs.append(stmp);
+        }
+        return hs.toString().toLowerCase();
+    }
+
+    /**
+     * https://live.jianyuekb.com/api/v1/ScheduleFlowV2/OpenApi/
+     * schoolId:UUFM5TID45X
+     * secert:UUFM5TID45X
+     * password:Jh&NAbn6Rm#p@6ZZ
+     */
+    @Test
+    public void ScheduleFlowTest() throws Exception {
+        long timestamp = System.currentTimeMillis();
+        System.out.println("timestamp:" + timestamp);
+        String md5Str = SaSecureUtil.md5("@ak8To$xSHFoT6FoqsqYb3" + timestamp);
+
+
+        String sign = calculateHMac("UUXQ8G4W9IU", md5Str);
+        System.out.println("sign:" + sign);
+
+//        JsonObject paramJson = new JsonObject();
+//        paramJson.addProperty("pageIndex", 1);
+//        paramJson.addProperty("pageSize", 200);
+
+        //获取时间戳
+//        long timestamp = System.currentTimeMillis();
+        //生成签名
+//        String sign = ScheduleUtil.createSign(timestamp);
+//        String result = ScheduleUtil.doPost("http://219.153.208.33:20000/api/v1/ScheduleFlowV2/OpenApi/SchoolDistrict/page", paramJson.toString(), sign, timestamp);
+//        System.out.println(result);
+
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        try {
+            Db use = Db.use(datasource);
+            String sql = "SELECT distinct table_name FROM jianyue_data WHERE 1 = 1";
+            List<JianyueData> query = use.query(sql, JianyueData.class);
+            Set<String> tables = new HashSet<>();
+            for (JianyueData jianyueData : query) {
+                tables.add(jianyueData.getTableName());
+            }
+            sql = "SELECT * FROM jianyue_data WHERE 0 = 0";
+            List<JianyueData> list = use.query(sql, JianyueData.class);
+            Map<String, Map<Long, String>> dataMap = new HashMap<>();
+            for (String table : tables) {
+                Map<Long, String> tableData = new HashMap<>();
+                for (JianyueData jianyueData : list) {
+                    if(!table.equals(jianyueData.getTableName())){
+                        continue;
+                    }
+                    tableData.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
+                }
+                dataMap.put(table, tableData);
+            }
+            DataUtil dataUtil = new DataUtil();
+            //查询校区
+            JsonArray schoolDistrictData = dataUtil.getSchoolDistrictData();
+            //推送年级
+            String tableName = "base_grade";
+            Map<Long, String> grade = dataUtil.insertGrade(use, tableName, schoolDistrictData.get(0).getAsString(), dataMap.get(tableName));
+            if(grade.isEmpty() && dataMap.get(tableName) != null){
+                grade = dataMap.get(tableName);
+            }
+
+            //推送学期
+            tableName = "base_semester";
+            dataUtil.insertSemester(use, tableName, dataMap.get(tableName));
+            //推送标签
+            tableName = "base_label";
+            Map<Long, String> tagMap = dataUtil.insertCourseTag(use, tableName, dataMap.get(tableName));
+            if(tagMap.isEmpty() && dataMap.get(tableName) != null){
+                tagMap = dataMap.get(tableName);
+            }
+            //推送课程
+            tableName = "base_course_subject";
+            dataUtil.insertCourse(use, tableName, dataMap.get(tableName), tagMap);
+            //推送教职工
+            tableName = "base_teacher";
+            Map<Long, String> teacherMap = dataUtil.insertTeacher(use, tableName, dataMap.get(tableName));
+            if(teacherMap.isEmpty() && dataMap.get(tableName) != null){
+                teacherMap = dataMap.get(tableName);
+            }
+            //推送学生
+            tableName = "base_student";
+            dataUtil.insertStudent(use, tableName, grade, dataMap.get(tableName));
+            //推送教室
+            tableName = "base_classroom";
+            Map<Long, String> classroomMap = dataUtil.insertClassRoom(use, tableName, schoolDistrictData.get(0).getAsString(), dataMap.get(tableName));
+            if(classroomMap.isEmpty() && dataMap.get(tableName) != null){
+                classroomMap = dataMap.get(tableName);
+            }
+            //推送行政班,先查询当前学期id
+            String currenSemeter = dataUtil.getCurrenSemeter();
+            tableName = "base_class";
+            dataUtil.insertClass(use, tableName, grade, teacherMap, currenSemeter, dataMap.get(tableName), classroomMap);
+
+        } catch (Exception e) {
+        }
+    }
+
+
+
+    void SubstitutePreTestin(String sign, Long timestamp){
+        JsonParser jsonParser = new JsonParser();
+        String url = apiUrl + "RescheduleApply/Extend/Substitute/PreTesting";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("timetableId", "4deba192-0b39-9821-5eac-3a1079ba6fbf");
+        jsonObject.addProperty("isCycles", Boolean.FALSE);
+        JsonArray extendIds = new JsonArray();
+        extendIds.add(14954799374790L);
+        jsonObject.add("extendIds", extendIds);
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        System.out.println(result);
+    }
+    void getPreCheck(String sign, Long timestamp){
+        JsonParser jsonParser = new JsonParser();
+        String url = apiUrl + "RescheduleApply/Extend/PreTesting";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("timetableId", "1e77cf3e-a027-1665-8100-3a106a58b8ab");
+        jsonObject.addProperty("isCycles", Boolean.FALSE);
+//        jsonObject.addProperty("startDate", "2024-01-01");
+//        jsonObject.addProperty("endDate", "2024-01-31");
+//        jsonObject.addProperty("dayOfweek", 5);
+        jsonObject.addProperty("numberOfday", 3);
+        jsonObject.addProperty("date", "2024-01-31");
+        jsonObject.addProperty("reschduleId", "4e2fc331-ce9d-f512-13fb-3a106a58bf82");
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        System.out.println(result);
+    }
+
+    void getTimetable(String sign, Long timestamp){
+        JsonParser jsonParser = new JsonParser();
+        String url = apiUrl + "RescheduleApply/Can/Reschedule/Timetable/List";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("timetableId", "1e77cf3e-a027-1665-8100-3a106a58b8ab");
+        jsonObject.addProperty("isCycles", Boolean.TRUE);
+        JsonObject cycles = new JsonObject();
+        cycles.addProperty("startDate", "2024-01-25");
+        cycles.addProperty("endDate", "2024-01-30");
+        cycles.addProperty("dayOfweek", 5);
+        cycles.addProperty("numberOfday", 3);
+        jsonObject.add("cycles", cycles);
+        jsonObject.addProperty("reschduleDate", "2024-02-02");
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        System.out.println(result);
+    }
+    List<String> getClassInfo(String sign, Long timestamp){
+        JsonParser jsonParser = new JsonParser();
+        String url  = apiUrl + "Class/page";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("pageSize", "200");
+        jsonObject.addProperty("pageIndex", "1");
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        System.out.println("ClassInfo:" + result);
+        JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+        JsonArray jsonArray = resultJson.get("data").getAsJsonObject().get("dataList").getAsJsonArray();
+        List<String> resultArray = new ArrayList<>();
+        for (JsonElement jsonElement : jsonArray) {
+            JsonObject asJsonObject = jsonElement.getAsJsonObject();
+            resultArray.add(asJsonObject.get("serialNo").getAsString());
+        }
+        return resultArray;
+    }
+    JsonArray getSchoolDistrictData(String sign, Long timestamp){
+        JsonParser jsonParser = new JsonParser();
+//        String url  = apiUrl + "SchoolDistrict/Create";
+//        JsonObject jsonObject = new JsonObject();
+//        jsonObject.addProperty("name", "test1");
+//        jsonObject.addProperty("shortName", "本部112");
+//        jsonObject.addProperty("note", "本部211");
+//        jsonObject.addProperty("sort", "2");
+//        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+//        JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+
+        String url  = apiUrl + "SchoolDistrict/page";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("pageSize", "15");
+        jsonObject.addProperty("pageIndex", "1");
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+
+        JsonArray jsonArray = resultJson.get("data").getAsJsonObject().get("dataList").getAsJsonArray();
+        JsonArray resultArray = new JsonArray();
+        for (JsonElement jsonElement : jsonArray) {
+            JsonObject asJsonObject = jsonElement.getAsJsonObject();
+            resultArray.add(asJsonObject.get("id").getAsString());
+        }
+        return resultArray;
+    }
+
+    List<String> getGradeInfo(String sign, Long timestamp, JsonArray schoolDistrictIds){
+        JsonParser jsonParser = new JsonParser();
+        String url  = apiUrl + "TimeTable/List";
+        JsonObject jsonObject = new JsonObject();
+//        jsonObject.addProperty("schoolDistrictIds", schoolDistrictIds.toString());
+        jsonObject.addProperty("pageSize", "15");
+        jsonObject.addProperty("pageIndex", "1");
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        System.out.println("grade:" + result);
+        JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+        JsonArray data = resultJson.get("data").getAsJsonArray();
+        if(data.size() == 0){
+            return new ArrayList<>();
+        }
+        JsonArray gradeArray = resultJson.get("data").getAsJsonObject().get("dataList").getAsJsonArray();
+        List<String> gradeIds = new ArrayList<>();
+        for (JsonElement jsonElement : gradeArray) {
+            JsonObject asJsonObject = jsonElement.getAsJsonObject();
+            gradeIds.add(asJsonObject.get("serialNo").getAsString());
+        }
+        
+        return gradeIds;
+    }
+
+    JsonArray getScheduleInfo(String sign, Long timestamp, List<String> ids) throws IOException {
+        JsonParser jsonParser = new JsonParser();
+        String url  = apiUrl + "TimeTable/List";
+        if(ids.isEmpty()){
+            JsonObject jsonObject = new JsonObject();
+            jsonObject.addProperty("startDate", "2024-01-01 00:00:00");
+            jsonObject.addProperty("endDate", "2024-02-21 23:59:59");
+            String result = doPost(url, jsonObject.toString(), sign, timestamp);
+            File file = new File("D:\\workspace\\其他\\课表\\file.txt");
+            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+            writer.write(result); // 写入字符串内容
+            writer.close();
+            return null;
+        }
+        for (String id : ids) {
+            JsonObject jsonObject = new JsonObject();
+            jsonObject.addProperty("classSerialNo", id);
+            jsonObject.addProperty("startDate", "2024-01-01 00:00:00");
+            jsonObject.addProperty("endDate", "2024-02-21 23:59:59");
+            String result = doPost(url, jsonObject.toString(), sign, timestamp);
+            System.out.println(id + ":" + result);
+        }
+
+        return null;
+    }
+
+//    List<String> insertClass(String sign, Long timestamp, String schoolDistrictId) throws InterruptedException {
+//        List<ClassroomJianyuekbVo> dataList = baseClassroomMapper.getJianyueList();
+//        String url  = apiUrl + "class/create";
+//        List<String> idList = new ArrayList<>();
+//        JsonParser jsonParser = new JsonParser();
+//
+//        String findUrl = apiUrl + "class/page";
+//
+//        for (ClassroomJianyuekbVo classroom : dataList) {
+//            JsonObject paramJson = new JsonObject();
+//            paramJson.addProperty("schoolDistrictId", schoolDistrictId);
+//            paramJson.addProperty("name", classroom.getName());
+//
+////            paramJson.addProperty("peopleCount", classroom.getPeopleCount());
+////            paramJson.addProperty("location", classroom.getLocation());
+//            paramJson.addProperty("peopleCount", 50);
+//            paramJson.addProperty("location", "无");
+//            paramJson.addProperty("extendId", classroom.getExtendId());
+//            paramJson.addProperty("floor", classroom.getFloor());
+////            String findResult = doPost(findUrl, paramJson.toString(), sign, timestamp);
+////            if(findResult != null){
+////                JsonObject resultJson = jsonParser.parse(findResult).getAsJsonObject();
+////                JsonObject data = resultJson.get("data").getAsJsonObject();
+////                if(data.get("total").getAsInt() != 0){
+////                    //调用update
+////                }
+////            }
+//
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//            if(result == null){
+//                System.out.println(paramJson.toString());
+//                continue;
+//            }
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//            idList.add(resultJson.get("data").getAsString());
+//        }
+//        return idList;
+//    }
+//
+//    List<String> insertClassRoom(String sign, Long timestamp, String schoolDistrictId) throws InterruptedException {
+//        List<ClassroomJianyuekbVo> dataList = baseClassroomMapper.getJianyueList();
+//        String url  = apiUrl + "classroom/create";
+//        List<String> idList = new ArrayList<>();
+//        JsonParser jsonParser = new JsonParser();
+//
+//        String findUrl = apiUrl + "ClassRoom/page";
+//
+//        for (ClassroomJianyuekbVo classroom : dataList) {
+//            JsonObject paramJson = new JsonObject();
+//            paramJson.addProperty("schoolDistrictId", schoolDistrictId);
+//            paramJson.addProperty("name", classroom.getName());
+//
+////            paramJson.addProperty("peopleCount", classroom.getPeopleCount());
+////            paramJson.addProperty("location", classroom.getLocation());
+//            paramJson.addProperty("peopleCount", 50);
+//            paramJson.addProperty("location", "无");
+//            paramJson.addProperty("extendId", classroom.getExtendId());
+//            paramJson.addProperty("floor", classroom.getFloor());
+////            String findResult = doPost(findUrl, paramJson.toString(), sign, timestamp);
+////            if(findResult != null){
+////                JsonObject resultJson = jsonParser.parse(findResult).getAsJsonObject();
+////                JsonObject data = resultJson.get("data").getAsJsonObject();
+////                if(data.get("total").getAsInt() != 0){
+////                    //调用update
+////                }
+////            }
+//
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//            if(result == null){
+//                System.out.println(paramJson.toString());
+//                continue;
+//            }
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//            idList.add(resultJson.get("data").getAsString());
+//        }
+//        return idList;
+//    }
+//
+//    List<String> insertStudent(String sign, Long timestamp, Map<Long, String> gradeMap) throws Exception {
+//
+//        List<StudentJianyuekbVo> dataList = baseStudentMapper.getJianyueStudentList();
+//        String url  = apiUrl + "student/create";
+//        List<String> idList = new ArrayList<>();
+//        JsonParser jsonParser = new JsonParser();
+//
+//        String findUrl = apiUrl + "Student/page";
+//
+//        for (StudentJianyuekbVo student : dataList) {
+//            JsonObject paramJson = new JsonObject();
+//            paramJson.addProperty("registerNo", student.getRegisterNo());
+//            paramJson.addProperty("gender", student.getGender());
+//
+//            paramJson.addProperty("realName", student.getRealName());
+//            paramJson.addProperty("alias", student.getAlias());
+//            paramJson.addProperty("extendId", student.getExtendId());
+//            paramJson.addProperty("gradeSerialNo", gradeMap.get(student.getGradeSerialNo()));
+////            String findResult = doPost(findUrl, paramJson.toString(), sign, timestamp);
+////            if(findResult != null){
+////                JsonObject resultJson = jsonParser.parse(findResult).getAsJsonObject();
+////                JsonObject data = resultJson.get("data").getAsJsonObject();
+////                if(data.get("total").getAsInt() != 0){
+////                    //调用update
+////                }
+////            }
+//            timestamp = System.currentTimeMillis();
+//            System.out.println("timestamp:" + timestamp);
+//            String md5Str = SaSecureUtil.md5("Jh&NAbn6Rm#p@6ZZ" + timestamp);
+//
+//
+//            sign = calculateHMac("UUFM5TID45X", md5Str);
+//            System.out.println("sign:" + sign);
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//            if(result == null){
+//                System.out.println(paramJson.toString());
+//                continue;
+//            }
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//            idList.add(resultJson.get("data").getAsString());
+//        }
+//        return idList;
+//    }
+//
+//    List<String> insertTeacher(String sign, Long timestamp) throws InterruptedException {
+//        List<XjrUser> xjrUsers = xjrUserMapper.selectJoinList(
+//            XjrUser.class, new MPJLambdaWrapper<XjrUser>()
+//            .innerJoin("xjr_user_role_relation t2 on t.id = t2.user_id")
+//            .eq("t2.role_id", 2)
+//        );
+//        String url  = apiUrl + "teacher/create";
+//        List<String> idList = new ArrayList<>();
+//        JsonParser jsonParser = new JsonParser();
+//
+//        String findUrl = apiUrl + "/Teacher/Page";
+//
+//        for (XjrUser user : xjrUsers) {
+//            Thread.sleep(1000);
+//            JsonObject paramJson = new JsonObject();
+//            paramJson.addProperty("jobNumber", user.getUserName());
+//            paramJson.addProperty("gender", user.getGender());
+//
+//            String name = user.getName().substring(0, 1) + user.getUserName();
+//            paramJson.addProperty("name", name);
+//            paramJson.addProperty("alias", name);
+//            paramJson.addProperty("extendId", user.getId().toString());
+//            String findResult = doPost(findUrl, paramJson.toString(), sign, timestamp);
+//            if(findResult != null){
+//                JsonObject resultJson = jsonParser.parse(findResult).getAsJsonObject();
+//                JsonObject data = resultJson.get("data").getAsJsonObject();
+//                if(data.get("total").getAsInt() != 0){
+//                    //调用update
+//                }
+//            }
+//
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//            if(result == null){
+//                System.out.println(paramJson.toString());
+//                continue;
+//            }
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//            idList.add(resultJson.get("data").getAsString());
+//        }
+//        return idList;
+//    }
+//
+//    List<String> insertCourse(String sign, Long timestamp){
+//        List<BaseCourseSubject> list = baseCourseSubjectService.list(
+//                new QueryWrapper<BaseCourseSubject>().lambda()
+//                        .eq(BaseCourseSubject::getDeleteMark, DeleteMark.NODELETE.getCode())
+//        );
+//        String url  = apiUrl + "courseclass/Create";
+//        List<String> idList = new ArrayList<>();
+//        JsonParser jsonParser = new JsonParser();
+//        for (BaseCourseSubject courseSubject : list) {
+//            JsonObject paramJson = new JsonObject();
+//            paramJson.addProperty("name", courseSubject.getName() + courseSubject.getCode());
+//            paramJson.addProperty("code", courseSubject.getCode());
+//            paramJson.addProperty("extendId", courseSubject.getId().toString());
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//            if(result == null){
+//                System.out.println("result is null, paramJson: " + paramJson.toString());
+//                continue;
+//            }
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//            if(resultJson.get("code").getAsInt() == -1){
+//                System.out.println("paramJson: " + paramJson.toString() + ", 返回结果:" + result);
+//            }
+//            idList.add(resultJson.get("data").getAsString());
+//        }
+//
+//        return idList;
+//    }
+//
+//
+//
+//    List<String> insertSemester(String sign, Long timestamp){
+//        List<BaseSemester> list = baseSemesterService.list(
+//            new QueryWrapper<BaseSemester>().lambda()
+//            .eq(BaseSemester::getDeleteMark, DeleteMark.NODELETE.getCode())
+//        );
+//        String url  = apiUrl + "semester/Create";
+//        List<String> idList = new ArrayList<>();
+//        JsonParser jsonParser = new JsonParser();
+//        SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        String spring = "春";
+//        String autumn = "秋";
+//
+//        for (BaseSemester semester : list) {
+//            JsonObject paramJson = new JsonObject();
+//
+//            paramJson.addProperty("schoolYear", Integer.parseInt(sdfYear.format(semester.getStartDate())));
+//            Integer period = null;
+//            if(semester.getName().contains(String.valueOf(spring))){
+//                period = 1;
+//            }else if(semester.getName().contains(autumn)){
+//                period = 2;
+//            }
+//            paramJson.addProperty("period", period);
+//            paramJson.addProperty("startDate", sdf.format(semester.getStartDate()));
+//            paramJson.addProperty("endDate", sdf.format(semester.getEndDate()));
+//            paramJson.addProperty("extendId", semester.getId().toString());
+//
+//            if(semester.getStartDate() != null && semester.getEndDate() != null && semester.getEndDate().getTime() > timestamp && semester.getStartDate().getTime() < timestamp){
+//                paramJson.addProperty("isCurrent", Boolean.TRUE);
+//            }else{
+//                paramJson.addProperty("isCurrent", Boolean.FALSE);
+//            }
+//            System.out.println(paramJson.toString());
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//            idList.add(resultJson.get("data").getAsString());
+//        }
+//
+//        return idList;
+//    }
+
+    /**
+     *  由于简约中校区中的本部不能删除,如果没有多的校区,就只查询本部的id即可
+     * @param sign 签名
+     * @param timestamp 时间戳
+     * @return 返回添加好的校区id
+     */
+    String insertSchoolDistrictData(String sign, Long timestamp){
+        JsonParser jsonParser = new JsonParser();
+//        String url  = apiUrl + "SchoolDistrict/Create";
+//        JsonObject jsonObject = new JsonObject();
+//        jsonObject.addProperty("name", "test1");
+//        jsonObject.addProperty("shortName", "本部112");
+//        jsonObject.addProperty("note", "本部211");
+//        jsonObject.addProperty("sort", "2");
+//        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+//        JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+
+        String url  = apiUrl + "SchoolDistrict/page";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("keyword", "本部");
+        jsonObject.addProperty("pageSize", "15");
+        jsonObject.addProperty("pageIndex", "1");
+        String result = doPost(url, jsonObject.toString(), sign, timestamp);
+        JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+
+        String id = resultJson.get("data").getAsJsonObject().get("dataList").getAsJsonArray().get(0).getAsJsonObject().get("id").getAsString();
+        return id;
+    }
+
+//    Map<Long, String> insertGrade(String sign, Long timestamp, String schoolDistrictId){
+//        List<BaseGrade> list = baseGradeService.list(
+//            new QueryWrapper<BaseGrade>().lambda()
+//            .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
+//        );
+//        String url = apiUrl + "eduyear/create";
+//        JsonParser jsonParser = new JsonParser();
+//        Map<Long, String> idMap = new HashMap<>();
+//        for (BaseGrade baseGrade : list) {
+//            JsonObject paramJson = new JsonObject();
+//            paramJson.addProperty("schoolDistrictId", schoolDistrictId);
+//            paramJson.addProperty("period", 4);
+//            paramJson.addProperty("startYear", baseGrade.getTitle().replaceAll("年", ""));
+//            paramJson.addProperty("extendId", baseGrade.getId().toString());
+//            paramJson.addProperty("year", 3);
+//
+//            String result = doPost(url, paramJson.toString(), sign, timestamp);
+//
+//            JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
+//
+//            idMap.put(baseGrade.getId(), resultJson.get("data").getAsString());
+//        }
+//
+//        return idMap;
+//    }
+
+
+
+    public static String doGet(String httpurl) throws Exception {
+        long timestamp = System.currentTimeMillis();
+
+        String password = "";
+
+        String md5Str = SaSecureUtil.md5(String.format("Jh&NAbn6Rm#p@6ZZ%d", timestamp));
+
+        System.out.println(md5Str);
+
+        String sign = calculateHMac("a7dbed0dfc70ebd92934cf9292de8749e9af01a2405217be881f9e77f6ba5320", md5Str);
+
+        System.out.println(sign);
+
+
+        HttpURLConnection connection = null;
+        InputStream is = null;
+        BufferedReader br = null;
+        String result = null;// 返回结果字符串
+        try {
+            // 创建远程url连接对象
+            URL url = new URL(httpurl);
+            // 通过远程url连接对象打开一个连接,强转成httpURLConnection类
+            connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestProperty("schoolId","UUFM5TID45X");
+            connection.setRequestProperty("sign",sign);
+            connection.setRequestProperty("timestamp",String.format("%d",timestamp));
+            // 设置连接方式:get
+            connection.setRequestMethod("GET");
+            // 设置连接主机服务器的超时时间:15000毫秒
+            connection.setConnectTimeout(15000);
+            // 设置读取远程返回的数据时间:60000毫秒
+            connection.setReadTimeout(60000);
+            // 发送请求
+            connection.connect();
+            // 通过connection连接,获取输入流
+            if (connection.getResponseCode() == 200) {
+                is = connection.getInputStream();
+                // 封装输入流is,并指定字符集
+                br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                // 存放数据
+                StringBuffer sbf = new StringBuffer();
+                String temp = null;
+                while ((temp = br.readLine()) != null) {
+                    sbf.append(temp);
+                    sbf.append("\r\n");
+                }
+                result = sbf.toString();
+            }
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            // 关闭资源
+            if (null != br) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != is) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            connection.disconnect();// 关闭远程连接
+        }
+        return result;
+    }
+
+    public static String doPost(String httpUrl, String param, String sign, Long timestamp) {
+        HttpURLConnection connection = null;
+        InputStream is = null;
+        OutputStream os = null;
+        BufferedReader br = null;
+        String result = null;
+        OutputStreamWriter writer = null;
+        try {
+            URL url = new URL(httpUrl);
+            // 通过远程url连接对象打开连接
+            connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestProperty("schoolId","UUFM5TID45X");
+            connection.setRequestProperty("sign",sign);
+            connection.setRequestProperty("timestamp",String.format("%d",timestamp));
+            // 设置连接请求方式
+            connection.setRequestMethod("POST");
+            // 设置连接主机服务器超时时间:15000毫秒
+            connection.setConnectTimeout(15000);
+            // 设置读取主机服务器返回数据超时时间:60000毫秒
+            connection.setReadTimeout(60000);
+            // 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
+            connection.setDoOutput(true);
+            // 默认值为:true,当前向远程服务读取数据时,设置为true,该参数可有可无
+            connection.setDoInput(true);
+            // 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
+            connection.setRequestProperty("Content-Type", "application/json");
+            // 设置鉴权信息:Authorization: Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0
+//            connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
+            writer = new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
+            //body参数放这里
+            writer.write(param);
+            writer.flush();
+
+            writer.close();
+            // 通过连接对象获取一个输出流
+//            os = connection.getOutputStream();
+//            // 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
+//            os.write(param.getBytes());
+            // 通过连接对象获取一个输入流,向远程读取
+            if (connection.getResponseCode() == 200) {
+                is = connection.getInputStream();
+                // 对输入流对象进行包装:charset根据工作项目组的要求来设置
+                br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                StringBuffer sbf = new StringBuffer();
+                String temp = null;
+                // 循环遍历一行一行读取数据
+                while ((temp = br.readLine()) != null) {
+                    sbf.append(temp);
+                    sbf.append("\r\n");
+                }
+                result = sbf.toString();
+            }else{
+                is = connection.getInputStream();
+                // 对输入流对象进行包装:charset根据工作项目组的要求来设置
+                br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                StringBuffer sbf = new StringBuffer();
+                String temp = null;
+                // 循环遍历一行一行读取数据
+                while ((temp = br.readLine()) != null) {
+                    sbf.append(temp);
+                    sbf.append("\r\n");
+                }
+                System.out.println(sbf.toString());
+            }
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            // 关闭资源
+            if (null != br) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != os) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != is) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            // 断开与远程地址url的连接
+            connection.disconnect();
+        }
+        return result;
+    }
+
+    public static String doPost(String httpUrl) {
+        HttpURLConnection connection = null;
+        InputStream is = null;
+        OutputStream os = null;
+        BufferedReader br = null;
+        String result = null;
+        OutputStreamWriter writer = null;
+        try {
+            URL url = new URL(httpUrl);
+            // 通过远程url连接对象打开连接
+            connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestProperty("schoolId","UUFM5TID45X");
+            // 设置连接请求方式
+            connection.setRequestMethod("POST");
+            // 设置连接主机服务器超时时间:15000毫秒
+            connection.setConnectTimeout(15000);
+            // 设置读取主机服务器返回数据超时时间:60000毫秒
+            connection.setReadTimeout(60000);
+            // 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true
+            connection.setDoOutput(true);
+            // 默认值为:true,当前向远程服务读取数据时,设置为true,该参数可有可无
+            connection.setDoInput(true);
+            // 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。
+            connection.setRequestProperty("Content-Type", "application/json");
+            // 设置鉴权信息:Authorization: Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0
+//            connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
+            writer = new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
+            //body参数放这里
+            writer.flush();
+
+            writer.close();
+            // 通过连接对象获取一个输出流
+//            os = connection.getOutputStream();
+//            // 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的
+//            os.write(param.getBytes());
+            // 通过连接对象获取一个输入流,向远程读取
+            if (connection.getResponseCode() == 200) {
+                is = connection.getInputStream();
+                // 对输入流对象进行包装:charset根据工作项目组的要求来设置
+                br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                StringBuffer sbf = new StringBuffer();
+                String temp = null;
+                // 循环遍历一行一行读取数据
+                while ((temp = br.readLine()) != null) {
+                    sbf.append(temp);
+                    sbf.append("\r\n");
+                }
+                result = sbf.toString();
+            }
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            // 关闭资源
+            if (null != br) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != os) {
+                try {
+                    os.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != is) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            // 断开与远程地址url的连接
+            connection.disconnect();
+        }
+        return result;
+    }
+}