diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index 7dfaa46..2fe4e0d 100644 --- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Shentun.WebPeis.AppointRegisterAsbitems; +using Shentun.WebPeis.AppointScheduleTimes; using Shentun.WebPeis.CustomerOrgs; using Shentun.WebPeis.Enums; using Shentun.WebPeis.MedicalPackages; @@ -66,6 +67,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters private readonly IRepository _questionAnswerAsbitemRepository; private readonly SysParmValueManager _sysParmValueManager; private readonly PersonManager _personManager; + private readonly AppointScheduleTimeManager _appointScheduleTimeManager; public AppointPatientRegisterAppService(IRepository repository, CacheService cacheService, IRepository itemTypeRepository, @@ -97,8 +99,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters IRepository questionAnswerRiskLevelRepository, IRepository questionAnswerAsbitemRepository, SysParmValueManager sysParmValueManager, - PersonManager personManager - + PersonManager personManager, + AppointScheduleTimeManager appointScheduleTimeManager ) { _repository = repository; @@ -133,8 +135,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters _questionAnswerAsbitemRepository = questionAnswerAsbitemRepository; _personManager = personManager; _sysParmValueManager = sysParmValueManager; - - + _appointScheduleTimeManager = appointScheduleTimeManager; } /// /// 创建预约,小程序使用 @@ -167,6 +168,10 @@ namespace Shentun.WebPeis.AppointPatientRegisters entity = await _appointPatientRegisterManager.CreateAsync(entity); await _repository.InsertAsync(entity); + + //修改预约数量 + await _appointScheduleTimeManager.UpdateAppointNumberAsync(input.AppointDate); + var result = ObjectMapper.Map(entity); return result; } @@ -540,7 +545,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.PreRegistration || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Registration) && patientRegister.CustomerOrgId != GuidFlag.PersonCustomerOrgId && - patientRegister.MedicalStartDate >= DateTime.Now.Date.AddDays(-365) + patientRegister.MedicalStartDate >= DateTime.Now.Date.AddDays(-365) orderby patientRegister.MedicalStartDate descending select new PatientRegisterDto() { diff --git a/src/Shentun.WebPeis.Domain/AppointScheduleTimes/AppointScheduleTimeManager.cs b/src/Shentun.WebPeis.Domain/AppointScheduleTimes/AppointScheduleTimeManager.cs index da422ab..67dbd47 100644 --- a/src/Shentun.WebPeis.Domain/AppointScheduleTimes/AppointScheduleTimeManager.cs +++ b/src/Shentun.WebPeis.Domain/AppointScheduleTimes/AppointScheduleTimeManager.cs @@ -4,17 +4,25 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Services; +using static log4net.Appender.RollingFileAppender; namespace Shentun.WebPeis.AppointScheduleTimes { public class AppointScheduleTimeManager : DomainService { + private readonly IRepository _appointScheduleRepository; + private readonly IRepository _appointScheduleTimeRepository; - public AppointScheduleTimeManager() + public AppointScheduleTimeManager( + IRepository appointScheduleRepository, + IRepository appointScheduleTimeRepository + ) { - + _appointScheduleRepository = appointScheduleRepository; + _appointScheduleTimeRepository = appointScheduleTimeRepository; } /// @@ -37,5 +45,25 @@ namespace Shentun.WebPeis.AppointScheduleTimes StopTime = entity.StopTime }; } + + /// + /// 修改已预约数量 + /// + /// + /// + public async Task UpdateAppointNumberAsync(DateTime AppointDate) + { + var appointScheduleEnt = await _appointScheduleRepository.FirstOrDefaultAsync(f => f.AppointDate == AppointDate.Date); + if (appointScheduleEnt != null) + { + var appointScheduleTimeEnt = await _appointScheduleTimeRepository.FirstOrDefaultAsync(f => f.StartTime == new TimeOnly(AppointDate.TimeOfDay.Hours, AppointDate.TimeOfDay.Minutes, AppointDate.TimeOfDay.Seconds)); + if (appointScheduleTimeEnt != null) + { + appointScheduleTimeEnt.AppointNumber += 1; + await _appointScheduleTimeRepository.UpdateAsync(appointScheduleTimeEnt); + } + + } + } } } diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgRegisterConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgRegisterConfigure.cs index 7a189d7..d2a205b 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgRegisterConfigure.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgRegisterConfigure.cs @@ -60,10 +60,10 @@ namespace Shentun.WebPeis.Configures .HasComment("计划号") .HasColumnName("register_no"); - entity.HasOne(d => d.CustomerOrg).WithMany(p => p.CustomerOrgRegisters) - .HasForeignKey(d => d.CustomerOrgId) - .OnDelete(DeleteBehavior.ClientSetNull) - .HasConstraintName("fk_customer_org_register"); + //entity.HasOne(d => d.CustomerOrg).WithMany(p => p.CustomerOrgRegisters) + // .HasForeignKey(d => d.CustomerOrgId) + // .OnDelete(DeleteBehavior.ClientSetNull) + // .HasConstraintName("fk_customer_org_register"); } } }