5 Commits
756ae9d7fd
...
36611787aa
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
36611787aa |
Merge branch 'master' of http://140.143.162.39:3000/shentun/peis
|
2 years ago |
|
|
9424461a61 |
同步组合项目
|
2 years ago |
|
|
93fac3c7e1 |
同步组合项目价格
|
2 years ago |
|
|
08f9a85007 |
Merge branch 'master' of http://140.143.162.39:3000/shentun/peis
|
2 years ago |
|
|
49b2967752 |
收费价格同步
|
2 years ago |
13 changed files with 462 additions and 7 deletions
-
2ThirdPlugIns/Shentun.Peis.PlugIns.Gem/ChargeRequests/Hzcy/ChargeRequestPlugInsHzcy.cs
-
2src/Shentun.ColumnReferencePlugIns/ChargeRequests/ChargeRequestPlugInsBase.cs
-
4src/Shentun.ColumnReferencePlugIns/ImportLisResults/ImportLisResultPlugInsBase.cs
-
4src/Shentun.ColumnReferencePlugIns/ImportPacsResults/ImportPacsResultPlugInsBase.cs
-
127src/Shentun.ColumnReferencePlugIns/SyncAsbitemPrice/AsbitemForSyncAsbitem.cs
-
17src/Shentun.ColumnReferencePlugIns/SyncAsbitemPrice/AsbitemFromSyncAsbitemInterface.cs
-
84src/Shentun.ColumnReferencePlugIns/SyncAsbitemPrice/SyncAsbitemPricePlugInsBase.cs
-
72src/Shentun.ColumnReferencePlugIns/SyncAsbitemPrice/SyncAsbitemPricePlugInsDbBase.cs
-
3src/Shentun.Peis.Domain.Shared/Enums/ThirdInterfaceTypeFlag.cs
-
5src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs
-
99src/Shentun.Peis.HttpApi.Host/Schedulers/SyncAsbitemPriceInterfaceWorker.cs
-
2test/Shentun.Peis.ColumnReference.Tests/ImportPacsResultPlugInsTest.cs
-
48test/Shentun.Peis.ColumnReference.Tests/SyncAsbitemPricePlugInsTest.cs
@ -0,0 +1,127 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.Peis.PlugIns.SyncAsbitemPrice |
|||
{ |
|||
public class AsbitemForSyncAsbitem |
|||
{ |
|||
public Guid Id { get; set; } |
|||
/// <summary>
|
|||
/// 名称
|
|||
/// </summary>
|
|||
public string DisplayName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 简称
|
|||
/// </summary>
|
|||
public string ShortName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 适用性别,M-男,F-女,A-全部
|
|||
/// </summary>
|
|||
public char ForSexId { get; set; } |
|||
/// <summary>
|
|||
/// 婚姻状况
|
|||
/// </summary>
|
|||
public char MaritalStatusId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 项目类别
|
|||
/// </summary>
|
|||
public Guid ItemTypeId { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 价格
|
|||
/// </summary>
|
|||
public decimal Price { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 仪器类别
|
|||
/// </summary>
|
|||
public Guid? DeviceTypeId { get; set; } |
|||
|
|||
|
|||
///// <summary>
|
|||
///// 发票类别
|
|||
///// </summary>
|
|||
//public Guid InvoiceItemTypeId { get; set; }
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 项目结果合并
|
|||
/// </summary>
|
|||
public char IsItemResultMerger { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 餐前项目
|
|||
/// </summary>
|
|||
public char IsBeforeEat { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 临床意义
|
|||
/// </summary>
|
|||
public string ClinicalMeaning { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 默认结果
|
|||
/// </summary>
|
|||
public string DefaultResult { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 候诊时间
|
|||
/// </summary>
|
|||
public decimal QueueTime { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 启用诊断函数
|
|||
/// </summary>
|
|||
public char IsDiagnosisFunction { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 诊断函数
|
|||
/// </summary>
|
|||
public string DiagnosisFunction { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 诊断函数处理完毕后继续处理
|
|||
/// </summary>
|
|||
public char IsContinueProcess { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 体检报告图片旋转90°
|
|||
/// </summary>
|
|||
public char IsPictureRotate { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 是检查项目
|
|||
/// </summary>
|
|||
public char IsCheck { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 是启用
|
|||
/// </summary>
|
|||
public char IsActive { get; set; } |
|||
|
|||
public string SimpleCode { get; set; } |
|||
|
|||
|
|||
public int DisplayOrder { get; set; } |
|||
|
|||
public string ConcurrencyStamp { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.Peis.PlugIns.SyncAsbitemPrice |
|||
{ |
|||
public class AsbitemFromSyncAsbitemInterface |
|||
{ |
|||
public string AsbitemId { get; set; } |
|||
public string AsbitemName { get; set; } |
|||
|
|||
public decimal? Price { get; set; } |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
using Dapper; |
|||
using Npgsql; |
|||
using Shentun.Peis.Asbitems; |
|||
using Shentun.Peis.Enums; |
|||
using Shentun.Peis.PlugIns.ChargeRequests; |
|||
using Shentun.Peis.PlugIns.LisRequests; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data.Common; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.Peis.PlugIns.SyncAsbitemPrice |
|||
{ |
|||
public class SyncAsbitemPricePlugInsBase : ThirdPlugInsBase |
|||
{ |
|||
public SyncAsbitemPricePlugInsBase(Guid thirdInterfaceId) : base(thirdInterfaceId) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public virtual async Task SyncAsbitemPriceAsync() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public async Task<List<AsbitemForSyncAsbitem>> GetAsbitemsAsync() |
|||
{ |
|||
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|||
{ |
|||
string sql; |
|||
sql = @" select * from asbitem where is_active = 'Y'
|
|||
";
|
|||
var asbitems = (await conn.QueryAsync<AsbitemForSyncAsbitem>(sql |
|||
)).ToList(); |
|||
|
|||
return asbitems; |
|||
} |
|||
} |
|||
|
|||
public async Task UpdateAsbitemPriceAsync(AsbitemForSyncAsbitem asbitem) |
|||
{ |
|||
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|||
{ |
|||
await conn.OpenAsync(); |
|||
using (var trans = await conn.BeginTransactionAsync()) |
|||
{ |
|||
try |
|||
{ |
|||
string sql; |
|||
sql = @" update asbitem set price = @Price" + |
|||
@" where id = @AsbitemId and concurrency_stamp = @ConcurrencyStamp
|
|||
";
|
|||
await conn.ExecuteAsync(sql, |
|||
new |
|||
{ |
|||
asbitem.Price, |
|||
asbitem.Id, |
|||
asbitem.ConcurrencyStamp |
|||
}, trans); |
|||
await trans.CommitAsync(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
await trans.RollbackAsync(); |
|||
throw ex; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
public override Task DoWork() |
|||
{ |
|||
SyncAsbitemPriceAsync().Wait(); |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
using Dapper; |
|||
using Npgsql; |
|||
using Org.BouncyCastle.Asn1.Ocsp; |
|||
using Shentun.Peis.Asbitems; |
|||
using Shentun.Peis.PlugIns.ImportLisResults; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data.Common; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Shentun.Peis.PlugIns.SyncAsbitemPrice |
|||
{ |
|||
public class SyncAsbitemPricePlugInsDbBase : SyncAsbitemPricePlugInsBase |
|||
{ |
|||
public SyncAsbitemPricePlugInsDbBase(Guid thirdInterfaceId) : base(thirdInterfaceId) |
|||
{ |
|||
} |
|||
|
|||
public override async Task SyncAsbitemPriceAsync() |
|||
{ |
|||
if (AsbitemColumnReferenceId == null || AsbitemColumnReferenceId == Guid.Empty) |
|||
{ |
|||
throw new Exception("没有设置组合项目编码对照"); |
|||
} |
|||
var asbitems = await GetAsbitemsAsync(); |
|||
using (DbConnection conn = CreateInterfaceDbConnect()) |
|||
{ |
|||
foreach (var asbItem in asbitems) |
|||
{ |
|||
var columnReferenceInterfaceCodeValues = await GetColumnReferenceInterfaceCodeValuesAsync(AsbitemColumnReferenceId, asbItem.Id.ToString()); |
|||
if(columnReferenceInterfaceCodeValues == null || !columnReferenceInterfaceCodeValues.Any()) |
|||
{ |
|||
continue; |
|||
} |
|||
string sql; |
|||
sql = InterfaceSql + " where " + InterfaceSqlKeyColumn + " = '" + columnReferenceInterfaceCodeValues[0].InterfaceCodeValue + "'"; |
|||
var interfaceAsbitems = (await conn.QueryAsync<AsbitemFromSyncAsbitemInterface>(sql)).ToList(); |
|||
if (interfaceAsbitems == null || !interfaceAsbitems.Any()) |
|||
{ |
|||
continue; |
|||
} |
|||
var interfaceAsbitem = interfaceAsbitems.First(); |
|||
if(interfaceAsbitem.Price == null || interfaceAsbitem.Price < 0) |
|||
{ |
|||
continue; |
|||
} |
|||
asbItem.Price = (decimal)interfaceAsbitem.Price; |
|||
await UpdateAsbitemPriceAsync(asbItem); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
public async Task<List<AsbitemFromSyncAsbitemInterface>> GetInterfaceAsbitems() |
|||
{ |
|||
using (DbConnection conn = CreateInterfaceDbConnect()) |
|||
{ |
|||
string sql; |
|||
sql = InterfaceSql; |
|||
var interfaceAsbitems = (await conn.QueryAsync<AsbitemFromSyncAsbitemInterface>(sql)).ToList(); |
|||
return interfaceAsbitems; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,99 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Logging; |
|||
using Shentun.Peis.ThirdInterfaces; |
|||
using Shentun.Utilities; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
|
|||
namespace Shentun.Peis.Schedulers |
|||
{ |
|||
|
|||
public interface ISyncAsbitemPriceInterfaceWorker |
|||
{ |
|||
public void DoWork(Guid interfaceId); |
|||
public void DoWork(); |
|||
} |
|||
public class SyncAsbitemPriceInterfaceWorker : ThirdInterfaceWorkerBase, ISyncAsbitemPriceInterfaceWorker |
|||
{ |
|||
private static long i; |
|||
private static bool _isRunning = false; |
|||
private static readonly object lockObject = new object(); |
|||
private readonly IConfiguration _configuration; |
|||
public SyncAsbitemPriceInterfaceWorker(IConfiguration configuration) |
|||
{ |
|||
_configuration = configuration; |
|||
} |
|||
public virtual void DoWork(Guid interfaceId) |
|||
{ |
|||
if (_isRunning) return; |
|||
//lock (lockObject)
|
|||
//{
|
|||
_isRunning = true; |
|||
try |
|||
{ |
|||
var backJobTypeIds = _configuration.GetSection("BackJobTypeId").Value; |
|||
|
|||
//Logger.LogInformation("Executed" + GetType().Name + "..!");
|
|||
var appServiceHelper = new AppServiceHelper(); |
|||
//appServiceHelper.Login();
|
|||
var thirdInterfaceDtos = appServiceHelper.CallAppService<object, List<ThirdInterfaceDto>>("api/app/ThirdInterface/GetList", null); |
|||
var thirdInterfaceDto = thirdInterfaceDtos.Where(o => o.Id == interfaceId).FirstOrDefault(); |
|||
if (thirdInterfaceDto == null) |
|||
{ |
|||
_isRunning = false; |
|||
return; |
|||
} |
|||
|
|||
if (!backJobTypeIds.Contains(thirdInterfaceDto.ThirdInterfaceType)) |
|||
{ |
|||
_isRunning = false; |
|||
return; |
|||
} |
|||
|
|||
if (thirdInterfaceDto.IsActive != 'Y') |
|||
{ |
|||
_isRunning = false; |
|||
return; |
|||
} |
|||
var parmValue = thirdInterfaceDto.ParmValue; |
|||
if (!string.IsNullOrWhiteSpace(parmValue)) |
|||
{ |
|||
var configurationBuilder = new ConfigurationBuilder() |
|||
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); |
|||
var interfaceConfig = configurationBuilder.Build(); |
|||
|
|||
var isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler") |
|||
.GetSection("IsActive").Value; |
|||
if (isActive != "Y") |
|||
{ |
|||
_isRunning = false; |
|||
return; |
|||
} |
|||
var assemblyName = interfaceConfig.GetSection("Interface").GetSection("AssemblyName").Value; |
|||
var className = interfaceConfig.GetSection("Interface").GetSection("ClassName").Value; |
|||
var funName = "DoWork"; |
|||
object[] classConstructorArg = new object[] { thirdInterfaceDto.Id }; |
|||
ReflectionHelper.Invoke(assemblyName, className, classConstructorArg, funName); |
|||
} |
|||
|
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
_isRunning = false; |
|||
Logger.LogError("Executed " + GetType().Name + " Error" + ex.Message); |
|||
} |
|||
_isRunning = false; |
|||
return; |
|||
//}
|
|||
} |
|||
|
|||
|
|||
public void DoWork() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
using Shentun.Peis.PlugIns.ImportLisResults; |
|||
using Shentun.Peis.PlugIns.SyncAsbitemPrice; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Xunit.Abstractions; |
|||
|
|||
namespace Shentun.Peis.PlugIns.Tests |
|||
{ |
|||
public class SyncAsbitemPricePlugInsTest |
|||
{ |
|||
private readonly ITestOutputHelper _output; |
|||
public SyncAsbitemPricePlugInsTest(ITestOutputHelper testOutputHelper) |
|||
{ |
|||
_output = testOutputHelper; |
|||
|
|||
} |
|||
|
|||
[Fact] |
|||
public async Task DoWorkAsync() |
|||
{ |
|||
|
|||
var input = new SyncAsbitemPricePlugInsDbBase(new Guid("8742ccb6-ab93-4e4d-aad9-873b69fafd8c")); |
|||
await input.DoWork(); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
[Fact] |
|||
public async Task GetInterfaceAsbitems() |
|||
{ |
|||
|
|||
var input = new SyncAsbitemPricePlugInsDbBase(new Guid("8742ccb6-ab93-4e4d-aad9-873b69fafd8c")); |
|||
var list = await input.GetInterfaceAsbitems(); |
|||
foreach (var item in list) |
|||
{ |
|||
_output.WriteLine(item.AsbitemId + "," + item.AsbitemName + "," + item.Price.ToString()); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue