...
|
...
|
@@ -8,6 +8,7 @@ import ( |
|
|
const (
|
|
|
AttendanceNotApprove = 1 // 未审核
|
|
|
AttendanceApproved = 2 // 已审核
|
|
|
AttendanceAutoApproved = 3 // 自动审核
|
|
|
)
|
|
|
|
|
|
// 生产考勤记录
|
...
|
...
|
@@ -59,86 +60,28 @@ func (productAttendanceRecord *ProductAttendanceRecord) Identify() interface{} { |
|
|
}
|
|
|
|
|
|
func (productAttendanceRecord *ProductAttendanceRecord) Update(data map[string]interface{}) error {
|
|
|
if productAttendanceId, ok := data["productAttendanceId"]; ok {
|
|
|
productAttendanceRecord.ProductAttendanceId = productAttendanceId.(int)
|
|
|
}
|
|
|
if orgId, ok := data["orgId"]; ok {
|
|
|
productAttendanceRecord.OrgId = orgId.(int)
|
|
|
}
|
|
|
if attendanceType, ok := data["attendanceType"]; ok {
|
|
|
productAttendanceRecord.AttendanceType = attendanceType.(int)
|
|
|
}
|
|
|
if userId, ok := data["userId"]; ok {
|
|
|
productAttendanceRecord.ProductWorker.UserId = userId.(int)
|
|
|
}
|
|
|
if userName, ok := data["userName"]; ok {
|
|
|
productAttendanceRecord.ProductWorker.UserName = userName.(string)
|
|
|
}
|
|
|
if employeeType, ok := data["employeeType"]; ok {
|
|
|
productAttendanceRecord.ProductWorker.EmployeeType = employeeType.(int)
|
|
|
}
|
|
|
if icCardNumber, ok := data["icCardNumber"]; ok {
|
|
|
productAttendanceRecord.ProductWorker.IcCardNumber = icCardNumber.(string)
|
|
|
}
|
|
|
if avatar, ok := data["avatar"]; ok {
|
|
|
productAttendanceRecord.ProductWorker.Avatar = avatar.(string)
|
|
|
}
|
|
|
if phone, ok := data["phone"]; ok {
|
|
|
productAttendanceRecord.ProductWorker.Phone = phone.(string)
|
|
|
}
|
|
|
if workStationId, ok := data["workStationId"]; ok {
|
|
|
productAttendanceRecord.WorkStation.WorkStationId = workStationId.(string)
|
|
|
}
|
|
|
if workshopId, ok := data["workshopId"]; ok {
|
|
|
productAttendanceRecord.WorkStation.WorkshopId = workshopId.(int)
|
|
|
}
|
|
|
if workshopName, ok := data["workshopName"]; ok {
|
|
|
productAttendanceRecord.WorkStation.WorkshopName = workshopName.(string)
|
|
|
}
|
|
|
if lineId, ok := data["lineId"]; ok {
|
|
|
productAttendanceRecord.WorkStation.LineId = lineId.(int)
|
|
|
}
|
|
|
if lineName, ok := data["lineName"]; ok {
|
|
|
productAttendanceRecord.WorkStation.LineName = lineName.(string)
|
|
|
}
|
|
|
if sectionId, ok := data["sectionId"]; ok {
|
|
|
productAttendanceRecord.WorkStation.SectionId = sectionId.(int)
|
|
|
}
|
|
|
if sectionName, ok := data["sectionName"]; ok {
|
|
|
productAttendanceRecord.WorkStation.SectionName = sectionName.(string)
|
|
|
}
|
|
|
if signIn, ok := data["signIn"]; ok {
|
|
|
productAttendanceRecord.SignIn = signIn.(time.Time)
|
|
|
}
|
|
|
if signOut, ok := data["signOut"]; ok {
|
|
|
productAttendanceRecord.SignOut = signOut.(time.Time)
|
|
|
}
|
|
|
if attendanceStatus, ok := data["attendanceStatus"]; ok {
|
|
|
productAttendanceRecord.AttendanceStatus = attendanceStatus.(int)
|
|
|
}
|
|
|
if workTimeBefore, ok := data["workTimeBefore"]; ok {
|
|
|
productAttendanceRecord.WorkTimeBefore = workTimeBefore.(float64)
|
|
|
}
|
|
|
if workTimeAfter, ok := data["workTimeAfter"]; ok {
|
|
|
productAttendanceRecord.WorkTimeAfter = workTimeAfter.(float64)
|
|
|
}
|
|
|
if createdAt, ok := data["createdAt"]; ok {
|
|
|
productAttendanceRecord.CreatedAt = createdAt.(time.Time)
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 计算审核前工时
|
|
|
func (productAttendanceRecord *ProductAttendanceRecord) ComputeWorkTimeBefore() float64 {
|
|
|
if productAttendanceRecord.SignIn.IsZero() {
|
|
|
return 0
|
|
|
}
|
|
|
if updatedAt, ok := data["updatedAt"]; ok {
|
|
|
productAttendanceRecord.UpdatedAt = updatedAt.(time.Time)
|
|
|
if productAttendanceRecord.SignOut.IsZero() {
|
|
|
return 0
|
|
|
}
|
|
|
if deletedAt, ok := data["deletedAt"]; ok {
|
|
|
productAttendanceRecord.DeletedAt = deletedAt.(time.Time)
|
|
|
if !productAttendanceRecord.SignOut.After(productAttendanceRecord.SignIn) {
|
|
|
return 0
|
|
|
}
|
|
|
return nil
|
|
|
return productAttendanceRecord.SignOut.Sub(productAttendanceRecord.SignIn).Hours()
|
|
|
}
|
|
|
|
|
|
func (productAttendanceRecord *ProductAttendanceRecord) Approve(approveUser *User, workTimeAfter float64) error {
|
|
|
if productAttendanceRecord.AttendanceStatus == AttendanceApproved {
|
|
|
func (productAttendanceRecord *ProductAttendanceRecord) Approve(approveUser *User, workTimeAfter float64, status int) error {
|
|
|
if productAttendanceRecord.AttendanceStatus == AttendanceApproved || productAttendanceRecord.AttendanceStatus == AttendanceAutoApproved {
|
|
|
return errors.New("已审核")
|
|
|
}
|
|
|
productAttendanceRecord.AttendanceStatus = AttendanceApproved
|
|
|
productAttendanceRecord.AttendanceStatus = status
|
|
|
productAttendanceRecord.WorkTimeAfter = workTimeAfter
|
|
|
if productAttendanceRecord.Ext != nil && productAttendanceRecord.Ext.AttendanceExt != nil {
|
|
|
productAttendanceRecord.Ext.AttendanceExt.ApproveUserId = approveUser.UserId
|
...
|
...
|
|