Browse Source

青藏铁路

bjmzak
DESKTOP-G961P6V\Zhh 1 year ago
parent
commit
21bcff1c48
  1. 30
      ThirdPlugIns/Shentun.Peis.PlugIns.Gem/PatientRegisters/Qztl/ImportPatientRegisterPlugInsQztl.cs
  2. 16
      ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsHzcyTest.cs
  3. 5
      src/Shentun.ColumnReferencePlugIns/PatientRegisters/ImportPatientRegisterPlugInsBase.cs
  4. 34
      src/Shentun.Peis.Application.Contracts/PatientRegisters/ImportPatientRegisterByCustomerOrgRegisterIdDto.cs
  5. 2
      src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs
  6. 55
      src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs
  7. 34
      test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs

30
ThirdPlugIns/Shentun.Peis.PlugIns.Gem/PatientRegisters/Qztl/ImportPatientRegisterPlugInsQztl.cs

@ -49,7 +49,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
}
public override async Task<List<string>> ImportPatientRegisterByCustomerOrgRegisterIdAsync(Guid customerOrgRegisterId)
public override async Task<ImportPatientRegisterByCustomerOrgRegisterIdDto> ImportPatientRegisterByCustomerOrgRegisterIdAsync(Guid customerOrgRegisterId)
{
CustomerOrgRegisterId = customerOrgRegisterId;
if(CustomerOrgRegisterId == Guid.Empty)
@ -60,9 +60,10 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
await InitAsync();
var errorList = new List<string>();
var qztlPatientRegisterFromInterface = await CallInterfaceServiceAsync();
var returnDto = new ImportPatientRegisterByCustomerOrgRegisterIdDto();
if (qztlPatientRegisterFromInterface == null)
{
return errorList;
return returnDto;
}
//删除人员
if (qztlPatientRegisterFromInterface.delIds != null)
@ -82,7 +83,8 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
patientRegister.CompleteFlag != PatientRegisterCompleteFlag.Registration)
{
//已检人员不允许删除
errorList.Add($"姓名:{patientRegister.PatientName},身份证号:{patientRegister.IdNo},已检不能删除");
returnDto.DeleteErrorNum++;
returnDto.DeleteErrorMessages.Add($"姓名:{patientRegister.PatientName},身份证号:{patientRegister.IdNo},已检不能删除");
continue;
}
var patientRegisterInputDto = new PatientRegisterIdInputDto()
@ -96,10 +98,13 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
var deleteIds = new List<string>();
deleteIds.Add(deleteUserId);
await AnswerOk(succesIds, deleteIds);
returnDto.DeleteSuccessNum++;
}
catch (Exception ex)
{
errorList.Add(error + ex.Message);
returnDto.DeleteErrorNum++;
returnDto.DeleteErrorMessages.Add(error + ex.Message);
continue;
}
@ -109,7 +114,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
if (qztlPatientRegisterFromInterface.plans == null)
{
return errorList;
return returnDto;
}
//设置导入人员信息
foreach (var patient in qztlPatientRegisterFromInterface.plans)
@ -253,13 +258,16 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
await UpdatePatientRegisterPlanUserId(patintRegister.PatientRegisterId, patient.id.ToString());
await AnswerOk(succesIds, deleteIds);
returnDto.ImportSuccessNum++;
IsNoPlanUserIdComplete = true;
continue;
}
//已经登记了该PlanUserId的不再登记
if (!string.IsNullOrWhiteSpace(patintRegister.Planuserid) && patintRegister.Planuserid == patient.id.ToString())
{
await AnswerOk(succesIds, deleteIds);
IsNoPlanUserIdComplete = true;
returnDto.ImportSuccessNum++;
}
}
if (IsNoPlanUserIdComplete)
@ -337,7 +345,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
var customerOrgGroupDetailOrAsbitemDtos = await CallAppServiceAsync<Guid, List<CustomerOrgGroupDetailOrAsbitemDto>>(
"api/app/customerorggroupdetail/getcustomerorggroupdetailinasbitem?CustomerOrgGroupId=" + customerOrgGroupDto.Id.ToString()
, Guid.Empty, "get");
if (!customerOrgGroupDetailOrAsbitemDtos.Any())
if (!customerOrgGroupDetailOrAsbitemDtos.Any() && customerOrgGroupDto.DisplayName!= "复检")
{
throw new Exception($"分组{customerOrgGroupDto.DisplayName}未包含项目");
}
@ -357,15 +365,15 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
"api/PatientRegister/CreatePatientRegister",
patientRegister);
//var succesIds = new List<string>();
//var deleteIds = new List<string>();
//succesIds.Add(patientRegister.Planuserid);
await AnswerOk(succesIds, deleteIds);
returnDto.ImportSuccessNum++;
}
catch (Exception ex)
{
errorList.Add(error + ",错误信息:"+ex.Message);
returnDto.ImportErrorNum++;
returnDto.ImportErrorMessages.Add(error + ",错误信息:" + ex.Message);
continue;
//throw new Exception(error + ex.Message);
//if (ex.Message.Contains("人员信息姓名和性别和原来的信息都不一致") ||
@ -381,7 +389,7 @@ namespace Shentun.Peis.PlugIns.Extensions.PatientRegisters.Qztl
}
}
return errorList;
return returnDto;
}

