2024-07-21 02:13:35 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/jasonlvhit/gocron"
|
|
|
|
"log"
|
|
|
|
"udesk/exceldeal"
|
|
|
|
"udesk/udesk/modifystate"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
log.Printf("准备执行...")
|
|
|
|
// 定义任务
|
|
|
|
//gocron.Every(5).Second().Do(job)
|
|
|
|
gocron.Every(1).Day().At("09:30").Do(job)
|
|
|
|
//gocron.Every(1).Minutes().Do(job)
|
|
|
|
// 开始定时任务
|
|
|
|
<-gocron.Start()
|
|
|
|
}
|
|
|
|
|
|
|
|
// 定义执行的job
|
|
|
|
func job() {
|
|
|
|
fmt.Println("任务开始")
|
2024-07-21 09:17:50 +08:00
|
|
|
remindList, closeList, err := exceldeal.GetSheetName("/rota/standby.xlsx")
|
2024-07-21 02:13:35 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("打开值班表失败:%v", err)
|
|
|
|
}
|
|
|
|
log.Println("应在线人员名字:", remindList)
|
|
|
|
log.Println("应离线人员名字:", closeList)
|
2024-07-21 09:17:50 +08:00
|
|
|
remindEmail, closeEmail := exceldeal.JsonDeal("/conf/email.json", remindList, closeList)
|
2024-07-21 02:13:35 +08:00
|
|
|
log.Println("应在线人员邮箱:", remindEmail)
|
|
|
|
log.Println("应离线人员邮箱:", closeEmail)
|
|
|
|
|
|
|
|
for _, rEmail := range closeEmail {
|
2024-07-22 11:29:46 +08:00
|
|
|
//2024.07.02 杨慧
|
|
|
|
if rEmail == "huiyang1@alauda.io" {
|
|
|
|
continue
|
|
|
|
}
|
2024-07-21 02:13:35 +08:00
|
|
|
err = modifystate.PostToModifyState(rEmail, "offline")
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, rEmail := range remindEmail {
|
|
|
|
err = modifystate.PostToModifyState(rEmail, "idle")
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
message := fmt.Sprintf("今日小雀: %v,备班1: %v\n昨日小雀: %v,备班1: %v\nudesk呼叫状态已修改。", remindList[0], remindList[1], closeList[0], closeList[1])
|
|
|
|
exceldeal.Send(message)
|
|
|
|
fmt.Println("任务结束")
|
|
|
|
}
|