| | |
| | | "silkserver/models" |
| | | "silkserver/pkg/logx" |
| | | "silkserver/pkg/timex" |
| | | "strings" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "参数不能为空") |
| | | return |
| | | } |
| | | //获取月份天数 |
| | | location, err := time.ParseInLocation("2006-01", "2024-04", time.Local) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "月份格式错误") |
| | | return |
| | | } |
| | | year, month, _ := location.Date() |
| | | date := timex.GetDate(year, month) |
| | | var details []response.AttendanceDetail |
| | | for i := 1; i <= date; i++ { |
| | | var ad response.AttendanceDetail |
| | | ad.Date = i |
| | | ad.Status = constvar.Vacation |
| | | details = append(details, ad) |
| | | } |
| | | |
| | | manages, err := models.NewAttendanceManageSearch().SetMonth(params.Month).SetPreload(true).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err) |
| | | return |
| | | } |
| | | |
| | | m := make(map[string]response.AttendanceStatistic) |
| | | for _, manage := range manages { |
| | | var as response.AttendanceStatistic |
| | |
| | | as.WorkerName = manage.WorkerName |
| | | as.WorkType = manage.WorkType.WorkName |
| | | as.Month = params.Month |
| | | as.Details = details |
| | | } |
| | | as.WeekdayOverTime = as.WeekdayOverTime.Add(manage.OverTimeDuration) |
| | | as.ActualAttendanceDays = as.ActualAttendanceDays + 1 |
| | | var ad response.AttendanceDetail |
| | | ad.Date = strings.ReplaceAll(manage.Date, params.Month+"-", "") |
| | | ad.Status = manage.Status |
| | | as.Details = append(as.Details, ad) |
| | | time2, _ := timex.StringToTime2(manage.Date) |
| | | day := time2.Day() |
| | | as.Details[day-1].Status = manage.Status |
| | | |
| | | m[manage.WorkerId] = as |
| | | } |