feai 北明接口

This commit is contained in:
2024-10-14 09:48:57 +08:00
parent 0fea33454c
commit 53713902fe
10 changed files with 425 additions and 14 deletions

View File

@@ -0,0 +1,53 @@
using Dlhis.Entity.Canteen.Entities;
using Dlhis.External.OpenApi.Response;
using Kurisu.AspNetCore.CustomClass;
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 CanteenController : ControllerBase
{
private readonly IDbContext _dbContext;
public CanteenController(IDbContext dbContext)
{
_dbContext = dbContext;
}
/// <summary>
/// 电子餐券记录
/// </summary>
/// <param name="factory"></param>
/// <param name="dateTimePeriods"></param>
/// <returns></returns>
[HttpGet("eMealVoucher/records")]
public async Task<List<EMealVoucherRecordResponse>> GetEMealVoucherRecordsAsync(string factory, [FromQuery] DateTimePeriod dateTimePeriods)
{
return await _dbContext.Queryable<EMealVoucherEntity>()
.Where(x => x.Factory == factory)
.WhereIF(dateTimePeriods.HasValue(), x => x.Date >= dateTimePeriods.Start && x.Date <= dateTimePeriods.End)
.Select(x => new EMealVoucherRecordResponse
{
No = x.No,
Title = x.Title,
Code = x.Code,
CostId = x.CostId,
Source = x.Source,
Phone = x.Phone,
Number = x.Number,
Reason = x.Reason,
Shifts = x.Shifts,
Factories = x.Factories,
Date = default,
Factory = x.Factory,
Details = SqlFunc.Subqueryable<EMealVoucherDetailEntity>().Where(p => p.No == x.No).ToList<EMealVoucherRecordDetailResponse>()
})
.ToListAsync();
}
}

View File

@@ -0,0 +1,65 @@
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.External.OpenApi.Response;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Dlhis.External.OpenApi.Controllers;
[Authorize]
[Route("api/[controller]")]
[ApiController]
public class DevicesController : ControllerBase
{
private readonly IDbContext _dbContext;
public DevicesController(IDbContext dbContext)
{
_dbContext = dbContext;
}
/// <summary>
/// 设备列表
/// </summary>
/// <param name="factory"></param>
/// <returns></returns>
[HttpGet("list")]
public async Task<List<DeviceResponse>> GetDeviceAsync(string factory)
{
return await _dbContext.Queryable<DeviceEntity>()
.LeftJoin<DeviceRegistryEntity>((x, xr) => x.UniqueNo == xr.DeviceUniqueNo)
.Where(x => x.TenantId == factory && (x.Type == DeviceTypeEnumType.Attendance || x.Type == DeviceTypeEnumType.Door))
.Select((x, xr) => new DeviceResponse
{
DeviceNo = x.UniqueNo,
HeartbeatInterval = x.HeartbeatInterval,
DirectionType = x.DeployDirection,
LastHeartbeatTime = xr.LastHeartbeatTime,
})
.ToListAsync();
}
/// <summary>
/// 设备事件记录
/// </summary>
/// <param name="factory"></param>
/// <param name="time"></param>
/// <returns></returns>
[HttpGet("event/records")]
public async Task<List<DeviceRecordResponse>> GetEventRecordPageAsync(string factory, DateTime time)
{
return await _dbContext.Queryable<DeviceUploadLogEntity>().Where(x => x.RaiseDateTime >= time)
.Where(x => x.TenantId == factory)
.Select(x => new DeviceRecordResponse
{
DeviceNo = x.DeviceUniqueNo,
Time = x.RaiseDateTime,
UserCode = x.UserUniqueNo,
Valid = x.Status,
SerialNo = x.SerialNo
})
.ToListAsync();
}
}

View File

@@ -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
};
}
}

View File

@@ -0,0 +1,29 @@
namespace Dlhis.External.OpenApi.Response;
public class AppointmentSummaryResponse
{
/// <summary>
/// 总人数
/// </summary>
public int Total { get; set; }
/// <summary>
/// 入场人数
/// </summary>
public int In { get; set; }
/// <summary>
/// 未入场人数
/// </summary>
public int NotIn { get; set; }
/// <summary>
/// 离场人数
/// </summary>
public int Leave { get; set; }
/// <summary>
/// 未离场人数
/// </summary>
public int NotLeave { get; set; }
}

View File

@@ -0,0 +1,29 @@
namespace Dlhis.External.OpenApi.Response;
public class DeviceRecordResponse
{
/// <summary>
/// 设备号
/// </summary>
public string DeviceNo { get; set; }
/// <summary>
/// 时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 学工号
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 是否合法
/// </summary>
public bool Valid { get; set; }
/// <summary>
/// 序号
/// </summary>
public string SerialNo { get; set; }
}

View File

@@ -0,0 +1,48 @@
using Dlhis.Entity.Device.Enums;
namespace Dlhis.External.OpenApi.Response;
public class DeviceResponse
{
public string DeviceNo { get; set; }
/// <summary>
/// 心跳间隔
/// </summary>
public int HeartbeatInterval { get; set; }
/// <summary>
/// 设备类型, 1:门禁, 3:考勤
/// </summary>
public DeviceTypeEnumType Type { get; set; }
/// <summary>
/// 部署方向,10:进;20:出
/// </summary>
public DeviceDeployDirectionEnumType? DirectionType { get; set; }
/// <summary>
/// 最后心跳时间
/// </summary>
public DateTime? LastHeartbeatTime { get; set; }
/// <summary>
/// 是否在线
/// </summary>
public bool IsOnline
{
get
{
if (!LastHeartbeatTime.HasValue)
return false;
if (HeartbeatInterval <= 0)
return true;
return LastHeartbeatTime.Value.AddSeconds(HeartbeatInterval) >= DateTime.Now;
}
}
}

View File

@@ -0,0 +1,116 @@
using Dlhis.Entity.Canteen.Enums;
namespace Dlhis.External.OpenApi.Response;
public class EMealVoucherRecordResponse
{
/// <summary>
/// oa流程id
/// </summary>
public string No { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 申请人工号
/// </summary>
public string Code { get; set; }
/// <summary>
/// 成本中心
/// </summary>
public string CostId { get; set; }
/// <summary>
/// 来宾公司
/// </summary>
public string Source { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 来宾人数
/// </summary>
public int Number { get; set; }
/// <summary>
/// 就餐事由
/// </summary>
public string Reason { get; set; }
/// <summary>
/// 就餐次
/// </summary>
public List<ShiftEnumType> Shifts { get; set; }
/// <summary>
/// 可消费厂区
/// </summary>
public List<string> Factories { get; set; }
/// <summary>
/// 申请日期
/// </summary>
public DateTime Date { get; set; }
/// <summary>
/// 厂区
/// </summary>
public string Factory { get; set; }
/// <summary>
/// 明细
/// </summary>
public List<EMealVoucherRecordDetailResponse> Details { get; set; }
}
public class EMealVoucherRecordDetailResponse
{
public string No { get; set; }
/// <summary>
/// 人员类型
/// </summary>
public string UserType { get; set; }
/// <summary>
/// 身份证
/// </summary>
public string IdNo { get; set; }
/// <summary>
/// 用餐人
/// </summary>
public string Name { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 就餐开始
/// </summary>
public DateTime Start { get; set; }
/// <summary>
/// 就餐结束
/// </summary>
public DateTime End { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Balance { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal OriginBalance { get; set; }
}