|
|
|
@ -2,12 +2,14 @@ |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Shentun.WebPeis.AppointScheduleTimes; |
|
|
|
using Shentun.WebPeis.Models; |
|
|
|
using Shentun.WebPeis.OrganizationUnits; |
|
|
|
using Shentun.WebPeis.SysParmValues; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using static log4net.Appender.RollingFileAppender; |
|
|
|
@ -25,6 +27,7 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
private readonly AppointScheduleManager _appointScheduleManager; |
|
|
|
private readonly AppointScheduleTimeManager _appointScheduleTimeManager; |
|
|
|
private readonly SysParmValueManager _sysParmValueManager; |
|
|
|
private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager; |
|
|
|
|
|
|
|
public AppointScheduleAppService(IRepository<AppointSchedule> appointScheduleRepository, |
|
|
|
CacheService cacheService, |
|
|
|
@ -32,7 +35,8 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
IRepository<AppointScheduleTemplate> appointScheduleTemplateRepository, |
|
|
|
IRepository<AppointScheduleTime> appointScheduleTimeRepository, |
|
|
|
AppointScheduleTimeManager appointScheduleTimeManager, |
|
|
|
SysParmValueManager sysParmValueManager) |
|
|
|
SysParmValueManager sysParmValueManager, |
|
|
|
WebPeisOrganizationUnitManager webPeisOrganizationUnitManager) |
|
|
|
{ |
|
|
|
_appointScheduleRepository = appointScheduleRepository; |
|
|
|
_cacheService = cacheService; |
|
|
|
@ -41,6 +45,7 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
_appointScheduleTimeRepository = appointScheduleTimeRepository; |
|
|
|
_appointScheduleTimeManager = appointScheduleTimeManager; |
|
|
|
_sysParmValueManager = sysParmValueManager; |
|
|
|
_webPeisOrganizationUnitManager = webPeisOrganizationUnitManager; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -51,8 +56,21 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
[HttpPost("api/app/AppointSchedule/GetAppointScheduleDateList")] |
|
|
|
public async Task<List<AppointScheduleDateDto>> GetAppointScheduleDateListAsync(MedicalCenterIdInputDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
var canAppointDaysStr = await _sysParmValueManager.GetSysParmValueAsync(input.MedicalCenterId, "appoint_schedule_can_appoint_days"); |
|
|
|
Guid medicalCenterId ; |
|
|
|
if (input == null || input.MedicalCenterId == Guid.Empty || input.MedicalCenterId == null) |
|
|
|
{ |
|
|
|
var webPeisOrganizationUnit = await _webPeisOrganizationUnitManager.GetMedicalCenterListAsync(); |
|
|
|
if (webPeisOrganizationUnit.Count > 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("体检中心参数不能为空"); |
|
|
|
} |
|
|
|
medicalCenterId = webPeisOrganizationUnit.First().Id; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
medicalCenterId = (Guid)input.MedicalCenterId; |
|
|
|
} |
|
|
|
var canAppointDaysStr = await _sysParmValueManager.GetSysParmValueAsync(medicalCenterId, "appoint_schedule_can_appoint_days"); |
|
|
|
if (!int.TryParse(canAppointDaysStr, out var canAppointDays)) |
|
|
|
{ |
|
|
|
canAppointDays = 30; |
|
|
|
@ -61,21 +79,21 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
var appointSchedules = (from appointSchedule in await _appointScheduleRepository.GetQueryableAsync() |
|
|
|
join appointScheduleTime in await _appointScheduleTimeRepository.GetQueryableAsync() |
|
|
|
on appointSchedule.AppointScheduleId equals appointScheduleTime.AppointScheduleId |
|
|
|
where appointSchedule.MedicalCenterId == input.MedicalCenterId && |
|
|
|
where appointSchedule.MedicalCenterId == medicalCenterId && |
|
|
|
appointSchedule.AppointDate >= DateTime.Now.Date && appointSchedule.AppointDate <= DateTime.Now.Date.AddDays(canAppointDays) |
|
|
|
select new |
|
|
|
{ |
|
|
|
appointSchedule, |
|
|
|
appointScheduleTime |
|
|
|
} |
|
|
|
{ |
|
|
|
appointSchedule, |
|
|
|
appointScheduleTime |
|
|
|
} |
|
|
|
).ToList(); |
|
|
|
var list = appointSchedules.GroupBy(o => o.appointSchedule) |
|
|
|
.Select(x => new AppointScheduleDateDto() |
|
|
|
{ |
|
|
|
AppointDate = x.Key.AppointDate, |
|
|
|
IsWork = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) == 0? 'N':'Y', |
|
|
|
IsFull = (x.Key.AmNumberLimit + x.Key.PmNumberLimit)<= x.Key.AppointScheduleTimes.Sum(m=>m.AppointNumber)?'Y':'N' |
|
|
|
}).ToList(); |
|
|
|
var list = appointSchedules.GroupBy(o => o.appointSchedule) |
|
|
|
.Select(x => new AppointScheduleDateDto() |
|
|
|
{ |
|
|
|
AppointDate = x.Key.AppointDate, |
|
|
|
IsWork = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) == 0 ? 'N' : 'Y', |
|
|
|
IsFull = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N' |
|
|
|
}).ToList(); |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@ -104,34 +122,7 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task<List<AppointScheduleDateDto>> GetAppointScheduleDateTestListAsync() |
|
|
|
{ |
|
|
|
var appointScheduleDateDtos = new List<AppointScheduleDateDto>(); |
|
|
|
DateTime startDate = DateTime.Now.Date; |
|
|
|
for (var i = 0; i < 60; i++) |
|
|
|
{ |
|
|
|
var appointScheduleDateDto = new AppointScheduleDateDto() |
|
|
|
{ |
|
|
|
AppointDate = startDate.AddDays(i), |
|
|
|
|
|
|
|
}; |
|
|
|
appointScheduleDateDtos.Add(new AppointScheduleDateDto() |
|
|
|
{ |
|
|
|
AppointDate = startDate.AddDays(i), |
|
|
|
|
|
|
|
}); |
|
|
|
if (appointScheduleDateDto.AppointDate.DayOfWeek == DayOfWeek.Sunday) |
|
|
|
{ |
|
|
|
appointScheduleDateDto.IsWork = 'N'; |
|
|
|
} |
|
|
|
else if (appointScheduleDateDto.AppointDate.DayOfWeek == DayOfWeek.Wednesday) |
|
|
|
{ |
|
|
|
appointScheduleDateDto.IsFull = 'Y'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return appointScheduleDateDtos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|