...
|
...
|
@@ -21,9 +21,10 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. |
|
|
var (
|
|
|
attendanceRecordDao, _ = dao.NewAttendanceRecordDao(ptr.transactionContext)
|
|
|
attendanceRecordRepository, _ = repository.NewProductAttendanceRecordRepository(ptr.transactionContext)
|
|
|
productGroupRepository, _ = repository.NewProductGroupRepository(ptr.transactionContext)
|
|
|
productCalendarRepository, _ = repository.NewProductCalendarRepository(ptr.transactionContext)
|
|
|
isSignIn = true
|
|
|
record *domain.ProductAttendanceRecord
|
|
|
//workStationId string //具体工位
|
|
|
workStation *domain.WorkStation
|
|
|
attendanceType int = domain.ParticipateSupport
|
|
|
worker *domain.User
|
...
|
...
|
@@ -37,7 +38,6 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. |
|
|
var (
|
|
|
device *domain.Device
|
|
|
err error
|
|
|
productGroupRepository, _ = repository.NewProductGroupRepository(ptr.transactionContext)
|
|
|
groupId = 0
|
|
|
groupName = ""
|
|
|
)
|
...
|
...
|
@@ -58,15 +58,17 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. |
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
groupMembers, groupMembersKeyFunc := FindGroupMembers(productGroupRepository, cid, oid, workStation.WorkStationId)
|
|
|
if v, ok := groupMembers[groupMembersKeyFunc(worker.UserId)]; ok {
|
|
|
var productCalendar *domain.ProductCalendar
|
|
|
productGroup, _ := FindMemberBelongToProductGroup(productGroupRepository, cid, oid, workStation.WorkStationId, worker)
|
|
|
if productGroup != nil {
|
|
|
attendanceType = domain.ParticipateNormal
|
|
|
groupId = v.GroupId
|
|
|
groupName = v.GroupName
|
|
|
groupId = productGroup.ProductGroupId
|
|
|
groupName = productGroup.GroupName
|
|
|
productCalendar, _ = productCalendarRepository.FindOne(map[string]interface{}{"companyId": cid, "orgId": oid, "workStationId": workStation.WorkStationId})
|
|
|
}
|
|
|
|
|
|
beginTime := utils.GetZeroTime(report.ActionTime)
|
|
|
endTime := time.Now()
|
|
|
beginTime := report.ActionTime.Add(-time.Hour * 13)
|
|
|
endTime := report.ActionTime
|
|
|
_, records, _ := attendanceRecordDao.WorkerAttendanceRecords(cid, oid, worker.UserId, "", beginTime, endTime)
|
|
|
for i := 0; i < len(records); i++ {
|
|
|
r := records[i]
|
...
|
...
|
@@ -76,7 +78,7 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. |
|
|
if !utils.TimeIsZero(r.SignIn) && utils.TimeIsZero(r.SignOut) {
|
|
|
if utils.TimeAfterEqual(report.ActionTime, r.SignIn) {
|
|
|
r.SignOut = report.ActionTime
|
|
|
r.WorkTimeBefore = r.ComputeWorkTimeBefore()
|
|
|
r.WorkTimeBefore = r.ComputeWorkTimeBefore(productCalendar)
|
|
|
log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 在其他工段打卡 下线当前工段:%v 签退 %v", worker.UserName, worker.UserId, r.WorkStation.SectionName, report))
|
|
|
if _, err = attendanceRecordRepository.Save(r); err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -148,10 +150,11 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. |
|
|
ProductGroupId: groupId,
|
|
|
}),
|
|
|
}
|
|
|
record.SetProductTimeByProductCalendar(productCalendar)
|
|
|
log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 签到 %v", worker.UserName, worker.UserId, report))
|
|
|
} else {
|
|
|
record.SignOut = report.ActionTime
|
|
|
record.WorkTimeBefore = record.ComputeWorkTimeBefore()
|
|
|
record.WorkTimeBefore = record.ComputeWorkTimeBefore(productCalendar)
|
|
|
log.Logger.Debug(fmt.Sprintf("【考勤汇报】 用户:%v(%v) 签退 %v", worker.UserName, worker.UserId, report))
|
|
|
}
|
|
|
|
...
|
...
|
|