add 考勤分页和补传
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
using Dlhis.Basic.WorkGrids.Request;
|
||||
using Dlhis.Basic.WorkGrids.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Requests;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
@@ -9,10 +15,12 @@ namespace Dlhis.Basic.WorkGrids.Services.Implements;
|
||||
public class WorkGridScheduleService : IWorkGridScheduleService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IJinkoJipApi _jinkoJipApi;
|
||||
|
||||
public WorkGridScheduleService(IDbContext dbContext)
|
||||
public WorkGridScheduleService(IDbContext dbContext ,IJinkoJipApi jinkoJipApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_jinkoJipApi = jinkoJipApi;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(WorkGridScheduleSaveRequest request)
|
||||
@@ -78,4 +86,62 @@ public class WorkGridScheduleService : IWorkGridScheduleService
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Pagination<WorkGridScheduleAttendancePageResponse>> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.LeftJoin<DeviceEntity>((log, d) => log.DeviceUniqueNo == d.UniqueNo)
|
||||
.Where(log => log.UserUniqueNo == request.UserCode )
|
||||
.WhereIF(request.DateTimePeriod.HasValue(), log => log.RaiseDateTime >= request.DateTimePeriod.Start
|
||||
&& log.RaiseDateTime <= request.DateTimePeriod.End)
|
||||
.OrderBy(log => log.RaiseDateTime)
|
||||
.Select((log, d) => new WorkGridScheduleAttendancePageResponse
|
||||
{
|
||||
Id = log.Id,
|
||||
OriginUserUniqueNo = log.UserUniqueNo,
|
||||
DeviceUniqueNo = log.DeviceUniqueNo,
|
||||
RaiseDateTime = log.RaiseDateTime,
|
||||
CreateTime = log.CreateTime,
|
||||
SerialNo = log.SerialNo,
|
||||
DeployPlace = d.DeployPlace,
|
||||
Sync = log.Sync,
|
||||
Status = log.Status
|
||||
})
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task ManuallyUploadAsync(List<long> logIds)
|
||||
{
|
||||
var requests = await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.LeftJoin<DeviceEntity>((x, device) => x.DeviceUniqueNo == device.UniqueNo)
|
||||
.Where(x => logIds.Contains(x.Id))
|
||||
.Where(x => x.NeedUpload && x.Sync == false)
|
||||
.Select((x, device) => new UploadAttendanceRequestItem
|
||||
{
|
||||
Id = x.Id,
|
||||
RaiseDateTime = x.RaiseDateTime,
|
||||
ZNOTE = device.DeployPlace,
|
||||
ZWORKCODE = x.UserUniqueNo
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (requests.Any())
|
||||
{
|
||||
foreach (var items in requests.Chunk(500))
|
||||
{
|
||||
var ids = items.Select(x => x.Id).ToList();
|
||||
var r = await _jinkoJipApi.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() });
|
||||
if (r.OLX == "0")
|
||||
{
|
||||
await _dbContext.Updateable<DeviceUploadLogEntity>()
|
||||
.SetColumns(x => x.Sync == true)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => ids.Contains(x.Id))
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user