16
ThirdPlugIns/Shentun.Peis.PlugIns.Gem/test/Shentun.Peis.PlugIns.Gem.Test/ImportPatientRegisterPlugInsHzcyTest.cs

@ -27,13 +27,19 @@ namespace Shentun.Peis.PlugIns.Extensions.Test
configParm = File.ReadAllText(filePath);
var input = new ImportPatientRegisterPlugInsQztl(new Guid("7f2b453c-e45c-44bf-ba6b-9ef192a3cf88"));
var errorList = await input.ImportPatientRegisterByCustomerOrgRegisterIdAsync(new Guid("3a126b36-b71a-e626-e8be-17d47216f927"));
foreach ( var item in errorList )
var result = await input.ImportPatientRegisterByCustomerOrgRegisterIdAsync(new Guid("3a126b36-b71a-e626-e8be-17d47216f927"));
_output.WriteLine("导入成功数:" + result.ImportSuccessNum.ToString());
_output.WriteLine("导入失败数:" + result.ImportErrorNum.ToString());
_output.WriteLine("删除成功数:" + result.DeleteSuccessNum.ToString());
_output.WriteLine("删除失败数:" + result.DeleteErrorNum.ToString());
foreach(var item in result.ImportErrorMessages)
{
_output.WriteLine(item);
_output.WriteLine("导入错误:"+item.ToString());
}
foreach (var item in result.DeleteErrorMessages)
{
_output.WriteLine("删除错误:" + item.ToString());
}
}
[Fact]

5
src/Shentun.ColumnReferencePlugIns/PatientRegisters/ImportPatientRegisterPlugInsBase.cs

@ -1,4 +1,5 @@
using System;
using Shentun.Peis.PatientRegisters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -17,7 +18,7 @@ namespace Shentun.Peis.PlugIns.PatientRegisters
{
}
public virtual async Task<List<string>> ImportPatientRegisterByCustomerOrgRegisterIdAsync(Guid customerOrgRegisterId)
public virtual async Task<ImportPatientRegisterByCustomerOrgRegisterIdDto> ImportPatientRegisterByCustomerOrgRegisterIdAsync(Guid customerOrgRegisterId)
{
throw new NotImplementedException();
}

34
src/Shentun.Peis.Application.Contracts/PatientRegisters/ImportPatientRegisterByCustomerOrgRegisterIdDto.cs

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.PatientRegisters
{
public class ImportPatientRegisterByCustomerOrgRegisterIdDto
{
/// <summary>
/// 导入成功数
/// </summary>
public int ImportSuccessNum { get; set; }
/// <summary>
/// 导入错误数
/// </summary>
public int ImportErrorNum { get; set; }
/// <summary>
/// 删除成功数
/// </summary>
public int DeleteSuccessNum { get; set; }
/// <summary>
/// 删除错误数
/// </summary>
public int DeleteErrorNum { get; set; }
/// <summary>
/// 导入错误信息
/// </summary>
public List<string> ImportErrorMessages { get; set; } = new List<string>();
/// <summary>
/// 删除错误信息
/// </summary>
public List<string> DeleteErrorMessages { get; set; } = new List<string>();
}
}

2
src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs

@ -413,7 +413,7 @@ namespace Shentun.Peis.CustomerOrgGroups
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPut("api/app/CustomerOrgGroup/GetListByCustomerOrgRegisterId")]
[HttpPost("api/app/CustomerOrgGroup/GetListByCustomerOrgRegisterId")]
public async Task<List<CustomerOrgGroupDto>> GetListByCustomerOrgRegisterIdAsync(CustomerOrgRegisterIdInputDto input)
{

55
src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs

@ -9,6 +9,7 @@ using NPOI.POIFS.Properties;
using NPOI.Util;
using NUglify.Helpers;
using Org.BouncyCastle.Asn1.Ocsp;
using Shentun.Peis.AppointPatientRegisters;
using Shentun.Peis.CommonCharTypes;
using Shentun.Peis.CustomerOrgRegisters;
using Shentun.Peis.CustomerOrgs;
@ -32,7 +33,9 @@ using Shentun.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
@ -113,6 +116,8 @@ namespace Shentun.Peis.PatientRegisters
private readonly ICurrentUser _currentUser;
private readonly IRepository<UserItemType> _userItemTypeRepository;
private readonly PatientOccupationalDiseaseManager _patientOccupationalDiseaseManager;
private readonly IRepository<ThirdInterface, Guid> _thirdInterfaceRepository;
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
public PatientRegisterAppService(
IRepository<PatientRegister, Guid> repository,
IRepository<Patient, Guid> patientRepository,
@ -163,7 +168,9 @@ namespace Shentun.Peis.PatientRegisters
IConfiguration configuration,
ICurrentUser currentUser,
IRepository<UserItemType> userItemTypeRepository,
PatientOccupationalDiseaseManager patientOccupationalDiseaseManager)
PatientOccupationalDiseaseManager patientOccupationalDiseaseManager,
IRepository<ThirdInterface, Guid> thirdInterfaceRepository,
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository)
: base(repository)
{
this._repository = repository;
@ -216,6 +223,8 @@ namespace Shentun.Peis.PatientRegisters
_currentUser = currentUser;
_userItemTypeRepository = userItemTypeRepository;
_patientOccupationalDiseaseManager = patientOccupationalDiseaseManager;
_thirdInterfaceRepository = thirdInterfaceRepository;
_customerOrgRegisterRepository = customerOrgRegisterRepository;
}
/// <summary>
/// 获取通过主键
@ -2517,13 +2526,53 @@ namespace Shentun.Peis.PatientRegisters
await CurrentUnitOfWork.SaveChangesAsync();
}
/// <summary>
/// 导入人员信息从第三方接口(青藏铁路接口)
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/patientregister/CreatePatientRegisterFromCustomerOrgInterface")]
public async Task CreatePatientRegisterFromCustomerOrgInterfaceAsync(CustomerOrgRegisterIdInputDto input)
public async Task<ImportPatientRegisterByCustomerOrgRegisterIdDto> CreatePatientRegisterFromCustomerOrgInterfaceAsync(CustomerOrgRegisterIdInputDto input)
{
if (input == null)
{
throw new UserFriendlyException("input参数不能为空");
}
var thirdInterfaces = await _thirdInterfaceRepository.GetListAsync(o => o.ThirdInterfaceType == ThirdInterfaceTypeFlag.ImportPatientRegister);
foreach(var thirdInterface in thirdInterfaces)
{
if (thirdInterface.IsActive != 'Y')
{
continue;
}
var parmValue = thirdInterface.ParmValue;
var configurationBuilder = new ConfigurationBuilder()
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
var config = configurationBuilder.Build();
var customerOrgIdStr = config.GetSection("Interface").GetSection("CustomerOrgId").Value;
if(!Guid.TryParse(customerOrgIdStr,out var customerOrgId))
{
throw new UserFriendlyException("接口配置中的CustomerOrgId无法解析成GUID");
}
var customerOrgRegister = (await _customerOrgRegisterRepository.GetQueryableAsync())
.Where(o => o.Id == input.CustomerOrgRegisterId).First();
if(customerOrgRegister.CustomerOrgId != customerOrgId)
{
continue;
}
object[] objects = [input.CustomerOrgRegisterId];
var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value;
var className = config.GetSection("Interface").GetSection("ClassName").Value;
var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync<ImportPatientRegisterByCustomerOrgRegisterIdDto>(assemblyName,
className, [thirdInterface.Id], "ImportPatientRegisterByCustomerOrgRegisterIdAsync", objects);
return pluginsOut;
}
return null;
}
[HttpPost("api/app/patientregister/GetSameNamePatient")]
public async Task<List<GetSameNamePatientDto>> GetSameNamePatientAsync(GetSameNamePatientInputDto getSameNamePatientInputDto)
@ -2715,7 +2764,7 @@ namespace Shentun.Peis.PatientRegisters
if (!string.IsNullOrEmpty(input.StartPatientNo) && !string.IsNullOrEmpty(input.EndPatientNo))
{
query = query.AsEnumerable().Where(m => String.Compare(m.ab.PatientNo, input.StartPatientNo, StringComparison.OrdinalIgnoreCase) > 0
query = query.Where(m => String.Compare(m.ab.PatientNo, input.StartPatientNo, StringComparison.OrdinalIgnoreCase) > 0
&& String.Compare(m.ab.PatientNo, input.EndPatientNo, StringComparison.OrdinalIgnoreCase) <= 0).AsQueryable();
}

34
test/Shentun.Peis.Application.Tests/PatientRegisterAppServiceTest.cs

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Shentun.Peis.CustomerOrgRegisters;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
using Shentun.Peis.PatientRegisters;
@ -661,5 +662,38 @@ namespace Shentun.Peis
await unitOfWork.CompleteAsync();
}
}
[Fact]
public async Task CreatePatientRegisterFromCustomerOrgInterfaceAsync()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = new CustomerOrgRegisterIdInputDto()
{
CustomerOrgRegisterId = new Guid("3a126b36-b71a-e626-e8be-17d47216f927")
};
var result = await _appService.CreatePatientRegisterFromCustomerOrgInterfaceAsync(entity);
if (result == null)
{
return;
}
_output.WriteLine("导入成功数:" + result.ImportSuccessNum.ToString());
_output.WriteLine("导入失败数:" + result.ImportErrorNum.ToString());
_output.WriteLine("删除成功数:" + result.DeleteSuccessNum.ToString());
_output.WriteLine("删除失败数:" + result.DeleteErrorNum.ToString());
foreach (var item in result.ImportErrorMessages)
{
_output.WriteLine("导入错误:" + item.ToString());
}
foreach (var item in result.DeleteErrorMessages)
{
_output.WriteLine("删除错误:" + item.ToString());
}
await unitOfWork.CompleteAsync();
}
}
}
}
Loading…
Cancel
Save