|
@@ -46,16 +46,15 @@ class JianyuekbScheduleTaskTest {
|
|
|
private IBaseClassService classService;
|
|
|
@Test
|
|
|
public void RefreshConnectionPool() throws Exception {
|
|
|
- String active = SpringUtil.getActiveProfile();
|
|
|
String sql = "SELECT * FROM course_receive_msg WHERE delete_mark = 0 AND is_callback = -1";
|
|
|
- List<Map<String, Object>> receiveMsgs = SqlRunnerAdapter.db().selectList(sql, CourseReceiveMsg.class);
|
|
|
+ List<Map<String, Object>> receiveMsgs = SqlRunnerAdapter.db().selectList(sql);
|
|
|
if(receiveMsgs.isEmpty()){
|
|
|
return;
|
|
|
}
|
|
|
JsonArray allScheduleInfo = new JsonArray();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
DataUtil dataUtil = new DataUtil();
|
|
|
-
|
|
|
+ //查询出传入排课系统的年级和班级
|
|
|
List<String> eduYearSerialNo1 = receiveMsgs.stream().map(x -> "'" + x.get("edu_year_serial_no").toString() + "'").collect(Collectors.toList());
|
|
|
|
|
|
//查询出传入排课系统的年级和班级
|
|
@@ -65,8 +64,13 @@ class JianyuekbScheduleTaskTest {
|
|
|
List<Map<String, Object>> jianyueData = SqlRunnerAdapter.db().selectList(sql);
|
|
|
Map<String, List<Long>> gradeClassMaps = new HashMap<>();//存入对应年级的所有班级id
|
|
|
for (Map<String, Object> el : jianyueData) {
|
|
|
- String orgId = el.get("source_id").toString().split("_")[0];
|
|
|
- String gradeId = el.get("source_id").toString().split("_")[1];
|
|
|
+ String gradeId = el.get("source_id").toString();
|
|
|
+ String orgId = null;
|
|
|
+ if(gradeId.contains("_")){
|
|
|
+ String[] split = el.get("source_id").toString().split("_");
|
|
|
+ gradeId = split[1];
|
|
|
+ orgId = split[0];
|
|
|
+ }
|
|
|
List<BaseClass> classList = classService.list(
|
|
|
new QueryWrapper<BaseClass>().lambda()
|
|
|
.eq(BaseClass::getGradeId, gradeId)
|
|
@@ -76,23 +80,26 @@ class JianyuekbScheduleTaskTest {
|
|
|
|
|
|
gradeClassMaps.put(el.get("jianyue_id").toString(), classIds);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
for (Map<String, Object> receiveMsg : receiveMsgs) {
|
|
|
String updSql = "update course_receive_msg set is_callback = 0 where id = " + receiveMsg.get("id").toString();
|
|
|
SqlRunnerAdapter.db().update(updSql);
|
|
|
|
|
|
String eduYearSerialNo = receiveMsg.get("edu_year_serial_no").toString();
|
|
|
String startDateStr = receiveMsg.get("start_date").toString();
|
|
|
+ LocalDate startDateObj = LocalDate.parse(startDateStr);
|
|
|
String endDateStr = receiveMsg.get("end_date").toString();
|
|
|
- //删除课表信息
|
|
|
+ LocalDate endDateObj = LocalDate.parse(endDateStr);
|
|
|
+ if(today.isAfter(startDateObj)){
|
|
|
+ startDateStr = today.format(formatter);
|
|
|
+ }
|
|
|
+ //删除课表信息;
|
|
|
+ String classIds = gradeClassMaps.get(eduYearSerialNo).toString().replace("[", "").replace("]", "");
|
|
|
String delSql = "delete from course_table where schedule_date between '" + startDateStr + "'" +
|
|
|
- " and '" + endDateStr + "'" +
|
|
|
- " and class_id in (" + gradeClassMaps.get(eduYearSerialNo).toString().replace("[","").replace("]","")+ ")";
|
|
|
+ " and '" + endDateStr +
|
|
|
+ "' and class_id in (" + classIds + ")";
|
|
|
SqlRunnerAdapter.db().delete(delSql);
|
|
|
|
|
|
- LocalDate startDateObj = LocalDate.parse(startDateStr);
|
|
|
- LocalDate endDateObj = LocalDate.parse(endDateStr);
|
|
|
long between = ChronoUnit.DAYS.between(startDateObj, endDateObj);
|
|
|
int times = Integer.parseInt(((between / 7) + 1) + "");
|
|
|
|
|
@@ -112,6 +119,10 @@ class JianyuekbScheduleTaskTest {
|
|
|
|
|
|
updSql = "update course_receive_msg set is_callback = 1 where id = " + receiveMsg.get("id").toString();
|
|
|
SqlRunnerAdapter.db().update(updSql);
|
|
|
+ //作废调课和顶课
|
|
|
+ updSql = "UPDATE wf_course_adjust SET enabled_mark = 0 WHERE adjust_type BETWEEN '" + startDateStr + "'" +
|
|
|
+ " and '" + endDateStr + "' and class_id in (" + classIds + ")";
|
|
|
+ SqlRunnerAdapter.db().update(updSql);
|
|
|
}
|
|
|
doExecute(allScheduleInfo);
|
|
|
}
|