attendance_record_dto.go
2.3 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
65
66
67
68
69
70
71
72
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/utils"
"time"
)
type AttendanceRecordDto struct {
// 考勤记录ID
ProductAttendanceId int `json:"productAttendanceId"`
// 企业id
//CompanyId int `json:"companyId,omitempty"`
// 组织ID
//OrgId int `json:"orgId,omitempty"`
// 考勤类型 1.正常 2.支援
AttendanceType int `json:"attendanceType,omitempty"`
// 班组名称
GroupName string `json:"groupName"`
// 生产工人
ProductWorker *domain.User `json:"productWorker,omitempty"`
// 审核人
ApproveUser *domain.User `json:"approveUser"`
//*domain.ProductAttendanceRecordExt
ApproveAt string `json:"approveAt"`
// 工作位置
*domain.WorkStation
// 签到
SignIn string `json:"signIn"`
// 签退
SignOut string `json:"signOut"`
// 考勤状态 1.未审核 2:已审核 3.自动审核
AttendanceStatus int `json:"attendanceStatus"`
// 工时(审核前)
WorkTimeBefore float64 `json:"workTimeBefore"`
// 工时(审核后)
WorkTimeAfter float64 `json:"workTimeAfter"`
// 签到日期
SignDate string `json:"signDate"`
// 组织名称
OrgName string `json:"orgName"`
// 权限标识 (当前登录组织匹配为true,否则false)
AuthFlag bool `json:"authFlag"`
}
func (d *AttendanceRecordDto) LoadDto(m *domain.ProductAttendanceRecord, orgId int) *AttendanceRecordDto {
d.ProductAttendanceId = m.ProductAttendanceId
d.AttendanceType = m.AttendanceType
d.ProductWorker = m.ProductWorker
d.WorkStation = m.WorkStation
if !m.SignIn.IsZero() {
d.SignIn = m.SignIn.Local().Format("15:04:05")
d.SignDate = m.ProductTime().Format("2006-01-02")
}
if !m.SignOut.IsZero() {
d.SignOut = m.SignOut.Local().Format("15:04:05")
}
d.WorkTimeBefore = utils.Round(m.WorkTimeBefore, 1)
d.WorkTimeAfter = m.WorkTimeAfter
d.AttendanceStatus = m.AttendanceStatus
d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
d.OrgName = m.Ext.OrgName
d.ApproveUser = m.ApproveUser()
d.GroupName = m.GroupName()
if m.Ext != nil && m.Ext.AttendanceExt != nil {
if m.Ext.AttendanceExt.ApproveAt > 0 {
t := time.Unix(m.Ext.AttendanceExt.ApproveAt, 0)
d.ApproveAt = t.Local().Format("2006-01-02 15:04:05")
}
}
return d
}