...
|
...
|
@@ -105,10 +105,10 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
var workTime float64 = 0
|
|
|
if cmd.WorkTime-cmd.BreakTime > 0 {
|
|
|
workTime = cmd.WorkTime - cmd.BreakTime
|
|
|
}
|
|
|
//var workTime float64 = 0
|
|
|
//if cmd.WorkTime-cmd.BreakTime > 0 {
|
|
|
// workTime = cmd.WorkTime - cmd.BreakTime
|
|
|
//}
|
|
|
signIn, err := xtime.ParseInLocation(time.Local, fmt.Sprintf("%v %v:00", cmd.ProductDate, cmd.SignIn))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -121,6 +121,9 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if !xtime.BeforeEqual(productDate, time.Now()) {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("日期需要小于等于%v", time.Now().Format("2006-01-02")))
|
|
|
}
|
|
|
newAttendance := &domain.ProductAttendanceRecord{
|
|
|
//ProductAttendanceId: cmd.ProductAttendanceId,
|
|
|
CompanyId: operateInfo.CompanyId,
|
...
|
...
|
@@ -131,20 +134,21 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
SignIn: signIn,
|
|
|
SignOut: signOut,
|
|
|
AttendanceStatus: cmd.AttendanceStatus,
|
|
|
WorkTimeBefore: workTime,
|
|
|
WorkTimeBefore: cmd.WorkTime,
|
|
|
WorkTimeAfter: 0,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
Ext: domain.NewExt(org.OrgName).WithAttendanceExt(&domain.ProductAttendanceRecordExt{
|
|
|
GroupName: productGroup.GroupName,
|
|
|
ProductGroupId: productGroup.ProductGroupId,
|
|
|
BreakTime: cmd.BreakTime,
|
|
|
}),
|
|
|
ProductDate: productDate,
|
|
|
}
|
|
|
|
|
|
if cmd.AttendanceStatus == domain.AttendanceApproved {
|
|
|
newAttendance.WorkTimeAfter = domain.AttendanceApproved
|
|
|
newAttendance.WorkTimeAfter = workTime
|
|
|
newAttendance.WorkTimeAfter = cmd.WorkTime
|
|
|
}
|
|
|
var (
|
|
|
attendanceRepository domain.ProductAttendanceRecordRepository
|
...
|
...
|
@@ -159,7 +163,10 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if count > 0 {
|
|
|
return nil, &application.ServiceError{Code: 10050001, Message: fmt.Sprintf("已存在员工%v的工时记录,是否继续新增", user.UserName)}
|
|
|
return map[string]interface{}{
|
|
|
"message": fmt.Sprintf("已存在员工%v的工时记录,是否继续新增", user.UserName),
|
|
|
"needConfirm": true,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
|
|
if attendance, err := attendanceRepository.Save(newAttendance); err != nil {
|
...
|
...
|
|