From bad7efc43ca71db11670ce9a55bc86e5a142997e Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 10 May 2024 18:47:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?pacs=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientPacsInfoDto.cs | 110 ++++++++++++++++++ .../PatientPacsInfoInputDto.cs | 19 +++ .../ThirdPartyPublicInterfaceAppService.cs | 92 ++++++++++++++- .../Filter/CustomerActionFilterAttribute.cs | 50 ++++---- .../CustomerExceptionFilterAttribute.cs | 47 ++++++-- .../Filter/ThirdReturn.cs | 11 ++ 6 files changed, 291 insertions(+), 38 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoDto.cs create mode 100644 src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoInputDto.cs create mode 100644 src/Shentun.Peis.HttpApi.Host/Filter/ThirdReturn.cs diff --git a/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoDto.cs b/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoDto.cs new file mode 100644 index 0000000..4ca87a8 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoDto.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.ThirdPartyPublicInterfaces +{ + public class PatientPacsInfoDto + { + /// + /// 人员信息 + /// + public PatientPacsInfo_PatientInfoDto PatientInfo { get; set; } + + /// + /// 项目信息 + /// + public List Items { get; set; } + } + + public class PatientPacsInfo_ItemsDto + { + /// + /// 申请单号 (check_request_no+排序值) check_request_no-1 check_request_no-2 + /// + public string sqdh { get; set; } + + /// + /// 项目编号 id + /// + public string xmbh { get; set; } + + /// + /// 项目名称 + /// + public string xmmc { get; set; } + + /// + /// 检查类型 + /// + public string xmlx { get; set; } + + /// + /// 科室编码 id + /// + public string ksbm { get; set; } + + /// + /// 科室名称 + /// + public string ksmc { get; set; } + } + + public class PatientPacsInfo_PatientInfoDto + { + /// + /// 体检编号 对应check_request_no + /// + public string tjbh { get; set; } + + /// + /// 姓名 + /// + public string xm { get; set; } + + /// + /// 性别 性别代码1.男 2.女 9.未知 + /// + public string xb { get; set; } + + /// + /// 年龄 + /// + public string nl { get; set; } + + /// + /// 出生日期 (格式yyyy-MM-dd HH:mm:SS) + /// + public string csrq { get; set; } + + /// + /// 登记人 + /// + public string djr { get; set; } + + /// + /// 登记日期 (格式yyyy-MM-dd HH:mm:SS) + /// + public string djrq { get; set; } + + /// + /// 身份证号 + /// + public string sfzh { get; set; } + + /// + /// 体检日期(格式yyyy-MM-dd HH:mm:SS) + /// + public string tjrq { get; set; } + + /// + /// 联系电话 + /// + public string lxdh { get; set; } + + /// + /// 地址 + /// + public string addr { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoInputDto.cs b/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoInputDto.cs new file mode 100644 index 0000000..ace0bba --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/ThirdPartyPublicInterfaces/PatientPacsInfoInputDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.ThirdPartyPublicInterfaces +{ + public class PatientPacsInfoInputDto + { + /// + /// 体检编号 + /// + public string tjbh { get; set; } + + /// + /// 检查类型 + /// + public string xmlx { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs b/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs index 61e5d19..3aced6f 100644 --- a/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs +++ b/src/Shentun.Peis.Application/ThirdPartyPublicInterfaces/ThirdPartyPublicInterfaceAppService.cs @@ -19,7 +19,6 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces /// /// 第三方公开接口 /// - [Authorize(PeisPermissions.Third.Default)] public class ThirdPartyPublicInterfaceAppService : ApplicationService { private readonly IRepository _patientRegisterRepository; @@ -28,6 +27,8 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces private readonly IRepository _registerCheckItemRepository; private readonly IRepository _itemRepository; private readonly IRepository _itemTypeRepository; + private readonly IRepository _asbitemRepository; + private readonly IRepository _patientRepository; private readonly CacheService _cacheService; public ThirdPartyPublicInterfaceAppService( IRepository patientRegisterRepository, @@ -36,7 +37,9 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces IRepository registerCheckAsbitemRepository, IRepository registerCheckItemRepository, IRepository itemRepository, - IRepository itemTypeRepository) + IRepository itemTypeRepository, + IRepository asbitemRepository, + IRepository patientRepository) { _patientRegisterRepository = patientRegisterRepository; _cacheService = cacheService; @@ -45,6 +48,8 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces _registerCheckItemRepository = registerCheckItemRepository; _itemRepository = itemRepository; _itemTypeRepository = itemTypeRepository; + _asbitemRepository = asbitemRepository; + _patientRepository = patientRepository; } @@ -53,6 +58,7 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces /// /// /// + [Authorize(PeisPermissions.Third.Default)] [HttpPost("api/Third/ThirdPartyPublicInterface/GetBasicInformationOfMedicalExaminationPersonnel")] public async Task GetBasicInformationOfMedicalExaminationPersonnelAsync(PublicPatientRegisterNoInputDto input) { @@ -94,6 +100,7 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces /// /// /// + [Authorize(PeisPermissions.Third.Default)] [HttpPost("api/Third/ThirdPartyPublicInterface/GetPhysicalExaminationDetailsItemInformation")] public async Task> GetPhysicalExaminationDetailsItemInformationAsync(PublicPatientRegisterNoInputDto input) { @@ -138,5 +145,86 @@ namespace Shentun.Peis.ThirdPartyPublicInterfaces + + /// + /// 查询pacs条码信息 + /// + /// + /// + [HttpPost("api/Third/ThirdPartyPublicInterface/getPatientItems")] + public async Task GetPatientPacsInfoAsync(PatientPacsInfoInputDto input) + { + if (input == null) + { + throw new UserFriendlyException($"请求参数错误"); + } + + if (string.IsNullOrEmpty(input.tjbh)) + throw new UserFriendlyException($"体检编号不能为空"); + + + var query = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join patient in await _patientRepository.GetQueryableAsync() on patientRegister.PatientId equals patient.Id into patientTemp + from patientHaveEmpty in patientTemp.DefaultIfEmpty() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + join asbitem in await _asbitemRepository.GetQueryableAsync() on registerCheckAsbitem.AsbitemId equals asbitem.Id + join itemType in await _itemTypeRepository.GetQueryableAsync() on asbitem.ItemTypeId equals itemType.Id into itemTypeTemp + from itemTypeHaveEmpty in itemTypeTemp.DefaultIfEmpty() + where registerCheck.CheckRequestNo == input.tjbh + orderby asbitem.DisplayOrder ascending + select new + { + patientRegister, + IdNo = patientHaveEmpty != null ? patientHaveEmpty.IdNo : "", + MobileTelephone = patientHaveEmpty != null ? patientHaveEmpty.MobileTelephone : "", + CheckRequestNo = registerCheck.CheckRequestNo, + asbitem, + ItemTypeName = itemTypeHaveEmpty != null ? itemTypeHaveEmpty.DisplayName : "", + ItemTypeId = itemTypeHaveEmpty != null ? itemTypeHaveEmpty.Id.ToString() : "" + }).ToList(); + + + if (!string.IsNullOrEmpty(input.xmlx)) + { + //检查类型检索 + } + + if (query.Count == 0) + throw new UserFriendlyException($"体检编号不存在"); + + var patientInfo = new PatientPacsInfo_PatientInfoDto + { + addr = "", + tjbh = query.FirstOrDefault().CheckRequestNo, + csrq = query.FirstOrDefault().patientRegister.BirthDate != null ? query.FirstOrDefault().patientRegister.BirthDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", + djr = _cacheService.GetSurnameAsync(query.FirstOrDefault().patientRegister.CreatorId).Result, + djrq = query.FirstOrDefault().patientRegister.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"), + lxdh = query.FirstOrDefault().MobileTelephone, + nl = query.FirstOrDefault().patientRegister.Age.ToString(), + sfzh = query.FirstOrDefault().IdNo, + tjrq = query.FirstOrDefault().patientRegister.MedicalStartDate != null ? query.FirstOrDefault().patientRegister.MedicalStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "", + xb = query.FirstOrDefault().patientRegister.SexId == 'M' ? "1" : (query.FirstOrDefault().patientRegister.SexId == 'F' ? "2" : "9"), + xm = query.FirstOrDefault().patientRegister.PatientName + }; + + + var items = query.Select(s => new PatientPacsInfo_ItemsDto + { + ksbm = s.ItemTypeId, + ksmc = s.ItemTypeName, + sqdh = s.CheckRequestNo + "-" + (query.IndexOf(s) + 1), + xmbh = s.asbitem.Id.ToString(), + xmlx = "1", + xmmc = s.asbitem.DisplayName, + }).ToList(); + + return new PatientPacsInfoDto + { + PatientInfo = patientInfo, + Items = items + }; + } + } } diff --git a/src/Shentun.Peis.HttpApi.Host/Filter/CustomerActionFilterAttribute.cs b/src/Shentun.Peis.HttpApi.Host/Filter/CustomerActionFilterAttribute.cs index ae2ad08..7cc99d9 100644 --- a/src/Shentun.Peis.HttpApi.Host/Filter/CustomerActionFilterAttribute.cs +++ b/src/Shentun.Peis.HttpApi.Host/Filter/CustomerActionFilterAttribute.cs @@ -2,15 +2,20 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Newtonsoft.Json; +using NPOI.SS.Formula.Functions; +using OpenAI_API.Moderation; using Shentun.Peis.DiagnosisFunctions; +using Shentun.Peis.Filter; //using Microsoft.AspNetCore.Mvc; //using Microsoft.AspNetCore.Mvc.Filters; using Shentun.WebApi.Service; +using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Volo.Abp; +using static Shentun.Peis.Permissions.PeisPermissions; namespace Shentun.Peis { @@ -19,9 +24,6 @@ namespace Shentun.Peis /// public class CustomerActionFilterAttribute : ActionFilterAttribute { - - - public override void OnActionExecuted(ActionExecutedContext context) { //if (context.Result is ObjectResult objRst) @@ -55,32 +57,24 @@ namespace Shentun.Peis else { - - - List filterApiUrl = new List { "/api/app/diagnosisfunction/getdiagnosisresult" }; - - - if (!filterApiUrl.Contains(context.HttpContext.Request.Path.ToString().ToLower())) + List filterApiUrl = new List { "/api/third/thirdpartypublicinterface/getpatientitems" }; + + if (filterApiUrl.Contains(context.HttpContext.Request.Path.ToString().ToLower())) + { + ThirdReturn msg = new ThirdReturn + { + code = "200", + message = "处理成功", + data = result.Value + }; + + context.Result = new OkObjectResult(msg); + } + else { context.Result = new OkObjectResult(ReturnValue.CreateSuccessInstance(result.Value)); - - //Type type = result.Value.GetType(); - - //PropertyInfo IsTH = type.GetProperty("CustomerMessage"); - - //if (IsTH != null) - //{ - // string message = IsTH.GetValue(result.Value).ToString(); - - // //FieldInfo field = type.GetField("<" + IsTH.Name + ">k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance); // 根据属性名称生成字段名称 - // //if (field != null) - // // field.SetValue(result.Value, null); // 将字段值设置为 null,相当于删除属性 - //} - - //GetDiagnosisResultDto myObj = (GetDiagnosisResultDto)result.Value; - //context.Result = new OkObjectResult(ReturnValue.CreateCustomErrorInstance(result.Value, message)); } - + } @@ -122,14 +116,14 @@ namespace Shentun.Peis //var result = context.Result as FileContentResult; //context.Result = new OkObjectResult(result); } + //else if (context.Result == null) //{ // //全局加返回值 // context.Result = new OkObjectResult(ReturnValue.CreateErrorInstance(context.Exception.Message)); //} else - { - + { //if (context.Exception != null && !string.IsNullOrEmpty(context.Exception.Message)) //{ // context.Result = new OkObjectResult(ReturnValue.CreateErrorInstance(context.Exception.Message)); diff --git a/src/Shentun.Peis.HttpApi.Host/Filter/CustomerExceptionFilterAttribute.cs b/src/Shentun.Peis.HttpApi.Host/Filter/CustomerExceptionFilterAttribute.cs index a5181a5..542cf55 100644 --- a/src/Shentun.Peis.HttpApi.Host/Filter/CustomerExceptionFilterAttribute.cs +++ b/src/Shentun.Peis.HttpApi.Host/Filter/CustomerExceptionFilterAttribute.cs @@ -3,8 +3,10 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Shentun.Peis.Filter; using Shentun.WebApi.Service; using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Volo.Abp; @@ -77,7 +79,7 @@ namespace Shentun.Peis { errorMessage = exceptionContext.Exception.Message; } - + } else { @@ -85,14 +87,43 @@ namespace Shentun.Peis } - exceptionContext.Result = new ContentResult + List filterApiUrl = new List { "/api/third/thirdpartypublicinterface/getpatientitems" }; + + + if (filterApiUrl.Contains(exceptionContext.HttpContext.Request.Path.ToString().ToLower())) { - // 返回状态码设置为200,表示成功 - StatusCode = 200, - // 设置返回格式 - ContentType = "application/json;charset=utf-8", - Content = JsonConvert.SerializeObject(ReturnValue.CreateErrorInstance(errorMessage)) - }; + ThirdReturn msg = new ThirdReturn + { + code = "-1", + message = exceptionContext.Exception.Message, + data = null + }; + + + exceptionContext.Result = new ContentResult + { + // 返回状态码设置为200,表示成功 + StatusCode = 200, + // 设置返回格式 + ContentType = "application/json;charset=utf-8", + Content = JsonConvert.SerializeObject(msg) + }; + } + else + { + + exceptionContext.Result = new ContentResult + { + // 返回状态码设置为200,表示成功 + StatusCode = 200, + // 设置返回格式 + ContentType = "application/json;charset=utf-8", + Content = JsonConvert.SerializeObject(ReturnValue.CreateErrorInstance(errorMessage)) + }; + } + + + } // 设置为true,表示异常已经被处理了 diff --git a/src/Shentun.Peis.HttpApi.Host/Filter/ThirdReturn.cs b/src/Shentun.Peis.HttpApi.Host/Filter/ThirdReturn.cs new file mode 100644 index 0000000..56ad795 --- /dev/null +++ b/src/Shentun.Peis.HttpApi.Host/Filter/ThirdReturn.cs @@ -0,0 +1,11 @@ +namespace Shentun.Peis.Filter +{ + public class ThirdReturn + { + public string code { get; set; } + + public string message { get; set; } + + public object data { get; set; } + } +} From 70336904c8dcb9ff029836bb4d7d9e3dd0ee70b2 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 10 May 2024 19:19:50 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerOrgs/CustomerOrgDto.cs | 10 ++++++++++ .../CustomerOrgs/CustomerOrgAppService.cs | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgDto.cs b/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgDto.cs index 99193ae..0618845 100644 --- a/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgDto.cs +++ b/src/Shentun.Peis.Application.Contracts/CustomerOrgs/CustomerOrgDto.cs @@ -120,5 +120,15 @@ namespace Shentun.Peis.CustomerOrgs /// 国家组织机构代码 /// public string CountryOrgCode { get; set; } + + /// + /// 销售员 + /// + public string SalesPerson { get; set; } + + /// + /// 销售员电话 + /// + public string SalesPersonPhone { get; set; } } } diff --git a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs index 8771494..1ea8538 100644 --- a/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgs/CustomerOrgAppService.cs @@ -61,7 +61,6 @@ namespace Shentun.Peis.CustomerOrgs var entityDto = await base.GetAsync(id); entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId); entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId); - return entityDto; } /// @@ -115,6 +114,8 @@ namespace Shentun.Peis.CustomerOrgs Fax = s.Fax, InvoiceName = s.InvoiceName, IsLock = s.IsLock, + SalesPerson = s.SalesPerson, + SalesPersonPhone = s.SalesPersonPhone, MedicalCenterId = s.MedicalCenterId, CountryOrgCode = s.CountryOrgCode, CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result, From a58d7496b864c33f322c04d24faf8d4c348cbfce Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 10 May 2024 23:06:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=AE=80=E6=8B=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Shentun.Utilities/LanguageConverter.cs | 170 ++++++++++++------ .../Shentun.Utilities.csproj | 1 + .../BaseDataHandleTest.cs | 28 ++- 3 files changed, 142 insertions(+), 57 deletions(-) diff --git a/src/Shentun.Utilities/LanguageConverter.cs b/src/Shentun.Utilities/LanguageConverter.cs index 054470c..26f5604 100644 --- a/src/Shentun.Utilities/LanguageConverter.cs +++ b/src/Shentun.Utilities/LanguageConverter.cs @@ -7,83 +7,141 @@ namespace Shentun.Utilities { public class LanguageConverter { - public static string GetPYSimpleCode(string data, int len = 50) - { + //public static string GetPYSimpleCode(string data, int len = 50) + //{ - string rtnValue = ""; + // string rtnValue = ""; - if (string.IsNullOrWhiteSpace(data)) - { - return ""; - } + // if (string.IsNullOrWhiteSpace(data)) + // { + // return ""; + // } - foreach (char obj in data) - { - try - { - ChineseChar chineseChar = new ChineseChar(obj); - string t = chineseChar.Pinyins[0].ToString(); - rtnValue += t.Substring(0, 1); - } - catch - { - rtnValue += obj.ToString(); - } - } - if (len > rtnValue.Length) - { - len = rtnValue.Length; - } - rtnValue = rtnValue.Substring(0, len).ToUpper(); - return rtnValue; - } + // foreach (char obj in data) + // { + // try + // { + // ChineseChar chineseChar = new ChineseChar(obj); + // string t = chineseChar.Pinyins[0].ToString(); + // rtnValue += t.Substring(0, 1); + // } + // catch + // { + // rtnValue += obj.ToString(); + // } + // } + // if (len > rtnValue.Length) + // { + // len = rtnValue.Length; + // } + // rtnValue = rtnValue.Substring(0, len).ToUpper(); + // return rtnValue; + //} - public static string GetPYCode(string data, int len = 50) - { + //public static string GetPYCode(string data, int len = 50) + //{ - string rtnValue = ""; + // string rtnValue = ""; - if (string.IsNullOrWhiteSpace(data)) - { - return ""; - } + // if (string.IsNullOrWhiteSpace(data)) + // { + // return ""; + // } - foreach (char obj in data) + // foreach (char obj in data) + // { + // try + // { + // ChineseChar chineseChar = new ChineseChar(obj); + // string t = chineseChar.Pinyins[0].TrimEnd('1', '2', '3', '4', '5').ToUpper(); + // rtnValue += t; + // } + // catch + // { + // rtnValue += obj.ToString(); + // } + // } + // if (len > rtnValue.Length) + // { + // len = rtnValue.Length; + // } + // rtnValue = rtnValue.Substring(0, len).ToUpper(); + // return rtnValue; + //} + + //public static string GetPYCodeWithSpace(string data) + //{ + // if(string.IsNullOrWhiteSpace(data)) + // { + // return ""; + // } + // string rtnValue = ""; + // for (int i = 0; i < data.Length; i++) + // { + // rtnValue += " " + LanguageConverter.GetPYCode(data.Substring(i, 1)); + // } + // return rtnValue.Trim(); + //} + + + #region 新版 + + + /// + /// 汉字转首字母 + /// + /// + /// + public static string GetPYSimpleCode(string strChinese) + { + + try { - try + if (strChinese.Length != 0) { - ChineseChar chineseChar = new ChineseChar(obj); - string t = chineseChar.Pinyins[0].TrimEnd('1', '2', '3', '4', '5').ToUpper(); - rtnValue += t; - } - catch - { - rtnValue += obj.ToString(); + StringBuilder fullSpell = new StringBuilder(); + for (int i = 0; i < strChinese.Length; i++) + { + var chr = strChinese[i]; + fullSpell.Append(GetSpell(chr)[0]); + } + + return fullSpell.ToString().ToUpper(); } } - if (len > rtnValue.Length) + catch (Exception e) { - len = rtnValue.Length; + + Console.WriteLine("首字母转化出错!" + e.Message); } - rtnValue = rtnValue.Substring(0, len).ToUpper(); - return rtnValue; + + return string.Empty; } - public static string GetPYCodeWithSpace(string data) + private static string GetSpell(char chr) { - if(string.IsNullOrWhiteSpace(data)) - { - return ""; - } - string rtnValue = ""; - for (int i = 0; i < data.Length; i++) + var coverchr = NPinyin.Pinyin.GetPinyin(chr); + + bool isChineses = ChineseChar.IsValidChar(coverchr[0]); + if (isChineses) { - rtnValue += " " + LanguageConverter.GetPYCode(data.Substring(i, 1)); + ChineseChar chineseChar = new ChineseChar(coverchr[0]); + foreach (string value in chineseChar.Pinyins) + { + if (!string.IsNullOrEmpty(value)) + { + return value.Remove(value.Length - 1, 1); + } + } } - return rtnValue.Trim(); + + return coverchr; + } + #endregion + } } diff --git a/src/Shentun.Utilities/Shentun.Utilities.csproj b/src/Shentun.Utilities/Shentun.Utilities.csproj index ae6f8ee..c71321c 100644 --- a/src/Shentun.Utilities/Shentun.Utilities.csproj +++ b/src/Shentun.Utilities/Shentun.Utilities.csproj @@ -13,6 +13,7 @@ + diff --git a/test/Shentun.Peis.Application.Tests/BaseDataHandleTest.cs b/test/Shentun.Peis.Application.Tests/BaseDataHandleTest.cs index e9f0241..ab5bc6d 100644 --- a/test/Shentun.Peis.Application.Tests/BaseDataHandleTest.cs +++ b/test/Shentun.Peis.Application.Tests/BaseDataHandleTest.cs @@ -10,6 +10,8 @@ using Volo.Abp.Uow; using Xunit.Abstractions; using Xunit; using Shentun.Peis.DataMigrations; +using Microsoft.International.Converters.PinYinConverter; +using Shentun.Utilities; namespace Shentun.Peis { @@ -21,11 +23,17 @@ namespace Shentun.Peis private readonly ITestOutputHelper _output; private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly BaseDataHandleAppService _appService; + private readonly IRepository _asbitemRepository; + private readonly IRepository _itemRepository; + private readonly IRepository _diagnosisRepository; public BaseDataHandleTest(ITestOutputHelper testOutputHelper) { _output = testOutputHelper; _unitOfWorkManager = GetRequiredService(); _appService = GetRequiredService(); + _asbitemRepository = GetRequiredService>(); + _itemRepository = GetRequiredService>(); + _diagnosisRepository = GetRequiredService>(); } //[Fact] @@ -48,6 +56,23 @@ namespace Shentun.Peis // } // } // } + [Fact] + public async void GetPYSimpleCode() + { + using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true)) + { + var diagnosisList = await _diagnosisRepository.GetListAsync(); + foreach (var diagnosis in diagnosisList) + { + diagnosis.SimpleCode = LanguageConverter.GetPYSimpleCode(diagnosis.DisplayName); + } + + await _diagnosisRepository.UpdateManyAsync(diagnosisList); + + await unitOfWork.CompleteAsync(); + } + } + @@ -74,7 +99,7 @@ namespace Shentun.Peis // } // } // } - + //} //[Fact] @@ -103,4 +128,5 @@ namespace Shentun.Peis //} } + }