diff --git a/Src/Dlhis.Basic/Appointment/Response/AppointmentSummaryResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentSummaryResponse.cs index 20f53870..b44049d5 100644 --- a/Src/Dlhis.Basic/Appointment/Response/AppointmentSummaryResponse.cs +++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentSummaryResponse.cs @@ -1,12 +1,11 @@ -namespace Dlhis.Basic.Appointment.Response -{ - public class AppointmentSummaryResponse - { - public int Total { get; set; } - public int In { get; set; } - public int NotIn { get; set; } - public int Leave { get; set; } +namespace Dlhis.Basic.Appointment.Response; - public int NotLeave { get; set; } - } +public class AppointmentSummaryResponse +{ + public int Total { get; set; } + public int In { get; set; } + public int NotIn { get; set; } + public int Leave { get; set; } + + public int NotLeave { get; set; } } \ No newline at end of file diff --git a/Src/Dlhis.Entity/Canteen/Entities/EMealVoucherDetailEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/EMealVoucherDetailEntity.cs index 35a963b2..f353f4e7 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/EMealVoucherDetailEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/EMealVoucherDetailEntity.cs @@ -63,13 +63,19 @@ public class EMealVoucherDetailEntity : SugarBaseEntity, IVersion /// [SugarColumn(ColumnDescription = "余额", ColumnDataType = "decimal(16,2)")] public decimal Balance { get; set; } + + /// + /// 金额 + /// + [SugarColumn(ColumnDescription = "原始余额", ColumnDataType = "decimal(16,2)")] + public decimal OriginBalance { get; set; } /// /// 版本 /// [SugarColumn(ColumnDescription = "版本")] public int Version { get; set; } - + [SugarColumn(ColumnDataType = "varchar(255)")] public string Signature { get; set; } diff --git a/Src/Dlhis.External/EMealVoucher/Services/Implements/EMealVoucherService.cs b/Src/Dlhis.External/EMealVoucher/Services/Implements/EMealVoucherService.cs index 817fb5e3..27c4a930 100644 --- a/Src/Dlhis.External/EMealVoucher/Services/Implements/EMealVoucherService.cs +++ b/Src/Dlhis.External/EMealVoucher/Services/Implements/EMealVoucherService.cs @@ -48,7 +48,8 @@ public class EMealVoucherService : IEMealVoucherService Phone = x.Phone, Start = x.Start, End = x.End, - Balance = x.Amount + Balance = x.Amount, + OriginBalance = x.Amount }).ToList(); var id = await _dbContext.InsertReturnIdentityAsync(voucher); diff --git a/Src/Dlhis.External/OpenApi/Controllers/CanteenController.cs b/Src/Dlhis.External/OpenApi/Controllers/CanteenController.cs new file mode 100644 index 00000000..c253cd15 --- /dev/null +++ b/Src/Dlhis.External/OpenApi/Controllers/CanteenController.cs @@ -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; + } + + /// + /// 电子餐券记录 + /// + /// + /// + /// + [HttpGet("eMealVoucher/records")] + public async Task> GetEMealVoucherRecordsAsync(string factory, [FromQuery] DateTimePeriod dateTimePeriods) + { + return await _dbContext.Queryable() + .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().Where(p => p.No == x.No).ToList() + }) + .ToListAsync(); + } +} \ No newline at end of file diff --git a/Src/Dlhis.External/OpenApi/Controllers/DeviceController.cs b/Src/Dlhis.External/OpenApi/Controllers/DeviceController.cs new file mode 100644 index 00000000..c0b81a2f --- /dev/null +++ b/Src/Dlhis.External/OpenApi/Controllers/DeviceController.cs @@ -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; + } + + /// + /// 设备列表 + /// + /// + /// + [HttpGet("list")] + public async Task> GetDeviceAsync(string factory) + { + return await _dbContext.Queryable() + .LeftJoin((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(); + } + + /// + /// 设备事件记录 + /// + /// + /// + /// + [HttpGet("event/records")] + public async Task> GetEventRecordPageAsync(string factory, DateTime time) + { + return await _dbContext.Queryable().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(); + } +} \ No newline at end of file diff --git a/Src/Dlhis.External/OpenApi/Controllers/GainfosController.cs b/Src/Dlhis.External/OpenApi/Controllers/GainfosController.cs index c1cb4bf9..82aa6217 100644 --- a/Src/Dlhis.External/OpenApi/Controllers/GainfosController.cs +++ b/Src/Dlhis.External/OpenApi/Controllers/GainfosController.cs @@ -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; } /// @@ -39,4 +45,63 @@ public class GainfosController : ControllerBase { return await _gainfoService.GetAttendanceRecordPageAsync(request); } + + /// + /// 访客明细 + /// + /// + /// + /// + /// + [HttpGet("visitor/summary")] + public async Task GetSummaryAsync(string factory, DateTime start, DateTime end) + { + var total = await _dbContext.Queryable() + .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().Where(p => p.Factory == factory).Any()) + .CountAsync(); + + var @in = await _dbContext.Queryable() + .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().Where(p => p.Factory == factory).Any()) + .CountAsync(); + + var notIn = await _dbContext.Queryable() + .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().Where(p => p.Factory == factory).Any()) + .CountAsync(); + + var leave = await _dbContext.Queryable() + .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().Where(p => p.Factory == factory).Any()) + .CountAsync(); + + var notLeave = await _dbContext.Queryable() + .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().Where(p => p.Factory == factory).Any()) + .CountAsync(); + + return new AppointmentSummaryResponse + { + Total = total, + In = @in, + NotIn = notIn, + Leave = leave, + NotLeave = notLeave + }; + } } \ No newline at end of file diff --git a/Src/Dlhis.External/OpenApi/Response/AppointmentSummaryResponse.cs b/Src/Dlhis.External/OpenApi/Response/AppointmentSummaryResponse.cs new file mode 100644 index 00000000..9694bf33 --- /dev/null +++ b/Src/Dlhis.External/OpenApi/Response/AppointmentSummaryResponse.cs @@ -0,0 +1,29 @@ +namespace Dlhis.External.OpenApi.Response; + +public class AppointmentSummaryResponse +{ + /// + /// 总人数 + /// + public int Total { get; set; } + + /// + /// 入场人数 + /// + public int In { get; set; } + + /// + /// 未入场人数 + /// + public int NotIn { get; set; } + + /// + /// 离场人数 + /// + public int Leave { get; set; } + + /// + /// 未离场人数 + /// + public int NotLeave { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.External/OpenApi/Response/DeviceRecordResponse.cs b/Src/Dlhis.External/OpenApi/Response/DeviceRecordResponse.cs new file mode 100644 index 00000000..64d8cad3 --- /dev/null +++ b/Src/Dlhis.External/OpenApi/Response/DeviceRecordResponse.cs @@ -0,0 +1,29 @@ +namespace Dlhis.External.OpenApi.Response; + +public class DeviceRecordResponse +{ + /// + /// 设备号 + /// + public string DeviceNo { get; set; } + + /// + /// 时间 + /// + public DateTime Time { get; set; } + + /// + /// 学工号 + /// + public string UserCode { get; set; } + + /// + /// 是否合法 + /// + public bool Valid { get; set; } + + /// + /// 序号 + /// + public string SerialNo { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.External/OpenApi/Response/DeviceResponse.cs b/Src/Dlhis.External/OpenApi/Response/DeviceResponse.cs new file mode 100644 index 00000000..1bdd81a7 --- /dev/null +++ b/Src/Dlhis.External/OpenApi/Response/DeviceResponse.cs @@ -0,0 +1,48 @@ +using Dlhis.Entity.Device.Enums; + +namespace Dlhis.External.OpenApi.Response; + +public class DeviceResponse +{ + public string DeviceNo { get; set; } + + /// + /// 心跳间隔 + /// + public int HeartbeatInterval { get; set; } + + + /// + /// 设备类型, 1:门禁, 3:考勤 + /// + public DeviceTypeEnumType Type { get; set; } + + + /// + /// 部署方向,10:进;20:出 + /// + public DeviceDeployDirectionEnumType? DirectionType { get; set; } + + + /// + /// 最后心跳时间 + /// + public DateTime? LastHeartbeatTime { get; set; } + + /// + /// 是否在线 + /// + public bool IsOnline + { + get + { + if (!LastHeartbeatTime.HasValue) + return false; + + if (HeartbeatInterval <= 0) + return true; + + return LastHeartbeatTime.Value.AddSeconds(HeartbeatInterval) >= DateTime.Now; + } + } +} \ No newline at end of file diff --git a/Src/Dlhis.External/OpenApi/Response/EMealVoucherRecordResponse.cs b/Src/Dlhis.External/OpenApi/Response/EMealVoucherRecordResponse.cs new file mode 100644 index 00000000..f1a95f15 --- /dev/null +++ b/Src/Dlhis.External/OpenApi/Response/EMealVoucherRecordResponse.cs @@ -0,0 +1,116 @@ +using Dlhis.Entity.Canteen.Enums; + +namespace Dlhis.External.OpenApi.Response; + +public class EMealVoucherRecordResponse +{ + /// + /// oa流程id + /// + public string No { get; set; } + + /// + /// 标题 + /// + public string Title { get; set; } + + /// + /// 申请人工号 + /// + public string Code { get; set; } + + /// + /// 成本中心 + /// + public string CostId { get; set; } + + /// + /// 来宾公司 + /// + public string Source { get; set; } + + /// + /// 联系人 + /// + public string Phone { get; set; } + + /// + /// 来宾人数 + /// + public int Number { get; set; } + + /// + /// 就餐事由 + /// + public string Reason { get; set; } + + /// + /// 就餐次 + /// + public List Shifts { get; set; } + + /// + /// 可消费厂区 + /// + public List Factories { get; set; } + + /// + /// 申请日期 + /// + public DateTime Date { get; set; } + + /// + /// 厂区 + /// + public string Factory { get; set; } + + /// + /// 明细 + /// + public List Details { get; set; } +} + +public class EMealVoucherRecordDetailResponse +{ + public string No { get; set; } + + /// + /// 人员类型 + /// + public string UserType { get; set; } + + /// + /// 身份证 + /// + public string IdNo { get; set; } + + /// + /// 用餐人 + /// + public string Name { get; set; } + + /// + /// 手机号 + /// + public string Phone { get; set; } + + /// + /// 就餐开始 + /// + public DateTime Start { get; set; } + + /// + /// 就餐结束 + /// + public DateTime End { get; set; } + + /// + /// 金额 + /// + public decimal Balance { get; set; } + + /// + /// 金额 + /// + public decimal OriginBalance { get; set; } +} \ No newline at end of file