entrydate2

This commit is contained in:
jiangyong27 2024-09-21 18:46:51 +08:00
parent 29c02b6064
commit f5a3da2053
3 changed files with 40 additions and 2 deletions

View File

@ -4,8 +4,8 @@ address = "0.0.0.0:9283"
log_level = 6
[mysql]
host = "14.22.116.197"
port = 9305
host = "192.168.2.50"
port = 13308
user = "root"
pass = "ZW5aaGVuMIIBIj"
db = "enterprise"

View File

@ -18,6 +18,41 @@ import (
type Staff struct {
}
func (s *Staff) MontorWorkAge() {
staffs, err := dao.NewStaffInfoDao().Query(model.StaffInfoStatusNormal)
if err != nil {
log.Errorf("db error :%s", err.Error())
return
}
nowDate := time.Now()
for _, staff := range staffs {
//离职的忽略
if staff.LeaveDate != "" {
continue
}
entryDate, _ := time.ParseInLocation("2006-01-02", staff.EntryDate, time.Local)
spanMonth := (nowDate.Year()-entryDate.Year())*12 + int(nowDate.Month()) - int(entryDate.Month())
log.Infof("staff[%s] entryDate[%s] spanMonth[%.1f]", staff.Username, staff.EntryDate, float64(spanMonth)/12.0)
if nowDate.Day() != entryDate.Day() || spanMonth%6 != 0 {
continue
}
message := make([]string, 0)
message = append(message, fmt.Sprintf("【员工半年提醒】[%s]", staff.Realname))
message = append(message, fmt.Sprintf("入职时间:%s", staff.EntryDate))
message = append(message, fmt.Sprintf("入职年限:%.1f", float64(spanMonth)/12))
message = append(message, fmt.Sprintf("基本工资:%s", staff.Salary))
message = append(message, fmt.Sprintf("身份证号:%s", staff.Idno))
if err := global.SendMessage([]string{"jiangyong"}, strings.Join(message, "\n")); err != nil {
log.Errorf("send message error :%s", err.Error())
}
}
}
func (s *Staff) SendStaffSalaryBill(month string) {
staffSalarys, err := dao.NewStaffSalaryDao().Query(month)
if err != nil {

View File

@ -17,6 +17,9 @@ func Init() error {
cron.Every(1).Day().At("01:00").Do(func() {
go staff.SyncStaffInfo()
})
cron.Every(1).Day().At("09:00").Do(func() {
go staff.MontorWorkAge()
})
//同步每日考勤数据
cron.Every(1).Day().At("05:00").Do(func() {