From c9b5e9e1dfed26dc7ae48135fd95d669aab5eba5 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 1 Dec 2023 10:40:26 +0800 Subject: [PATCH] 1201 --- .../Asbitems/AsbitemDto.cs | 2 +- .../Asbitems/GetAsbitemListDto.cs | 24 +++++ .../GetListInFilterDto.cs | 1 + .../CreatePatientRegisterExcelRequestDto.cs | 2 +- .../PatientRegisters/GetListInSearchDto.cs | 11 ++- .../Asbitems/AsbitemAppService.cs | 95 ++++++++++++------- .../InternalReportAppService.cs | 8 +- .../MyUser/MyUserAppService.cs | 15 +-- .../PatientRegisterAppService.cs | 60 ++++++++---- .../RegisterAsbitemAppService.cs | 2 + .../Data/CustomerAuditPropertySetter.cs | 3 + .../Data/DefaultDataSeederContributor.cs | 34 ++++--- src/Shentun.Peis.Domain/DateHelper.cs | 61 +++++++++++- .../RegisterAsbitemManager.cs | 7 ++ .../RegisterChecks/RegisterCheckManager.cs | 3 + .../EntityFrameworkCore/SnakeToCamelCase.cs | 77 +++++++++++++++ 16 files changed, 326 insertions(+), 79 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/Asbitems/GetAsbitemListDto.cs create mode 100644 src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/SnakeToCamelCase.cs diff --git a/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs b/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs index 77edd8e..1155beb 100644 --- a/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs +++ b/src/Shentun.Peis.Application.Contracts/Asbitems/AsbitemDto.cs @@ -109,7 +109,7 @@ namespace Shentun.Peis.Asbitems /// - /// 是启用 + /// 是否启用 /// public char IsActive { get; set; } diff --git a/src/Shentun.Peis.Application.Contracts/Asbitems/GetAsbitemListDto.cs b/src/Shentun.Peis.Application.Contracts/Asbitems/GetAsbitemListDto.cs new file mode 100644 index 0000000..b813ca6 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/Asbitems/GetAsbitemListDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.Asbitems +{ + public class GetAsbitemListDto + { + /// + /// 项目类别ID 非必传 + /// + public Guid? ItemTypeId { get; set; } + + /// + /// 组合项目名称(支持拼音简码) 非必传 + /// + public string? AsbitemName { get; set; } + + /// + /// 如果只显示启用的数据 传Y,其他的可以传N、null或者不传这个字段 + /// + public char IsFilterActive { get; set; } = 'N'; + } +} diff --git a/src/Shentun.Peis.Application.Contracts/GetListInFilterDto.cs b/src/Shentun.Peis.Application.Contracts/GetListInFilterDto.cs index 31d11ce..50d7b04 100644 --- a/src/Shentun.Peis.Application.Contracts/GetListInFilterDto.cs +++ b/src/Shentun.Peis.Application.Contracts/GetListInFilterDto.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Text; using Volo.Abp.Application.Dtos; diff --git a/src/Shentun.Peis.Application.Contracts/PatientRegisters/CreatePatientRegisterExcelRequestDto.cs b/src/Shentun.Peis.Application.Contracts/PatientRegisters/CreatePatientRegisterExcelRequestDto.cs index 9ca01fb..d08ee2c 100644 --- a/src/Shentun.Peis.Application.Contracts/PatientRegisters/CreatePatientRegisterExcelRequestDto.cs +++ b/src/Shentun.Peis.Application.Contracts/PatientRegisters/CreatePatientRegisterExcelRequestDto.cs @@ -42,7 +42,7 @@ namespace Shentun.Peis.PatientRegisters /// /// 单位ID /// - [Required(ErrorMessage ="单位ID不能为空")] + [Required(ErrorMessage = "单位ID不能为空")] public Guid? CustomerOrgId { get; set; } diff --git a/src/Shentun.Peis.Application.Contracts/PatientRegisters/GetListInSearchDto.cs b/src/Shentun.Peis.Application.Contracts/PatientRegisters/GetListInSearchDto.cs index e48b3ba..9e7b118 100644 --- a/src/Shentun.Peis.Application.Contracts/PatientRegisters/GetListInSearchDto.cs +++ b/src/Shentun.Peis.Application.Contracts/PatientRegisters/GetListInSearchDto.cs @@ -10,7 +10,8 @@ namespace Shentun.Peis.PatientRegisters /// /// 搜索查询参数,不筛选字段传null /// - public class GetListInSearchDto: PagedAndSortedResultRequestDto + //public class GetListInSearchDto: PagedAndSortedResultRequestDto + public class GetListInSearchDto { /// /// 单位id @@ -64,6 +65,12 @@ namespace Shentun.Peis.PatientRegisters /// public string? Phone { get; set; } - public override int MaxResultCount { get; set; } = 50; + //public override int MaxResultCount { get; set; } = 50; + + public int MaxResultCount { get; set; } = 50; + + public int SkipCount { get; set; } = 0; + + } } diff --git a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs index 41266fb..e9249c5 100644 --- a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs +++ b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs @@ -65,6 +65,7 @@ namespace Shentun.Peis.Asbitems /// /// /// + [RemoteService(false)] public async Task> GetListInFilterAsync(GetListInFilterDto input) { int totalCount = 0; @@ -110,7 +111,7 @@ namespace Shentun.Peis.Asbitems IsBeforeEat = s.IsBeforeEat, CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) - }).OrderBy(o=>o.DisplayOrder).ToList(); + }).OrderBy(o => o.DisplayOrder).ToList(); return new PagedResultDto(totalCount, entdto); @@ -120,46 +121,68 @@ namespace Shentun.Peis.Asbitems /// - /// 获取列表 根据项目类别获取 + /// 获取列表 整合多条件查询 项目类别、名字、拼音简码、是否只显示启用的数据(默认显示全部) /// - /// + /// /// - public async Task> GetListInItemTypeAsync(Guid ItemTypeId) + [HttpPost("api/app/asbitem/getasbitemlist")] + public async Task> GetAsbitemListAsync(GetAsbitemListDto input) { - var entlist = await Repository.GetListAsync(m => m.ItemTypeId == ItemTypeId); - var userList = await _userRepository.GetListAsync(); + var query = from a in await Repository.GetQueryableAsync() + join b in await _userRepository.GetQueryableAsync() on a.CreatorId equals b.Id into bb + from ab in bb.DefaultIfEmpty() + join c in await _userRepository.GetQueryableAsync() on a.LastModifierId equals c.Id into cc + from ac in cc.DefaultIfEmpty() + select new { a, ab, ac }; - var entdto = entlist.Select(s => new AsbitemDto + + if (input.ItemTypeId != null && input.ItemTypeId != Guid.Empty) { - ClinicalMeaning = s.ClinicalMeaning, - ItemTypeId = ItemTypeId, - CreationTime = s.CreationTime, - CreatorId = s.CreatorId, - DefaultResult = s.DefaultResult, - DeviceTypeId = s.DeviceTypeId, - DiagnosisFunction = s.DiagnosisFunction, - DisplayName = s.DisplayName, - DisplayOrder = s.DisplayOrder, - ForSexId = s.ForSexId, - Id = s.Id, - InvoiceItemTypeId = s.InvoiceItemTypeId, - IsActive = s.IsActive, - IsBeforeEat = s.IsBeforeEat, - IsCheck = s.IsCheck, - IsContinueProcess = s.IsContinueProcess, - IsDiagnosisFunction = s.IsDiagnosisFunction, - IsItemResultMerger = s.IsItemResultMerger, - IsPictureRotate = s.IsPictureRotate, - LastModificationTime = s.LastModificationTime, - LastModifierId = s.LastModifierId, - Price = s.Price, - QueueTime = s.QueueTime, - ShortName = s.ShortName, - SimpleCode = s.SimpleCode, - CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), - LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) - }).OrderBy(o=>o.DisplayOrder).ToList(); + query = query.Where(m => m.a.ItemTypeId == input.ItemTypeId); + } + + if (!string.IsNullOrEmpty(input.AsbitemName)) + { + query = query.Where(m => (!string.IsNullOrEmpty(m.a.DisplayName) && m.a.DisplayName.Contains(input.AsbitemName)) + || (!string.IsNullOrEmpty(m.a.SimpleCode) && m.a.SimpleCode.Contains(input.AsbitemName))); + } + + if (input.IsFilterActive == 'Y') + { + query = query.Where(m => m.a.IsActive == 'Y'); + } + + var entdto = query.Select(s => new AsbitemDto + { + ClinicalMeaning = s.a.ClinicalMeaning, + ItemTypeId = s.a.ItemTypeId, + CreationTime = s.a.CreationTime, + CreatorId = s.a.CreatorId, + DefaultResult = s.a.DefaultResult, + DeviceTypeId = s.a.DeviceTypeId, + DiagnosisFunction = s.a.DiagnosisFunction, + DisplayName = s.a.DisplayName, + DisplayOrder = s.a.DisplayOrder, + ForSexId = s.a.ForSexId, + Id = s.a.Id, + InvoiceItemTypeId = s.a.InvoiceItemTypeId, + IsActive = s.a.IsActive, + IsBeforeEat = s.a.IsBeforeEat, + IsCheck = s.a.IsCheck, + IsContinueProcess = s.a.IsContinueProcess, + IsDiagnosisFunction = s.a.IsDiagnosisFunction, + IsItemResultMerger = s.a.IsItemResultMerger, + IsPictureRotate = s.a.IsPictureRotate, + LastModificationTime = s.a.LastModificationTime, + LastModifierId = s.a.LastModifierId, + Price = s.a.Price, + QueueTime = s.a.QueueTime, + ShortName = s.a.ShortName, + SimpleCode = s.a.SimpleCode, + CreatorName = s.ab != null ? s.ab.UserName : "", + LastModifierName = s.ac != null ? s.ac.UserName : "" + }).OrderBy(o => o.DisplayOrder).ToList(); return entdto; } @@ -238,6 +261,6 @@ namespace Shentun.Peis.Asbitems } - + } } diff --git a/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs b/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs index f1ffc79..aa5de75 100644 --- a/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs +++ b/src/Shentun.Peis.Application/InternalReports/InternalReportAppService.cs @@ -99,12 +99,14 @@ namespace Shentun.Peis.InternalReports join b in await _userRepository.GetQueryableAsync() on ad.CheckDoctorId equals b.Id.ToString() into bb from ab in bb.DefaultIfEmpty() where (a.CreationTime >= Convert.ToDateTime(input.StartDate) && - a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)) + a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1) + && ad.CompleteFlag == '1' + ) select new { a, CheckDoctorId = ad.CheckDoctorId, - DoctorName = ab != null ? ab.UserName : "", + DoctorName = ab != null ? ab.UserName : ad.CheckDoctorId, AsbitemName = ac != null ? ac.DisplayName : "" }); @@ -114,7 +116,7 @@ namespace Shentun.Peis.InternalReports } - var ssd = query.ToQueryString(); + //var ssd = query.ToQueryString(); var entlistdto = query.GroupBy(g => new { g.a.AsbitemId, g.a.CreatorId, }) .Select(s => new GetDoctorPersonnelWorkLoadReportDto diff --git a/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs b/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs index e8ab97c..3ca28ad 100644 --- a/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs +++ b/src/Shentun.Peis.Application/MyUser/MyUserAppService.cs @@ -1,4 +1,5 @@ using IdentityModel.Client; +using log4net.ObjectRenderer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; @@ -141,15 +142,15 @@ namespace Shentun.Peis.MyUser var user = await _userManager.FindByIdAsync(input.UserId.ToString()); if (user != null) { - //var isPassWord = await _userManager.CheckPasswordAsync(user, input.OldPassWord); - //if (!isPassWord) - //{ - // throw new UserFriendlyException("原密码不正确"); - //} + var RemoveMsg = await _userManager.RemovePasswordAsync(user); - await _userManager.RemovePasswordAsync(user); + if (!RemoveMsg.Succeeded) + throw new UserFriendlyException($"操作失败,{RemoveMsg.Errors.FirstOrDefault().Code}"); - await _userManager.AddPasswordAsync(user, input.NewPassWord); + var AddPasswordMsg = await _userManager.AddPasswordAsync(user, input.NewPassWord); + + if (!AddPasswordMsg.Succeeded) + throw new UserFriendlyException($"操作失败,{AddPasswordMsg.Errors.FirstOrDefault().Code}"); } } diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index ece8907..12ea38e 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -1262,7 +1262,7 @@ namespace Shentun.Peis.PatientRegisters { msg = new CreatePatientRegisterExcelDto { code = -1, msg = "[数据:" + input.PatientName + "的性别不符合所选的单位分组]=>" + "导入失败" }; } - + #endregion } @@ -1337,18 +1337,34 @@ namespace Shentun.Peis.PatientRegisters Guid PatientId = Guid.Empty; short MedicalTimes = 1; - #region 解析身份证号码 - var autoCardInfo = DateHelper.AutoIDCard(input.IdNo); - if (autoCardInfo != null) + + + if (!string.IsNullOrEmpty(input.IdNo)) { - input.BirthDate = autoCardInfo.BirthDate; - SexId = autoCardInfo.SexId; - input.Age = autoCardInfo.Age; + #region 解析身份证号码 + + var autoCardInfo = DateHelper.AutoIDCard(input.IdNo); + if (autoCardInfo != null) + { + input.BirthDate = autoCardInfo.BirthDate; + SexId = autoCardInfo.SexId; + input.Age = autoCardInfo.Age; + } + #endregion + } + else if (input.BirthDate != null) + { + input.Age = DateHelper.AutoAgeInBirthday(input.BirthDate.ToString()); + } + else if (input.Age != null) + { + input.BirthDate = DateHelper.AutoBirthdayInAge(input.Age.Value); } - #endregion + + #region 生成档案信息 @@ -1572,7 +1588,7 @@ namespace Shentun.Peis.PatientRegisters .Where(m => m.CustomerOrgGroupId == CustomerOrgGroupId) .Select(s => new RegisterAsbitem { - Amount = 1, + Amount = s.Amount, AsbitemId = s.AsbitemId, ChargePrice = s.Price, GroupPackageId = CustomerOrgGroupId, @@ -1846,15 +1862,27 @@ namespace Shentun.Peis.PatientRegisters //ThirdInfo = input.ThirdInfo }; - #region 解析身份证号码 获取最新年龄 + if (!string.IsNullOrEmpty(oldPatientEntity.IdNo)) + { + #region 解析身份证号码 获取最新年龄 + var autoCardInfo = DateHelper.AutoIDCard(oldPatientEntity.IdNo); + if (autoCardInfo != null) + { + createPatientRegisterEntity.Age = autoCardInfo.Age; + createPatientRegisterEntity.SexId = autoCardInfo.SexId; + createPatientRegisterEntity.BirthDate = DateOnly.Parse(autoCardInfo.BirthDate); + } - var autoCardInfo = DateHelper.AutoIDCard(oldPatientEntity.IdNo); - if (autoCardInfo != null) + #endregion + } + else if (oldPatientRegisterEntity.BirthDate != null) { - createPatientRegisterEntity.Age = autoCardInfo.Age; + createPatientRegisterEntity.Age = DateHelper.AutoAgeInBirthday(oldPatientEntity.BirthDate.ToString()); + } + else if (oldPatientRegisterEntity.Age != null) + { + createPatientRegisterEntity.BirthDate = DateOnly.Parse(DateHelper.AutoBirthdayInAge(oldPatientRegisterEntity.Age.Value)); } - - #endregion var patientRegisterEntity_New = await _repository.InsertAsync(createPatientRegisterEntity, true); if (patientRegisterEntity_New != null) @@ -1866,7 +1894,7 @@ namespace Shentun.Peis.PatientRegisters .Where(m => m.CustomerOrgGroupId == input.CustomerOrgGroupId) .Select(s => new RegisterAsbitem { - Amount = 1, + Amount = s.Amount, AsbitemId = s.AsbitemId, ChargePrice = s.Price, GroupPackageId = input.CustomerOrgGroupId, diff --git a/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs b/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs index 89c3e92..9b24e76 100644 --- a/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs +++ b/src/Shentun.Peis.Application/RegisterAsbitems/RegisterAsbitemAppService.cs @@ -161,6 +161,7 @@ namespace Shentun.Peis.RegisterAsbitems /// /// [HttpPost("api/app/registerasbitem/delete")] + [RemoteService(false)] public async Task DeleteAsync(Guid RegisterAsbitemId) { await _registerAsbitemManager.DeleteAsync(RegisterAsbitemId); @@ -190,6 +191,7 @@ namespace Shentun.Peis.RegisterAsbitems /// /// [HttpPost("api/app/registerasbitem/update")] + [RemoteService(false)] public async Task UpdateAsync(Guid RegisterAsbitemId, UpdateRegisterAsbitemDto input) { var oldent = await _registerAsbitemRepository.GetAsync(RegisterAsbitemId); diff --git a/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs b/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs index ba149e3..1c761a1 100644 --- a/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs +++ b/src/Shentun.Peis.Domain/Data/CustomerAuditPropertySetter.cs @@ -17,6 +17,9 @@ namespace Shentun.Peis.Data //{ //} + /// + /// 生成默认ID + /// public class CustomerAuditPropertySetter : IAuditPropertySetter, ITransientDependency { protected ICurrentUser CurrentUser { get; } diff --git a/src/Shentun.Peis.Domain/Data/DefaultDataSeederContributor.cs b/src/Shentun.Peis.Domain/Data/DefaultDataSeederContributor.cs index db70c89..afc5086 100644 --- a/src/Shentun.Peis.Domain/Data/DefaultDataSeederContributor.cs +++ b/src/Shentun.Peis.Domain/Data/DefaultDataSeederContributor.cs @@ -27,7 +27,7 @@ namespace Shentun.Peis.Data { public class DefaultDataSeederContributor : IDataSeedContributor, ITransientDependency { - + private readonly IRepository _sysParmTypeRepository; private readonly IRepository _sysParmRepository; private readonly IRepository _sysParmValueRepository; @@ -77,7 +77,7 @@ namespace Shentun.Peis.Data public async Task SeedAsync(DataSeedContext context) { - + //初始化系统参数数据 await CreateSysParmAllAsync(); @@ -712,7 +712,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("指引单格式"), DisplayOrder = 1, Id = "guide_sheet_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -721,7 +722,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("检验申请单格式"), DisplayOrder = 2, Id = "lis_request_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -730,7 +732,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("检验条码格式"), DisplayOrder = 3, Id = "lis_barcode_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -739,7 +742,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("检查条码格式"), DisplayOrder = 4, Id = "check_request_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -748,7 +752,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("体检报告格式"), DisplayOrder = 5, Id = "medical_report_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -757,7 +762,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("职业病报告格式"), DisplayOrder = 6, Id = "occupational_disease_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -766,7 +772,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("Web查询体检报告格式"), DisplayOrder = 7, Id = "medical_report_web_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -775,7 +782,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("发票格式"), DisplayOrder = 8, Id = "patient_bill_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -784,7 +792,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("单位收据格式"), DisplayOrder = 9, Id = "customer_org_bill_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); sysParms.Add(new SysParm { @@ -793,7 +802,8 @@ namespace Shentun.Peis.Data SimpleCode = LanguageConverter.GetPYSimpleCode("会员卡收据格式"), DisplayOrder = 10, Id = "card_bill_print_format", - ValueType = '1' + ValueType = '1', + IsPublic = 'Y' }); #endregion diff --git a/src/Shentun.Peis.Domain/DateHelper.cs b/src/Shentun.Peis.Domain/DateHelper.cs index dd30dcf..3e7afa9 100644 --- a/src/Shentun.Peis.Domain/DateHelper.cs +++ b/src/Shentun.Peis.Domain/DateHelper.cs @@ -275,7 +275,7 @@ namespace Shentun.Peis } - + short age = 0; @@ -298,5 +298,64 @@ namespace Shentun.Peis } } + + /// + /// 出生日期转换年龄 + /// + /// 出生日期 + /// + public static short? AutoAgeInBirthday(string birthday) + { + if (!string.IsNullOrEmpty(birthday)) + { + short age; + + try + { + DateTime cvdate = Convert.ToDateTime(birthday); + if (cvdate > DateTime.Now || cvdate < new DateTime(1900, 1, 1)) + { + return null; + } + } + catch + { + return null; + } + + + DateTime dt = Convert.ToDateTime(birthday); + age = (short)(DateTime.Now.Year - dt.Year); + if (DateTime.Now.Month < dt.Month || (DateTime.Now.Month == dt.Month && DateTime.Now.Day < dt.Day)) + { + age--; + } + + + return age; + } + else + { + return null; + } + } + + + /// + /// 年龄转换出生日期 + /// + /// 年龄 + /// + public static string AutoBirthdayInAge(short age) + { + string birthday; + + DateTime now = DateTime.Now; + birthday = now.AddYears(0 - age).ToString("yyyy-MM-dd"); + + return birthday; + + } + } } diff --git a/src/Shentun.Peis.Domain/RegisterAsbitems/RegisterAsbitemManager.cs b/src/Shentun.Peis.Domain/RegisterAsbitems/RegisterAsbitemManager.cs index 9f99703..24294cc 100644 --- a/src/Shentun.Peis.Domain/RegisterAsbitems/RegisterAsbitemManager.cs +++ b/src/Shentun.Peis.Domain/RegisterAsbitems/RegisterAsbitemManager.cs @@ -96,6 +96,7 @@ namespace Shentun.Peis.RegisterAsbitems #endregion + RegisterAsbitem entity = new RegisterAsbitem @@ -166,7 +167,13 @@ namespace Shentun.Peis.RegisterAsbitems await _registerCheckItemRepository.InsertManyAsync(registerCheckItemList); } + else + { + var asbitemEntity = await _asbitemRepository.FindAsync(m => m.Id == ent.AsbitemId); + if (asbitemEntity.IsCheck == 'Y') + throw new UserFriendlyException($"{asbitemEntity.DisplayName}项目未包含明细项目"); + } #endregion } diff --git a/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs b/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs index a3c77b2..8161e50 100644 --- a/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs +++ b/src/Shentun.Peis.Domain/RegisterChecks/RegisterCheckManager.cs @@ -59,6 +59,9 @@ namespace Shentun.Peis.RegisterChecks if (registerCheckEnt != null) { registerCheckEnt.CompleteFlag = CompleteFlag; + registerCheckEnt.CheckDate = DateOnly.FromDateTime(DateTime.Now); + //记录当前操作者ID + registerCheckEnt.CheckDoctorId = _currentUser.Id.ToString(); return await _registerCheckRepository.UpdateAsync(registerCheckEnt); } else diff --git a/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/SnakeToCamelCase.cs b/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/SnakeToCamelCase.cs new file mode 100644 index 0000000..6885232 --- /dev/null +++ b/src/Shentun.Peis.EntityFrameworkCore/EntityFrameworkCore/SnakeToCamelCase.cs @@ -0,0 +1,77 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Shentun.Peis.EntityFrameworkCore +{ + public static class SnakeToCamelCase + { + //[Flags] + //public enum ConvertOptions + //{ + // All = 2 << 0, + // Tables = 2 << 1, + // Properties = 2 << 2, + // Keys = 2 << 3, + // ForeignKeys = 2 << 4, + // Indexes = 2 << 5, + //}; + //private static Regex leadingUndescoreRegex = new Regex(@"^_", RegexOptions.Compiled); + //private static Regex camelCaseRegex = new Regex(@"([a-z0-9])([A-Z])", RegexOptions.Compiled); + + //public static string ToSnakeCase(this string input) + //{ + // if (string.IsNullOrEmpty(input)) { return input; } + + // var noLeadingUndescore = leadingUndescoreRegex.Replace(input, ""); + // return camelCaseRegex.Replace(noLeadingUndescore, "$1_$2").ToLower(); + //} + + //public static void ToSnakeCase(this ModelBuilder modelBuilder, ConvertOptions options = ConvertOptions.All) + //{ + // bool convertAll = (options & ConvertOptions.All) == ConvertOptions.All; + // bool convertTables = (options & ConvertOptions.Tables) == ConvertOptions.Tables; + // bool convertProperties = (options & ConvertOptions.Properties) == ConvertOptions.Properties; + // bool convertKeys = (options & ConvertOptions.Keys) == ConvertOptions.Keys; + // bool convertForeignKeys = (options & ConvertOptions.ForeignKeys) == ConvertOptions.ForeignKeys; + // bool convertIndexes = (options & ConvertOptions.Indexes) == ConvertOptions.Indexes; + + // foreach (var entity in modelBuilder.Model.GetEntityTypes()) + // { + // if (convertAll || convertTables) + // if (entity.BaseType == null) + // entity.SetTableName(entity.GetTableName().ToSnakeCase()); + + // if (convertAll || convertProperties) + // foreach (var property in entity.GetProperties()) + // { + // property.SetColumnName(property.GetDefaultColumnName() .GetColumnName().ToSnakeCase()); + // } + + // if (convertAll || convertKeys) + // foreach (var key in entity.GetKeys()) + // { + // key.SetName(key.GetName().ToSnakeCase()); + // } + + // if (convertAll || convertForeignKeys) + // foreach (var key in entity.GetForeignKeys()) + // { + // key.SetConstraintName(key.GetConstraintName().ToSnakeCase()); + // } + + // if (convertAll || convertIndexes) + // foreach (var index in entity.GetIndexes()) + // { + + // //index.SetName(index.GetName().ToSnakeCase()); + // } + // } + //} + + } +}