131 lines
5.9 KiB
C#
131 lines
5.9 KiB
C#
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.Aop;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using SqlSugar;
|
|
|
|
namespace Dlhis.External.OpenApi.Controllers;
|
|
|
|
[Authorize]
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class GainfosController : ControllerBase
|
|
{
|
|
private readonly IGainfoService _gainfoService;
|
|
private readonly IDbContext _dbContext;
|
|
|
|
public GainfosController(IGainfoService gainfoService, IDbContext dbContext)
|
|
{
|
|
_gainfoService = gainfoService;
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取山西所有人员
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("shanxi/all")]
|
|
public async Task<List<GainfoOpenResponse>> GetAllGainfosAsync()
|
|
{
|
|
return await _gainfoService.GetAllGainfosAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据厂区获取人员
|
|
/// </summary>
|
|
/// <param name="factory"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("list")]
|
|
public async Task<List<GainfoOpenResponse>> GetGainfosAsync(string factory)
|
|
{
|
|
return await _gainfoService.GetGainfosAsync(factory);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取归档人员数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("/archive/pagination")]
|
|
public async Task<Pagination<GainfoOpenResponse>> GetGainfoLeavePageAsync([FromQuery] GainfoArchivePageRequest request)
|
|
{
|
|
return await _gainfoService.GetGainfoLeavePageAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取考勤数据
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("attendance/pagination")]
|
|
[IgnoreTenant]
|
|
public async Task<Pagination<DeviceUploadLogResponse>> GetAttendanceRecordPageAsync([FromQuery] DeviceUploadLogMyRecordRequest request)
|
|
{
|
|
return await _gainfoService.GetAttendanceRecordPageAsync(request);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 访客明细
|
|
/// </summary>
|
|
/// <param name="factory"></param>
|
|
/// <param name="start"></param>
|
|
/// <param name="end"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("visitor/summary")]
|
|
[IgnoreTenant]
|
|
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
|
|
};
|
|
}
|
|
} |