From e6f8da2e0cd5cab1f8287d5ce901b86f5f18c22c Mon Sep 17 00:00:00 2001 From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com> Date: Tue, 11 Jun 2024 01:58:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=92=E8=97=8F=E9=93=81=E8=B7=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Qztl/ImportPatientRegisterPlugInsQztl.cs | 126 +++++++++++------- .../ImportPatientRegisterPlugInsHzcyTest.cs | 6 +- .../ImportPatientRegisterPlugInsBase.cs | 4 +- .../CustomerOrgRegisterIdInputDto.cs | 2 +- .../Asbitems/AsbitemAppService.cs | 1 + .../CustomerOrgGroupAppService.cs | 1 + .../CustomerOrgRegisterAppService.cs | 11 ++ .../PatientRegisterAppService.cs | 8 ++ 8 files changed, 106 insertions(+), 53 deletions(-) rename src/Shentun.Peis.Application.Contracts/{CustomerOrgGroups => CustomerOrgRegisters}/CustomerOrgRegisterIdInputDto.cs (81%) diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/PatientRegisters/Qztl/ImportPatientRegisterPlugInsQztl.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/PatientRegisters/Qztl/ImportPatientRegisterPlugInsQztl.cs index 512216a..a7e2b99 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/PatientRegisters/Qztl/ImportPatientRegisterPlugInsQztl.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/PatientRegisters/Qztl/ImportPatientRegisterPlugInsQztl.cs @@ -36,6 +36,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl private CustomerOrgRegisterDto _customerOrgRegisterDto; private List _personnelTypes; private List _customerOrgGroupDtos; + private Guid _customerOrgRegisterId; private string _answerWebApiUrl; public ImportPatientRegisterPlugInsQztl(Guid thirdInterfaceId) : base(thirdInterfaceId) @@ -48,54 +49,71 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl } - public override async Task ImportAsync() + public override async Task> ImportAsync(Guid customerOrgRegisterId) { + _customerOrgRegisterId = customerOrgRegisterId; + if(_customerOrgRegisterId == Guid.Empty) + { + throw new Exception("customerOrgRegisterId参数不能为空"); + } await LoginAsync(); await InitAsync(); - + var errorList = new List(); var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync(); if (qztlPatientRegisterFromInterface == null) { - return; + return errorList; } //删除人员 - if(qztlPatientRegisterFromInterface.delIds != null) + if (qztlPatientRegisterFromInterface.delIds != null) { foreach (var deleteUserId in qztlPatientRegisterFromInterface.delIds) { - var patientRegister = await GetPatientRegisterByPlanUserId(deleteUserId); - if (patientRegister == null) + var error = deleteUserId; + try { - continue; + + var patientRegister = await GetPatientRegisterByPlanUserId(deleteUserId); + if (patientRegister == null) + { + continue; + } + if (patientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration && + patientRegister.CompleteFlag != PatientRegisterCompleteFlag.Registration) + { + //已检人员不允许删除 + continue; + } + var patientRegisterInputDto = new PatientRegisterIdInputDto() + { + PatientRegisterId = patientRegister.PatientRegisterId + }; + await CallAppServiceAsync( + "api/app/PatientRegister/DeleteById", patientRegisterInputDto); + //发送答复通知 + var succesIds = new List(); + var deleteIds = new List(); + deleteIds.Add(deleteUserId); + await AnswerOk(succesIds, deleteIds); } - if (patientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration && - patientRegister.CompleteFlag != PatientRegisterCompleteFlag.Registration) + catch (Exception ex) { - //已检人员不允许删除 + errorList.Add(error + ex.Message); continue; } - var patientRegisterInputDto = new PatientRegisterIdInputDto() - { - PatientRegisterId = patientRegister.PatientRegisterId - }; - await CallAppServiceAsync( - "api/app/PatientRegister/DeleteById", patientRegisterInputDto); - //发送答复通知 - var succesIds = new List(); - var deleteIds = new List(); - deleteIds.Add(deleteUserId); - await AnswerOk(succesIds, deleteIds); + } } - + if (qztlPatientRegisterFromInterface.plans == null) { - return; + return errorList; } //设置导入人员信息 foreach (var patient in qztlPatientRegisterFromInterface.plans) { + var error = $"姓名:{patient.personName},身份证:{patient.cardId}"; try { //婚姻状况 @@ -177,7 +195,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl _customerOrgGroupDtos = await CallAppServiceAsync>( "api/app/customer-org-group/in-customer-org-id/" + _importCustomerOrgId.ToString() , Guid.Empty, "get"); - customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); + customerOrgGroupDto = _customerOrgGroupDtos.Where(o => o.DisplayName == "复检").FirstOrDefault(); if (customerOrgGroupDto == null) { throw new Exception("没有复检这个分组"); @@ -237,7 +255,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl IsNoPlanUserIdComplete = true; } //已经登记了该PlanUserId的不再登记 - if(!string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.Planuserid == patient.id.ToString()) + if (!string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.Planuserid == patient.id.ToString()) { await AnswerOk(succesIds, deleteIds); IsNoPlanUserIdComplete = true; @@ -346,24 +364,32 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl catch (Exception ex) { - - if (ex.Message.Contains("人员信息姓名和性别和原来的信息都不一致") || - ex.Message.Contains("身份证号解析出的性别与填入的性别不一致")) - { - continue; - } - - else - { - throw ex; - } + errorList.Add(error + ",错误信息:"+ex.Message); + continue; + //throw new Exception(error + ex.Message); + //if (ex.Message.Contains("人员信息姓名和性别和原来的信息都不一致") || + // ex.Message.Contains("身份证号解析出的性别与填入的性别不一致")) + //{ + // continue; + //} + + //else + //{ + // throw ex; + //} } } + return errorList; + } public async Task InitAsync() { + if (_customerOrgRegisterId == Guid.Empty) + { + throw new Exception("customerOrgRegisterId参数不能为空"); + } var customerOrgIdStr = InterfaceConfig.GetSection("Interface").GetSection("单位编号").Value; _hospitalId = InterfaceConfig.GetSection("Interface").GetSection("HospitalId").Value; _aesKEY = InterfaceConfig.GetSection("Interface").GetSection("aesKEY").Value; @@ -372,6 +398,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl { return; } + if (!Guid.TryParse(customerOrgIdStr, out _importCustomerOrgId)) { throw new Exception("单位编号不正确"); @@ -388,20 +415,20 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl { string sql; sql = @" - SELECT id as customer_org_id, - display_name as customer_org_name, - parent_id , - path_code - from - customer_org - where id = @CustomerOrgId + SELECT customer_org.id as customer_org_id, + customer_org.display_name as customer_org_name, + customer_org.parent_id as parent_id, + customer_org.path_code as path_code + from customer_org ,customer_org_register + where customer_org.id = customer_org_register.customer_org_id and + customer_org_register.id = @CustomerOrgRegisterId "; var customerOrgForPlugInss = (await conn.QueryAsync(sql, - new { CustomerOrgId = _importCustomerOrgId })).FirstOrDefault(); + new { CustomerOrgRegisterId = _customerOrgRegisterId })).FirstOrDefault(); if (customerOrgForPlugInss == null) { - throw new Exception("单位编号不正确,找不到单位"); + throw new Exception("单位登记次数不正确,找不到单位"); } var year = customerOrgForPlugInss.CustomerOrgName.Substring( @@ -417,6 +444,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl } _year = year; + _importCustomerOrgId = customerOrgForPlugInss.CustomerOrgId; } //加载单位信息 _customerOrgDto = await CallAppServiceAsync( @@ -425,10 +453,10 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl CustomerOrgId = _importCustomerOrgId, }); //加载单位登记信息 - _customerOrgRegisterDto = await CallAppServiceAsync( - "api/app/CustomerOrgRegister/GetLastCustomerOrgRegisterByCustomerOrgId", new CustomerOrgIdInputDto() + _customerOrgRegisterDto = await CallAppServiceAsync( + "api/app/CustomerOrgRegister/GetById", new CustomerOrgRegisterIdInputDto() { - CustomerOrgId = _importCustomerOrgId, + CustomerOrgRegisterId = _customerOrgRegisterId, }); //加载人员类别列表 _personnelTypes = await CallAppServiceAsync>("api/app/PersonnelType/GetAll", ""); @@ -454,7 +482,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl } public async Task GetPatientRegisterByPlanUserId(string planUserId) { - if(string.IsNullOrWhiteSpace(planUserId)) + if (string.IsNullOrWhiteSpace(planUserId)) { throw new Exception("planUserId不能为空"); } diff --git a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsHzcyTest.cs b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsHzcyTest.cs index 0295360..aeda033 100644 --- a/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsHzcyTest.cs +++ b/ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsHzcyTest.cs @@ -27,7 +27,11 @@ namespace Shentun.Peis.PlugIns.Extensions.Test configParm = File.ReadAllText(filePath); var input = new ImportPatientRegisterPlugInsQztl(new Guid("7f2b453c-e45c-44bf-ba6b-9ef192a3cf88")); - await input.ImportAsync(); + var errorList = await input.ImportAsync(new Guid("3a126b36-b71a-e626-e8be-17d47216f927")); + foreach ( var item in errorList ) + { + _output.WriteLine(item); + } } diff --git a/src/Shentun.ColumnReferencePlugIns/PatientRegisters/ImportPatientRegisterPlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/PatientRegisters/ImportPatientRegisterPlugInsBase.cs index 4e77838..5ce8e8a 100644 --- a/src/Shentun.ColumnReferencePlugIns/PatientRegisters/ImportPatientRegisterPlugInsBase.cs +++ b/src/Shentun.ColumnReferencePlugIns/PatientRegisters/ImportPatientRegisterPlugInsBase.cs @@ -16,9 +16,9 @@ namespace Shentun.Peis.PlugIns.PatientRegisters { } - public virtual async Task ImportAsync() + public virtual async Task> ImportAsync(Guid customerOrgRegisterId) { - return; + throw new NotImplementedException(); } } } diff --git a/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CustomerOrgRegisterIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/CustomerOrgRegisters/CustomerOrgRegisterIdInputDto.cs similarity index 81% rename from src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CustomerOrgRegisterIdInputDto.cs rename to src/Shentun.Peis.Application.Contracts/CustomerOrgRegisters/CustomerOrgRegisterIdInputDto.cs index 6d1ed17..5d508c3 100644 --- a/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CustomerOrgRegisterIdInputDto.cs +++ b/src/Shentun.Peis.Application.Contracts/CustomerOrgRegisters/CustomerOrgRegisterIdInputDto.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace Shentun.Peis.CustomerOrgGroups +namespace Shentun.Peis.CustomerOrgRegisters { public class CustomerOrgRegisterIdInputDto { diff --git a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs index 9a70b97..624364d 100644 --- a/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs +++ b/src/Shentun.Peis.Application/Asbitems/AsbitemAppService.cs @@ -124,6 +124,7 @@ namespace Shentun.Peis.Asbitems DisplayName = s.a.DisplayName, DisplayOrder = s.a.DisplayOrder, ForSexId = s.a.ForSexId, + MaritalStatusId = s.a.MaritalStatusId, Id = s.a.Id, CollectItemTypeId = s.a.CollectItemTypeId, //InvoiceItemTypeId = s.a.InvoiceItemTypeId, diff --git a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs index 8747543..8276aee 100644 --- a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Shentun.Peis.CustomerOrgGroupDetails; using Shentun.Peis.CustomerOrgGroups; +using Shentun.Peis.CustomerOrgRegisters; using Shentun.Peis.CustomerOrgs; using Shentun.Peis.HelperDto; using Shentun.Peis.Models; diff --git a/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs b/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs index f5d6b4a..23ace90 100644 --- a/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgRegisters/CustomerOrgRegisterAppService.cs @@ -63,6 +63,17 @@ namespace Shentun.Peis.CustomerOrgRegisters { return await base.GetAsync(id); } + + /// + /// 获取通过主键 + /// + /// + /// + [HttpPost("api/app/CustomerOrgRegister/GetById")] + public async Task GetByIdAsync(CustomerOrgRegisterIdInputDto input) + { + return await base.GetAsync(input.CustomerOrgRegisterId); + } /// /// 获取列表 团检体检登记 遗弃 /// diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index 567fefa..865c33f 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -2517,6 +2517,14 @@ namespace Shentun.Peis.PatientRegisters await CurrentUnitOfWork.SaveChangesAsync(); } + [HttpPost("api/app/patientregister/CreatePatientRegisterFromCustomerOrgInterface")] + public async Task CreatePatientRegisterFromCustomerOrgInterfaceAsync(CustomerOrgRegisterIdInputDto input) + { + if (input == null) + { + throw new UserFriendlyException("input参数不能为空"); + } + } [HttpPost("api/app/patientregister/GetSameNamePatient")] public async Task> GetSameNamePatientAsync(GetSameNamePatientInputDto getSameNamePatientInputDto) {