...
|
...
|
@@ -21,13 +21,14 @@ 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
|
|
|
org *domain.Org
|
|
|
workStation *domain.WorkStation
|
|
|
attendanceType int = domain.ParticipateSupport
|
|
|
worker *domain.User
|
|
|
org *domain.Org
|
|
|
)
|
|
|
|
|
|
if err := report.Valid(); err != nil {
|
...
|
...
|
@@ -35,11 +36,10 @@ func (ptr *PGWorkerAttendanceReportService) Report(cid, oid int, report *domain. |
|
|
}
|
|
|
|
|
|
var (
|
|
|
device *domain.Device
|
|
|
err error
|
|
|
productGroupRepository, _ = repository.NewProductGroupRepository(ptr.transactionContext)
|
|
|
groupId = 0
|
|
|
groupName = ""
|
|
|
device *domain.Device
|
|
|
err error
|
|
|
groupId = 0
|
|
|
groupName = ""
|
|
|
)
|
|
|
deviceRepository, _ := dao.NewDeviceDao(ptr.transactionContext)
|
|
|
if device, err = deviceRepository.FindDeviceByDeviceCode(cid, oid, report.Sn); err != nil {
|
...
|
...
|
@@ -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))
|
|
|
}
|
|
|
|
...
|
...
|
|