fix 优化summary
This commit is contained in:
@@ -64,12 +64,13 @@ public class AppointmentsController : ControllerBase
|
||||
/// 根据身份证获取当天预约信息
|
||||
/// </summary>
|
||||
/// <param name="idNo"></param>
|
||||
/// <param name="factory"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("today")]
|
||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo)
|
||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo, string factory)
|
||||
{
|
||||
return await _appointmentService.GetTodayByIdNoAsync(idNo);
|
||||
return await _appointmentService.GetTodayByIdNoAsync(idNo, factory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,4 +84,19 @@ public class AppointmentsController : ControllerBase
|
||||
{
|
||||
return await _appointmentService.GetRecordPageByIdNoAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据明细
|
||||
/// </summary>
|
||||
/// <param name="factory"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet("summary")]
|
||||
public async Task<AppointmentSummaryResponse> GetSummaryAsync(string factory, DateTime start, DateTime end)
|
||||
{
|
||||
end = start.Date.AddDays(1).AddMilliseconds(-1);
|
||||
return await _appointmentService.GetSummaryAsync(factory, start, end);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,11 @@ public class AppointmentPageResponse
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 对接人姓名
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来访人来源/公司
|
||||
/// </summary>
|
||||
@@ -23,7 +28,7 @@ public class AppointmentPageResponse
|
||||
/// 申请时间
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
@@ -38,4 +43,4 @@ public class AppointmentPageResponse
|
||||
/// 申请事由
|
||||
/// </summary>
|
||||
public string Reason { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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; }
|
||||
|
||||
public int NotLeave { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,12 @@ public interface IAppointmentService : IScopeDependency
|
||||
/// 根据身份证获取最新访客预约
|
||||
/// </summary>
|
||||
/// <param name="idNo"></param>
|
||||
/// <param name="factory"></param>
|
||||
/// <returns></returns>
|
||||
Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo);
|
||||
Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo, string factory);
|
||||
|
||||
|
||||
Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request);
|
||||
|
||||
Task<AppointmentSummaryResponse> GetSummaryAsync(string factory, DateTime start, DateTime end);
|
||||
}
|
||||
@@ -98,10 +98,8 @@ public class AppointmentService : IAppointmentService
|
||||
}
|
||||
}
|
||||
|
||||
//********************************************************** 用户操作 *******************************************************************
|
||||
|
||||
|
||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo)
|
||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(string idNo, string factory)
|
||||
{
|
||||
var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");
|
||||
try
|
||||
@@ -117,13 +115,29 @@ public class AppointmentService : IAppointmentService
|
||||
return await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => ga.IdNo == idNo)
|
||||
.Where((x, ga) => ga.IdNo == idNo)
|
||||
.Where(x => (x.IsEnterDoorArea && SqlFunc.DateIsSame(x.DoorStart, now)) || (x.IsEnterWorkplace && SqlFunc.DateIsSame(x.WorkplaceStart, now)))
|
||||
.Where(x => (x.IsEnterDoorArea && SqlFunc.DateIsSame(x.DoorStart, now) && x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Wait) ||
|
||||
(x.IsEnterWorkplace && SqlFunc.DateIsSame(x.WorkplaceStart, now) && x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Wait))
|
||||
.Where(x => SqlFunc.Subqueryable<VisitorAppointmentEntity>().Where(p => p.Factory == factory).Where(p => p.No == x.No).Any())
|
||||
.Select(x => new AppointmentDetailResponse
|
||||
{
|
||||
No = x.No,
|
||||
Mst = SqlFunc.Subqueryable<VisitorAppointmentDetailEntity>().Where(p => p.No == x.No).First<AppointmentPageResponse>()
|
||||
Mst = SqlFunc.Subqueryable<VisitorAppointmentEntity>()
|
||||
.LeftJoin<GainfoEntity>((p, ga) => p.Code == ga.Code)
|
||||
.Where((p, ga) => p.No == x.No)
|
||||
.First((p, ga) => new AppointmentPageResponse
|
||||
{
|
||||
No = p.No,
|
||||
Title = p.Title,
|
||||
Code = p.Code,
|
||||
Name = ga.Name,
|
||||
Source = p.Source,
|
||||
Date = p.Date,
|
||||
Remark = p.Remark,
|
||||
Factory = p.Factory,
|
||||
Reason = p.Reason
|
||||
}, false)
|
||||
}, true)
|
||||
.SingleAsync();
|
||||
.FirstAsync();
|
||||
}
|
||||
|
||||
public async Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request)
|
||||
@@ -147,4 +161,52 @@ public class AppointmentService : IAppointmentService
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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 => 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.Leave) || (x.IsEnterWorkplace && x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Leave))
|
||||
.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 => 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