using System; using System.Collections.Generic; using System.Text; using System.Threading; using ConsoleApp; using KdbndpTypes; using Microsoft.Extensions.DependencyInjection; using SlnMesnac.Common; using SlnMesnac.Model.domain; using SlnMesnac.Model.dto; using SlnMesnac.Repository.service; namespace SlnMesnac.Business.business { /// /// RFID打卡业务逻辑类 /// public class RfidHandleBusniess { private IRecordStaffAttendanceService _recordStaffAttendanceService; private IRecordStaffCommuteService _recordStaffCommuteService; public RfidHandleBusniess(IRecordStaffAttendanceService recordStaffAttendanceService, IRecordStaffCommuteService recordStaffCommuteService) { this._recordStaffAttendanceService = recordStaffAttendanceService; this._recordStaffCommuteService = recordStaffCommuteService; } /// /// 处理并插入打卡记录 /// /// /// /// public List HandleAndInsertStaffAttendance(BaseStaffInfo staff,int isCheckOn) { RecordStaffAttendance recordStaffAttendance = new RecordStaffAttendance { StaffId = staff.StaffId, AttendanceType = isCheckOn.ToString(), TeamCode = staff.TeamCode, Remark = staff.Remark, CreateBy = staff.StaffName, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; _recordStaffAttendanceService.Insert(recordStaffAttendance); return _recordStaffAttendanceService.GetRecordStaffAttendances(); } /// /// 处理上下班记录 /// public void HandleStaffCommute(BaseStaffInfo staff, int isCheckOn) { if(isCheckOn == 0) { RecordStaffCommute recordStaffCommute = new RecordStaffCommute { StaffId = staff.StaffId, TeamCode = staff.TeamCode, //Classes = StartWorkTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = staff.Remark, CreateBy = staff.StaffName, CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; _recordStaffCommuteService.Insert(recordStaffCommute); } else { //根据id和上班时间不超过九小时的查找对应记录 RecordStaffCommute recordStaffCommute = _recordStaffCommuteService.GetStaffCommuteByIdAndDuration(staff.StaffId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); //更新这个记录的下班打卡时间和在班时长率 } } } }