考勤异常

This commit is contained in:
jiangyong27 2024-04-25 12:23:19 +08:00
parent 7d17120f12
commit 45b5c1d499
3 changed files with 17 additions and 4 deletions

View File

@ -65,10 +65,15 @@ func (d *ApprovalVacationDao) GetBySpNo(spNo string) (*model.ApprovalVacation, e
return &u, nil
}
func (d *ApprovalVacationDao) GetByUsername(username, month string) ([]*model.ApprovalVacation, error) {
func (d *ApprovalVacationDao) GetByUsername(username, month, day string) ([]*model.ApprovalVacation, error) {
var u []*model.ApprovalVacation
tx := GetDB().Table(d.TableName())
if month != "" {
tx = tx.Where("month = ?", month)
}
if day != "" {
tx = tx.Where("vacation_date = ?", day)
}
tx = tx.Where("username = ?", username)
res := tx.Find(&u)
if res.Error != nil {

View File

@ -89,13 +89,21 @@ func (c *Checkin) MonitorCheckinDay(day string) {
if checkin.Exception == "" {
continue
}
approvals, err := dao.NewApprovalVacationDao().GetByUsername(checkin.Username, "", checkin.Day)
if err != nil {
log.Errorf("db error :%s", err.Error())
continue
}
if len(approvals) > 0 {
continue
}
message := make([]string, 0)
message = append(message, fmt.Sprintf("【考勤异常】%s", checkin.Username))
message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day))
message = append(message, fmt.Sprintf("上班时间:%s", goutil.TimeToDateTime(checkin.StartTime)))
message = append(message, fmt.Sprintf("下班时间:%s", goutil.TimeToDateTime(checkin.EndTime)))
message = append(message, fmt.Sprintf("异常原因:%s", checkin.Exception))
global.SendMessage([]string{"jiangyong"}, strings.Join(message, "\n"))
global.SendMessage([]string{"jiangyong", checkin.Username}, strings.Join(message, "\n"))
}
}

View File

@ -160,7 +160,7 @@ func (s *Staff) SyncStaffSalary(month string) {
}
// 休假申请
approveVacations, err := dao.NewApprovalVacationDao().GetByUsername(staff.Username, month)
approveVacations, err := dao.NewApprovalVacationDao().GetByUsername(staff.Username, month, "")
if err != nil {
log.Errorf("db error :%s", err.Error())
continue