|
|
@ -2,6 +2,7 @@ |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Nito.AsyncEx.Synchronous; |
|
|
using Nito.AsyncEx.Synchronous; |
|
|
using Shentun.WebPeis.AppointScheduleTimes; |
|
|
using Shentun.WebPeis.AppointScheduleTimes; |
|
|
|
|
|
using Shentun.WebPeis.CustomerOrgs; |
|
|
using Shentun.WebPeis.Models; |
|
|
using Shentun.WebPeis.Models; |
|
|
using Shentun.WebPeis.OrganizationUnits; |
|
|
using Shentun.WebPeis.OrganizationUnits; |
|
|
using Shentun.WebPeis.SysParmValues; |
|
|
using Shentun.WebPeis.SysParmValues; |
|
|
@ -31,7 +32,7 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
private readonly SysParmValueManager _sysParmValueManager; |
|
|
private readonly SysParmValueManager _sysParmValueManager; |
|
|
private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager; |
|
|
private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager; |
|
|
private readonly IRepository<AppointScheduleExcludeCustomerOrg> _appointScheduleExcludeCustomerOrgRepository; |
|
|
private readonly IRepository<AppointScheduleExcludeCustomerOrg> _appointScheduleExcludeCustomerOrgRepository; |
|
|
|
|
|
|
|
|
|
|
|
private readonly IRepository<CustomerOrg> _customerOrgRepository; |
|
|
public AppointScheduleAppService(IRepository<AppointSchedule> appointScheduleRepository, |
|
|
public AppointScheduleAppService(IRepository<AppointSchedule> appointScheduleRepository, |
|
|
CacheService cacheService, |
|
|
CacheService cacheService, |
|
|
AppointScheduleManager appointScheduleManager, |
|
|
AppointScheduleManager appointScheduleManager, |
|
|
@ -41,7 +42,8 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
SysParmValueManager sysParmValueManager, |
|
|
SysParmValueManager sysParmValueManager, |
|
|
WebPeisOrganizationUnitManager webPeisOrganizationUnitManager, |
|
|
WebPeisOrganizationUnitManager webPeisOrganizationUnitManager, |
|
|
IRepository<AppointScheduleTemplateTime> appointScheduleTemplateTimeRepository, |
|
|
IRepository<AppointScheduleTemplateTime> appointScheduleTemplateTimeRepository, |
|
|
IRepository<AppointScheduleExcludeCustomerOrg> appointScheduleExcludeCustomerOrgRepository) |
|
|
|
|
|
|
|
|
IRepository<AppointScheduleExcludeCustomerOrg> appointScheduleExcludeCustomerOrgRepository, |
|
|
|
|
|
IRepository<CustomerOrg> customerOrgRepository) |
|
|
{ |
|
|
{ |
|
|
_appointScheduleRepository = appointScheduleRepository; |
|
|
_appointScheduleRepository = appointScheduleRepository; |
|
|
_cacheService = cacheService; |
|
|
_cacheService = cacheService; |
|
|
@ -53,6 +55,7 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
_webPeisOrganizationUnitManager = webPeisOrganizationUnitManager; |
|
|
_webPeisOrganizationUnitManager = webPeisOrganizationUnitManager; |
|
|
_appointScheduleTemplateTimeRepository = appointScheduleTemplateTimeRepository; |
|
|
_appointScheduleTemplateTimeRepository = appointScheduleTemplateTimeRepository; |
|
|
_appointScheduleExcludeCustomerOrgRepository = appointScheduleExcludeCustomerOrgRepository; |
|
|
_appointScheduleExcludeCustomerOrgRepository = appointScheduleExcludeCustomerOrgRepository; |
|
|
|
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -120,8 +123,18 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
bool isAdd = false; |
|
|
bool isAdd = false; |
|
|
if (input != null && input.CustomerOrgId != null) |
|
|
if (input != null && input.CustomerOrgId != null) |
|
|
{ |
|
|
{ |
|
|
if (appointScheduleExcludeCustomerOrgIds.FirstOrDefault(f => f.appointScheduleId == item.Key.AppointScheduleId |
|
|
|
|
|
&& f.customerOrgId == input.CustomerOrgId) == null) |
|
|
|
|
|
|
|
|
List<Guid?> customerOrgIds = new List<Guid?>(); |
|
|
|
|
|
var customerOrgIdList = appointScheduleExcludeCustomerOrgIds.Where(m => m.appointScheduleId == item.Key.AppointScheduleId); |
|
|
|
|
|
if (customerOrgIdList.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var customerOrgId in customerOrgIdList) |
|
|
|
|
|
{ |
|
|
|
|
|
var customerOrgIdsTemp = await GetCustomerOrgChildrenId(input.CustomerOrgId.Value); |
|
|
|
|
|
customerOrgIds.AddRange(customerOrgIdsTemp); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!customerOrgIds.Any() || !customerOrgIds.Contains(input.CustomerOrgId)) |
|
|
{ |
|
|
{ |
|
|
isAdd = true; |
|
|
isAdd = true; |
|
|
} |
|
|
} |
|
|
@ -147,14 +160,6 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var list = appointSchedules.GroupBy(o => o.appointSchedule)
|
|
|
|
|
|
// .Select(x => new AppointScheduleDateDto()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// AppointScheduleId = x.Key.AppointScheduleId,
|
|
|
|
|
|
// AppointDate = x.Key.AppointDate,
|
|
|
|
|
|
// IsWork = x.Key.IsWork,
|
|
|
|
|
|
// IsFull = x.Key.AppointScheduleTimes.Sum(m => m.NumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N'
|
|
|
|
|
|
// }).ToList();
|
|
|
|
|
|
return entListDto; |
|
|
return entListDto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -381,5 +386,37 @@ namespace Shentun.WebPeis.AppointSchedules |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取包含子级的ID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="CustomerOrgId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async Task<List<Guid?>> GetCustomerOrgChildrenId(Guid CustomerOrgId) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var customerOrg = await _customerOrgRepository.GetAsync(g => g.CustomerOrgId == CustomerOrgId); |
|
|
|
|
|
var customerOrgEntList = await _customerOrgRepository.GetListAsync(o => o.PathCode.StartsWith(customerOrg.PathCode)); |
|
|
|
|
|
List<Guid?> CustomerOrgIds = new List<Guid?>(); |
|
|
|
|
|
|
|
|
|
|
|
GetChildren(customerOrgEntList, CustomerOrgId, CustomerOrgIds); |
|
|
|
|
|
|
|
|
|
|
|
return CustomerOrgIds; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void GetChildren(List<CustomerOrg> customerOrgEntList, Guid CustomerOrgId, List<Guid?> CustomerOrgIds) |
|
|
|
|
|
{ |
|
|
|
|
|
CustomerOrgIds.Add(CustomerOrgId); |
|
|
|
|
|
var entlist = customerOrgEntList.Where(m => m.ParentId == CustomerOrgId).ToList(); |
|
|
|
|
|
if (entlist.Count > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var ent in entlist) |
|
|
|
|
|
{ |
|
|
|
|
|
GetChildren(customerOrgEntList, ent.CustomerOrgId, CustomerOrgIds); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |