|
|
|
@ -49,7 +49,8 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
|
|
|
|
private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() |
|
|
|
{ |
|
|
|
ConnectionString = "Data Source=.;Initial Catalog=mypeis;User ID=sa;Password=123;", |
|
|
|
// ConnectionString = "Data Source=.;Initial Catalog=mypeis;User ID=sa;Password=123;Encrypt=false;",
|
|
|
|
ConnectionString = "server=.;uid=sa;pwd=123;database=mypeis;Encrypt=false;", |
|
|
|
DbType = SqlSugar.DbType.SqlServer, |
|
|
|
IsAutoCloseConnection = true |
|
|
|
}); |
|
|
|
@ -82,6 +83,7 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
//默认体检中心
|
|
|
|
private readonly Guid defaultMedicalCenterId = Guid.Parse("0de5b78a-731d-4f80-b262-655ebbf04581"); |
|
|
|
private readonly string defaultMedicalConclusionType = "01"; |
|
|
|
private readonly Guid defaultSampleContainerId = Guid.Parse("3a1230dc-90fc-1bbc-dbd4-da9de6f2a67d"); |
|
|
|
|
|
|
|
private readonly IRepository<DeviceType, Guid> _deviceTypeRepository; |
|
|
|
private readonly IRepository<ItemType, Guid> _itemTypeRepository; |
|
|
|
@ -129,6 +131,8 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
private readonly IRepository<Report, string> _reportRepository; |
|
|
|
private readonly IRepository<ReportFormat, string> _reportFormatRepository; |
|
|
|
private readonly IRepository<ReportFormatTemplate, string> _reportFormatTemplateRepository; |
|
|
|
private readonly IRepository<SampleGroup, Guid> _sampleGroupRepository; |
|
|
|
private readonly IRepository<SampleGroupDetail> _sampleGroupDetailRepository; |
|
|
|
|
|
|
|
private Dictionary<string, string> veryPatientNo = new Dictionary<string, string>(); |
|
|
|
|
|
|
|
@ -178,7 +182,9 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
IRepository<SumDiagnosis> sumDiagnosisRepository, |
|
|
|
IRepository<Report, string> reportRepository, |
|
|
|
IRepository<ReportFormat, string> reportFormatRepository, |
|
|
|
IRepository<ReportFormatTemplate, string> reportFormatTemplateRepository) |
|
|
|
IRepository<ReportFormatTemplate, string> reportFormatTemplateRepository, |
|
|
|
IRepository<SampleGroup, Guid> sampleGroupRepository, |
|
|
|
IRepository<SampleGroupDetail> sampleGroupDetailRepository) |
|
|
|
{ |
|
|
|
_deviceTypeRepository = deviceTypeRepository; |
|
|
|
_itemTypeRepository = itemTypeRepository; |
|
|
|
@ -226,6 +232,8 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
_reportRepository = reportRepository; |
|
|
|
_reportFormatRepository = reportFormatRepository; |
|
|
|
_reportFormatTemplateRepository = reportFormatTemplateRepository; |
|
|
|
_sampleGroupRepository = sampleGroupRepository; |
|
|
|
_sampleGroupDetailRepository = sampleGroupDetailRepository; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1776,7 +1784,7 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 迁移民族数据 民族对应
|
|
|
|
/// 迁移 民族字段对应数据
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task TransferNationData() |
|
|
|
@ -1812,6 +1820,110 @@ namespace Shentun.Peis.DataMigrations |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 迁移条码分组数据
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task TransferSampleGroupData() |
|
|
|
{ |
|
|
|
var count = await _sampleGroupRepository.GetCountAsync(); |
|
|
|
if (count == 0) |
|
|
|
{ |
|
|
|
List<SampleGroup> dataList = new List<SampleGroup>(); |
|
|
|
var oldSampleGroupList = await Db.Ado.GetDataTableAsync("select * from vessels_type order by display_order asc"); |
|
|
|
if (oldSampleGroupList.Rows.Count > 0) |
|
|
|
{ |
|
|
|
List<FieldComparison> fieldComparisons = new List<FieldComparison>(); |
|
|
|
|
|
|
|
foreach (DataRow row in oldSampleGroupList.Rows) |
|
|
|
{ |
|
|
|
#region 转成成新的标本类型ID
|
|
|
|
|
|
|
|
Guid newSampleTypeId = Guid.Parse("3a120298-82b8-0429-d2e8-75ccde686899"); //默认取其他 ID
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["specimen_type_id"].ToString())) |
|
|
|
{ |
|
|
|
var oldSampleType = (await _fieldComparisonRepository.GetQueryableAsync()) |
|
|
|
.Where(m => m.TableName == "sample_type" && m.OldKeyValue == row["specimen_type_id"].ToString()).FirstOrDefault(); |
|
|
|
if (oldSampleType != null) |
|
|
|
{ |
|
|
|
newSampleTypeId = Guid.Parse(oldSampleType.NewKeyValue); |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
Guid sampleGroupId = GuidGenerator.Create(); |
|
|
|
|
|
|
|
var data = new SampleGroup(sampleGroupId) |
|
|
|
{ |
|
|
|
DisplayName = row["vessels_type_name"].ToString(), |
|
|
|
DisplayOrder = oldSampleGroupList.Rows.IndexOf(row) + 1, |
|
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["vessels_type_name"].ToString()), |
|
|
|
SampleContainerId = defaultSampleContainerId, |
|
|
|
SampleTypeId = newSampleTypeId |
|
|
|
}; |
|
|
|
|
|
|
|
var ent = await _sampleGroupRepository.InsertAsync(data, true); |
|
|
|
|
|
|
|
fieldComparisons.Add(new FieldComparison |
|
|
|
{ |
|
|
|
TableName = "sample_group", |
|
|
|
FieldName = "id", |
|
|
|
NewKeyValue = sampleGroupId.ToString(), |
|
|
|
OldKeyValue = row["vessels_type_id"].ToString() |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
await _fieldComparisonRepository.InsertManyAsync(fieldComparisons); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 迁移条码分组明细数据
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task TransferSampleGroupDetailData() |
|
|
|
{ |
|
|
|
var count = await _sampleGroupDetailRepository.GetCountAsync(); |
|
|
|
if (count == 0) |
|
|
|
{ |
|
|
|
List<SampleGroupDetail> dataList = new List<SampleGroupDetail>(); |
|
|
|
var oldSampleGroupDetailList = await Db.Ado.GetDataTableAsync("select * from vessels_type_detail "); |
|
|
|
if (oldSampleGroupDetailList.Rows.Count > 0) |
|
|
|
{ |
|
|
|
|
|
|
|
foreach (DataRow row in oldSampleGroupDetailList.Rows) |
|
|
|
{ |
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) |
|
|
|
{ |
|
|
|
Guid newSampleGroupId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()) |
|
|
|
.Where(m => m.TableName == "sample_group" && m.OldKeyValue == row["vessels_type_id"].ToString()).FirstOrDefault().NewKeyValue); |
|
|
|
|
|
|
|
Guid newAsbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()) |
|
|
|
.Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue); |
|
|
|
|
|
|
|
var data = new SampleGroupDetail |
|
|
|
{ |
|
|
|
AsbitemId = newAsbitemId, |
|
|
|
SampleGroupId = newSampleGroupId |
|
|
|
}; |
|
|
|
|
|
|
|
var ent = await _sampleGroupDetailRepository.InsertAsync(data); |
|
|
|
|
|
|
|
await uow.CompleteAsync(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#region 人员登记
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|