Browse Source

增加预约单位限制

master
wxd 12 months ago
parent
commit
43abf110f5
  1. 19
      src/Shentun.WebPeis.Application.Contracts/AppointScheduleExcludeCustomerOrgs/CreateAppointScheduleExcludeCustomerOrgInputDto.cs
  2. 13
      src/Shentun.WebPeis.Application.Contracts/AppointSchedules/GetAppointScheduleDateListInputDto.cs
  3. 66
      src/Shentun.WebPeis.Application/AppointScheduleExcludeCustomerOrgs/AppointScheduleExcludeCustomerOrgAppService.cs
  4. 79
      src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs
  5. 39
      src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplateExcludeCustomerOrg.cs
  6. 26
      src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointScheduleExcludeCustomerOrgConfigure.cs
  7. 2
      src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs
  8. 8161
      src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121015657_add_appoint_schedule_template_exclude_customer_org.Designer.cs
  9. 40
      src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121015657_add_appoint_schedule_template_exclude_customer_org.cs
  10. 8161
      src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121042932_update_appoint_schedule_exclude_customer_org.Designer.cs
  11. 61
      src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121042932_update_appoint_schedule_exclude_customer_org.cs
  12. 45
      src/Shentun.WebPeis.EntityFrameworkCore/Migrations/WebPeisDbContextModelSnapshot.cs
  13. 2
      test/Shentun.WebPeis.Application.Tests/AppointScheduleAppServiceTest.cs

19
src/Shentun.WebPeis.Application.Contracts/AppointScheduleExcludeCustomerOrgs/CreateAppointScheduleExcludeCustomerOrgInputDto.cs

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointScheduleExcludeCustomerOrgs
{
public class CreateAppointScheduleExcludeCustomerOrgInputDto
{
/// <summary>
/// 预约计划Id
/// </summary>
public Guid AppointScheduleId { get; set; }
/// <summary>
/// 单位ID
/// </summary>
public List<Guid> CustomerOrgIds { get; set; } = new List<Guid>();
}
}

13
src/Shentun.WebPeis.Application.Contracts/AppointSchedules/GetAppointScheduleDateListInputDto.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointSchedules
{
public class GetAppointScheduleDateListInputDto
{
public Guid? MedicalCenterId { get; set; }
public Guid? CustomerOrgId { get; set; }
}
}

66
src/Shentun.WebPeis.Application/AppointScheduleExcludeCustomerOrgs/AppointScheduleExcludeCustomerOrgAppService.cs

@ -0,0 +1,66 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.WebPeis.Models;
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;
namespace Shentun.WebPeis.AppointScheduleExcludeCustomerOrgs
{
/// <summary>
/// 设置预约日期的禁止单位
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class AppointScheduleExcludeCustomerOrgAppService : ApplicationService
{
private readonly IRepository<AppointScheduleExcludeCustomerOrg> _appointScheduleExcludeCustomerOrgRepository;
public AppointScheduleExcludeCustomerOrgAppService(
IRepository<AppointScheduleExcludeCustomerOrg> appointScheduleExcludeCustomerOrgRepository
)
{
_appointScheduleExcludeCustomerOrgRepository = appointScheduleExcludeCustomerOrgRepository;
}
/// <summary>
/// 添加、修改、删除
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/AppointScheduleExcludeCustomerOrg/Create")]
public async Task CreateAppointScheduleExcludeCustomerOrgAsync(CreateAppointScheduleExcludeCustomerOrgInputDto input)
{
if (input.AppointScheduleId == Guid.Empty)
{
throw new UserFriendlyException("预约计划ID不能为空");
}
//删除
await _appointScheduleExcludeCustomerOrgRepository.DeleteAsync(d => d.AppointScheduleId == input.AppointScheduleId);
if (input.CustomerOrgIds.Any())
{
List<AppointScheduleExcludeCustomerOrg> appointScheduleExcludeCustomerOrgs = new List<AppointScheduleExcludeCustomerOrg>();
foreach (var customerOrgId in input.CustomerOrgIds)
{
if (appointScheduleExcludeCustomerOrgs.FirstOrDefault(f => f.CustomerOrgId == customerOrgId) == null)
{
appointScheduleExcludeCustomerOrgs.Add(new AppointScheduleExcludeCustomerOrg
{
AppointScheduleExcludeCustomerOrgId = GuidGenerator.Create(),
CustomerOrgId = customerOrgId,
AppointScheduleId = input.AppointScheduleId
});
}
}
await _appointScheduleExcludeCustomerOrgRepository.InsertManyAsync(appointScheduleExcludeCustomerOrgs);
}
}
}
}

79
src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs

