考勤异常
This commit is contained in:
parent
7d17120f12
commit
45b5c1d499
|
@ -65,10 +65,15 @@ func (d *ApprovalVacationDao) GetBySpNo(spNo string) (*model.ApprovalVacation, e
|
||||||
return &u, nil
|
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
|
var u []*model.ApprovalVacation
|
||||||
tx := GetDB().Table(d.TableName())
|
tx := GetDB().Table(d.TableName())
|
||||||
|
if month != "" {
|
||||||
tx = tx.Where("month = ?", month)
|
tx = tx.Where("month = ?", month)
|
||||||
|
}
|
||||||
|
if day != "" {
|
||||||
|
tx = tx.Where("vacation_date = ?", day)
|
||||||
|
}
|
||||||
tx = tx.Where("username = ?", username)
|
tx = tx.Where("username = ?", username)
|
||||||
res := tx.Find(&u)
|
res := tx.Find(&u)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
|
|
|
@ -89,13 +89,21 @@ func (c *Checkin) MonitorCheckinDay(day string) {
|
||||||
if checkin.Exception == "" {
|
if checkin.Exception == "" {
|
||||||
continue
|
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 := make([]string, 0)
|
||||||
message = append(message, fmt.Sprintf("【考勤异常】%s", checkin.Username))
|
message = append(message, fmt.Sprintf("【考勤异常】%s", checkin.Username))
|
||||||
message = append(message, fmt.Sprintf("考勤日期:%s", checkin.Day))
|
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.StartTime)))
|
||||||
message = append(message, fmt.Sprintf("下班时间:%s", goutil.TimeToDateTime(checkin.EndTime)))
|
message = append(message, fmt.Sprintf("下班时间:%s", goutil.TimeToDateTime(checkin.EndTime)))
|
||||||
message = append(message, fmt.Sprintf("异常原因:%s", checkin.Exception))
|
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"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
if err != nil {
|
||||||
log.Errorf("db error :%s", err.Error())
|
log.Errorf("db error :%s", err.Error())
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue