attendance_record_dto.go 1.8 KB
package dto

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/domain"
)

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"`
	// 生产工人
	ProductWorker *domain.User `json:"productWorker,omitempty"`
	*domain.ProductAttendanceRecordExt
	// 工作位置
	*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.Format("15:04:05")
		d.SignDate = m.SignIn.Format("2006-01-02")
	}
	if !m.SignOut.IsZero() {
		d.SignOut = m.SignOut.Format("15:04:05")
	}
	d.WorkTimeBefore = m.WorkTimeBefore
	d.WorkTimeAfter = m.WorkTimeAfter
	d.AttendanceStatus = m.AttendanceStatus
	d.AuthFlag = domain.CheckOrgAuth(orgId, m.OrgId)
	if m.Ext != nil {
		d.OrgName = m.Ext.OrgName
		d.ProductAttendanceRecordExt = m.Ext.AttendanceExt
	}
	return d
}