You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1851 lines
82 KiB
1851 lines
82 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using Shentun.Peis.CustomerOrgs;
|
|
using Shentun.Peis.DataMigrations;
|
|
using Shentun.Peis.Enums;
|
|
using Shentun.Peis.ItemTypes;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.MyUser;
|
|
using Shentun.Utilities;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Uow;
|
|
|
|
namespace Shentun.Peis.CQDJExportDatas
|
|
{
|
|
/// <summary>
|
|
/// 重庆垫江数据导入
|
|
/// </summary>
|
|
public class CQDJExportDataAppService : ApplicationService
|
|
{
|
|
|
|
//默认指引类别ID
|
|
private readonly char defaultGuidTypeId = '0';
|
|
//默认体检报告类别ID
|
|
private readonly char defaultMedicalReportTypeId = '0';
|
|
//默认检查类别
|
|
private readonly char defaultCheckTypeFlag = '0';
|
|
|
|
//默认发票项目类别id
|
|
private Guid defaultInvoiceItemTypeId = Guid.Empty;
|
|
|
|
//默认汇总项目类别id
|
|
private Guid defaultCollectItemTypeId = Guid.Empty;
|
|
|
|
//默认企业性质
|
|
private Guid defaultOrgTypeId = Guid.Empty;
|
|
|
|
//默认容器ID
|
|
private Guid defaultSampleContainerId = Guid.Empty;
|
|
|
|
//默认体检中心
|
|
private readonly Guid defaultMedicalCenterId = Guid.Parse("7b754abf-9882-4f23-affd-d50103febfee");
|
|
|
|
//老系统数据库配置
|
|
private readonly SqlSugarClient oldDb = new SqlSugarClient(new ConnectionConfig()
|
|
{
|
|
|
|
ConnectionString = "server=192.168.1.119;uid=sa;pwd=st@123;database=Peis;Encrypt=false;",
|
|
DbType = SqlSugar.DbType.SqlServer,
|
|
IsAutoCloseConnection = true
|
|
});
|
|
|
|
private readonly ILogger<CQDJExportDataAppService> _logger;
|
|
private readonly UnitOfWorkManager _unitOfWorkManager;
|
|
private readonly IRepository<IdentityUser, Guid> _identityUserRepository;
|
|
private readonly MyUserAppService _myUserAppService;
|
|
private readonly IRepository<ItemType, Guid> _itemTypeRepository;
|
|
private readonly ItemTypeManager _itemTypeManager;
|
|
private readonly IRepository<FieldComparison, Guid> _fieldComparisonRepository;
|
|
private readonly IRepository<Item, Guid> _itemRepository;
|
|
private readonly IRepository<Asbitem, Guid> _asbitemRepository;
|
|
private readonly IRepository<AsbitemDetail> _asbitemDetailRepository;
|
|
private readonly IRepository<MedicalPackage, Guid> _medicalPackageRepository;
|
|
private readonly IRepository<MedicalPackageDetail> _medicalPackageDetailRepository;
|
|
private readonly IRepository<DeviceType, Guid> _deviceTypeRepository;
|
|
private readonly IRepository<Unit, Guid> _unitRepository;
|
|
private readonly IRepository<CollectItemType, Guid> _collectItemTypeRepository;
|
|
private readonly IRepository<InvoiceItemType, Guid> _invoiceItemTypeRepository;
|
|
private readonly IRepository<AsbitemGuide> _asbitemGuideRepository;
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository;
|
|
private readonly CustomerOrgManager _customerOrgManager;
|
|
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
|
|
private readonly IRepository<CustomerOrgGroup, Guid> _customerOrgGroupRepository;
|
|
private readonly IRepository<CustomerOrgGroupDetail> _customerOrgGroupDetailRepository;
|
|
private readonly IRepository<CustomerOrgType, Guid> _customerOrgTypeRepository;
|
|
private readonly IRepository<SampleContainer, Guid> _sampleContainerRepository;
|
|
|
|
public CQDJExportDataAppService(
|
|
IRepository<IdentityUser, Guid> identityUserRepository,
|
|
UnitOfWorkManager unitOfWorkManager,
|
|
ILogger<CQDJExportDataAppService> logger,
|
|
MyUserAppService myUserAppService,
|
|
IRepository<ItemType, Guid> itemTypeRepository,
|
|
ItemTypeManager itemTypeManager,
|
|
IRepository<FieldComparison, Guid> fieldComparisonRepository,
|
|
IRepository<Item, Guid> itemRepository,
|
|
IRepository<Asbitem, Guid> asbitemRepository,
|
|
IRepository<AsbitemDetail> asbitemDetailRepository,
|
|
IRepository<MedicalPackage, Guid> medicalPackageRepository,
|
|
IRepository<MedicalPackageDetail> medicalPackageDetailRepository,
|
|
IRepository<DeviceType, Guid> deviceTypeRepository,
|
|
IRepository<Unit, Guid> unitRepository,
|
|
IRepository<CollectItemType, Guid> collectItemTypeRepository,
|
|
IRepository<InvoiceItemType, Guid> invoiceItemTypeRepository,
|
|
IRepository<AsbitemGuide> asbitemGuideRepository,
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository,
|
|
CustomerOrgManager customerOrgManager,
|
|
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository,
|
|
IRepository<CustomerOrgGroup, Guid> customerOrgGroupRepository,
|
|
IRepository<CustomerOrgGroupDetail> customerOrgGroupDetailRepository,
|
|
IRepository<CustomerOrgType, Guid> customerOrgTypeRepository,
|
|
IRepository<SampleContainer, Guid> sampleContainerRepository)
|
|
{
|
|
_identityUserRepository = identityUserRepository;
|
|
_unitOfWorkManager = unitOfWorkManager;
|
|
_logger = logger;
|
|
_myUserAppService = myUserAppService;
|
|
_itemTypeRepository = itemTypeRepository;
|
|
_itemTypeManager = itemTypeManager;
|
|
_fieldComparisonRepository = fieldComparisonRepository;
|
|
_itemRepository = itemRepository;
|
|
_asbitemRepository = asbitemRepository;
|
|
_asbitemDetailRepository = asbitemDetailRepository;
|
|
_medicalPackageRepository = medicalPackageRepository;
|
|
_medicalPackageDetailRepository = medicalPackageDetailRepository;
|
|
_deviceTypeRepository = deviceTypeRepository;
|
|
_unitRepository = unitRepository;
|
|
_collectItemTypeRepository = collectItemTypeRepository;
|
|
_invoiceItemTypeRepository = invoiceItemTypeRepository;
|
|
_asbitemGuideRepository = asbitemGuideRepository;
|
|
_customerOrgRepository = customerOrgRepository;
|
|
_customerOrgManager = customerOrgManager;
|
|
_customerOrgRegisterRepository = customerOrgRegisterRepository;
|
|
_customerOrgGroupRepository = customerOrgGroupRepository;
|
|
_customerOrgGroupDetailRepository = customerOrgGroupDetailRepository;
|
|
_customerOrgTypeRepository = customerOrgTypeRepository;
|
|
_sampleContainerRepository = sampleContainerRepository;
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移后台用户数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/CQDJExportData/TransferUserData")]
|
|
public async Task TransferUserData()
|
|
{
|
|
|
|
var oldUserList = await oldDb.Ado.GetDataTableAsync("select GKHM,GKMM,XM from [futian_user].[GZRY]");
|
|
if (oldUserList.Rows.Count > 0)
|
|
{
|
|
if (await _identityUserRepository.CountAsync() == 1)
|
|
{
|
|
foreach (DataRow row in oldUserList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
string newUserName = LanguageConverter.GetPYSimpleCode(row["GKHM"].ToString().Trim());
|
|
|
|
var isUserName = await _identityUserRepository.FirstOrDefaultAsync(m => m.UserName == newUserName);
|
|
if (isUserName != null)
|
|
{
|
|
newUserName += "2";
|
|
}
|
|
var userEnt = new IdentityUserCreateNoEmailDto
|
|
{
|
|
Email = "",
|
|
IsActive = true,
|
|
LockoutEnabled = false,
|
|
Name = "",
|
|
Password = string.IsNullOrWhiteSpace(row["GKMM"].ToString()) ? "888888" : row["GKMM"].ToString(),
|
|
PhoneNumber = "",
|
|
RoleNames = new string[] { "admin" },
|
|
Surname = row["XM"].ToString().Trim(),
|
|
UserName = newUserName,
|
|
UserPhoto = "",
|
|
UserSign = ""
|
|
};
|
|
|
|
await _myUserAppService.CreateAsync(userEnt);
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("用户数据已存在,未处理");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 导入项目类别 仪器类别
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/CQDJExportData/TransferBasicData")]
|
|
public async Task TransferBasicData()
|
|
{
|
|
await InitData(); //初始数据
|
|
await TransferItemTypeData();
|
|
await TransferDeviceTypeData();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 导入项目相关
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/CQDJExportData/TransferItemWithDetailData")]
|
|
public async Task TransferItemWithDetailData()
|
|
{
|
|
await InitData(); //初始数据
|
|
await TransferItemData();
|
|
await TransferAsbitemData();
|
|
await TransferAsbitemDetailData();
|
|
await TransferMedicalPackageData();
|
|
await TransferMedicalPackageDetailData();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 导入单位相关
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/CQDJExportData/TransferCustomerWithDetailData")]
|
|
public async Task TransferCustomerWithDetailData()
|
|
{
|
|
await InitData(); //初始数据
|
|
await TransferTopCustomerOrgData();
|
|
await TransferTwoCustomerOrgData();
|
|
await TransferThreeCustomerOrgData();
|
|
await TransferCustomerOrgRegisterData();
|
|
await TransferCustomerOrgGroupData();
|
|
await TransferCustomerOrgGroupDetailData();
|
|
await TransferPHCustomerOrgGroupDetailData();
|
|
}
|
|
|
|
#region 基础
|
|
/// <summary>
|
|
/// 迁移项目类别-科室数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferItemTypeData()
|
|
{
|
|
var count = await _itemTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldItemTypeList = await oldDb.Ado.GetDataTableAsync("SELECT [LXBH],[MC],[XSLX],[JCJYLX] FROM [futian_user].[TJ_TJLXB] order by DISP_ORDER asc");
|
|
if (oldItemTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldItemTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid itemTypeId = StringConvertGuidHelper.GenerateURLUUID(row["LXBH"].ToString().Trim());
|
|
|
|
var data = new ItemType(itemTypeId)
|
|
{
|
|
DisplayName = row["MC"].ToString(),
|
|
DisplayOrder = oldItemTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
CheckTypeFlag = defaultCheckTypeFlag,
|
|
GuidTypeId = defaultGuidTypeId,
|
|
IsMergeAsbitem = 'N',
|
|
IsWrap = 'N',
|
|
MedicalReportTypeId = defaultMedicalReportTypeId,
|
|
ParentId = null,
|
|
PathCode = _itemTypeManager.CreatePathCode(null).Result,
|
|
IsCheckRequest = 'N'
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "item_type",
|
|
FieldName = "id",
|
|
NewKeyValue = itemTypeId.ToString(),
|
|
OldKeyValue = row["LXBH"].ToString().Trim()
|
|
};
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"项目类别数据处理完毕,处理数量{oldItemTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"项目类别数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移仪器类别数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferDeviceTypeData()
|
|
{
|
|
var count = await _deviceTypeRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
//处理临床类型
|
|
var oldDeviceTypeList = await oldDb.Ado.GetDataTableAsync(" select LCLX,MC from [futian_user].TJ_LCLXB order by DISP_ORDER asc");
|
|
if (oldDeviceTypeList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldDeviceTypeList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid deviceTypeId = StringConvertGuidHelper.GenerateURLUUID(row["LCLX"].ToString());
|
|
|
|
var data = new DeviceType(deviceTypeId)
|
|
{
|
|
CheckTypeFlag = '0',
|
|
DisplayName = row["MC"].ToString(),
|
|
DisplayOrder = oldDeviceTypeList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString())
|
|
};
|
|
|
|
await _deviceTypeRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "device_type",
|
|
FieldName = "id",
|
|
NewKeyValue = deviceTypeId.ToString(),
|
|
OldKeyValue = row["LCLX"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
|
|
//处理功能类型
|
|
var oldGNLXList = await oldDb.Ado.GetDataTableAsync(" select GNLX from futian_user.TJ_ZHXM_HD where GNLX != '' group by GNLX");
|
|
if (oldGNLXList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldGNLXList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid deviceTypeId = GuidGenerator.Create();
|
|
|
|
var data = new DeviceType(deviceTypeId)
|
|
{
|
|
CheckTypeFlag = '1',
|
|
DisplayName = row["GNLX"].ToString(),
|
|
DisplayOrder = oldDeviceTypeList.Rows.IndexOf(row) + 1 + oldDeviceTypeList.Rows.Count,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["GNLX"].ToString())
|
|
};
|
|
|
|
await _deviceTypeRepository.InsertAsync(data);
|
|
|
|
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
_logger.LogInformation($"仪器类别数据处理完毕,处理数量{oldDeviceTypeList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("仪器类别数据已存在,未处理");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 项目相关
|
|
/// <summary>
|
|
/// 迁移项目数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferItemData()
|
|
{
|
|
var count = await _itemRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldItemList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].[TJ_TJXMB] order by DISP_ORDER asc ");
|
|
if (oldItemList.Rows.Count > 0)
|
|
{
|
|
|
|
List<Item> tempItemList = new List<Item>();
|
|
|
|
var unitList = await _unitRepository.GetListAsync();
|
|
|
|
foreach (DataRow row in oldItemList.Rows)
|
|
{
|
|
var itemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item_type" && m.OldKeyValue == row["LXBH"].ToString().Trim()).FirstOrDefault().NewKeyValue);
|
|
|
|
string mc = row["MC"].ToString();
|
|
|
|
#region 重复项目跳过
|
|
|
|
if (tempItemList.Count(f => f.DisplayName == row["MC"].ToString() && f.ItemTypeId == itemTypeId) > 0)
|
|
{
|
|
//项目类别下重名了
|
|
_logger.LogInformation($"项目【{row["MC"].ToString()}】,Id【{row["TJXM"].ToString()}】已存在,跳过导入");
|
|
continue;
|
|
//mc = mc + "_重";
|
|
//_logger.LogInformation($"项目【{row["MC"].ToString()}】,Id【{row["TJXM"].ToString()}】已存在,更改名称");
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
#region 根据临床类型生成二级科室
|
|
|
|
|
|
|
|
Guid? deviceTypeId = null;
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["LCLX"].ToString()))
|
|
{
|
|
deviceTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "device_type" && m.OldKeyValue == row["LCLX"].ToString()).FirstOrDefault().NewKeyValue);
|
|
|
|
var itemTypeEnt = await _itemTypeRepository.GetAsync(itemTypeId);
|
|
var deviceTypeEnt = await _deviceTypeRepository.GetAsync(deviceTypeId.Value);
|
|
|
|
|
|
var itemTypeChildEnt = await _itemTypeRepository.FirstOrDefaultAsync(m => m.ParentId == itemTypeEnt.Id && m.DisplayName == deviceTypeEnt.DisplayName);
|
|
if (itemTypeChildEnt == null)
|
|
{
|
|
Guid autoItemTypeId = GuidGenerator.Create();
|
|
|
|
#region 排序值
|
|
|
|
int displayOrder = (await _itemTypeRepository.CountAsync(m => m.ParentId == itemTypeEnt.Id)) + 1;
|
|
|
|
#endregion
|
|
|
|
var item_type_data = new ItemType(autoItemTypeId)
|
|
{
|
|
DisplayName = deviceTypeEnt.DisplayName,
|
|
DisplayOrder = displayOrder,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(deviceTypeEnt.DisplayName),
|
|
CheckTypeFlag = itemTypeEnt.CheckTypeFlag,
|
|
GuidTypeId = itemTypeEnt.GuidTypeId,
|
|
IsMergeAsbitem = itemTypeEnt.IsMergeAsbitem,
|
|
IsWrap = itemTypeEnt.IsWrap,
|
|
MedicalReportTypeId = itemTypeEnt.MedicalReportTypeId,
|
|
ParentId = itemTypeEnt.Id,
|
|
PathCode = _itemTypeManager.CreatePathCode(itemTypeEnt.Id).Result,
|
|
IsCheckRequest = itemTypeEnt.IsCheckRequest
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(item_type_data);
|
|
itemTypeId = autoItemTypeId;
|
|
}
|
|
else
|
|
{
|
|
itemTypeId = itemTypeChildEnt.Id;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
Guid? unitId = null;
|
|
if (!string.IsNullOrWhiteSpace(row["DW"].ToString()))
|
|
{
|
|
var tempUnit = unitList.FirstOrDefault(f => f.DisplayName == row["DW"].ToString().Trim());
|
|
if (tempUnit == null)
|
|
{
|
|
//创建单位
|
|
Guid newUnitId = GuidGenerator.Create();
|
|
var unitEntity = new Unit(newUnitId)
|
|
{
|
|
DisplayName = row["DW"].ToString().Trim(),
|
|
DisplayOrder = unitList.Count + oldItemList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["DW"].ToString().Trim())
|
|
};
|
|
|
|
await _unitRepository.InsertAsync(unitEntity);
|
|
|
|
unitId = newUnitId;
|
|
}
|
|
else
|
|
{
|
|
unitId = tempUnit.Id;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
Guid itemId = StringConvertGuidHelper.GenerateURLUUID(row["TJXM"].ToString());
|
|
|
|
var data = new Item(itemId)
|
|
{
|
|
DisplayName = mc,
|
|
DisplayOrder = oldItemList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
CalculationFunction = "",
|
|
DefaultResult = row["ZCTS"].ToString(),
|
|
DiagnosisFunction = "",
|
|
EnglishShortName = "",
|
|
InputCheck = "",
|
|
IsActive = row["QYBZ"].ToString() == "1" ? 'Y' : 'N',
|
|
IsCalculationItem = 'N',
|
|
IsContinueProcess = 'N',
|
|
IsDiagnosisFunction = 'N',
|
|
IsNameIntoSummary = Convert.ToChar(row["MCJRXJ"]),
|
|
IsProduceSummary = Convert.ToChar(row["SFXJ"]),
|
|
ItemTypeId = itemTypeId,
|
|
LineModeFlag = '0',
|
|
Price = 0,
|
|
PriceItemId = null,
|
|
ReferenceRangeTypeFlag = row["JGLX"].ToString().Trim() == "1" ? '1' : '2',
|
|
ResultTemplateTypeFlag = '0',
|
|
UnitId = unitId,
|
|
DeviceTypeId = deviceTypeId
|
|
};
|
|
|
|
await _itemRepository.InsertAsync(data);
|
|
|
|
tempItemList.Add(data);
|
|
|
|
//if (row["reference_range_type"].ToString() == "2" && !string.IsNullOrWhiteSpace(row["reference_range_value"].ToString()))
|
|
//{
|
|
// //增加字符型参考范围到参考范围表
|
|
|
|
// Guid referenceRangeId = GuidGenerator.Create();
|
|
|
|
// var referenceRange = new ReferenceRange(referenceRangeId)
|
|
// {
|
|
// AgeLowerLimit = 0,
|
|
// AgeUpperLimit = 200,
|
|
// CriticalRangeValue = "",
|
|
// ItemId = itemId,
|
|
// ForSexId = ForSexFlag.All,
|
|
// LowerDiagnosisId = null,
|
|
// ReferenceRangeTypeFlag = ItemReferenceRangeTypeFlag.Character,
|
|
// UpperDiagnosisId = null,
|
|
// ReferenceRangeValue = row["reference_range_value"].ToString()
|
|
// };
|
|
|
|
// //referenceRanges.Add(referenceRange);
|
|
// await _referenceRangeRepository.InsertAsync(referenceRange);
|
|
//}
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "item",
|
|
FieldName = "id",
|
|
NewKeyValue = itemId.ToString(),
|
|
OldKeyValue = row["TJXM"].ToString()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"项目数据处理完毕,处理数量{oldItemList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("项目数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移组合项目数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferAsbitemData()
|
|
{
|
|
var count = await _asbitemRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldAsbitemList = await oldDb.Ado.GetDataTableAsync(" select * from futian_user.TJ_ZHXM_HD order by DISP_ORDER asc ");
|
|
if (oldAsbitemList.Rows.Count > 0)
|
|
{
|
|
List<Asbitem> tempAsbitemList = new List<Asbitem>();
|
|
|
|
foreach (DataRow row in oldAsbitemList.Rows)
|
|
{
|
|
string mc = row["MC"].ToString();
|
|
|
|
|
|
|
|
#region 重复组合项目跳过
|
|
|
|
if (tempAsbitemList.Count(f => f.DisplayName == row["MC"].ToString()) > 0)
|
|
{
|
|
//重名了
|
|
//mc = mc + "_重";
|
|
_logger.LogInformation($"组合项目【{row["MC"].ToString()}】,Id【{row["BH"].ToString()}】已存在,跳过导入");
|
|
continue;
|
|
}
|
|
|
|
#endregion
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
#region 根据仪器类别生成二级科室
|
|
|
|
var itemTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item_type" && m.OldKeyValue == row["TJLX"].ToString().Trim()).FirstOrDefault().NewKeyValue);
|
|
|
|
Guid? deviceTypeId = null;
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["LCLX"].ToString()) || !string.IsNullOrWhiteSpace(row["GNLX"].ToString()))
|
|
{
|
|
|
|
var deviceTypeEnt = new DeviceType();
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["LCLX"].ToString()))
|
|
{
|
|
deviceTypeId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "device_type" && m.OldKeyValue == row["LCLX"].ToString().Trim()).FirstOrDefault().NewKeyValue);
|
|
deviceTypeEnt = await _deviceTypeRepository.GetAsync(deviceTypeId.Value);
|
|
}
|
|
else
|
|
{
|
|
deviceTypeEnt = await _deviceTypeRepository.FirstOrDefaultAsync(f => f.DisplayName == row["GNLX"].ToString());
|
|
}
|
|
|
|
|
|
var itemTypeEnt = await _itemTypeRepository.GetAsync(itemTypeId);
|
|
|
|
|
|
|
|
var itemTypeChildEnt = await _itemTypeRepository.FirstOrDefaultAsync(m => m.ParentId == itemTypeEnt.Id && m.DisplayName == deviceTypeEnt.DisplayName);
|
|
if (itemTypeChildEnt == null)
|
|
{
|
|
Guid autoItemTypeId = GuidGenerator.Create();
|
|
|
|
#region 排序值
|
|
|
|
int displayOrder = (await _itemTypeRepository.CountAsync(m => m.ParentId == itemTypeEnt.Id)) + 1;
|
|
|
|
#endregion
|
|
|
|
var item_type_data = new ItemType(autoItemTypeId)
|
|
{
|
|
DisplayName = deviceTypeEnt.DisplayName,
|
|
DisplayOrder = displayOrder,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(deviceTypeEnt.DisplayName),
|
|
CheckTypeFlag = itemTypeEnt.CheckTypeFlag,
|
|
GuidTypeId = itemTypeEnt.GuidTypeId,
|
|
IsMergeAsbitem = itemTypeEnt.IsMergeAsbitem,
|
|
IsWrap = itemTypeEnt.IsWrap,
|
|
MedicalReportTypeId = itemTypeEnt.MedicalReportTypeId,
|
|
ParentId = itemTypeEnt.Id,
|
|
PathCode = _itemTypeManager.CreatePathCode(itemTypeEnt.Id).Result,
|
|
IsCheckRequest = itemTypeEnt.IsCheckRequest
|
|
};
|
|
|
|
await _itemTypeRepository.InsertAsync(item_type_data);
|
|
itemTypeId = autoItemTypeId;
|
|
}
|
|
else
|
|
{
|
|
itemTypeId = itemTypeChildEnt.Id;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
Guid asbitemId = StringConvertGuidHelper.GenerateURLUUID(row["BH"].ToString().Trim());
|
|
|
|
var data = new Asbitem(asbitemId)
|
|
{
|
|
DisplayName = mc,
|
|
DisplayOrder = oldAsbitemList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
DefaultResult = row["ZCXJ"].ToString(),
|
|
DiagnosisFunction = "",
|
|
IsActive = row["YXBZ"].ToString() == "1" ? 'Y' : 'N',
|
|
IsContinueProcess = 'N',
|
|
IsDiagnosisFunction = 'N',
|
|
ItemTypeId = itemTypeId,
|
|
Price = Convert.ToDecimal(row["DJ"]),
|
|
DeviceTypeId = deviceTypeId,
|
|
ClinicalMeaning = row["LCYY"].ToString(),
|
|
ForSexId = ConvertForSex(row["XB"].ToString()),
|
|
CollectItemTypeId = defaultCollectItemTypeId,
|
|
IsBeforeEat = row["SFCQ"].ToString() == "0" ? 'Y' : 'N',
|
|
IsCheck = 'Y',
|
|
IsItemResultMerger = 'N',
|
|
IsPictureRotate = 'N',
|
|
QueueTime = 0,
|
|
ShortName = row["MC"].ToString().Length > 20 ? "" : row["MC"].ToString(),
|
|
BarcodeMode = '0',
|
|
DiseaseScreeningTypeId = null,
|
|
ForPregnantFlag = 'A',
|
|
IsWebAppoint = 'N',
|
|
MaritalStatusId = 'A',
|
|
Warn = "",
|
|
IsOutsend = 'N',
|
|
MedicalCenterId = defaultMedicalCenterId
|
|
};
|
|
|
|
await _asbitemRepository.InsertAsync(data);
|
|
|
|
tempAsbitemList.Add(data);
|
|
|
|
#region 指引信息
|
|
|
|
if (!string.IsNullOrWhiteSpace(row["TSXX"].ToString()))
|
|
{
|
|
var asbitemGuideData = new AsbitemGuide
|
|
{
|
|
AsbitemId = asbitemId,
|
|
ForSexId = ForSexFlag.All,
|
|
Guide = row["TSXX"].ToString(),
|
|
MedicalCenterId = defaultMedicalCenterId
|
|
};
|
|
|
|
await _asbitemGuideRepository.InsertAsync(asbitemGuideData);
|
|
}
|
|
|
|
#endregion
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "asbitem",
|
|
FieldName = "id",
|
|
NewKeyValue = asbitemId.ToString(),
|
|
OldKeyValue = row["BH"].ToString().Trim()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"组合项目数据处理完毕,处理数量{oldAsbitemList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("组合项目数据已存在,未处理");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移组合项目明细数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferAsbitemDetailData()
|
|
{
|
|
var count = await _asbitemDetailRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldAsbitemDetailList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].[TJ_ZHXM_DT] ");
|
|
if (oldAsbitemDetailList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldAsbitemDetailList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
var asbitem_dz = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["BH"].ToString().Trim()).FirstOrDefault();
|
|
var item_dz = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "item" && m.OldKeyValue == row["TJXM"].ToString().Trim()).FirstOrDefault();
|
|
if (asbitem_dz != null && item_dz != null)
|
|
{
|
|
Guid asbitemId = Guid.Parse(asbitem_dz.NewKeyValue);
|
|
Guid itemId = Guid.Parse(item_dz.NewKeyValue);
|
|
var data = new AsbitemDetail
|
|
{
|
|
AsbitemId = asbitemId,
|
|
ItemId = itemId
|
|
};
|
|
|
|
await _asbitemDetailRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"组合项目明细未找到,asbitem_id=>【{row["BH"].ToString().Trim()}】,item_id=>【{row["TJXM"].ToString().Trim()}】");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"组合项目明细数据处理完毕,处理数量{oldAsbitemDetailList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("组合项目明细数据已存在,未处理");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移体检套餐数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferMedicalPackageData()
|
|
{
|
|
var count = await _medicalPackageRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldMedicalPackageList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].TJ_TC_HD order by DISP_ORDER asc");
|
|
if (oldMedicalPackageList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldMedicalPackageList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid medicalPackageId = StringConvertGuidHelper.GenerateURLUUID(row["BH"].ToString().Trim());
|
|
|
|
var data = new MedicalPackage(medicalPackageId)
|
|
{
|
|
DisplayName = row["MC"].ToString(),
|
|
DisplayOrder = oldMedicalPackageList.Rows.IndexOf(row) + 1,
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
ForSexId = ConvertForSex(row["XB"].ToString()),
|
|
IsActive = row["SFQY"].ToString() == "1" ? 'Y' : 'N',
|
|
Price = Convert.ToDecimal(row["JG"].ToString()),
|
|
Remark = row["BZ"].ToString(),
|
|
AgeLowerLimit = 0,
|
|
AgeUpperLimit = 200,
|
|
IsBasicRecommend = 'N',
|
|
IsWebAppoint = 'N',
|
|
MaritalStatusId = 'A'
|
|
};
|
|
|
|
await _medicalPackageRepository.InsertAsync(data);
|
|
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
TableName = "medical_package",
|
|
FieldName = "id",
|
|
NewKeyValue = medicalPackageId.ToString(),
|
|
OldKeyValue = row["BH"].ToString().Trim()
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检套餐数据处理完毕,处理数量{oldMedicalPackageList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检套餐数据已存在,未处理");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移体检套餐明细数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferMedicalPackageDetailData()
|
|
{
|
|
var count = await _medicalPackageDetailRepository.GetCountAsync();
|
|
|
|
if (count == 0)
|
|
{
|
|
var oldMedicalPackageDetailList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].[TJ_TC_DT] ");
|
|
if (oldMedicalPackageDetailList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldMedicalPackageDetailList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
var asbitem_dz = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["ZHXM"].ToString().Trim()).FirstOrDefault();
|
|
var medical_package_dz = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "medical_package" && m.OldKeyValue == row["TCBH"].ToString().Trim()).FirstOrDefault();
|
|
if (asbitem_dz != null && medical_package_dz != null)
|
|
{
|
|
Guid asbitemId = Guid.Parse(asbitem_dz.NewKeyValue);
|
|
Guid MedicalPackageId = Guid.Parse(medical_package_dz.NewKeyValue);
|
|
|
|
var asbitemEnt = await _asbitemRepository.GetAsync(asbitemId);
|
|
|
|
var data = new MedicalPackageDetail
|
|
{
|
|
AsbitemId = asbitemId,
|
|
Amount = 1,
|
|
MedicalPackageId = MedicalPackageId,
|
|
Price = asbitemEnt.Price
|
|
};
|
|
|
|
await _medicalPackageDetailRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation($"套餐明细未找到,asbitem_id=>【{row["ZHXM"].ToString().Trim()}】,medical_package_id=>【{row["TCBH"].ToString().Trim()}】");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检套餐明细数据处理完毕,处理数量{oldMedicalPackageDetailList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检套餐明细数据已存在,未处理");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 单位相关
|
|
|
|
/// <summary>
|
|
/// 迁移体检单位数据 一级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferTopCustomerOrgData()
|
|
{
|
|
var count = await _customerOrgRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldCustomerOrgList = await oldDb.Ado.GetDataTableAsync(" select * from [futian_user].HYDWDMB where len(BH)=4 order by BH asc");
|
|
if (oldCustomerOrgList.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in oldCustomerOrgList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
Guid customerOrgId = StringConvertGuidHelper.GenerateURLUUID(row["BH"].ToString());
|
|
|
|
|
|
if (row["BH"].ToString() == "0000")
|
|
{
|
|
customerOrgId = Guid.Parse("00000000-0000-0000-0000-000000000001");
|
|
}
|
|
|
|
#region 备注 导入联系人姓名、电话
|
|
string remark = "";
|
|
if (!string.IsNullOrWhiteSpace(row["DWFZR"].ToString()))
|
|
{
|
|
remark = row["DWFZR"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(row["LXDH"].ToString()))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(remark))
|
|
{
|
|
remark += "|" + row["LXDH"].ToString();
|
|
}
|
|
else
|
|
{
|
|
remark = row["LXDH"].ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
var data = new CustomerOrg(customerOrgId)
|
|
{
|
|
Accounts = "",
|
|
Address = row["LXDZ"].ToString(),
|
|
Bank = "",
|
|
DisplayName = row["MC"].ToString(),
|
|
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
|
|
Fax = "",
|
|
InvoiceName = row["MC"].ToString(),
|
|
IsActive = 'Y',
|
|
IsLock = 'N',
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
OrgTypeId = defaultOrgTypeId, //默认为私营
|
|
ParentId = null,
|
|
PathCode = _customerOrgManager.CreatePathCode(null).GetAwaiter().GetResult(),
|
|
PostalCode = row["YZBM"].ToString(),
|
|
Remark = remark,
|
|
ShortName = row["MC"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
Telephone = row["LXDH"].ToString(),
|
|
CountryOrgCode = row["BH"].ToString(),
|
|
SalesPerson = "",
|
|
SalesPersonPhone = "",
|
|
MedicalTypeId = null
|
|
};
|
|
|
|
await _customerOrgRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgId.ToString(),
|
|
OldKeyValue = row["BH"].ToString(),
|
|
TableName = "customer_org"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检单位一级数据处理完毕,处理数量{oldCustomerOrgList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检单位一级数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移体检单位数据 二级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferTwoCustomerOrgData()
|
|
{
|
|
var count = (await _customerOrgRepository.GetQueryableAsync()).Where(m => m.PathCode.Length > 5).Count();
|
|
if (count == 0)
|
|
{
|
|
|
|
|
|
var oldCustomerOrgList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].HYDWDMB where len(BH)=7 order by BH asc");
|
|
if (oldCustomerOrgList.Rows.Count > 0)
|
|
{
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
|
|
foreach (DataRow row in oldCustomerOrgList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
#region 查找上级ID
|
|
string oldId = row["BH"].ToString();
|
|
string oldParentId = oldId.Substring(0, 4);
|
|
Guid parentId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == oldParentId).FirstOrDefault().NewKeyValue);
|
|
#endregion
|
|
|
|
|
|
Guid customerOrgId = StringConvertGuidHelper.GenerateURLUUID(row["BH"].ToString());
|
|
|
|
|
|
#region 备注 导入联系人姓名、电话
|
|
string remark = "";
|
|
if (!string.IsNullOrWhiteSpace(row["DWFZR"].ToString()))
|
|
{
|
|
remark = row["DWFZR"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(row["LXDH"].ToString()))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(remark))
|
|
{
|
|
remark += "|" + row["LXDH"].ToString();
|
|
}
|
|
else
|
|
{
|
|
remark = row["LXDH"].ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
var data = new CustomerOrg(customerOrgId)
|
|
{
|
|
Accounts = "",
|
|
Address = row["LXDZ"].ToString(),
|
|
Bank = "",
|
|
DisplayName = row["MC"].ToString(),
|
|
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
|
|
Fax = "",
|
|
InvoiceName = row["MC"].ToString(),
|
|
IsActive = 'Y',
|
|
IsLock = 'N',
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
OrgTypeId = defaultOrgTypeId, //默认为私营
|
|
ParentId = parentId,
|
|
PathCode = _customerOrgManager.CreatePathCode(parentId).GetAwaiter().GetResult(),
|
|
PostalCode = row["YZBM"].ToString(),
|
|
Remark = remark,
|
|
ShortName = row["MC"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
Telephone = row["LXDH"].ToString(),
|
|
CountryOrgCode = row["BH"].ToString(),
|
|
SalesPerson = "",
|
|
SalesPersonPhone = "",
|
|
MedicalTypeId = null
|
|
};
|
|
|
|
await _customerOrgRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgId.ToString(),
|
|
OldKeyValue = row["BH"].ToString(),
|
|
TableName = "customer_org"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
_logger.LogInformation($"体检单位二级数据处理完毕,处理数量{oldCustomerOrgList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检单位二级数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移体检单位数据 三级
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferThreeCustomerOrgData()
|
|
{
|
|
var count = (await _customerOrgRepository.GetQueryableAsync()).Where(m => m.PathCode.Length > 11).Count();
|
|
if (count == 0)
|
|
{
|
|
|
|
var oldCustomerOrgList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].HYDWDMB where len(BH)=10 order by BH asc");
|
|
if (oldCustomerOrgList.Rows.Count > 0)
|
|
{
|
|
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
|
|
foreach (DataRow row in oldCustomerOrgList.Rows)
|
|
{
|
|
string oldId = row["BH"].ToString();
|
|
string oldParentId = oldId.Substring(0, 7);
|
|
var parentFirst = fieldComparisonList.Where(m => m.OldKeyValue == oldParentId).FirstOrDefault();
|
|
|
|
if (parentFirst != null)
|
|
{
|
|
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
|
|
#region 查找上级ID
|
|
Guid parentId = Guid.Parse(parentFirst.NewKeyValue);
|
|
#endregion
|
|
|
|
|
|
// Guid customerOrgId = GuidGenerator.Create();
|
|
Guid customerOrgId = StringConvertGuidHelper.GenerateURLUUID(row["BH"].ToString());
|
|
|
|
#region 备注 导入联系人姓名、电话
|
|
string remark = "";
|
|
if (!string.IsNullOrWhiteSpace(row["DWFZR"].ToString()))
|
|
{
|
|
remark = row["DWFZR"].ToString();
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(row["LXDH"].ToString()))
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(remark))
|
|
{
|
|
remark += "|" + row["LXDH"].ToString();
|
|
}
|
|
else
|
|
{
|
|
remark = row["LXDH"].ToString();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
var data = new CustomerOrg(customerOrgId)
|
|
{
|
|
Accounts = "",
|
|
Address = row["LXDZ"].ToString(),
|
|
Bank = "",
|
|
DisplayName = row["MC"].ToString(),
|
|
DisplayOrder = oldCustomerOrgList.Rows.IndexOf(row) + 1,
|
|
Fax = "",
|
|
InvoiceName = row["MC"].ToString(),
|
|
IsActive = 'Y',
|
|
IsLock = 'N',
|
|
MedicalCenterId = defaultMedicalCenterId,
|
|
OrgTypeId = defaultOrgTypeId, //默认为私营
|
|
ParentId = parentId,
|
|
PathCode = _customerOrgManager.CreatePathCode(parentId).GetAwaiter().GetResult(),
|
|
PostalCode = row["YZBM"].ToString(),
|
|
Remark = remark,
|
|
ShortName = row["MC"].ToString(),
|
|
SimpleCode = LanguageConverter.GetPYSimpleCode(row["MC"].ToString()),
|
|
Telephone = row["LXDH"].ToString(),
|
|
CountryOrgCode = row["BH"].ToString(),
|
|
SalesPerson = "",
|
|
SalesPersonPhone = "",
|
|
MedicalTypeId = null
|
|
};
|
|
|
|
|
|
|
|
|
|
await _customerOrgRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgId.ToString(),
|
|
OldKeyValue = row["BH"].ToString(),
|
|
TableName = "customer_org"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"体检单位三级数据处理完毕,处理数量{oldCustomerOrgList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("体检单位三级数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移单位体检次数数据 无字典
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferCustomerOrgRegisterData()
|
|
{
|
|
var count = await _customerOrgRegisterRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldCustomerOrgRegisterList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].TJ_DWTJJLB order by DWTJCS asc");
|
|
if (oldCustomerOrgRegisterList.Rows.Count > 0)
|
|
{
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
|
|
foreach (DataRow row in oldCustomerOrgRegisterList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["DWBH"].ToString()).FirstOrDefault().NewKeyValue);
|
|
Guid customerOrgRegisterId = GuidGenerator.Create();
|
|
|
|
if (customerOrgId == GuidFlag.PersonCustomerOrgId)
|
|
customerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId;
|
|
var data = new CustomerOrgRegister(customerOrgRegisterId)
|
|
{
|
|
BeginTime = Convert.ToDateTime(row["KSRQ"].ToString()),
|
|
CustomerOrgId = customerOrgId,
|
|
EndTime = !string.IsNullOrWhiteSpace(row["JSRQ"].ToString()) ? Convert.ToDateTime(row["JSRQ"].ToString()) : null,
|
|
IsComplete = row["WCBZ"].ToString() == "1" ? 'Y' : 'N',
|
|
MedicalTimes = (short)Convert.ToInt32(row["DWTJCS"].ToString()),
|
|
RegisterName = "",
|
|
RegisterNo = ""
|
|
};
|
|
|
|
await _customerOrgRegisterRepository.InsertAsync(data);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
}
|
|
}
|
|
_logger.LogInformation($"单位体检次数数据处理完毕,处理数量{oldCustomerOrgRegisterList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("单位体检次数数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 迁移单位分组
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferCustomerOrgGroupData()
|
|
{
|
|
var count = await _customerOrgGroupRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
var oldCustomerOrgGroupList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].TJ_DWFZ_HD ");
|
|
if (oldCustomerOrgGroupList.Rows.Count > 0)
|
|
{
|
|
List<FieldComparison> fieldComparisonList = await _fieldComparisonRepository.GetListAsync(m => m.TableName == "customer_org");
|
|
List<CustomerOrgRegister> customerOrgRegisterList = await _customerOrgRegisterRepository.GetListAsync();
|
|
|
|
foreach (DataRow row in oldCustomerOrgGroupList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
//新系统单位ID
|
|
Guid customerOrgId = Guid.Parse(fieldComparisonList.Where(m => m.OldKeyValue == row["DWBH"].ToString().Trim()).FirstOrDefault().NewKeyValue);
|
|
Guid customerOrgRegisterId = customerOrgRegisterList.Where(m => m.CustomerOrgId == customerOrgId
|
|
&& m.MedicalTimes == (short)Convert.ToInt32(row["DWTJCS"].ToString())).FirstOrDefault().Id;
|
|
|
|
|
|
Guid customerOrgGroupId = StringConvertGuidHelper.GenerateURLUUID(row["BH"].ToString().Trim());
|
|
var data = new CustomerOrgGroup(customerOrgGroupId)
|
|
{
|
|
AgeLowerLimit = 0,
|
|
AgeUpperLimit = 200,
|
|
CustomerOrgRegisterId = customerOrgRegisterId,
|
|
DisplayName = row["FZMC"].ToString(),
|
|
DisplayOrder = oldCustomerOrgGroupList.Rows.IndexOf(row) + 1,
|
|
ForSexId = ConvertForSex(row["XB"].ToString()),
|
|
JobPost = "",
|
|
JobTitle = "",
|
|
MaritalStatusId = row["HYZK"].ToString() == "9" ? 'A' : Convert.ToChar(row["HYZK"].ToString()),
|
|
Price = string.IsNullOrWhiteSpace(row["JG"].ToString()) ? 0 : Convert.ToDecimal(row["JG"].ToString()),
|
|
Remark = "",
|
|
CanAddMoney = 0
|
|
};
|
|
|
|
await _customerOrgGroupRepository.InsertAsync(data);
|
|
|
|
var fieldComparison = new FieldComparison
|
|
{
|
|
FieldName = "id",
|
|
NewKeyValue = customerOrgGroupId.ToString(),
|
|
OldKeyValue = row["BH"].ToString().Trim(),
|
|
TableName = "customer_org_group"
|
|
};
|
|
|
|
await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
await uow.CompleteAsync();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"单位分组数据处理完毕,处理数量{oldCustomerOrgGroupList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("单位分组数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 迁移单位分组明细数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferCustomerOrgGroupDetailData()
|
|
{
|
|
var count = await _customerOrgGroupDetailRepository.GetCountAsync();
|
|
if (count == 0)
|
|
{
|
|
|
|
int pclcount = 200;
|
|
|
|
var oldCustomerOrgGroupList = await oldDb.Ado.GetDataTableAsync("select * from [futian_user].[TJ_DWFZ_DT] ");
|
|
if (oldCustomerOrgGroupList.Rows.Count > 0)
|
|
{
|
|
List<CustomerOrgGroupDetail> tempList = new List<CustomerOrgGroupDetail>();
|
|
|
|
foreach (DataRow row in oldCustomerOrgGroupList.Rows)
|
|
{
|
|
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
{
|
|
var customer_org_group_dz = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "customer_org_group" && m.OldKeyValue == row["FZBH"].ToString().Trim()).FirstOrDefault();
|
|
var asbitem_dz = (await _fieldComparisonRepository.GetQueryableAsync()).Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["TJXM"].ToString().Trim()).FirstOrDefault();
|
|
if (asbitem_dz != null && customer_org_group_dz != null)
|
|
{
|
|
//新系统单位分组ID
|
|
Guid customerOrgGroupId = Guid.Parse(customer_org_group_dz.NewKeyValue);
|
|
Guid asbitemId = Guid.Parse(asbitem_dz.NewKeyValue);
|
|
|
|
//decimal price = 0;
|
|
//if (!decimal.TryParse(row["price"].ToString(), out price))
|
|
//{
|
|
// price = 0;
|
|
//}
|
|
|
|
var data = new CustomerOrgGroupDetail
|
|
{
|
|
AsbitemId = asbitemId,
|
|
CustomerOrgGroupId = customerOrgGroupId,
|
|
Price = 0,
|
|
Amount = 1
|
|
};
|
|
|
|
tempList.Add(data);
|
|
|
|
if (tempList.Count >= pclcount)
|
|
{
|
|
await _customerOrgGroupDetailRepository.InsertManyAsync(tempList);
|
|
|
|
tempList = new List<CustomerOrgGroupDetail>();
|
|
|
|
}
|
|
else
|
|
{
|
|
if (oldCustomerOrgGroupList.Rows.IndexOf(row) == oldCustomerOrgGroupList.Rows.Count - 1)
|
|
{
|
|
await _customerOrgGroupDetailRepository.InsertManyAsync(tempList);
|
|
}
|
|
}
|
|
}
|
|
|
|
await uow.CompleteAsync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
_logger.LogInformation($"单位分组明细数据处理完毕,处理数量{oldCustomerOrgGroupList.Rows.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("单位分组明细数据已存在,未处理");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 平衡分组明细
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task TransferPHCustomerOrgGroupDetailData()
|
|
{
|
|
var customerOrgGroupList = await _customerOrgGroupRepository.GetListAsync();
|
|
if (customerOrgGroupList.Count > 0)
|
|
{
|
|
var customerOrgGroupDetailList = (from customerOrgGroupDetail in await _customerOrgGroupDetailRepository.GetQueryableAsync()
|
|
join asbitem in await _asbitemRepository.GetQueryableAsync() on customerOrgGroupDetail.AsbitemId equals asbitem.Id
|
|
select new
|
|
{
|
|
customerOrgGroupDetail,
|
|
asbitem.Price
|
|
}).ToList();
|
|
|
|
foreach (var item in customerOrgGroupList)
|
|
{
|
|
//当前分组的明细
|
|
var tempCustomerOrgGroupDetailList = customerOrgGroupDetailList.Where(m => m.customerOrgGroupDetail.CustomerOrgGroupId == item.Id).ToList();
|
|
|
|
if (tempCustomerOrgGroupDetailList.Count > 0)
|
|
{
|
|
var fzPrice = item.Price; //分组价格
|
|
var detailSumPrice = tempCustomerOrgGroupDetailList.Sum(s => s.Price); //明细汇总价格
|
|
|
|
decimal bl = Math.Round(fzPrice / detailSumPrice, 2); //折算比例
|
|
|
|
decimal tempSumZkP = 0M;
|
|
|
|
foreach (var detailItem in tempCustomerOrgGroupDetailList)
|
|
{
|
|
var zkP = Math.Round(detailItem.Price * bl, 2);
|
|
|
|
if (tempCustomerOrgGroupDetailList.IndexOf(detailItem) == tempCustomerOrgGroupDetailList.Count - 1)
|
|
{
|
|
//最后一个
|
|
decimal tempMM = tempSumZkP + zkP;
|
|
if (tempMM > fzPrice)
|
|
{
|
|
//大于分组价格
|
|
var cj = tempMM - fzPrice;
|
|
zkP = zkP - cj;
|
|
}
|
|
else if (tempMM < fzPrice)
|
|
{
|
|
//大于分组价格
|
|
var cj = fzPrice - tempMM;
|
|
zkP = zkP + cj;
|
|
}
|
|
}
|
|
|
|
detailItem.customerOrgGroupDetail.Price = zkP;
|
|
tempSumZkP += zkP;
|
|
}
|
|
|
|
|
|
await _customerOrgGroupDetailRepository.UpdateManyAsync(tempCustomerOrgGroupDetailList.Select(s => s.customerOrgGroupDetail));
|
|
|
|
}
|
|
}
|
|
|
|
_logger.LogInformation($"平衡分组明细,处理数量{customerOrgGroupList.Count}");
|
|
}
|
|
else
|
|
{
|
|
_logger.LogInformation("平衡分组明细,未处理");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 条码分组相关
|
|
|
|
///// <summary>
|
|
///// 迁移标本类型数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//private async Task TransferSampleTypeData()
|
|
//{
|
|
// var count = await _sampleTypeRepository.GetCountAsync();
|
|
// if (count == 0)
|
|
// {
|
|
// var oldSampleTypeList = await oldDb.Ado.GetDataTableAsync("select specimen_type_id,specimen_type_name from specimen_type order by display_order asc");
|
|
// if (oldSampleTypeList.Rows.Count > 0)
|
|
// {
|
|
|
|
// foreach (DataRow row in oldSampleTypeList.Rows)
|
|
// {
|
|
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
// {
|
|
// //Guid sampleTypeId = GuidGenerator.Create();
|
|
// Guid sampleTypeId = StringConvertGuidHelper.GenerateURLUUID(row["specimen_type_id"].ToString());
|
|
|
|
// var data = new SampleType(sampleTypeId)
|
|
// {
|
|
// DisplayName = row["specimen_type_name"].ToString(),
|
|
// DisplayOrder = oldSampleTypeList.Rows.IndexOf(row) + 1,
|
|
// SimpleCode = LanguageConverter.GetPYSimpleCode(row["specimen_type_name"].ToString())
|
|
// };
|
|
|
|
// await _sampleTypeRepository.InsertAsync(data);
|
|
|
|
// var fieldComparison = new FieldComparison
|
|
// {
|
|
// TableName = "sample_type",
|
|
// FieldName = "id",
|
|
// NewKeyValue = sampleTypeId.ToString(),
|
|
// OldKeyValue = row["specimen_type_id"].ToString()
|
|
// };
|
|
|
|
// await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
// await uow.CompleteAsync();
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
// _logger.LogInformation($"标本类型数据处理完毕,处理数量{oldSampleTypeList.Rows.Count}");
|
|
// }
|
|
// else
|
|
// {
|
|
// _logger.LogInformation($"标本类型数据已存在,未处理");
|
|
// }
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 迁移条码分组数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[RemoteService(false)]
|
|
//public async Task TransferSampleGroupData()
|
|
//{
|
|
// var count = await _sampleGroupRepository.GetCountAsync();
|
|
// if (count == 0)
|
|
// {
|
|
// //获取一条条码类型的数据
|
|
// Guid defaultSampleTypeId = Guid.Empty;
|
|
// var sampleTypeEnt = await _sampleTypeRepository.FirstOrDefaultAsync();
|
|
// if (sampleTypeEnt != null)
|
|
// {
|
|
// defaultSampleTypeId = sampleTypeEnt.Id;
|
|
// }
|
|
// if (defaultSampleTypeId != Guid.Empty)
|
|
// {
|
|
// var oldSampleGroupList = await oldDb.Ado.GetDataTableAsync("select * from vessels_type order by display_order");
|
|
// if (oldSampleGroupList.Rows.Count > 0)
|
|
// {
|
|
// foreach (DataRow row in oldSampleGroupList.Rows)
|
|
// {
|
|
// using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
|
|
// {
|
|
// #region 转成成新的标本类型ID
|
|
|
|
// Guid newSampleTypeId = defaultSampleTypeId; //默认取其他 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();
|
|
// Guid sampleGroupId = StringConvertGuidHelper.GenerateURLUUID(row["vessels_type_id"].ToString());
|
|
// 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,
|
|
// SamplePrintCount = string.IsNullOrWhiteSpace(row["label_num"].ToString()) ? 0 : Convert.ToInt32(row["label_num"].ToString()),
|
|
// SampleTypeId = newSampleTypeId
|
|
// };
|
|
|
|
// await _sampleGroupRepository.InsertAsync(data);
|
|
|
|
// var fieldComparison = new FieldComparison
|
|
// {
|
|
// TableName = "sample_group",
|
|
// FieldName = "id",
|
|
// NewKeyValue = sampleGroupId.ToString(),
|
|
// OldKeyValue = row["vessels_type_id"].ToString()
|
|
// };
|
|
|
|
// await _fieldComparisonRepository.InsertAsync(fieldComparison);
|
|
|
|
// await uow.CompleteAsync();
|
|
// }
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
// _logger.LogInformation($"条码分组数据处理完毕,处理数量{oldSampleGroupList.Rows.Count}");
|
|
// }
|
|
// else
|
|
// {
|
|
// _logger.LogInformation($"条码类型未获取到默认数据,跳过条码分组数据处理");
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// _logger.LogInformation("条码分组数据已存在,未处理");
|
|
// }
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
///// 迁移条码分组明细数据
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//[RemoteService(false)]
|
|
//public async Task TransferSampleGroupDetailData()
|
|
//{
|
|
// var count = await _sampleGroupDetailRepository.GetCountAsync();
|
|
// if (count == 0)
|
|
// {
|
|
// var oldSampleGroupDetailList = await oldDb.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
|
|
// };
|
|
|
|
// await _sampleGroupDetailRepository.InsertAsync(data);
|
|
|
|
// await uow.CompleteAsync();
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
// }
|
|
// _logger.LogInformation($"条码分组明细数据处理完毕,处理数量{oldSampleGroupDetailList.Rows.Count}");
|
|
// }
|
|
// else
|
|
// {
|
|
// _logger.LogInformation("条码分组明细数据已存在,未处理");
|
|
// }
|
|
//}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 私有
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private async Task InitData()
|
|
{
|
|
|
|
#region 发票项目类别
|
|
defaultInvoiceItemTypeId = GuidGenerator.Create();
|
|
|
|
var invoiceItemTypeFirst = await _invoiceItemTypeRepository.FirstOrDefaultAsync();
|
|
if (invoiceItemTypeFirst == null)
|
|
{
|
|
var tempEntity = new InvoiceItemType(defaultInvoiceItemTypeId)
|
|
{
|
|
DisplayName = "检查费",
|
|
DisplayOrder = 1,
|
|
SimpleCode = "JCF"
|
|
};
|
|
|
|
await _invoiceItemTypeRepository.InsertAsync(tempEntity, true);
|
|
}
|
|
else
|
|
{
|
|
defaultInvoiceItemTypeId = invoiceItemTypeFirst.Id;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 汇总项目类别
|
|
defaultCollectItemTypeId = GuidGenerator.Create();
|
|
|
|
var collectItemTypeFirst = await _collectItemTypeRepository.FirstOrDefaultAsync();
|
|
if (collectItemTypeFirst == null)
|
|
{
|
|
var tempEntity = new CollectItemType(defaultCollectItemTypeId)
|
|
{
|
|
DisplayName = "检查费",
|
|
DisplayOrder = 1,
|
|
SimpleCode = "JCF",
|
|
InvoiceItemTypeId = defaultInvoiceItemTypeId
|
|
};
|
|
|
|
await _collectItemTypeRepository.InsertAsync(tempEntity, true);
|
|
}
|
|
else
|
|
{
|
|
defaultCollectItemTypeId = collectItemTypeFirst.Id;
|
|
}
|
|
#endregion
|
|
|
|
#region 企业性质
|
|
defaultOrgTypeId = GuidGenerator.Create();
|
|
|
|
var customerOrgTypeFirst = await _customerOrgTypeRepository.FirstOrDefaultAsync();
|
|
if (customerOrgTypeFirst == null)
|
|
{
|
|
var tempEntity = new CustomerOrgType(defaultOrgTypeId)
|
|
{
|
|
DisplayName = "其他",
|
|
DisplayOrder = 1,
|
|
SimpleCode = "QT"
|
|
|
|
};
|
|
|
|
await _customerOrgTypeRepository.InsertAsync(tempEntity, true);
|
|
}
|
|
else
|
|
{
|
|
defaultOrgTypeId = customerOrgTypeFirst.Id;
|
|
}
|
|
#endregion
|
|
|
|
#region 默认标本容器
|
|
|
|
|
|
defaultSampleContainerId = GuidGenerator.Create();
|
|
|
|
var sampleContainerFirst = await _sampleContainerRepository.FirstOrDefaultAsync();
|
|
if (sampleContainerFirst == null)
|
|
{
|
|
var tempEntity = new SampleContainer(defaultSampleContainerId)
|
|
{
|
|
DisplayName = "其他",
|
|
DisplayOrder = 1,
|
|
SimpleCode = "QT"
|
|
|
|
};
|
|
|
|
await _sampleContainerRepository.InsertAsync(tempEntity, true);
|
|
}
|
|
else
|
|
{
|
|
defaultSampleContainerId = sampleContainerFirst.Id;
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 转换老系统适用性别
|
|
/// </summary>
|
|
/// <param name="forSexId"></param>
|
|
/// <returns></returns>
|
|
private char ConvertForSex(string forSexId)
|
|
{
|
|
if (forSexId == "1")
|
|
{
|
|
return 'M';
|
|
}
|
|
else if (forSexId == "0")
|
|
{
|
|
return 'F';
|
|
}
|
|
else
|
|
{
|
|
return 'A';
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|