pg_approve_attendance_records.go
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package domainService
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
)
type PGApproveAttendanceRecordsService struct {
transactionContext *pgTransaction.TransactionContext
}
// 批量审核考勤记录
func (ptr *PGApproveAttendanceRecordsService) BatchApproveAttendanceRecords(opt *domain.OperateInfo, list []*domain.ProductAttendanceRecord, approveUserId int, workTime float64, status int) (interface{}, error) {
var productAttendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext)
var attendance *domain.ProductAttendanceRecord
var err error
log.Logger.Debug("【自动审核考勤记录任务】 启动")
var user *domain.User = &domain.User{}
userService := NewUserService()
if approveUserId > 0 {
user, err = userService.User(approveUserId)
if err != nil {
return nil, err
}
}
for i := range list {
attendance = list[i]
t := attendance.WorkTimeBefore
if workTime > 0 {
t = workTime
}
if t <= 0 && status == domain.AttendanceAutoApproved {
continue
}
if err = attendance.Approve(user, t, status); err != nil {
return nil, err
}
if _, err := productAttendanceRecordRepository.Save(attendance); err != nil {
return nil, err
}
}
for i := range list {
attendance = list[i]
if e := SendWorkshopWorkTimeStaticJob(attendance); e != nil {
log.Logger.Error("【发送工时统计任务失败】" + e.Error())
}
}
return struct{}{}, nil
}
func NewPGApproveAttendanceRecordsService(transactionContext *pgTransaction.TransactionContext) (*PGApproveAttendanceRecordsService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &PGApproveAttendanceRecordsService{
transactionContext: transactionContext,
}, nil
}
}