diff --git a/src/Shentun.Peis.Application.Contracts/Diagnosises/DiagnosisInSuggestionDto.cs b/src/Shentun.Peis.Application.Contracts/Diagnosises/DiagnosisInSuggestionDto.cs new file mode 100644 index 00000000..e444e3d4 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/Diagnosises/DiagnosisInSuggestionDto.cs @@ -0,0 +1,14 @@ +using Shentun.Peis.SuggestionDtos; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.Diagnosises +{ + public class DiagnosisInSuggestionDto:DiagnosisDto + { + public List Suggestions { get; set; } + } + + +} diff --git a/src/Shentun.Peis.Application.Contracts/Diagnosises/DiagnosisInSuggestionRequestDto.cs b/src/Shentun.Peis.Application.Contracts/Diagnosises/DiagnosisInSuggestionRequestDto.cs new file mode 100644 index 00000000..9cc7b21b --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/Diagnosises/DiagnosisInSuggestionRequestDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.Diagnosises +{ + public class DiagnosisInSuggestionRequestDto + { + /// + /// 诊断名称 + /// + public string? DiagnosisName { get; set; } + + /// + /// 项目类别 + /// + public Guid? ItemTypeId { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/SuggestionDtos/SuggestionDto.cs b/src/Shentun.Peis.Application.Contracts/SuggestionDtos/SuggestionDto.cs new file mode 100644 index 00000000..13780f2b --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/SuggestionDtos/SuggestionDto.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace Shentun.Peis.SuggestionDtos +{ + public class SuggestionDto: AuditedEntityDtoName + { + /// + /// 诊断ID + /// + public Guid DiagnosisId { get; set; } + /// + /// 建议内容 + /// + public string SuggestionContent { get; set; } = null!; + + public int DisplayOrder { get; set; } + + } +} diff --git a/src/Shentun.Peis.Application.Contracts/SumDiagnosises/GetSumDiagnosisListInPatientRegisterIdDto.cs b/src/Shentun.Peis.Application.Contracts/SumDiagnosises/GetSumDiagnosisListInPatientRegisterIdDto.cs new file mode 100644 index 00000000..3092e924 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/SumDiagnosises/GetSumDiagnosisListInPatientRegisterIdDto.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace Shentun.Peis.SumDiagnosises +{ + public class GetSumDiagnosisListInPatientRegisterIdDto: SumDiagnosisDto + { + + /// + /// 诊断名称 + /// + public string DiagnosisName { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/SumDiagnosises/SumDiagnosisDto.cs b/src/Shentun.Peis.Application.Contracts/SumDiagnosises/SumDiagnosisDto.cs new file mode 100644 index 00000000..ca64d8c3 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/SumDiagnosises/SumDiagnosisDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Text; + +namespace Shentun.Peis.SumDiagnosises +{ + public class SumDiagnosisDto + { + /// + /// 病人登记ID + /// + public Guid PatientRegisterId { get; set; } + /// + /// 诊断ID + /// + [Key] + public Guid DiagnosisId { get; set; } + /// + /// 建议头ID + /// + public Guid SumSuggestionHeaderId { get; set; } + + public int DisplayOrder { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/CreateSumSuggestionHeaderOrContentDto.cs b/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/CreateSumSuggestionHeaderOrContentDto.cs index 79d69b56..bc356d9c 100644 --- a/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/CreateSumSuggestionHeaderOrContentDto.cs +++ b/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/CreateSumSuggestionHeaderOrContentDto.cs @@ -17,6 +17,8 @@ namespace Shentun.Peis.SumSuggestionHeaders /// public string SuggestionTitle { get; set; } + public Guid? DiagnosisId { get; set; } + public List Details { get; set; } } } diff --git a/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionHeaderOrContentDto.cs b/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionHeaderOrContentDto.cs index 8267d1cc..3d8e2442 100644 --- a/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionHeaderOrContentDto.cs +++ b/src/Shentun.Peis.Application.Contracts/SumSuggestionHeaders/SumSuggestionHeaderOrContentDto.cs @@ -2,6 +2,8 @@ using Shentun.Peis.SumSummaryContents; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; using System.Text; namespace Shentun.Peis.SumSuggestionHeaders @@ -31,5 +33,10 @@ namespace Shentun.Peis.SumSuggestionHeaders public int DisplayOrder { get; set; } public List Details { get; set; } + + + + } + } diff --git a/src/Shentun.Peis.Application/Diagnosises/DiagnosisAppService.cs b/src/Shentun.Peis.Application/Diagnosises/DiagnosisAppService.cs index ced1f755..29514186 100644 --- a/src/Shentun.Peis.Application/Diagnosises/DiagnosisAppService.cs +++ b/src/Shentun.Peis.Application/Diagnosises/DiagnosisAppService.cs @@ -1,11 +1,13 @@ using AutoMapper.Internal.Mappers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Shentun.Peis.Diagnosises; using Shentun.Peis.GuidTypes; using Shentun.Peis.HelperDto; using Shentun.Peis.Items; using Shentun.Peis.Models; +using Shentun.Peis.SuggestionDtos; using System; using System.Collections.Generic; using System.Linq; @@ -32,14 +34,17 @@ namespace Shentun.Peis.Diagnosises CreateDiagnosisDto, UpdateDiagnosisDto> { + private readonly IRepository _suggestionRepository; private readonly IRepository _userRepository; private readonly DiagnosisManager _manager; public DiagnosisAppService( IRepository repository, + IRepository suggestionRepository, IRepository userRepository, DiagnosisManager manager) : base(repository) { + this._suggestionRepository = suggestionRepository; this._userRepository = userRepository; _manager = manager; } @@ -62,83 +67,144 @@ namespace Shentun.Peis.Diagnosises } /// - /// 获取列表 诊断 + /// 获取列表 诊断 可以按项目类别搜 两个接口组合到一起 /// /// /// - [HttpPost("api/app/diagnosis/GetListAsync")] - public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + [HttpPost("api/app/diagnosis/getlistinsuggestion")] + public async Task> GetListInSuggestionAsync(DiagnosisInSuggestionRequestDto input) { - return await base.GetListAsync(input); - - } + var query = from a in await Repository.GetQueryableAsync() + join b in await _suggestionRepository.GetQueryableAsync() on a.Id equals b.DiagnosisId into bb + from ab in bb.DefaultIfEmpty() + join c in await _userRepository.GetQueryableAsync() on a.CreatorId equals c.Id into cc + from ac in cc.DefaultIfEmpty() + join d in await _userRepository.GetQueryableAsync() on a.LastModifierId equals d.Id into dd + from ad in dd.DefaultIfEmpty() + join e in await _userRepository.GetQueryableAsync() on ab.CreatorId equals e.Id into ee + from ae in ee.DefaultIfEmpty() + join f in await _userRepository.GetQueryableAsync() on ab.LastModifierId equals f.Id into ff + from af in ff.DefaultIfEmpty() + select new { a, ab, ac, ad, ae, af }; + if (input.ItemTypeId != null) + { + query = query.Where(m => m.a.ItemTypeId == input.ItemTypeId); + } - /// - /// 获取列表 根据项目类别获取 - /// - /// - /// - public async Task> GetListInItemTypeAsync(Guid ItemTypeId) - { - var entlist = await Repository.GetListAsync(m => m.ItemTypeId == ItemTypeId); + if (!string.IsNullOrEmpty(input.DiagnosisName)) + { + query = query.Where(m => m.a.DisplayName == input.DiagnosisName); + } - var userList = await _userRepository.GetListAsync(); - var entdto = entlist.Select(s => new DiagnosisDto + var entlist = query.GroupBy(g => g.a.Id).Select(s => new DiagnosisInSuggestionDto { - CreationTime = s.CreationTime, - CreatorId = s.CreatorId, - DisplayName = s.DisplayName, - DisplayOrder = s.DisplayOrder, - Id = s.Id, - LastModificationTime = s.LastModificationTime, - LastModifierId = s.LastModifierId, - SimpleCode = s.SimpleCode, - CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), - LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) - }).ToList(); - - return entdto; + CreationTime = s.FirstOrDefault().a.CreationTime, + CreatorId = s.FirstOrDefault().a.CreatorId, + DisplayName = s.FirstOrDefault().a.DisplayName, + DisplayOrder = s.FirstOrDefault().a.DisplayOrder, + Id = s.FirstOrDefault().a.Id, + LastModificationTime = s.FirstOrDefault().a.LastModificationTime, + LastModifierId = s.FirstOrDefault().a.LastModifierId, + SimpleCode = s.FirstOrDefault().a.SimpleCode, + CreatorName = s.FirstOrDefault().ac != null ? s.FirstOrDefault().ac.UserName : "", + LastModifierName = s.FirstOrDefault().ad != null ? s.FirstOrDefault().ad.UserName : "", + DiagnosisLevelId = s.FirstOrDefault().a.DiagnosisLevelId, + ForSexId = s.FirstOrDefault().a.ForSexId, + IsIll = s.FirstOrDefault().a.IsIll, + IsSummaryTemplate = s.FirstOrDefault().a.IsSummaryTemplate, + ItemTypeId = s.FirstOrDefault().a.ItemTypeId, + SuggestionName = s.FirstOrDefault().a.SuggestionName, + Suggestions = s.Where(m => m.ab != null).Select(ss => new SuggestionDto + { + CreationTime = ss.ab.CreationTime, + CreatorId = ss.ab.CreatorId, + CreatorName = s.FirstOrDefault().ae != null ? s.FirstOrDefault().ae.UserName : "", + LastModifierName = s.FirstOrDefault().af != null ? s.FirstOrDefault().af.UserName : "", + DiagnosisId = ss.ab.DiagnosisId, + DisplayOrder = ss.ab.DisplayOrder, + Id = ss.ab.Id, + LastModificationTime = ss.ab.LastModificationTime, + LastModifierId = ss.ab.LastModifierId, + SuggestionContent = ss.ab.SuggestionContent + + }).OrderBy(o => o.DisplayOrder).ToList(), + + }).OrderBy(o => o.DisplayOrder).ToList(); + + + return entlist; + } - /// - /// 获取列表 诊断 带搜索 - /// - /// - /// - [HttpPost("api/app/diagnosis/getlistinfilter")] - public async Task> GetListInFilterAsync(GetListInFilterDto input) - { - int totalCount = 0; - if (!string.IsNullOrEmpty(input.Filter)) - totalCount = (await Repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).Count(); - else - totalCount = await Repository.CountAsync(); + ///// + ///// 获取列表 根据项目类别获取 + ///// + ///// + ///// + //public async Task> GetListInItemTypeAsync(Guid ItemTypeId) + //{ + // var entlist = await Repository.GetListAsync(m => m.ItemTypeId == ItemTypeId); - var entlist = await PageHelper.GetPageListInFitler(Repository, _userRepository, input); - var userList = await _userRepository.GetListAsync(); - var entdto = entlist.Select(s => new DiagnosisDto - { - CreationTime = s.CreationTime, - CreatorId = s.CreatorId, - DisplayName = s.DisplayName, - DisplayOrder = s.DisplayOrder, - Id = s.Id, - LastModificationTime = s.LastModificationTime, - LastModifierId = s.LastModifierId, - SimpleCode = s.SimpleCode, - CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), - LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) - }).ToList(); + // var userList = await _userRepository.GetListAsync(); - return new PagedResultDto(totalCount, entdto); + // var entdto = entlist.Select(s => new DiagnosisDto + // { + // CreationTime = s.CreationTime, + // CreatorId = s.CreatorId, + // DisplayName = s.DisplayName, + // DisplayOrder = s.DisplayOrder, + // Id = s.Id, + // LastModificationTime = s.LastModificationTime, + // LastModifierId = s.LastModifierId, + // SimpleCode = s.SimpleCode, + // CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), + // LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) + // }).ToList(); + // return entdto; + //} - } + ///// + ///// 获取列表 诊断 带搜索 + ///// + ///// + ///// + //[HttpPost("api/app/diagnosis/getlistinfilter")] + //public async Task> GetListInFilterAsync(GetListInFilterDto input) + //{ + // int totalCount = 0; + + // if (!string.IsNullOrEmpty(input.Filter)) + // totalCount = (await Repository.GetListAsync()).Where(m => m.DisplayName.Contains(input.Filter)).Count(); + // else + // totalCount = await Repository.CountAsync(); + + + // var entlist = await PageHelper.GetPageListInFitler(Repository, _userRepository, input); + // var userList = await _userRepository.GetListAsync(); + // var entdto = entlist.Select(s => new DiagnosisDto + // { + // CreationTime = s.CreationTime, + // CreatorId = s.CreatorId, + // DisplayName = s.DisplayName, + // DisplayOrder = s.DisplayOrder, + // Id = s.Id, + // LastModificationTime = s.LastModificationTime, + // LastModifierId = s.LastModifierId, + // SimpleCode = s.SimpleCode, + // CreatorName = EntityHelper.GetUserNameNoSql(userList, s.CreatorId), + // LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.LastModifierId) + // }).ToList(); + + // return new PagedResultDto(totalCount, entdto); + + + //} /// /// 创建 diff --git a/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs b/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs index fc224cca..4660382f 100644 --- a/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs +++ b/src/Shentun.Peis.Application/ItemTypes/ItemTypeAppService.cs @@ -115,8 +115,54 @@ namespace Shentun.Peis.ItemTypes return GetTree(items.ToList(), 0, ""); } + + /// + /// 获取项目类别树型结构 根据ID 只获取上级数据,不包含下级数据 + /// + /// 当前项目类别ID + /// + [HttpGet("api/app/itemtype/getbycodeparent")] + public async Task> GetByCodeParentAsync(Guid ItemTypeId) + { + var dataList = await Repository.GetListAsync(); + var items = from p in dataList + select new TreeChildViewDto() + { + Id = p.Id, + ParentId = p.ParentId, + Code = p.PathCode, + DisplayName = p.DisplayName + }; + return GetTreeParent(items.ToList(), 0, "", ItemTypeId); + } + #region 私有方法 + /// + /// 使用Code进行递归 + /// + /// + /// + /// + /// + /// + private List GetTreeParent(List items, int deep, string prefix, Guid ItemTypeId) + { + return (from p in items + where p.Code.StartsWith(prefix) && p.Code.Count(a => a == '.') == deep && p.Id != ItemTypeId + let subs = GetTreeParent(items, deep + 1, p.Code, ItemTypeId) + select new TreeChildViewDto() + { + Id = p.Id, + ParentId = p.ParentId, + Code = p.Code, + DisplayName = p.DisplayName, + TreeChildren = subs.ToList() + } + ).ToList(); + } + + /// /// 使用Code进行递归 /// diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index 41dab3f9..a531a9d2 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -1,6 +1,8 @@ -using Microsoft.AspNetCore.Authorization; +using Castle.Core.Logging; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Shentun.Peis.CommonCharTypes; using Shentun.Peis.CustomerOrgRegisters; using Shentun.Peis.CustomerOrgs; @@ -33,7 +35,7 @@ namespace Shentun.Peis.PatientRegisters /// 人员体检登记 /// [ApiExplorerSettings(GroupName = "Work")] - [Authorize] + //[Authorize] public class PatientRegisterAppService : CrudAppService< PatientRegister, //The Book entity PatientRegisterDto, //Used to show books @@ -61,6 +63,7 @@ namespace Shentun.Peis.PatientRegisters private readonly IRepository _registerCheckItemRepository; private readonly IRepository _itemRepository; private readonly IPatientRegisterChargeRepository _patientRegisterChargeRepository; + private readonly ILogger _logger; private readonly CustomerOrgManager _customerOrgManager; private readonly CustomerOrgRegisterManager _customerOrgRegisterManager; private readonly PatientManager _patientManager; @@ -94,6 +97,7 @@ namespace Shentun.Peis.PatientRegisters //IRepository customerOrgRepository, //IRepository primarykeyBuilderRepository, IPatientRegisterChargeRepository patientRegisterChargeRepository, + ILogger logger, CustomerOrgManager customerOrgManager, CustomerOrgRegisterManager customerOrgRegisterManager, PatientManager patientManager, @@ -121,6 +125,7 @@ namespace Shentun.Peis.PatientRegisters this._registerCheckItemRepository = registerCheckItemRepository; this._itemRepository = itemRepository; this._patientRegisterChargeRepository = patientRegisterChargeRepository; + this._logger = logger; this._customerOrgManager = customerOrgManager; this._customerOrgRegisterManager = customerOrgRegisterManager; this._patientManager = patientManager; @@ -590,10 +595,12 @@ namespace Shentun.Peis.PatientRegisters /// public string UpLoadImg(UpdatePhotoDto input) { - string imgurl = "UpLoad/" + input.PatientRegisterId + ".png"; + //_logger.LogInformation(input.Photo); + + string imgurl = "UpLoad/" + input.PatientRegisterId; var isupload = ImageHelper.Base64StrToImage(input.Photo, imgurl); - if (isupload) - return imgurl; + if (!string.IsNullOrEmpty(isupload)) + return isupload; else return ""; } diff --git a/src/Shentun.Peis.Application/SumDiagnosises/SumDiagnosisAppService.cs b/src/Shentun.Peis.Application/SumDiagnosises/SumDiagnosisAppService.cs new file mode 100644 index 00000000..4837fcd1 --- /dev/null +++ b/src/Shentun.Peis.Application/SumDiagnosises/SumDiagnosisAppService.cs @@ -0,0 +1,63 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Shentun.Peis.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace Shentun.Peis.SumDiagnosises +{ + /// + /// 总检诊断 + /// + [ApiExplorerSettings(GroupName = "Work")] + [Authorize] + public class SumDiagnosisAppService : ApplicationService + { + private readonly IRepository _diagnosisRepository; + private readonly IRepository _sumDiagnosisRepository; + + public SumDiagnosisAppService( + IRepository diagnosisRepository, + IRepository sumDiagnosisRepository + ) + { + this._diagnosisRepository = diagnosisRepository; + this._sumDiagnosisRepository = sumDiagnosisRepository; + } + + /// + /// 总检诊断列表查询接口 + /// + /// 体检人员ID + /// + [HttpGet("api/app/sumdiagnosis/getsumdiagnosislistinpatientregisterid")] + public async Task> GetSumDiagnosisListInPatientRegisterIdAsync(Guid PatientRegisterId) + { + var query = from a in await _sumDiagnosisRepository.GetQueryableAsync() + join b in await _diagnosisRepository.GetQueryableAsync() on a.DiagnosisId equals b.Id into bb + from ab in bb.DefaultIfEmpty() + where (a.PatientRegisterId == PatientRegisterId) + select new + { + a, + DiagnosisName = ab.DisplayName + }; + + var entlist = query.Select(s => new GetSumDiagnosisListInPatientRegisterIdDto + { + DiagnosisName = s.DiagnosisName, + DiagnosisId = s.a.DiagnosisId, + DisplayOrder = s.a.DisplayOrder, + PatientRegisterId = s.a.PatientRegisterId, + SumSuggestionHeaderId = s.a.SumSuggestionHeaderId + }).OrderBy(o => o.DisplayOrder).ToList(); + + return entlist; + } + } +} diff --git a/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs b/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs index d68c75c7..9e358292 100644 --- a/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs +++ b/src/Shentun.Peis.Application/SumSuggestionHeaders/SumSuggestionHeaderAppService.cs @@ -26,16 +26,19 @@ namespace Shentun.Peis.SumSuggestionHeaders private readonly IRepository _sumSuggestionHeaderRepository; private readonly IRepository _sumSuggestionContentRepository; private readonly IRepository _registerCheckRepository; + private readonly IRepository _sumDiagnosisRepository; public SumSuggestionHeaderAppService( IRepository sumSuggestionHeaderRepository, IRepository sumSuggestionContentRepository, - IRepository registerCheckRepository + IRepository registerCheckRepository, + IRepository sumDiagnosisRepository ) { this._sumSuggestionHeaderRepository = sumSuggestionHeaderRepository; this._sumSuggestionContentRepository = sumSuggestionContentRepository; this._registerCheckRepository = registerCheckRepository; + this._sumDiagnosisRepository = sumDiagnosisRepository; } @@ -68,7 +71,7 @@ namespace Shentun.Peis.SumSuggestionHeaders DisplayOrder = sa.DisplayOrder, SuggestionContent = sa.SuggestionContent, SumSuggestionHeaderId = sa.SumSuggestionHeaderId - }).OrderBy(o => o.DisplayOrder).ToList() + }).OrderBy(o => o.DisplayOrder).ToList(), }).OrderBy(o => o.DisplayOrder).ToList(); } else @@ -87,7 +90,7 @@ namespace Shentun.Peis.SumSuggestionHeaders msg = checklist.Select(s => new SumSuggestionHeaderOrContentDto { Id = s.Id, - SuggestionTitle =string.Join(",",s.RegisterAsbitems.Select(rs=>rs.Asbitem.DisplayName).ToList()), + SuggestionTitle = string.Join(",", s.RegisterAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()), SuggestionFlag = null, PatientRegisterId = s.RegisterAsbitems.FirstOrDefault().PatientRegisterId, DisplayOrder = 0, @@ -136,6 +139,23 @@ namespace Shentun.Peis.SumSuggestionHeaders if (sumSuggestionHeaderEnt_New != null) { + + #region 插入SumDiagnosis + if (item.DiagnosisId != null && item.DiagnosisId != Guid.Empty) + { + + SumDiagnosis sumDiagnosis = new SumDiagnosis + { + DiagnosisId = item.DiagnosisId.Value, + DisplayOrder = input.IndexOf(item) + 1, + PatientRegisterId = item.PatientRegisterId, + SumSuggestionHeaderId = sumSuggestionHeaderEnt_New.Id + }; + + await _sumDiagnosisRepository.InsertAsync(sumDiagnosis); + } + #endregion + #region 插入SumSuggestionContent List sumSuggestionContentList = new List(); foreach (var item2 in item.Details) diff --git a/src/Shentun.Peis.Domain/ImageHelper.cs b/src/Shentun.Peis.Domain/ImageHelper.cs index 18a7222f..8588ad84 100644 --- a/src/Shentun.Peis.Domain/ImageHelper.cs +++ b/src/Shentun.Peis.Domain/ImageHelper.cs @@ -22,9 +22,9 @@ namespace Shentun.Peis /// base64字符串 /// 图片保存地址,如:/Content/Images/10000.png /// - public static bool Base64StrToImage(string base64Str, string savePath) + public static string Base64StrToImage(string base64Str, string savePath) { - var ret = true; + var ret = ""; try { @@ -32,8 +32,21 @@ namespace Shentun.Peis if (bitmap != null) { + string ImageSuffix = ""; + if (ImageFormat.Png.Guid == bitmap.RawFormat.Guid) + { + ImageSuffix = ".png"; + } + else if (ImageFormat.Gif.Guid == bitmap.RawFormat.Guid) + { + ImageSuffix = ".gif"; + } + else + { + ImageSuffix = ".jpg"; + } - + savePath = savePath + ImageSuffix; //创建文件夹 var folderPath = savePath.Substring(0, savePath.LastIndexOf('/')); @@ -64,15 +77,17 @@ namespace Shentun.Peis bmpNew.Dispose(); bitmap.Dispose(); + + ret = savePath; } else { - ret = false; + ret = ""; } } catch (Exception ex) { - ret = false; + ret = ""; } return ret; diff --git a/src/Shentun.Peis.Domain/Suggestions/Suggestion.cs b/src/Shentun.Peis.Domain/Suggestions/Suggestion.cs index 1b0b82b4..dd3b4d82 100644 --- a/src/Shentun.Peis.Domain/Suggestions/Suggestion.cs +++ b/src/Shentun.Peis.Domain/Suggestions/Suggestion.cs @@ -13,14 +13,14 @@ namespace Shentun.Peis.Models /// [Table("suggestion")] [Index(nameof(DiagnosisId), nameof(SuggestionContent), Name = "ix_suggestion", IsUnique = true)] - public class Suggestion: AuditedEntity, IHasConcurrencyStamp + public class Suggestion : AuditedEntity, IHasConcurrencyStamp { - /// - /// 诊断ID - /// + /// + /// 诊断ID + /// [Column("diagnosis_id")] //[StringLength(8)] - public Guid DiagnosisId { get; set; } + public Guid DiagnosisId { get; set; } /// /// 建议内容 /// diff --git a/src/Shentun.Peis.HttpApi.Host/Filter/ErrorHandlingMiddleware.cs b/src/Shentun.Peis.HttpApi.Host/Filter/ErrorHandlingMiddleware.cs new file mode 100644 index 00000000..581b7f6c --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Filter/ErrorHandlingMiddleware.cs @@ -0,0 +1,84 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Newtonsoft.Json; +using Shentun.WebApi.Service; +using System; +using System.Threading.Tasks; +using TencentCloud.Bpaas.V20181217.Models; + +namespace Shentun.Peis.Filter +{ + public class ErrorHandlingMiddleware + { + private readonly RequestDelegate next; + + public ErrorHandlingMiddleware(RequestDelegate next) + { + this.next = next; + } + + public async Task Invoke(HttpContext context) + { + try + { + await next(context); + } + catch (Exception ex) + { + var statusCode = context.Response.StatusCode; + if (ex is ArgumentException) + { + statusCode = 200; + } + await HandleExceptionAsync(context, statusCode, ex.Message); + } + finally + { + var statusCode = context.Response.StatusCode; + var msg = ""; + if (statusCode == 401) + { + msg = "未授权"; + } + else if (statusCode == 404) + { + msg = "未找到服务"; + } + + else if (statusCode == 400) + { + msg = "Token失效"; + } + else if (statusCode == 502) + { + msg = "请求错误"; + } + //else if (statusCode != 200) + //{ + // msg = "未知错误"; + //} + if (!string.IsNullOrWhiteSpace(msg)) + { + await HandleExceptionAsync(context, statusCode, msg); + } + } + } + //异常错误信息捕获,将错误信息用Json方式返回 + private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg) + { + var result = JsonConvert.SerializeObject(ReturnValue.CreateErrorInstance(msg)); + context.Response.StatusCode = 200; + context.Response.ContentType = "application/json;charset=utf-8"; + return context.Response.WriteAsync(result); + } + } + //扩展方法 + public static class ErrorHandlingExtensions + { + public static IApplicationBuilder UseErrorHandling(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } + } + +} diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 4b008e0a..b5131648 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -50,6 +50,7 @@ using static IdentityModel.ClaimComparer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Http; +using Shentun.Peis.Filter; namespace Shentun.Peis; [DependsOn( @@ -361,8 +362,8 @@ public class PeisHttpApiHostModule : AbpModule var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); - - //app.UseErrorHandling(); + //请求错误提示配置 + app.UseErrorHandling(); if (env.IsDevelopment()) { @@ -402,6 +403,9 @@ public class PeisHttpApiHostModule : AbpModule app.UseRouting(); app.UseCors(); + + + app.UseAuthentication(); app.UseAbpOpenIddictValidation(); diff --git a/src/Shentun.Peis.HttpApi.Host/UpLoad/3a0d9430-4a1f-e05d-7ef6-a34cca06519f.jpg b/src/Shentun.Peis.HttpApi.Host/UpLoad/3a0d9430-4a1f-e05d-7ef6-a34cca06519f.jpg new file mode 100644 index 00000000..8b15b4e4 Binary files /dev/null and b/src/Shentun.Peis.HttpApi.Host/UpLoad/3a0d9430-4a1f-e05d-7ef6-a34cca06519f.jpg differ diff --git a/src/Shentun.Peis.HttpApi.Host/UpLoad/3a0d9430-4a1f-e05d-7ef6-a34cca06519f.png b/src/Shentun.Peis.HttpApi.Host/UpLoad/3a0d9430-4a1f-e05d-7ef6-a34cca06519f.png new file mode 100644 index 00000000..b2deb02f Binary files /dev/null and b/src/Shentun.Peis.HttpApi.Host/UpLoad/3a0d9430-4a1f-e05d-7ef6-a34cca06519f.png differ