diff --git a/admin-core/pom.xml b/admin-core/pom.xml
index 5b245600..8f5a2712 100644
--- a/admin-core/pom.xml
+++ b/admin-core/pom.xml
@@ -166,9 +166,10 @@
org.slf4j
slf4j-api
-
+
+ cn.hutool
+ hutool-all
+ 5.7.22
+
-
-
-
diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/Day.java b/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/Day.java
new file mode 100644
index 00000000..efd5ed8f
--- /dev/null
+++ b/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/Day.java
@@ -0,0 +1,42 @@
+
+package com.ibeetl.admin.core.util.holidays;
+
+@SuppressWarnings("unused")
+public class Day {
+ /**
+ * 时间
+ */
+ private String date;
+ /**
+ * 是否休息日
+ */
+ private Boolean isOffDay;
+ /**
+ * 中文名称
+ */
+ private String name;
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(String date) {
+ this.date = date;
+ }
+
+ public Boolean getOffDay() {
+ return isOffDay;
+ }
+
+ public void setOffDay(Boolean offDay) {
+ isOffDay = offDay;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/Holidays.java b/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/Holidays.java
new file mode 100644
index 00000000..cb65e9e9
--- /dev/null
+++ b/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/Holidays.java
@@ -0,0 +1,53 @@
+
+package com.ibeetl.admin.core.util.holidays;
+
+import java.util.List;
+
+public class Holidays {
+
+ private String $id;
+ private String $schema;
+ private List days;
+ private List papers;
+ private Long year;
+
+ public String get$id() {
+ return $id;
+ }
+
+ public void set$id(String $id) {
+ this.$id = $id;
+ }
+
+ public String get$schema() {
+ return $schema;
+ }
+
+ public void set$schema(String $schema) {
+ this.$schema = $schema;
+ }
+
+ public List getDays() {
+ return days;
+ }
+
+ public void setDays(List days) {
+ this.days = days;
+ }
+
+ public List getPapers() {
+ return papers;
+ }
+
+ public void setPapers(List papers) {
+ this.papers = papers;
+ }
+
+ public Long getYear() {
+ return year;
+ }
+
+ public void setYear(Long year) {
+ this.year = year;
+ }
+}
diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/HolidaysUtils.java b/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/HolidaysUtils.java
new file mode 100644
index 00000000..b6dc1723
--- /dev/null
+++ b/admin-core/src/main/java/com/ibeetl/admin/core/util/holidays/HolidaysUtils.java
@@ -0,0 +1,56 @@
+package com.ibeetl.admin.core.util.holidays;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.logging.log4j.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ *
+ * 节假日查询工具
+ *
+ *
+ * @author mlx
+ * @date 2022/9/11
+ * @modified
+ */
+public abstract class HolidaysUtils {
+
+ private static final Logger log = LoggerFactory.getLogger(HolidaysUtils.class);
+
+ private volatile static Map cache = new ConcurrentHashMap<>();
+ /**
+ * 线路一
+ * https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/{年份}.json
+ */
+ private static final String githubHolidaysURL1 = "https://raw.githubusercontent.com/NateScarlet/holiday-cn/master/%s.json";
+
+ /**
+ * 线路二
+ * https://cdn.jsdelivr.net/gh/NateScarlet/holiday-cn@master/{年份}.json
+ */
+ private static final String githubHolidaysURL2 = "https://cdn.jsdelivr.net/gh/NateScarlet/holiday-cn@master/%s.json";
+
+ public static Holidays get() {
+ int year = DateUtil.thisYear();
+ if (cache.containsKey(year)) {
+ return cache.get(year);
+ }
+ String URL1 = String.format(githubHolidaysURL2, year);
+ String URL2 = String.format(githubHolidaysURL2, year);
+ String defaultResponseStr = HttpUtil.get(URL1);
+ String secondResponseStr = HttpUtil.get(URL2);
+ String responseStr = ObjectUtil.defaultIfBlank(defaultResponseStr, secondResponseStr);
+ Holidays holidays = JSONObject.parseObject(responseStr, Holidays.class);
+ log.info("正在从{} 获取节假日列表信息。", Strings.isNotBlank(defaultResponseStr) ? URL1 : URL2);
+ cache.put(year, holidays);
+ return holidays;
+ }
+
+}
diff --git a/http/TeacherOpenCourseScheduleSessionHttp.http b/http/TeacherOpenCourseScheduleSessionHttp.http
index 8c5ebe34..05776e3a 100644
--- a/http/TeacherOpenCourseScheduleSessionHttp.http
+++ b/http/TeacherOpenCourseScheduleSessionHttp.http
@@ -1,6 +1,6 @@
POST http://localhost:9090/server/jlw/teacherOpenCourseScheduleSession/addSession.json
Content-Type: application/json
-Cookie: JSESSIONID=F74A384F5C293F55D26E00CF608C358C
+Cookie: JSESSIONID=C6B69E52BCBD67B087124FF688F1A55D
{
"startTime": "2022-09-11 00:00:00",
diff --git a/web/pom.xml b/web/pom.xml
index cfbcdb4f..f4a142f1 100644
--- a/web/pom.xml
+++ b/web/pom.xml
@@ -231,12 +231,6 @@
-
- cn.hutool
- hutool-all
- 4.0.12
-
-
diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseScheduleSessionOptions.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseScheduleSessionOptions.java
index 5d2fe615..12d1a44c 100644
--- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseScheduleSessionOptions.java
+++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseScheduleSessionOptions.java
@@ -11,10 +11,10 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
-/*
-* 课程开课-新增排课页面的设置
-* gen by Spring Boot2 Admin 2022-09-10
-*/
+/*
+ * 课程开课-新增排课页面的设置
+ * gen by Spring Boot2 Admin 2022-09-10
+ */
@Data
@Accessors(chain = true)
public class TeacherOpenCourseScheduleSessionOptions {
@@ -36,8 +36,8 @@ public class TeacherOpenCourseScheduleSessionOptions {
/**
* 上课教室类型
*/
- @NotNull(message = "上课教室类型不能为空", groups =ValidateConfig.ADD.class)
- private ClassRoomType classRoomType;
+// @NotNull(message = "上课教室类型不能为空", groups =ValidateConfig.ADD.class)
+// private ClassRoomType classRoomType;
/**
* 开课节次List
*/
@@ -90,11 +90,14 @@ public class TeacherOpenCourseScheduleSessionOptions {
T6(7),
T7(1);
+ /**
+ * 星期转为数字
+ */
@Getter
- private Integer i;
+ private Integer weekNumber;
- WeekDetailType(int i) {
- this.i = i;
+ WeekDetailType(int weekNumber) {
+ this.weekNumber = weekNumber;
}
}
diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScheduleSessionService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScheduleSessionService.java
index 8453ffc7..81b480e5 100644
--- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScheduleSessionService.java
+++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseScheduleSessionService.java
@@ -11,6 +11,9 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
+import com.ibeetl.admin.core.util.holidays.Day;
+import com.ibeetl.admin.core.util.holidays.Holidays;
+import com.ibeetl.admin.core.util.holidays.HolidaysUtils;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.TeacherOpenCourseScheduleSessionDao;
@@ -25,11 +28,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
+import static cn.hutool.core.date.DatePattern.NORM_DATE_PATTERN;
+
/**
* 新增排课 Service
@@ -165,23 +169,28 @@ public class TeacherOpenCourseScheduleSessionService extends CoreBaseService dateTimes = DateUtil.rangeToList(options.getStartTime(), endTime, DateField.DAY_OF_YEAR);
+
// 断言,确保开课节次不为空
Assert.notEmpty(options.getSessionClassList(), "开课节次不能为空!");
- String[] lFtv = new String[]{
- "0101 春节", "0102 大年初二", "0103 大年初三", "0104 大年初四",
- "0105 大年初五", "0106 大年初六", "0107 大年初七",
- "0505 端午节", "1223 过小年", "1230 除夕"};
-
// 节假日处理
if (!options.getOpenOnHolidays()) {
- dateTimes = dateTimes.stream().filter(dt -> !Arrays.stream(lFtv).anyMatch(e -> e.split(" ")[0].equals(DateUtil.format(dt, "MMdd"))))
+
+ // 获取github上的节假日列表
+ Holidays holidays = HolidaysUtils.get();
+ Assert.notNull(holidays, "获取节假日列表失败!");
+
+ // 获取节假日列表,只获取节假日中的休息日,非休息日则是需要补班的日期。
+ List collect = holidays.getDays().stream().filter(Day::getOffDay).map(Day::getDate).collect(Collectors.toList());
+ dateTimes = dateTimes.stream().filter(dt -> !collect.stream().anyMatch(e -> e.equals(DateUtil.format(dt, NORM_DATE_PATTERN))))
.collect(Collectors.toList());
}
// 开课星期处理
if (ObjectUtil.isNotEmpty(options.getWeekDetail())) {
- dateTimes = dateTimes.stream().filter(dt -> options.getWeekDetail().stream().anyMatch(e -> e.getI().equals(DateUtil.dayOfWeek(dt))))
+
+ // 指定星期的日期时间
+ dateTimes = dateTimes.stream().filter(dt -> options.getWeekDetail().stream().anyMatch(e -> e.getWeekNumber().equals(DateUtil.dayOfWeek(dt))))
.collect(Collectors.toList());
}
diff --git a/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/index.js b/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/index.js
index c8a61a36..cbb657bc 100644
--- a/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/index.js
+++ b/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/index.js
@@ -83,20 +83,20 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) {
hideField :false,
hide:$.isEmpty(sx_['schoolClassIds'])?false:sx_['schoolClassIds'],
},
- {
- field : 'orgId',
- title : '组织ID',
- align:"center",
- hideField :false,
- hide:$.isEmpty(sx_['orgId'])?false:sx_['orgId'],
- },
- {
- field : 'userId',
- title : '用户ID',
- align:"center",
- hideField :false,
- hide:$.isEmpty(sx_['userId'])?false:sx_['userId'],
- },
+ // {
+ // field : 'orgId',
+ // title : '组织ID',
+ // align:"center",
+ // hideField :false,
+ // hide:$.isEmpty(sx_['orgId'])?false:sx_['orgId'],
+ // },
+ // {
+ // field : 'userId',
+ // title : '用户ID',
+ // align:"center",
+ // hideField :false,
+ // hide:$.isEmpty(sx_['userId'])?false:sx_['userId'],
+ // },
{
field : 'teacherOpenCourseScheduleSessionTagName',
title : '课次名称',
diff --git a/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/teacherOpenCourseScheduleSessionApi.js b/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/teacherOpenCourseScheduleSessionApi.js
index 15e71d6a..9c386f80 100644
--- a/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/teacherOpenCourseScheduleSessionApi.js
+++ b/web/src/main/resources/static/js/jlw/teacherOpenCourseScheduleSession/teacherOpenCourseScheduleSessionApi.js
@@ -5,7 +5,8 @@ layui.define([], function(exports) {
Lib.submitForm("/jlw/teacherOpenCourseScheduleSession/edit.json",form,{},callback)
},
addTeacherOpenCourseScheduleSession:function(form,callback){
- Lib.submitForm("/jlw/teacherOpenCourseScheduleSession/add.json",form,{},callback)
+ // Lib.submitForm("/jlw/teacherOpenCourseScheduleSession/add.json",form,{},callback)
+ Lib.submitForm("/jlw/teacherOpenCourseScheduleSession/addSession.json",form,{},callback)
},
del:function(ids,callback){
Common.post("/jlw/teacherOpenCourseScheduleSession/delete.json",{"ids":ids},function(){