Selaa lähdekoodia

排课工具数据同步推送

dzx 9 kuukautta sitten
vanhempi
commit
d995bf0c84
1 muutettua tiedostoa jossa 58 lisäystä ja 26 poistoa
  1. 58 26
      src/main/java/com/xjrsoft/module/schedule/util/DataUtil.java

+ 58 - 26
src/main/java/com/xjrsoft/module/schedule/util/DataUtil.java

@@ -23,7 +23,6 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.CompletableFuture;
 
 /**
  * @author dzx
@@ -55,7 +54,7 @@ public class DataUtil {
                 long timestamp = System.currentTimeMillis();
                 //生成签名
                 String sign = ScheduleUtil.createSign(timestamp);
-                String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
                 continue;
             }
 
@@ -80,13 +79,11 @@ public class DataUtil {
                 " INNER JOIN base_office_build t2 ON t1.office_build_id = t2.id" +
                 " WHERE t1.delete_mark = 0 AND t2.delete_mark = 0";
         List<ClassroomJianyuekbVo> dataList = db.query(sql, ClassroomJianyuekbVo.class);
-        String url  = ScheduleUtil.apiUrl + "classroom/create";
+
         JsonParser jsonParser = new JsonParser();
         Map<Long, String> idMap = new HashMap<>();
         for (ClassroomJianyuekbVo classroom : dataList) {
-            if(ids != null && ids.get(classroom.getExtendId()) != null){
-                continue;
-            }
+            String url  = ScheduleUtil.apiUrl + "classroom/create";
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("schoolDistrictId", schoolDistrictId);
             paramJson.addProperty("name", classroom.getName());
@@ -95,10 +92,19 @@ public class DataUtil {
             paramJson.addProperty("location", classroom.getLocation());
             paramJson.addProperty("extendId", classroom.getExtendId());
             paramJson.addProperty("floor", classroom.getFloor());
+
             //获取时间戳
             long timestamp = System.currentTimeMillis();
             //生成签名
             String sign = ScheduleUtil.createSign(timestamp);
+
+            if(ids != null && ids.get(classroom.getExtendId()) != null){
+                url  = ScheduleUtil.apiUrl + "classroom/update";
+                paramJson.addProperty("serialNo", ids.get(classroom.getExtendId()));
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                continue;
+            }
+
             String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
             if(result == null){
                 continue;
@@ -120,13 +126,11 @@ public class DataUtil {
                 " AND t1.student_id IS NOT NULL AND t1.student_id != ''" +
                 " AND t3.archives_status = 'FB2901'";
         List<StudentJianyuekbVo> dataList = db.query(sql, StudentJianyuekbVo.class);
-        String url  = ScheduleUtil.apiUrl + "student/create";
+
         JsonParser jsonParser = new JsonParser();
         Map<Long, String> idMap = new HashMap<>();
         for (StudentJianyuekbVo student : dataList) {
-            if(ids != null && ids.get(student.getExtendId()) != null){
-                continue;
-            }
+            String url  = ScheduleUtil.apiUrl + "student/create";
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("registerNo", student.getRegisterNo());
             if("SB10001".equals(student.getGender())){
@@ -143,6 +147,14 @@ public class DataUtil {
             long timestamp = System.currentTimeMillis();
             //生成签名
             String sign = ScheduleUtil.createSign(timestamp);
+
+            if(ids != null && ids.get(student.getExtendId()) != null){
+                paramJson.addProperty("serialNo", ids.get(student.getExtendId()));
+                url  = ScheduleUtil.apiUrl + "student/update";
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                continue;
+            }
+
             String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
             if(result == null){
                 continue;
@@ -166,14 +178,11 @@ public class DataUtil {
                 " inner join " + tableName + " t3 on t1.id = t3.user_id" +
                 " where t1.delete_mark = 0 and t2.role_id = 2";
         List<XjrUser> xjrUsers = db.query(sql, XjrUser.class);
-        String url  = ScheduleUtil.apiUrl + "teacher/create";
         JsonParser jsonParser = new JsonParser();
 
         Map<Long, String> idMap = new HashMap<>();
         for (XjrUser user : xjrUsers) {
-            if(ids != null && ids.get(user.getId()) != null){
-                continue;
-            }
+            String url  = ScheduleUtil.apiUrl + "teacher/create";
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("jobNumber", user.getUserName());
             if("SB10001".equals(user.getGender())){
@@ -189,6 +198,13 @@ public class DataUtil {
             long timestamp = System.currentTimeMillis();
             //生成签名
             String sign = ScheduleUtil.createSign(timestamp);
+            if(ids != null && ids.get(user.getId()) != null){
+                url  = ScheduleUtil.apiUrl + "teacher/update";
+                paramJson.addProperty("serialNo", ids.get(user.getId()));
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                continue;
+            }
+
             String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
             if(result == null){
                 continue;
@@ -206,13 +222,12 @@ public class DataUtil {
     public Map<Long, String> insertCourse(Db db, String tableName, Map<Long, String> ids, Map<Long, String> tagMap) throws Exception {
         String sql = "select * from " + tableName + " where delete_mark = 0";
         List<BaseCourseSubject> list = db.query(sql, BaseCourseSubject.class);
-        String url  = ScheduleUtil.apiUrl + "courseclass/Create";
+
         Map<Long, String> idMap = new HashMap<>();
         JsonParser jsonParser = new JsonParser();
         for (BaseCourseSubject courseSubject : list) {
-            if(ids != null && ids.get(courseSubject.getId()) != null){
-                continue;
-            }
+            String url  = ScheduleUtil.apiUrl + "courseclass/Create";
+
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("name", courseSubject.getName());
             paramJson.addProperty("code", courseSubject.getCode());
@@ -227,6 +242,14 @@ public class DataUtil {
             long timestamp = System.currentTimeMillis();
             //生成签名
             String sign = ScheduleUtil.createSign(timestamp);
+
+            if(ids != null && ids.get(courseSubject.getId()) != null){
+                url  = ScheduleUtil.apiUrl + "courseclass/update";
+                paramJson.addProperty("id", ids.get(courseSubject.getId()));
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                continue;
+            }
+
             String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
             if(result == null){
                 continue;
@@ -246,7 +269,7 @@ public class DataUtil {
     public Map<Long, String> insertSemester(Db db, String tableName, Map<Long, String> ids) throws Exception {
         String sql = "select * from " + tableName + " where delete_mark = 0";
         List<BaseSemester> list = db.query(sql, BaseSemester.class);
-        String url  = ScheduleUtil.apiUrl + "semester/Create";
+
         Map<Long, String> idMap = new HashMap<>();
         JsonParser jsonParser = new JsonParser();
         SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
@@ -255,9 +278,7 @@ public class DataUtil {
         String autumn = "秋";
 
         for (BaseSemester semester : list) {
-            if(ids != null && ids.get(semester.getId()) != null){
-                continue;
-            }
+            String url  = ScheduleUtil.apiUrl + "semester/Create";
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("schoolYear", Integer.parseInt(sdfYear.format(semester.getStartDate())));
             Integer period = null;
@@ -282,6 +303,12 @@ public class DataUtil {
             }else{
                 paramJson.addProperty("isCurrent", Boolean.FALSE);
             }
+            if(ids != null && ids.get(semester.getId()) != null){
+                url  = ScheduleUtil.apiUrl + "semester/update";
+                paramJson.addProperty("serialNo", ids.get(semester.getId()));
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                continue;
+            }
 
             String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
 
@@ -335,13 +362,11 @@ public class DataUtil {
     public Map<Long, String> insertGrade(Db db, String tableName, String schoolDistrictId, Map<Long, String> ids) throws Exception {
         String sql = "select * from " + tableName + " where delete_mark = 0 and status = 1";
         List<BaseGrade> list = db.query(sql, BaseGrade.class);
-        String url = ScheduleUtil.apiUrl + "eduyear/create";
+
         JsonParser jsonParser = new JsonParser();
         Map<Long, String> idMap = new HashMap<>();
         for (BaseGrade baseGrade : list) {
-            if(ids !=null && ids.get(baseGrade.getId()) != null){
-                continue;
-            }
+            String url = ScheduleUtil.apiUrl + "eduyear/create";
             JsonObject paramJson = new JsonObject();
             paramJson.addProperty("schoolDistrictId", schoolDistrictId);
             paramJson.addProperty("period", 4);
@@ -354,6 +379,13 @@ public class DataUtil {
             //生成签名
             String sign = ScheduleUtil.createSign(timestamp);
 
+            if(ids !=null && ids.get(baseGrade.getId()) != null){
+                paramJson.addProperty("serialNo", ids.get(baseGrade.getId()));
+                url = ScheduleUtil.apiUrl + "eduyear/update";
+                ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+                continue;
+            }
+
             String result = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
 
             JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();