改进排班的算法:现在可以每周轮换一次片区,而且现在将结构体给模板

This commit is contained in:
2025-04-27 16:01:42 +08:00
parent 1d76fa2ab3
commit 43d0a1ebe0
3 changed files with 78 additions and 45 deletions

14
handler/utils.go Normal file
View File

@@ -0,0 +1,14 @@
package handler
import (
"github.com/golang-module/carbon/v2"
"zsxyww.com/scheduler/config"
)
// 输入一个时间,返回时间是第几周的第几天
func getWorkDay(in carbon.Carbon) (weekOffset int, dayOffset int) {
time := carbon.Parse(config.StartTime)
_weekOffset := time.DiffInWeeks(in)
_dayOffset := in.DayOfWeek()
return int(_weekOffset), _dayOffset
}