@ -30,6 +30,7 @@ namespace Shentun.WebPeis.AppointSchedules
private readonly AppointScheduleTimeManager _appointScheduleTimeManager;
private readonly SysParmValueManager _sysParmValueManager;
private readonly WebPeisOrganizationUnitManager _webPeisOrganizationUnitManager;
private readonly IRepository<AppointScheduleExcludeCustomerOrg> _appointScheduleExcludeCustomerOrgRepository;
public AppointScheduleAppService(IRepository<AppointSchedule> appointScheduleRepository,
CacheService cacheService,
@ -39,7 +40,8 @@ namespace Shentun.WebPeis.AppointSchedules
AppointScheduleTimeManager appointScheduleTimeManager,
SysParmValueManager sysParmValueManager,
WebPeisOrganizationUnitManager webPeisOrganizationUnitManager,
IRepository<AppointScheduleTemplateTime> appointScheduleTemplateTimeRepository)
IRepository<AppointScheduleTemplateTime> appointScheduleTemplateTimeRepository,
IRepository<AppointScheduleExcludeCustomerOrg> appointScheduleExcludeCustomerOrgRepository)
{
_appointScheduleRepository = appointScheduleRepository;
_cacheService = cacheService;
@ -50,16 +52,18 @@ namespace Shentun.WebPeis.AppointSchedules
_sysParmValueManager = sysParmValueManager;
_webPeisOrganizationUnitManager = webPeisOrganizationUnitManager;
_appointScheduleTemplateTimeRepository = appointScheduleTemplateTimeRepository;
_appointScheduleExcludeCustomerOrgRepository = appointScheduleExcludeCustomerOrgRepository;
}
/// <summary>
/// 获取预约日期列表,小程序使用
/// 获取预约日期列表,小程序使用 筛选设置了不允许预约的单位
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/AppointSchedule/GetAppointScheduleDateList")]
public async Task<List<AppointScheduleDateDto>> GetAppointScheduleDateListAsync(MedicalCenterIdInputDto input)
public async Task<List<AppointScheduleDateDto>> GetAppointScheduleDateListAsync(GetAppointScheduleDateListInputDto input)
{
Guid medicalCenterId;
if (input == null || input.MedicalCenterId == Guid.Empty || input.MedicalCenterId == null)
{
@ -92,15 +96,66 @@ namespace Shentun.WebPeis.AppointSchedules
appointScheduleTime
}
).ToList();
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 list;
List<AppointScheduleDateDto> entListDto = new List<AppointScheduleDateDto>();
var list = appointSchedules.GroupBy(o => o.appointSchedule);
//查询被禁止的单位ID
var appointScheduleExcludeCustomerOrgIds = (from appointSchedule in await _appointScheduleRepository.GetQueryableAsync()
join appointScheduleExcludeCustomerOrgRepository in await _appointScheduleExcludeCustomerOrgRepository.GetQueryableAsync()
on appointSchedule.AppointScheduleId equals appointScheduleExcludeCustomerOrgRepository.AppointScheduleId
select new
{
appointScheduleId = appointSchedule.AppointScheduleId,
customerOrgId = appointScheduleExcludeCustomerOrgRepository.CustomerOrgId
}).ToList();
foreach (var item in list)
{
bool isAdd = false;
if (input != null && input.CustomerOrgId != null)
{
if (appointScheduleExcludeCustomerOrgIds.FirstOrDefault(f => f.appointScheduleId == item.Key.AppointScheduleId
&& f.customerOrgId == input.CustomerOrgId) == null)
{
isAdd = true;
}
}
else
{
isAdd = true;
}
if (isAdd)
{
entListDto.Add(new AppointScheduleDateDto
{
AppointScheduleId = item.Key.AppointScheduleId,
AppointDate = item.Key.AppointDate,
IsWork = item.Key.IsWork,
IsFull = item.Key.AppointScheduleTimes.Sum(m => m.NumberLimit) <= item.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N'
});
}
}
//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;
}
/// <summary>

39
src/Shentun.WebPeis.Domain/Models/AppointScheduleTemplateExcludeCustomerOrg.cs

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.Domain.Entities;
using System.ComponentModel.DataAnnotations;
namespace Shentun.WebPeis.Models
{
/// <summary>
/// 预约计划模板排除的单位
/// </summary>
public class AppointScheduleExcludeCustomerOrg : AuditedEntity, IHasConcurrencyStamp
{
/// <summary>
/// 主键
/// </summary>
public Guid AppointScheduleExcludeCustomerOrgId { get; set; }
/// <summary>
/// 预约计划Id
/// </summary>
public Guid AppointScheduleId { get; set; }
/// <summary>
/// 单位ID
/// </summary>
public Guid CustomerOrgId { get; set; }
[StringLength(40)]
public string ConcurrencyStamp { get; set; }
public override object?[] GetKeys()
{
return [AppointScheduleExcludeCustomerOrgId];
}
}
}

26
src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointScheduleExcludeCustomerOrgConfigure.cs

@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Shentun.WebPeis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shentun.WebPeis.Configures
{
internal class AppointScheduleExcludeCustomerOrgConfigure : IEntityTypeConfiguration<AppointScheduleExcludeCustomerOrg>
{
public void Configure(EntityTypeBuilder<AppointScheduleExcludeCustomerOrg> entity)
{
entity.HasKey(e => e.AppointScheduleExcludeCustomerOrgId).HasName("appoint_schedule_exclude_customer_org_pkey");
entity.ToTable("appoint_schedule_exclude_customer_org");
entity.Property(e => e.AppointScheduleId).HasComment("预约计划Id");
entity.Property(e => e.CustomerOrgId).HasComment("单位ID");
}
}
}

