Compare commits

...

3 Commits

Author SHA1 Message Date
root 2b3da5a34e 更新 Dockerfile 2024-07-26 19:14:26 +08:00
Your Name 943988061a yanghui append 2024-07-26 17:36:14 +08:00
Your Name fec5d416b0 跨月支持 2024-07-26 17:22:20 +08:00
4 changed files with 37 additions and 12 deletions

View File

@ -1,7 +1,7 @@
FROM alpine:latest
ENV TZ=Asia/Shanghai
USER root
RUN apk --no-cache add tzdata
# 合并复制指令
COPY udeskstate /usr/local/bin/
COPY ./email.json /conf/

View File

@ -9,10 +9,6 @@ import (
"time"
)
var nowMouth = time.Now().Month().String()
var nowDay = time.Now().Day()
var M = dateToChinese(nowMouth)
func JsonDeal(file string, remindList []string, closeList []string) (r, c []string) {
emailJson, err := os.ReadFile(file)
if err != nil {
@ -54,7 +50,11 @@ func GetSheetName(file string) (remindList, closeList []string, err error) {
//遍历所有工作表的A2格
sheets := f.GetSheetMap()
var sheetName string
for _, s := range sheets {
var bSheet string //上月sheet
var nowMouth = time.Now().Month().String()
var nowDay = time.Now().Day()
var M = dateToChinese(nowMouth)
for key, s := range sheets {
//// 读取A2单元格的值
a2value, err := f.GetCellValue(s, "A2")
if err != nil {
@ -63,21 +63,42 @@ func GetSheetName(file string) (remindList, closeList []string, err error) {
}
//检查月份是否与当前月份相等
//如果与当前时间的月份相等则记录工作表名称
if a2value == M {
if a2value == M && key != 0 {
sheetName = s
bSheet = sheets[key-1]
} else if a2value == M && key == 0 {
sheetName = s
bSheet = ""
}
}
rows, _ := f.GetRows(sheetName)
for i, row := range rows {
log.Printf("按行读取excel中的值:索引:%v,行值:%v\n", i, row)
if i == nowDay {
if i == nowDay && nowDay == 1 {
nowRow := cleanSlice(row)
remindList = append(remindList, nowRow[3], nowRow[4])
log.Println("第一分支判断提醒列表:", remindList)
if len(bSheet) != 0 {
brows, _ := f.GetRows(bSheet)
bMRow := brows[len(brows)-1] //上月最后一天
closeList = append(closeList, cleanSlice(bMRow)[2], cleanSlice(bMRow)[3])
} else if len(bSheet) == 0 {
log.Println("没有上个月的excel或者上个月excel的未按顺序排列")
closeList = append(closeList, "", "")
}
} else if i == nowDay && nowDay == 2 {
nowRow := cleanSlice(row)
remindList = append(remindList, nowRow[2], nowRow[3])
} else if i == nowDay-1 {
yesterdayRow := cleanSlice(row)
closeList = append(closeList, yesterdayRow[2], yesterdayRow[3])
log.Println("第二分支判断提醒列表:", remindList)
closeList = append(closeList, cleanSlice(rows[nowDay-1])[3], cleanSlice(rows[nowDay-1])[4])
} else if i == nowDay && nowDay != 1 && nowDay != 2 {
nowRow := cleanSlice(row)
remindList = append(remindList, nowRow[2], nowRow[3])
log.Println("第三分支判断提醒列表:", remindList)
closeList = append(closeList, cleanSlice(rows[nowDay-1])[2], cleanSlice(rows[nowDay-1])[3])
}
}
return remindList, closeList, nil

View File

@ -32,6 +32,10 @@ func job() {
log.Println("应离线人员邮箱:", closeEmail)
for _, rEmail := range closeEmail {
//2024.07.02 杨慧
if rEmail == "huiyang1@alauda.io" {
continue
}
err = modifystate.PostToModifyState(rEmail, "offline")
if err != nil {
return

Binary file not shown.