Compare commits
3 Commits
main
...
cross-mout
Author | SHA1 | Date |
---|---|---|
root | 2b3da5a34e | |
Your Name | 943988061a | |
Your Name | fec5d416b0 |
|
@ -1,7 +1,7 @@
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
ENV TZ=Asia/Shanghai
|
ENV TZ=Asia/Shanghai
|
||||||
USER root
|
USER root
|
||||||
|
RUN apk --no-cache add tzdata
|
||||||
# 合并复制指令
|
# 合并复制指令
|
||||||
COPY udeskstate /usr/local/bin/
|
COPY udeskstate /usr/local/bin/
|
||||||
COPY ./email.json /conf/
|
COPY ./email.json /conf/
|
||||||
|
|
|
@ -9,10 +9,6 @@ import (
|
||||||
"time"
|
"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) {
|
func JsonDeal(file string, remindList []string, closeList []string) (r, c []string) {
|
||||||
emailJson, err := os.ReadFile(file)
|
emailJson, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -54,7 +50,11 @@ func GetSheetName(file string) (remindList, closeList []string, err error) {
|
||||||
//遍历所有工作表的A2格
|
//遍历所有工作表的A2格
|
||||||
sheets := f.GetSheetMap()
|
sheets := f.GetSheetMap()
|
||||||
var sheetName string
|
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单元格的值
|
//// 读取A2单元格的值
|
||||||
a2value, err := f.GetCellValue(s, "A2")
|
a2value, err := f.GetCellValue(s, "A2")
|
||||||
if err != nil {
|
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
|
sheetName = s
|
||||||
|
bSheet = sheets[key-1]
|
||||||
|
} else if a2value == M && key == 0 {
|
||||||
|
sheetName = s
|
||||||
|
bSheet = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rows, _ := f.GetRows(sheetName)
|
rows, _ := f.GetRows(sheetName)
|
||||||
for i, row := range rows {
|
for i, row := range rows {
|
||||||
log.Printf("按行读取excel中的值:索引:%v,行值:%v\n", i, row)
|
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)
|
nowRow := cleanSlice(row)
|
||||||
remindList = append(remindList, nowRow[2], nowRow[3])
|
remindList = append(remindList, nowRow[2], nowRow[3])
|
||||||
|
log.Println("第二分支判断提醒列表:", remindList)
|
||||||
} else if i == nowDay-1 {
|
closeList = append(closeList, cleanSlice(rows[nowDay-1])[3], cleanSlice(rows[nowDay-1])[4])
|
||||||
yesterdayRow := cleanSlice(row)
|
} else if i == nowDay && nowDay != 1 && nowDay != 2 {
|
||||||
closeList = append(closeList, yesterdayRow[2], yesterdayRow[3])
|
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
|
return remindList, closeList, nil
|
||||||
|
|
4
main.go
4
main.go
|
@ -32,6 +32,10 @@ func job() {
|
||||||
log.Println("应离线人员邮箱:", closeEmail)
|
log.Println("应离线人员邮箱:", closeEmail)
|
||||||
|
|
||||||
for _, rEmail := range closeEmail {
|
for _, rEmail := range closeEmail {
|
||||||
|
//2024.07.02 杨慧
|
||||||
|
if rEmail == "huiyang1@alauda.io" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
err = modifystate.PostToModifyState(rEmail, "offline")
|
err = modifystate.PostToModifyState(rEmail, "offline")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
BIN
standby.xlsx
BIN
standby.xlsx
Binary file not shown.
Loading…
Reference in New Issue