2
src/Shentun.WebPeis.EntityFrameworkCore/EntityFrameworkCore/WebPeisDbContext.cs

@ -246,6 +246,8 @@ public partial class WebPeisDbContext : AbpDbContext<WebPeisDbContext>,
public virtual DbSet<WeChatOrder> WeChatOrders { get; set; }
public virtual DbSet<WeChatOrderRefund> WeChatOrderRefunds { get; set; }
public virtual DbSet<AppointScheduleExcludeCustomerOrg> AppointScheduleExcludeCustomerOrgs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);

8161
src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121015657_add_appoint_schedule_template_exclude_customer_org.Designer.cs
File diff suppressed because it is too large
View File

40
src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121015657_add_appoint_schedule_template_exclude_customer_org.cs

@ -0,0 +1,40 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.WebPeis.Migrations
{
/// <inheritdoc />
public partial class add_appoint_schedule_template_exclude_customer_org : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "appoint_schedule_template_exclude_customer_org",
columns: table => new
{
appoint_schedule_template_exclude_customer_org_id = table.Column<Guid>(type: "uuid", nullable: false),
appoint_schedule_template_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "预约计划模板Id"),
customer_org_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "单位ID"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
creation_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: true),
last_modification_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("appoint_schedule_template_exclude_customer_org_pkey", x => x.appoint_schedule_template_exclude_customer_org_id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "appoint_schedule_template_exclude_customer_org");
}
}
}

8161
src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121042932_update_appoint_schedule_exclude_customer_org.Designer.cs
File diff suppressed because it is too large
View File

61
src/Shentun.WebPeis.EntityFrameworkCore/Migrations/20241121042932_update_appoint_schedule_exclude_customer_org.cs

@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shentun.WebPeis.Migrations
{
/// <inheritdoc />
public partial class update_appoint_schedule_exclude_customer_org : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "appoint_schedule_template_exclude_customer_org");
migrationBuilder.CreateTable(
name: "appoint_schedule_exclude_customer_org",
columns: table => new
{
appoint_schedule_exclude_customer_org_id = table.Column<Guid>(type: "uuid", nullable: false),
appoint_schedule_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "预约计划Id"),
customer_org_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "单位ID"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
creation_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: true),
last_modification_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("appoint_schedule_exclude_customer_org_pkey", x => x.appoint_schedule_exclude_customer_org_id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "appoint_schedule_exclude_customer_org");
migrationBuilder.CreateTable(
name: "appoint_schedule_template_exclude_customer_org",
columns: table => new
{
appoint_schedule_template_exclude_customer_org_id = table.Column<Guid>(type: "uuid", nullable: false),
appoint_schedule_template_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "预约计划模板Id"),
concurrency_stamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
creation_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
creator_id = table.Column<Guid>(type: "uuid", nullable: true),
customer_org_id = table.Column<Guid>(type: "uuid", nullable: false, comment: "单位ID"),
last_modification_time = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
last_modifier_id = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("appoint_schedule_template_exclude_customer_org_pkey", x => x.appoint_schedule_template_exclude_customer_org_id);
});
}
}
}

45
src/Shentun.WebPeis.EntityFrameworkCore/Migrations/WebPeisDbContextModelSnapshot.cs

@ -364,6 +364,51 @@ namespace Shentun.WebPeis.Migrations
b.ToTable("appoint_schedule_customer_org", (string)null);
});
modelBuilder.Entity("Shentun.WebPeis.Models.AppointScheduleExcludeCustomerOrg", b =>
{
b.Property<Guid>("AppointScheduleExcludeCustomerOrgId")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("appoint_schedule_exclude_customer_org_id");
b.Property<Guid>("AppointScheduleId")
.HasColumnType("uuid")
.HasColumnName("appoint_schedule_id")
.HasComment("预约计划Id");
b.Property<string>("ConcurrencyStamp")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("character varying(40)")
.HasColumnName("concurrency_stamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("creation_time");
b.Property<Guid?>("CreatorId")
.HasColumnType("uuid")
.HasColumnName("creator_id");
b.Property<Guid>("CustomerOrgId")
.HasColumnType("uuid")
.HasColumnName("customer_org_id")
.HasComment("单位ID");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_modification_time");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uuid")
.HasColumnName("last_modifier_id");
b.HasKey("AppointScheduleExcludeCustomerOrgId")
.HasName("appoint_schedule_exclude_customer_org_pkey");
b.ToTable("appoint_schedule_exclude_customer_org", (string)null);
});
modelBuilder.Entity("Shentun.WebPeis.Models.AppointScheduleTemplate", b =>
{
b.Property<Guid>("AppointScheduleTemplateId")

2
test/Shentun.WebPeis.Application.Tests/AppointScheduleAppServiceTest.cs

@ -35,7 +35,7 @@ namespace Shentun.WebPeis
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new MedicalCenterIdInputDto()
var entity = new GetAppointScheduleDateListInputDto()
{
MedicalCenterId = new Guid("150da355-dfbf-466b-9697-355836a862c4")
};

Loading…
Cancel
Save