add 考勤分页和补传
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
using Dlhis.Basic.Device.Services;
|
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Device.Entities;
|
using Dlhis.Entity.Device.Entities;
|
||||||
using Dlhis.Entity.Device.Enums;
|
using Dlhis.Entity.Device.Enums;
|
||||||
|
|||||||
@@ -151,4 +151,25 @@ public class WorkGridsController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _workGridScheduleService.GetListSummaryAsync(workGridCode, start, end);
|
return await _workGridScheduleService.GetListSummaryAsync(workGridCode, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取网格人员考勤记录分页
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("user/attendance/page")]
|
||||||
|
public async Task<Pagination<WorkGridScheduleAttendancePageResponse>> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request)
|
||||||
|
{
|
||||||
|
return await _workGridScheduleService.GetAttendancePageAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网格人员考勤记录补传
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logIds"></param>
|
||||||
|
[HttpPost("user/attendance/upload")]
|
||||||
|
public async Task ManuallyUploadAsync(List<long> logIds)
|
||||||
|
{
|
||||||
|
await _workGridScheduleService.ManuallyUploadAsync(logIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Kurisu.AspNetCore.CustomClass;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.WorkGrids.Request;
|
||||||
|
|
||||||
|
public class WorkGridScheduleAttendancePageRequest : PageDto
|
||||||
|
{
|
||||||
|
[Required(ErrorMessage = "工号不能为空")]
|
||||||
|
public string UserCode { get; set; }
|
||||||
|
|
||||||
|
public DateTimePeriod DateTimePeriod { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Dlhis.Basic.WorkGrids.Response;
|
||||||
|
|
||||||
|
public class WorkGridScheduleAttendancePageResponse
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备号
|
||||||
|
/// </summary>
|
||||||
|
public string DeviceUniqueNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备部署点
|
||||||
|
/// </summary>
|
||||||
|
public string DeployPlace { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户学工号
|
||||||
|
/// </summary>
|
||||||
|
public string UserCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名称
|
||||||
|
/// </summary>
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上传时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime RaiseDateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 记录创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序列号
|
||||||
|
/// </summary>
|
||||||
|
public string SerialNo { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string OriginUserUniqueNo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否同步sap
|
||||||
|
/// </summary>
|
||||||
|
public bool Sync { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否需要上传
|
||||||
|
/// </summary>
|
||||||
|
public bool NeedUpload { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否有效
|
||||||
|
/// </summary>
|
||||||
|
public bool Status { get; set; }
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Dlhis.Basic.WorkGrids.Request;
|
using Dlhis.Basic.WorkGrids.Request;
|
||||||
using Dlhis.Basic.WorkGrids.Response;
|
using Dlhis.Basic.WorkGrids.Response;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
|
|
||||||
namespace Dlhis.Basic.WorkGrids.Services;
|
namespace Dlhis.Basic.WorkGrids.Services;
|
||||||
|
|
||||||
@@ -13,4 +14,8 @@ public interface IWorkGridScheduleService : IScopeDependency
|
|||||||
Task<List<WorkGridScheduleResponse>> GetListAsync(Guid workGridCode, DateOnly date);
|
Task<List<WorkGridScheduleResponse>> GetListAsync(Guid workGridCode, DateOnly date);
|
||||||
|
|
||||||
Task<IEnumerable<WorkGridScheduleSummaryResponse>> GetListSummaryAsync(Guid workGridCode, DateOnly start, DateOnly end);
|
Task<IEnumerable<WorkGridScheduleSummaryResponse>> GetListSummaryAsync(Guid workGridCode, DateOnly start, DateOnly end);
|
||||||
|
|
||||||
|
Task<Pagination<WorkGridScheduleAttendancePageResponse>> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request);
|
||||||
|
|
||||||
|
Task ManuallyUploadAsync(List<long> logIds);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
using Dlhis.Basic.WorkGrids.Request;
|
using Dlhis.Basic.WorkGrids.Request;
|
||||||
using Dlhis.Basic.WorkGrids.Response;
|
using Dlhis.Basic.WorkGrids.Response;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
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.DataAccess.SqlSugar.Services;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|
||||||
@@ -9,10 +15,12 @@ namespace Dlhis.Basic.WorkGrids.Services.Implements;
|
|||||||
public class WorkGridScheduleService : IWorkGridScheduleService
|
public class WorkGridScheduleService : IWorkGridScheduleService
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
|
private readonly IJinkoJipApi _jinkoJipApi;
|
||||||
|
|
||||||
public WorkGridScheduleService(IDbContext dbContext)
|
public WorkGridScheduleService(IDbContext dbContext ,IJinkoJipApi jinkoJipApi)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
_jinkoJipApi = jinkoJipApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveAsync(WorkGridScheduleSaveRequest request)
|
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