|
|
@@ -2,23 +2,14 @@ package com.xjrsoft.xjrsoftboot;
|
|
|
|
|
|
import cn.dev33.satoken.secure.SaSecureUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+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.enums.DeleteMark;
|
|
|
-import com.xjrsoft.module.base.entity.BaseCourseSubject;
|
|
|
-import com.xjrsoft.module.base.entity.BaseGrade;
|
|
|
-import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
-import com.xjrsoft.module.base.mapper.BaseClassroomMapper;
|
|
|
-import com.xjrsoft.module.base.service.IBaseCourseSubjectService;
|
|
|
-import com.xjrsoft.module.base.service.IBaseGradeService;
|
|
|
-import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
-import com.xjrsoft.module.schedule.vo.ClassroomJianyuekbVo;
|
|
|
-import com.xjrsoft.module.schedule.vo.StudentJianyuekbVo;
|
|
|
-import com.xjrsoft.module.student.mapper.BaseStudentMapper;
|
|
|
-import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
-import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
|
|
|
+import com.xjrsoft.config.JianyuekbConfig;
|
|
|
+import com.xjrsoft.module.schedule.entity.JianyueData;
|
|
|
+import com.xjrsoft.module.schedule.mapper.JianyueMapper;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -28,6 +19,9 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
import javax.crypto.Mac;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
|
import java.io.BufferedReader;
|
|
|
+import java.io.BufferedWriter;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileWriter;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
@@ -36,11 +30,8 @@ import java.io.OutputStreamWriter;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
// 简约课表测试
|
|
|
@RunWith(SpringRunner.class)
|
|
|
@@ -50,22 +41,7 @@ public class ScheduleFlowTest {
|
|
|
public static final String ALGORITHM = "HmacSHA256";
|
|
|
public static final String apiUrl = "https://live.jianyuekb.com/api/v1/ScheduleFlowV2/OpenApi/";
|
|
|
@Autowired
|
|
|
- private IBaseGradeService baseGradeService;
|
|
|
- @Autowired
|
|
|
- private IBaseSemesterService baseSemesterService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IBaseCourseSubjectService baseCourseSubjectService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private XjrUserMapper xjrUserMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BaseStudentMapper baseStudentMapper;
|
|
|
- @Autowired
|
|
|
- private BaseClassroomMapper baseClassroomMapper;
|
|
|
-
|
|
|
-
|
|
|
+ private JianyueMapper jianyueMapper;
|
|
|
|
|
|
public static String calculateHMac(String key, String data) throws Exception {
|
|
|
Mac sha256_HMAC = Mac.getInstance(ALGORITHM);
|
|
|
@@ -111,124 +87,292 @@ public class ScheduleFlowTest {
|
|
|
@Test
|
|
|
public void ScheduleFlowTest() throws Exception {
|
|
|
long timestamp = System.currentTimeMillis();
|
|
|
-
|
|
|
+ System.out.println("timestamp:" + timestamp);
|
|
|
String md5Str = SaSecureUtil.md5("Jh&NAbn6Rm#p@6ZZ" + timestamp);
|
|
|
|
|
|
+
|
|
|
String sign = calculateHMac("UUFM5TID45X", md5Str);
|
|
|
+ System.out.println("sign:" + sign);
|
|
|
+
|
|
|
//查询校区id
|
|
|
- String schoolDistrictId = insertSchoolDistrictData(sign, timestamp);
|
|
|
- System.out.println("schoolDistrictId:" + schoolDistrictId);
|
|
|
+// String schoolDistrictId = insertSchoolDistrictData(sign, timestamp);
|
|
|
+// System.out.println("schoolDistrictId:" + schoolDistrictId);
|
|
|
// //新增年级,并返回添加好的年级id
|
|
|
// Map<Long, String> gradeMap = insertGrade(sign, timestamp, schoolDistrictId);
|
|
|
//新增年级,并返回添加好的年级id
|
|
|
- insertSemester(sign, timestamp);
|
|
|
- //新增课程
|
|
|
+// insertSemester(sign, timestamp);
|
|
|
+// //新增课程
|
|
|
// insertCourse(sign, timestamp);
|
|
|
- //新增教师
|
|
|
+// //新增教师
|
|
|
// insertTeacher(sign, timestamp);
|
|
|
|
|
|
// insertStudent(sign, timestamp, gradeMap);
|
|
|
-
|
|
|
+//
|
|
|
// insertClassRoom(sign, timestamp,schoolDistrictId);
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- 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();
|
|
|
+ //先查寻出年级序列号
|
|
|
+// JsonArray schoolDistrictData = getSchoolDistrictData(sign, timestamp);
|
|
|
+// List<String> gradeInfo = getGradeInfo(sign, timestamp, schoolDistrictData);
|
|
|
+//
|
|
|
+// //班级信息
|
|
|
+// List<String> classInfo = getClassInfo(sign, timestamp);
|
|
|
+//
|
|
|
+// //查询课表信息
|
|
|
+ List<JianyueData> baseClass = jianyueMapper.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);
|
|
|
|
|
|
- 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
|
|
|
-// }
|
|
|
-// }
|
|
|
+ @Test
|
|
|
+ void test(){
|
|
|
+ System.out.println();
|
|
|
+ }
|
|
|
|
|
|
- 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());
|
|
|
+ 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 idList;
|
|
|
+ return resultArray;
|
|
|
}
|
|
|
-
|
|
|
- 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<>();
|
|
|
+ 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 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 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();
|
|
|
|
|
|
- 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());
|
|
|
+ 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 idList;
|
|
|
+ return resultArray;
|
|
|
}
|
|
|
|
|
|
- List<String> insertStudent(String sign, Long timestamp, Map<Long, String> gradeMap) throws InterruptedException {
|
|
|
-
|
|
|
- List<StudentJianyuekbVo> dataList = baseStudentMapper.getJianyueStudentList();
|
|
|
- String url = apiUrl + "student/create";
|
|
|
- List<String> idList = new ArrayList<>();
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
- String findUrl = apiUrl + "Student/page";
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- for (StudentJianyuekbVo student : dataList) {
|
|
|
- JsonObject paramJson = new JsonObject();
|
|
|
- paramJson.addProperty("registerNo", student.getRegisterNo());
|
|
|
- paramJson.addProperty("gender", student.getGender());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- paramJson.addProperty("realName", student.getRealName());
|
|
|
- paramJson.addProperty("alias", student.getAlias());
|
|
|
- paramJson.addProperty("extendId", student.getExtendId());
|
|
|
- paramJson.addProperty("gradeSerialNo", gradeMap.get(student.getGradeSerialNo()));
|
|
|
+// 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();
|
|
|
@@ -237,132 +381,90 @@ public class ScheduleFlowTest {
|
|
|
// //调用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> 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;
|
|
|
- }
|
|
|
+//
|
|
|
+// 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即可
|
|
|
@@ -393,31 +495,31 @@ public class ScheduleFlowTest {
|
|
|
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;
|
|
|
- }
|
|
|
+// 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;
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -531,6 +633,100 @@ public class ScheduleFlowTest {
|
|
|
// 通过连接对象获取一个输出流
|
|
|
// 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) {
|