feai 北明接口
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
using Dlhis.External.OpenApi.Request;
|
||||
using Dlhis.Entity.Visitor.Entity;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Dlhis.External.OpenApi.Request;
|
||||
using Dlhis.External.OpenApi.Response;
|
||||
using Dlhis.External.OpenApi.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.External.OpenApi.Controllers;
|
||||
|
||||
@@ -13,10 +17,12 @@ namespace Dlhis.External.OpenApi.Controllers;
|
||||
public class GainfosController : ControllerBase
|
||||
{
|
||||
private readonly IGainfoService _gainfoService;
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public GainfosController(IGainfoService gainfoService)
|
||||
public GainfosController(IGainfoService gainfoService, IDbContext dbContext)
|
||||
{
|
||||
_gainfoService = gainfoService;
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,4 +45,63 @@ public class GainfosController : ControllerBase
|
||||
{
|
||||
return await _gainfoService.GetAttendanceRecordPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 访客明细
|
||||
/// </summary>
|
||||
/// <param name="factory"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("visitor/summary")]
|
||||
public async Task<AppointmentSummaryResponse> GetSummaryAsync(string factory, DateTime start, DateTime end)
|
||||
{
|
||||
var total = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => (x.IsEnterDoorArea && ((x.DoorStart >= start && x.DoorStart <= end) || x.DoorEnd >= start && x.DoorEnd <= end)) ||
|
||||
(x.IsEnterWorkplace && ((x.WorkplaceStart >= start && x.WorkplaceStart <= end) || (x.WorkplaceEnd >= start && x.WorkplaceEnd <= end)))
|
||||
)
|
||||
.Where(x => SqlFunc.Subqueryable<VisitorAppointmentEntity>().Where(p => p.Factory == factory).Any())
|
||||
.CountAsync();
|
||||
|
||||
var @in = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => (x.IsEnterDoorArea && ((x.DoorStart >= start && x.DoorStart <= end) || x.DoorEnd >= start && x.DoorEnd <= end)) ||
|
||||
(x.IsEnterWorkplace && ((x.WorkplaceStart >= start && x.WorkplaceStart <= end) || (x.WorkplaceEnd >= start && x.WorkplaceEnd <= end)))
|
||||
)
|
||||
.Where(x => (x.IsEnterDoorArea && x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived) || (x.IsEnterWorkplace && x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived))
|
||||
.Where(x => SqlFunc.Subqueryable<VisitorAppointmentEntity>().Where(p => p.Factory == factory).Any())
|
||||
.CountAsync();
|
||||
|
||||
var notIn = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => (x.IsEnterDoorArea && ((x.DoorStart >= start && x.DoorStart <= end) || x.DoorEnd >= start && x.DoorEnd <= end)) ||
|
||||
(x.IsEnterWorkplace && ((x.WorkplaceStart >= start && x.WorkplaceStart <= end) || (x.WorkplaceEnd >= start && x.WorkplaceEnd <= end)))
|
||||
)
|
||||
.Where(x => (x.IsEnterDoorArea && x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Wait) || (x.IsEnterWorkplace && x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Wait))
|
||||
.Where(x => SqlFunc.Subqueryable<VisitorAppointmentEntity>().Where(p => p.Factory == factory).Any())
|
||||
.CountAsync();
|
||||
|
||||
var leave = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => (x.IsEnterDoorArea && x.DoorEnd >= start && x.DoorEnd <= end) ||
|
||||
(x.IsEnterWorkplace && x.WorkplaceEnd >= start && x.WorkplaceEnd <= end)
|
||||
)
|
||||
.Where(x => (x.IsEnterDoorArea && x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Leave) || (x.IsEnterWorkplace && x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Leave))
|
||||
.Where(x => SqlFunc.Subqueryable<VisitorAppointmentEntity>().Where(p => p.Factory == factory).Any())
|
||||
.CountAsync();
|
||||
|
||||
var notLeave = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.Where(x => (x.IsEnterDoorArea && x.DoorEnd >= start && x.DoorEnd <= end) ||
|
||||
(x.IsEnterWorkplace && x.WorkplaceEnd >= start && x.WorkplaceEnd <= end)
|
||||
)
|
||||
.Where(x => (x.IsEnterDoorArea && x.DoorStatus != VisitorAppointmentDetailStatusEnumType.Leave) || (x.IsEnterWorkplace && x.WorkplaceStatus != VisitorAppointmentDetailStatusEnumType.Leave))
|
||||
.Where(x => SqlFunc.Subqueryable<VisitorAppointmentEntity>().Where(p => p.Factory == factory).Any())
|
||||
.CountAsync();
|
||||
|
||||
return new AppointmentSummaryResponse
|
||||
{
|
||||
Total = total,
|
||||
In = @in,
|
||||
NotIn = notIn,
|
||||
Leave = leave,
|
||||
NotLeave = notLeave
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user