...
|
...
|
@@ -109,6 +109,18 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
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())
|
|
|
}
|
|
|
signOut, err := xtime.ParseInLocation(time.Local, fmt.Sprintf("%v %v:00", cmd.ProductDate, cmd.SignOut))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
productDate, err := xtime.ParseInLocation(time.Local, cmd.ProductDate)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
newAttendance := &domain.ProductAttendanceRecord{
|
|
|
//ProductAttendanceId: cmd.ProductAttendanceId,
|
|
|
CompanyId: operateInfo.CompanyId,
|
...
|
...
|
@@ -116,8 +128,8 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
AttendanceType: cmd.AttendanceType,
|
|
|
ProductWorker: user,
|
|
|
WorkStation: workStation,
|
|
|
SignIn: cmd.SignIn,
|
|
|
SignOut: cmd.SignOut,
|
|
|
SignIn: signIn,
|
|
|
SignOut: signOut,
|
|
|
AttendanceStatus: cmd.AttendanceStatus,
|
|
|
WorkTimeBefore: workTime,
|
|
|
WorkTimeAfter: 0,
|
...
|
...
|
@@ -127,7 +139,7 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
GroupName: productGroup.GroupName,
|
|
|
ProductGroupId: productGroup.ProductGroupId,
|
|
|
}),
|
|
|
ProductDate: xtime.New(cmd.ProductDate).BeginningOfDay(),
|
|
|
ProductDate: productDate,
|
|
|
}
|
|
|
|
|
|
if cmd.AttendanceStatus == domain.AttendanceApproved {
|
...
|
...
|
@@ -142,12 +154,12 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
attendanceRepository, _, _ = factory.FastPgAttendance(transactionContext, 0)
|
|
|
if !cmd.Prepared {
|
|
|
// 检查时间段内是否有重复的打卡记录
|
|
|
count, _, err := attendanceRecordDao.WorkerAttendanceRecordsByProductDate(operateInfo.CompanyId, operateInfo.OrgId, cmd.ProductWorkerId, newAttendance.ProductDate, cmd.SignIn, cmd.SignIn)
|
|
|
count, _, err := attendanceRecordDao.WorkerAttendanceRecordsByProductDate(operateInfo.CompanyId, operateInfo.OrgId, cmd.ProductWorkerId, newAttendance.ProductDate, newAttendance.SignIn, newAttendance.SignIn)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if count > 0 {
|
|
|
return nil, &application.ServiceError{Code: 10040001, Message: fmt.Sprintf("已存在员工%v的工时记录,是否继续新增", user.UserName)}
|
|
|
return nil, &application.ServiceError{Code: 10050001, Message: fmt.Sprintf("已存在员工%v的工时记录,是否继续新增", user.UserName)}
|
|
|
}
|
|
|
}
|
|
|
if attendance, err := attendanceRepository.Save(newAttendance); err != nil {
|
...
|
...
|
@@ -157,7 +169,7 @@ func (attendanceService *AttendanceService) CreateAttendance(operateInfo *domain |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return attendance, nil
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|