You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.7 KiB
C#
80 lines
2.7 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using SlnMesnac.Model.domain;
|
|
using SlnMesnac.Repository.service.@base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace SlnMesnac.Repository.service.Impl
|
|
{
|
|
public class RecordStaffAttendanceServiceImpl : BaseServiceImpl<RecordStaffAttendance>,IRecordStaffAttendanceService
|
|
{
|
|
private readonly ILogger<RecordStaffAttendance> _logger;
|
|
|
|
public RecordStaffAttendanceServiceImpl(Repository<RecordStaffAttendance> rep, ILogger<RecordStaffAttendance> logger) : base(rep)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
public List<RecordStaffAttendance> GetRecordStaffAttendances()
|
|
{
|
|
List<RecordStaffAttendance> records = null;
|
|
try
|
|
{
|
|
records = base._rep.GetList();
|
|
records = records.OrderByDescending(x => x.CreateTime).Take(20).ToList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError($"获取员工打卡信息异常{ex.Message}");
|
|
}
|
|
return records;
|
|
}
|
|
|
|
public RecordStaffAttendance GetRecordStaffAttendanceByStaffId(string staffId)
|
|
{
|
|
RecordStaffAttendance recordStaffAttendances = _rep.AsQueryable().Where(x => x.StaffId == staffId).OrderByDescending(x => x.CreateTime).First();
|
|
if (recordStaffAttendances != null)
|
|
{
|
|
return recordStaffAttendances;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool InsertRecordStaffAttendance(List<RecordStaffAttendance> records)
|
|
{
|
|
bool result = false;
|
|
try
|
|
{
|
|
base._rep.AsTenant().BeginTran();
|
|
result = base._rep.InsertRange(records);
|
|
base._rep.AsTenant().CommitTran();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
base._rep.AsTenant().RollbackTran();
|
|
_logger.LogError($"员工打卡信息添加异常:{ex.Message}");
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public RecordStaffAttendance GetLastestOnRecord()
|
|
{
|
|
RecordStaffAttendance recordStaffAttendances = _rep.AsQueryable().Where(x => x.AttendanceType == "0")
|
|
.OrderByDescending(x => x.CreateTime).First();
|
|
return recordStaffAttendances;
|
|
}
|
|
|
|
public RecordStaffAttendance GetLastestOffRecord()
|
|
{
|
|
RecordStaffAttendance recordStaffAttendances = _rep.AsQueryable().Where(x => x.AttendanceType == "1")
|
|
.OrderByDescending(x => x.CreateTime).First();
|
|
return recordStaffAttendances;
|
|
}
|
|
}
|
|
}
|