|
@@ -1,6 +1,8 @@
|
|
package com.xjrsoft.module.schedule.util;
|
|
package com.xjrsoft.module.schedule.util;
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import cn.hutool.db.Entity;
|
|
import com.google.gson.JsonArray;
|
|
import com.google.gson.JsonArray;
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
@@ -19,10 +21,13 @@ import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author dzx
|
|
* @author dzx
|
|
@@ -85,13 +90,17 @@ public class DataUtil {
|
|
BaseClass baseClass = SqlRunnerAdapterUtil.convertMapToEntity(baseClassMap, BaseClass.class);
|
|
BaseClass baseClass = SqlRunnerAdapterUtil.convertMapToEntity(baseClassMap, BaseClass.class);
|
|
String url = ScheduleUtil.apiUrl + "class/create";
|
|
String url = ScheduleUtil.apiUrl + "class/create";
|
|
JsonObject paramJson = new JsonObject();
|
|
JsonObject paramJson = new JsonObject();
|
|
- paramJson.addProperty("teacherSerialNo", teacherMap.get(baseClass.getTeacherId().toString()));
|
|
|
|
|
|
+ if(baseClass.getTeacherId() != null && teacherMap.get(baseClass.getTeacherId().toString()) != null){
|
|
|
|
+ paramJson.addProperty("teacherSerialNo", teacherMap.get(baseClass.getTeacherId().toString()));
|
|
|
|
+ }
|
|
paramJson.addProperty("name", baseClass.getName());
|
|
paramJson.addProperty("name", baseClass.getName());
|
|
|
|
|
|
paramJson.addProperty("semesterSerialNo", semesterSerialNo);
|
|
paramJson.addProperty("semesterSerialNo", semesterSerialNo);
|
|
paramJson.addProperty("eduYearSerialNo", gradeMap.get(baseClass.getOrgId() + "_" + baseClass.getGradeId().toString()));
|
|
paramJson.addProperty("eduYearSerialNo", gradeMap.get(baseClass.getOrgId() + "_" + baseClass.getGradeId().toString()));
|
|
paramJson.addProperty("extendId", baseClass.getId());
|
|
paramJson.addProperty("extendId", baseClass.getId());
|
|
- paramJson.addProperty("classRoomSerialNo", classroomMap.get(baseClass.getClassroomId().toString()));
|
|
|
|
|
|
+ if(baseClass.getClassroomId() != null && classroomMap.get(baseClass.getClassroomId().toString()) != null){
|
|
|
|
+ paramJson.addProperty("classRoomSerialNo", classroomMap.get(baseClass.getClassroomId().toString()));
|
|
|
|
+ }
|
|
if(ids != null && ids.get(baseClass.getId().toString()) != null){
|
|
if(ids != null && ids.get(baseClass.getId().toString()) != null){
|
|
url = ScheduleUtil.apiUrl + "class/update";
|
|
url = ScheduleUtil.apiUrl + "class/update";
|
|
paramJson.addProperty("serialNo", ids.get(baseClass.getId().toString()));
|
|
paramJson.addProperty("serialNo", ids.get(baseClass.getId().toString()));
|
|
@@ -224,27 +233,26 @@ public class DataUtil {
|
|
JsonParser jsonParser = new JsonParser();
|
|
JsonParser jsonParser = new JsonParser();
|
|
|
|
|
|
Map<String, String> idMap = new HashMap<>();
|
|
Map<String, String> idMap = new HashMap<>();
|
|
- for (Map<String, Object> userMap : xjrUsers) {
|
|
|
|
- XjrUser user = SqlRunnerAdapterUtil.convertMapToEntity(userMap, XjrUser.class);
|
|
|
|
|
|
+ for (Map<String, Object> user : xjrUsers) {
|
|
String url = ScheduleUtil.apiUrl + "teacher/create";
|
|
String url = ScheduleUtil.apiUrl + "teacher/create";
|
|
JsonObject paramJson = new JsonObject();
|
|
JsonObject paramJson = new JsonObject();
|
|
- paramJson.addProperty("jobNumber", user.getUserName());
|
|
|
|
- if("SB10001".equals(user.getGender())){
|
|
|
|
|
|
+ paramJson.addProperty("jobNumber", user.get("user_name").toString());
|
|
|
|
+ if("SB10001".equals(user.get("gender").toString())){
|
|
paramJson.addProperty("gender", 1);
|
|
paramJson.addProperty("gender", 1);
|
|
- }else if("SB10002".equals(user.getGender())){
|
|
|
|
|
|
+ }else if("SB10002".equals(user.get("gender").toString())){
|
|
paramJson.addProperty("gender", 2);
|
|
paramJson.addProperty("gender", 2);
|
|
}
|
|
}
|
|
|
|
|
|
- paramJson.addProperty("name", user.getName());
|
|
|
|
- paramJson.addProperty("alias", user.getNickName());
|
|
|
|
- paramJson.addProperty("extendId", user.getId().toString());
|
|
|
|
|
|
+ paramJson.addProperty("name", user.get("name").toString());
|
|
|
|
+ paramJson.addProperty("alias", user.get("nick_name").toString());
|
|
|
|
+ paramJson.addProperty("extendId", user.get("id").toString());
|
|
//获取时间戳
|
|
//获取时间戳
|
|
long timestamp = System.currentTimeMillis();
|
|
long timestamp = System.currentTimeMillis();
|
|
//生成签名
|
|
//生成签名
|
|
String sign = ScheduleUtil.createSign(timestamp);
|
|
String sign = ScheduleUtil.createSign(timestamp);
|
|
- if(ids != null && ids.get(user.getId().toString()) != null){
|
|
|
|
|
|
+ if(ids != null && ids.get(user.get("id").toString()) != null){
|
|
url = ScheduleUtil.apiUrl + "teacher/update";
|
|
url = ScheduleUtil.apiUrl + "teacher/update";
|
|
- paramJson.addProperty("serialNo", ids.get(user.getId().toString()));
|
|
|
|
|
|
+ paramJson.addProperty("serialNo", ids.get(user.get("id").toString()));
|
|
ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
|
|
ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -254,7 +262,7 @@ public class DataUtil {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
|
|
JsonObject resultJson = jsonParser.parse(result).getAsJsonObject();
|
|
- idMap.put(user.getId().toString(), resultJson.get("data").getAsString());
|
|
|
|
|
|
+ idMap.put(user.get("id").toString(), resultJson.get("data").getAsString());
|
|
}
|
|
}
|
|
//插入记录表
|
|
//插入记录表
|
|
insertRecord(tableName, idMap);
|
|
insertRecord(tableName, idMap);
|
|
@@ -608,6 +616,66 @@ public class DataUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void insertCourseTableEntiy(JsonArray data, Map<String, String> classroomMap, Map<String, String> coureseMap,
|
|
|
|
+ Map<String, String> semesterMap, Map<String, String> teacherMap, Map<String, String> classMap) {
|
|
|
|
+ Map<Integer, Integer> tmePeriod = ScheduleUtil.getTmePeriod();
|
|
|
|
+ String tableName = "course_table";
|
|
|
|
+ List<Entity> entityList = new ArrayList();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
|
|
|
+ List<Map<String, Object>> list = SqlRunnerAdapter.db().selectList("select * from course_table");
|
|
|
|
+ Set<String> serialNos = new HashSet<>();
|
|
|
|
+ for (Map<String, Object> objectMap : list) {
|
|
|
|
+ if(objectMap.get("jianyue_id") == null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ serialNos.add(objectMap.get("jianyue_id").toString());
|
|
|
|
+ }
|
|
|
|
+ for (JsonElement jsonElement : data) {
|
|
|
|
+ JsonObject asJsonObject = jsonElement.getAsJsonObject();
|
|
|
|
+ JsonArray teachers = asJsonObject.get("teachers").getAsJsonArray();
|
|
|
|
+ if(asJsonObject.get("courseClassId").isJsonNull() || coureseMap.get(asJsonObject.get("courseClassId").getAsString()) == null){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(serialNos.contains(asJsonObject.get("id").getAsString())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ int timeNumber = asJsonObject.get("numberOfDay").getAsInt();//节次
|
|
|
|
+
|
|
|
|
+ Entity entity = Entity.create(tableName);
|
|
|
|
+ entity.set("id", IdUtil.getSnowflakeNextId());
|
|
|
|
+ entity.set("base_semester_id", semesterMap.get(asJsonObject.get("semesterSerialNo").getAsString()));
|
|
|
|
+
|
|
|
|
+ if(teachers.size() > 0){
|
|
|
|
+ JsonObject teacherJson = teachers.get(0).getAsJsonObject();
|
|
|
|
+ entity.set("teacher_id", (teacherMap.get(teacherJson.get("teacherSerialNo").getAsString())==null?0:teacherMap.get(teacherJson.get("teacherSerialNo").getAsString())));
|
|
|
|
+ entity.set("teacher_name", teacherJson.get("name").getAsString());
|
|
|
|
+ entity.set("teacher_serial_no", teacherJson.get("teacherSerialNo").getAsString());
|
|
|
|
+ }else{
|
|
|
|
+ entity.set("teacher_id", 0);
|
|
|
|
+// entity.set("teacher_name", "");
|
|
|
|
+// entity.set("teacher_serial_no", "");
|
|
|
|
+ }
|
|
|
|
+ entity.set("course_id", coureseMap.get(asJsonObject.get("courseClassId").getAsString()));
|
|
|
|
+ entity.set("course_name", asJsonObject.get("courseClassName").getAsString());
|
|
|
|
+ entity.set("class_id", classMap.get(asJsonObject.get("classSerialNo").getAsString()));
|
|
|
|
+ entity.set("class_name", asJsonObject.get("className").getAsString());
|
|
|
|
+ entity.set("weeks", asJsonObject.get("dayOfWeek").getAsInt());
|
|
|
|
+ entity.set("weeks_cn", asJsonObject.get("dayOfWeekName").getAsString());
|
|
|
|
+ entity.set("time_period", tmePeriod.get(asJsonObject.get("timeOption").getAsInt()));
|
|
|
|
+ entity.set("time_number", timeNumber);
|
|
|
|
+ entity.set("site_id", (classroomMap.get(asJsonObject.get("classRoomSerialNo").getAsString()) == null ? 0 : classroomMap.get(asJsonObject.get("classRoomSerialNo").getAsString())));
|
|
|
|
+ entity.set("site_name", asJsonObject.get("classRoomName").getAsString());
|
|
|
|
+ entity.set("status", 1);
|
|
|
|
+ entity.set("create_date", sdf.format(new Date()));
|
|
|
|
+ entity.set("schedule_date", asJsonObject.get("scheduleDate").getAsString());
|
|
|
|
+ entity.set("jianyue_id", asJsonObject.get("id").getAsString());
|
|
|
|
+ entityList.add(entity);
|
|
|
|
+ }
|
|
|
|
+ if(!entityList.isEmpty()){
|
|
|
|
+ SqlRunnerAdapter.db().dynamicInsertBatch(tableName, entityList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 提取课时相关信息
|
|
* 提取课时相关信息
|
|
* @param data 数据
|
|
* @param data 数据
|
|
@@ -627,26 +695,25 @@ public class DataUtil {
|
|
json.add("numberOfDay", asJsonObject.get("numberOfDay"));
|
|
json.add("numberOfDay", asJsonObject.get("numberOfDay"));
|
|
infoMap.put(numberOfDayName, json);
|
|
infoMap.put(numberOfDayName, json);
|
|
}
|
|
}
|
|
-// List<String> sqls = new ArrayList<>();
|
|
|
|
int count = 1;
|
|
int count = 1;
|
|
for (String number : infoMap.keySet()) {
|
|
for (String number : infoMap.keySet()) {
|
|
- String substring1 = number.substring(number.length() - 1);
|
|
|
|
JsonObject jsonObject = infoMap.get(number);
|
|
JsonObject jsonObject = infoMap.get(number);
|
|
|
|
+ int timeNumber = jsonObject.get("numberOfDay").getAsInt();//节次
|
|
long id = System.currentTimeMillis();
|
|
long id = System.currentTimeMillis();
|
|
- String fullName = "第" +substring1 + "节课";
|
|
|
|
|
|
+
|
|
String sql = "INSERT INTO class_time(id,time_period,number,full_name,short_name,create_date,summer_start_time"
|
|
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) + ","
|
|
+ ",summer_end_time,winter_start_time,winter_end_time) select " + id + String.format("%04d", count) + ","
|
|
+ jsonObject.get("tmePeriod").getAsInt() + ","
|
|
+ jsonObject.get("tmePeriod").getAsInt() + ","
|
|
- + substring1 + ","
|
|
|
|
- + "'" + fullName + "',"
|
|
|
|
- + "'" + fullName + "',now(),"
|
|
|
|
|
|
+ + timeNumber + ","
|
|
|
|
+ + "'" + number + "',"
|
|
|
|
+ + "'" + number + "',now(),"
|
|
+ "'" + jsonObject.get("startTime").getAsString() + "',"
|
|
+ "'" + jsonObject.get("startTime").getAsString() + "',"
|
|
+ "'" + jsonObject.get("endTime").getAsString() + "',"
|
|
+ "'" + jsonObject.get("endTime").getAsString() + "',"
|
|
+ "'" + jsonObject.get("startTime").getAsString() + "',"
|
|
+ "'" + jsonObject.get("startTime").getAsString() + "',"
|
|
+ "'" + jsonObject.get("endTime").getAsString() + "' FROM DUAL"
|
|
+ "'" + jsonObject.get("endTime").getAsString() + "' FROM DUAL"
|
|
+ " WHERE NOT EXISTS(SELECT * FROM class_time WHERE time_period = "
|
|
+ " WHERE NOT EXISTS(SELECT * FROM class_time WHERE time_period = "
|
|
+ jsonObject.get("tmePeriod").getAsInt()
|
|
+ jsonObject.get("tmePeriod").getAsInt()
|
|
- + " and number = " + substring1 + ")";
|
|
|
|
|
|
+ + " and number = " + timeNumber + ")";
|
|
// sqls.add(sql);
|
|
// sqls.add(sql);
|
|
SqlRunnerAdapter.db().insert(sql);
|
|
SqlRunnerAdapter.db().insert(sql);
|
|
count ++;
|
|
count ++;
|