@ -15,6 +15,7 @@ using Shentun.Peis.ItemTypes;
using Shentun.Peis.Migrations ;
using Shentun.Peis.Models ;
using Shentun.Peis.MyUser ;
using Shentun.Peis.OrganizationUnits ;
using Shentun.Peis.PatientRegisters ;
using Shentun.Peis.RegisterCheckItems ;
using Shentun.Utilities ;
@ -29,6 +30,7 @@ using System.Threading.Tasks;
using Volo.Abp ;
using Volo.Abp.Application.Services ;
using Volo.Abp.Caching ;
using Volo.Abp.Data ;
using Volo.Abp.Domain.Entities ;
using Volo.Abp.Domain.Repositories ;
using Volo.Abp.EntityFrameworkCore ;
@ -40,7 +42,7 @@ using static System.Formats.Asn1.AsnWriter;
namespace Shentun.Peis.CCTJExportDatas
{
/// <summary>
/// 长城体检中心 老系统 数据导入1
/// 长城体检中心数据导入
/// </summary>
[Authorize]
public class CCTJExportDataAppService : ApplicationService
@ -137,6 +139,24 @@ namespace Shentun.Peis.CCTJExportDatas
private static List < CustomerOrgRegister > _customerOrgRegisterList = new List < CustomerOrgRegister > ( ) ;
private static List < IdentityUser > _userList = new List < IdentityUser > ( ) ;
private readonly IRepository < GuideType , char > _guideTypeRepository ;
private readonly IRepository < MedicalReportType , char > _medicalReportTypeRepository ;
private readonly IRepository < MedicalConclusionType > _medicalConclusionTypeRepository ;
private readonly IRepository < SampleContainer , Guid > _sampleContainerRepository ;
private readonly IRepository < CustomerOrgType , Guid > _customerOrgTypeRepository ;
private readonly IRepository < OrganizationUnit , Guid > _organizationUnitRepository ;
private readonly PeisOrganizationUnitManager _organizationUnitManager ;
private readonly IRepository < Sex > _sexRepository ;
private readonly IRepository < ForSex > _forSexRepository ;
private readonly IRepository < MaritalStatus > _maritalStatusRepository ;
private readonly IRepository < ResultStatus > _resultStatusRepository ;
private readonly IRepository < PayMode > _payModeRepository ;
private readonly IRepository < DiagnosisLevel , short > _diagnosisLevelRepository ;
private readonly IdentityUserManager _identityUserManager ;
private readonly IRepository < IdentityUserOrganizationUnit > _identityUserOrganizationUnitRepository ;
private readonly IRepository < CommonTable , Guid > _commonTableRepository ;
public CCTJExportDataAppService (
UnitOfWorkManager unitOfWorkManager ,
IRepository < DeviceType , Guid > deviceTypeRepository ,
@ -194,7 +214,23 @@ namespace Shentun.Peis.CCTJExportDatas
IRepository < CardRegister , Guid > cardRegisterRepository ,
IServiceScopeFactory serviceScopeFactory ,
IDbContextProvider < PeisDbContext > dbContextProvider ,
ICurrentUser currentUser )
ICurrentUser currentUser ,
IRepository < GuideType , char > guideTypeRepository ,
IRepository < MedicalReportType , char > medicalReportTypeRepository ,
IRepository < MedicalConclusionType > medicalConclusionTypeRepository ,
IRepository < SampleContainer , Guid > sampleContainerRepository ,
IRepository < CustomerOrgType , Guid > customerOrgTypeRepository ,
IRepository < OrganizationUnit , Guid > organizationUnitRepository ,
PeisOrganizationUnitManager organizationUnitManager ,
IRepository < Sex > sexRepository ,
IRepository < ForSex > forSexRepository ,
IRepository < MaritalStatus > maritalStatusRepository ,
IRepository < ResultStatus > resultStatusRepository ,
IRepository < PayMode > payModeRepository ,
IRepository < DiagnosisLevel , short > diagnosisLevelRepository ,
IdentityUserManager identityUserManager ,
IRepository < IdentityUserOrganizationUnit > identityUserOrganizationUnitRepository ,
IRepository < CommonTable , Guid > commonTableRepository )
{
_unitOfWorkManager = unitOfWorkManager ;
_deviceTypeRepository = deviceTypeRepository ;
@ -253,6 +289,202 @@ namespace Shentun.Peis.CCTJExportDatas
_serviceScopeFactory = serviceScopeFactory ;
_dbContextProvider = dbContextProvider ;
_currentUser = currentUser ;
_guideTypeRepository = guideTypeRepository ;
_medicalReportTypeRepository = medicalReportTypeRepository ;
_medicalConclusionTypeRepository = medicalConclusionTypeRepository ;
_sampleContainerRepository = sampleContainerRepository ;
_customerOrgTypeRepository = customerOrgTypeRepository ;
_organizationUnitRepository = organizationUnitRepository ;
_organizationUnitManager = organizationUnitManager ;
_sexRepository = sexRepository ;
_forSexRepository = forSexRepository ;
_maritalStatusRepository = maritalStatusRepository ;
_resultStatusRepository = resultStatusRepository ;
_payModeRepository = payModeRepository ;
_diagnosisLevelRepository = diagnosisLevelRepository ;
_identityUserManager = identityUserManager ;
_identityUserOrganizationUnitRepository = identityUserOrganizationUnitRepository ;
_commonTableRepository = commonTableRepository ;
}
/// <summary>
/// 默认数据处理
/// </summary>
/// <returns></returns>
[HttpPost("api/app/CCTJExportData/HandDefaultData")]
public async Task HandDefaultData ( )
{
#region 默认指引类别
var isDefaultGuidType = await _guideTypeRepository . FirstOrDefaultAsync ( f = > f . Id = = defaultGuidTypeId ) ;
if ( isDefaultGuidType = = null )
{
List < GuideType > guideTypes = new List < GuideType > ( ) ;
guideTypes . Add ( new GuideType ( defaultGuidTypeId )
{
DisplayName = "普通检查" ,
SimpleCode = "PTJC" ,
DisplayOrder = 1
} ) ;
guideTypes . Add ( new GuideType ( '1' )
{
DisplayName = "检验" ,
SimpleCode = "JY" ,
DisplayOrder = 2
} ) ;
guideTypes . Add ( new GuideType ( '2' )
{
DisplayName = "特检" ,
SimpleCode = "TJ" ,
DisplayOrder = 3
} ) ;
guideTypes . Add ( new GuideType ( '3' )
{
DisplayName = "放射" ,
SimpleCode = "FS" ,
DisplayOrder = 4
} ) ;
await _guideTypeRepository . InsertManyAsync ( guideTypes ) ;
}
#endregion
#region 默认体检报告类别
var isDefaultMedicalReportType = await _medicalReportTypeRepository . FirstOrDefaultAsync ( f = > f . Id = = defaultMedicalReportTypeId ) ;
if ( isDefaultMedicalReportType = = null )
{
List < MedicalReportType > medicalReportTypes = new List < MedicalReportType > ( ) ;
medicalReportTypes . Add ( new MedicalReportType ( defaultMedicalReportTypeId )
{
DisplayName = "普通检查" ,
SimpleCode = "PTJC" ,
DisplayOrder = 1
} ) ;
medicalReportTypes . Add ( new MedicalReportType ( '1' )
{
DisplayName = "检验" ,
SimpleCode = "JY" ,
DisplayOrder = 2
} ) ;
medicalReportTypes . Add ( new MedicalReportType ( '2' )
{
DisplayName = "特检" ,
SimpleCode = "TJ" ,
DisplayOrder = 3
} ) ;
medicalReportTypes . Add ( new MedicalReportType ( '3' )
{
DisplayName = "放射" ,
SimpleCode = "FS" ,
DisplayOrder = 4
} ) ;
await _medicalReportTypeRepository . InsertManyAsync ( medicalReportTypes ) ;
}
#endregion
#region 默认体检结论类别
var isDefaultMedicalConclusionType = await _medicalConclusionTypeRepository . FirstOrDefaultAsync ( f = > f . Id = = defaultMedicalConclusionType ) ;
if ( isDefaultMedicalConclusionType = = null )
{
var defaultEnt = new MedicalConclusionType
{
Id = defaultMedicalConclusionType ,
DisplayName = "社会体检" ,
DisplayOrder = 1
} ;
await _medicalConclusionTypeRepository . InsertAsync ( defaultEnt ) ;
}
#endregion
#region 默认体检中心
var isDefaultMedicalCenter = await _organizationUnitRepository . FirstOrDefaultAsync ( f = > f . Id = = defaultMedicalCenterId ) ;
if ( isDefaultMedicalCenter = = null )
{
OrganizationUnit defaultEnt = new OrganizationUnit ( defaultMedicalCenterId , "石家庄长城体检中心" , null ) ;
defaultEnt . SetProperty ( "IsPeis" , 'Y' ) ;
await _organizationUnitManager . CreateAsync ( defaultEnt ) ;
}
#endregion
#region 默认容器
var isDefaultSampleContainer = await _sampleContainerRepository . FirstOrDefaultAsync ( f = > f . Id = = defaultSampleContainerId ) ;
if ( isDefaultSampleContainer = = null )
{
var defaultEnt = new SampleContainer ( defaultSampleContainerId )
{
DisplayName = "管子" ,
SimpleCode = "GZ" ,
DisplayOrder = 1 ,
ContainerColor = 1 6 7 1 1 6 8 0 ,
ContainerColorName = "其它" ,
ContainerRemark = ""
} ;
await _sampleContainerRepository . InsertAsync ( defaultEnt ) ;
}
#endregion
#region 默认单位性质
var isDefaultOrgType = await _customerOrgTypeRepository . FirstOrDefaultAsync ( f = > f . Id = = defaultOrgTypeId ) ;
if ( isDefaultOrgType = = null )
{
var defaultEnt = new CustomerOrgType ( defaultOrgTypeId )
{
DisplayName = "其它" ,
SimpleCode = "QT" ,
DisplayOrder = 1
} ;
await _customerOrgTypeRepository . InsertAsync ( defaultEnt ) ;
}
#endregion
#region 诊断级别
var isDiagnosisLevel = await _diagnosisLevelRepository . CountAsync ( ) ;
if ( isDiagnosisLevel = = 0 )
{
List < DiagnosisLevel > diagnosisLevels = new List < DiagnosisLevel > ( ) ;
diagnosisLevels . Add ( new DiagnosisLevel ( 1 )
{
DisplayName = "一级" ,
DisplayOrder = 1
} ) ;
diagnosisLevels . Add ( new DiagnosisLevel ( 2 )
{
DisplayName = "二级" ,
DisplayOrder = 2
} ) ;
diagnosisLevels . Add ( new DiagnosisLevel ( 3 )
{
DisplayName = "三级" ,
DisplayOrder = 3
} ) ;
diagnosisLevels . Add ( new DiagnosisLevel ( 4 )
{
DisplayName = "四级" ,
DisplayOrder = 4
} ) ;
await _diagnosisLevelRepository . InsertManyAsync ( diagnosisLevels ) ;
}
#endregion
await CreateSexAsync ( ) ;
await CreateForSexAsync ( ) ;
await CreateMaritalStatusAsync ( ) ;
await CreateResultStatusAsync ( ) ;
}
@ -260,7 +492,6 @@ namespace Shentun.Peis.CCTJExportDatas
/// 处理基础数据
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpPost("api/app/CCTJExportData/HandBaseData")]
public async Task HandBaseData ( )
{
@ -275,6 +506,8 @@ namespace Shentun.Peis.CCTJExportDatas
await TransferNationData ( ) ;
await TransferMedicalConclusionData ( ) ;
await TransferUserData ( ) ;
await TransferUserOrganizationUnitData ( ) ;
await TransferPayModeData ( ) ;
}
@ -282,7 +515,6 @@ namespace Shentun.Peis.CCTJExportDatas
/// 处理基础项目相关数据
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpPost("api/app/CCTJExportData/HandBaseItemData")]
public async Task HandBaseItemData ( )
{
@ -760,39 +992,55 @@ namespace Shentun.Peis.CCTJExportDatas
[RemoteService(false)]
public async Task TransferNationData ( )
{
var newNationList = await _nationRepository . GetListAsync ( ) ;
var oldNationList = await oldDb . Ado . GetDataTableAsync ( "select * from nation" ) ;
if ( oldNationList . Rows . Count > 0 )
var count = await _nationRepository . GetCountAsync ( ) ;
if ( count = = 0 )
{
foreach ( DataRow row in oldNationList . Rows )
var oldNationList = await oldDb . Ado . GetDataTableAsync ( "select * from nation order by nation_id asc" ) ;
if ( oldNationList . Rows . Count > 0 )
{
string oldName = row [ "nation_name" ] . ToString ( ) ; //老系统名称
var newNationEnt = newNationList . Where ( m = > m . DisplayName . Contains ( oldName ) ) . FirstOrDefault ( ) ;
if ( newNationEnt ! = null )
foreach ( DataRow row in oldNationList . Rows )
{
var fieldComparison = new FieldComparison
using ( var uow = _unitOfWorkManager . Begin ( requiresNew : true , isTransactional : true ) )
{
FieldName = "id" ,
NewKeyValue = newNationEnt . Id . ToString ( ) ,
OldKeyValue = row [ "nation_id" ] . ToString ( ) ,
TableName = "nation"
} ;
await _fieldComparisonRepository . InsertAsync ( fieldComparison ) ;
var data = new Nation ( )
{
Id = row [ "nation_id" ] . ToString ( ) ,
CountryCode = "" ,
DisplayName = row [ "nation_name" ] . ToString ( ) ,
DisplayOrder = oldNationList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = row [ "py_simple_code" ] . ToString ( )
} ;
await _nationRepository . InsertAsync ( data ) ;
var fieldComparison = new FieldComparison
{
TableName = "nation" ,
FieldName = "id" ,
NewKeyValue = row [ "nation_id" ] . ToString ( ) ,
OldKeyValue = row [ "nation_id" ] . ToString ( )
} ;
await _fieldComparisonRepository . InsertAsync ( fieldComparison ) ;
await uow . CompleteAsync ( ) ;
}
}
}
_logger . LogInformation ( $"民族数据处理完毕,处理数量{oldNationList.Rows.Count}" ) ;
}
else
{
_logger . LogInformation ( $"民族数据无需处理" ) ;
_logger . LogInformation ( $"民族数据已存在,未 处理" ) ;
}
}
/// <summary>
/// 迁移体检结论数据
/// </summary>
@ -844,6 +1092,74 @@ namespace Shentun.Peis.CCTJExportDatas
}
}
/// <summary>
/// 迁移用户对应的科室
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferUserOrganizationUnitData ( )
{
var count = await _identityUserOrganizationUnitRepository . CountAsync ( ) ;
if ( count = = 0 )
{
var identityUserList = await _identityUserRepository . GetListAsync ( ) ;
if ( identityUserList . Count > 0 )
{
foreach ( var item in identityUserList )
{
await _identityUserManager . SetOrganizationUnitsAsync ( item . Id , defaultMedicalCenterId ) ;
}
}
_logger . LogInformation ( $"用户对应的科室处理完毕,处理数量{identityUserList.Count}" ) ;
}
else
{
_logger . LogInformation ( "用户对应的科室已存在,未处理" ) ;
}
}
/// <summary>
/// 迁移收费方式数据
/// </summary>
/// <returns></returns>
[RemoteService(false)]
public async Task TransferPayModeData ( )
{
var count = await _payModeRepository . GetCountAsync ( ) ;
if ( count = = 0 )
{
var oldPaymentModeList = await oldDb . Ado . GetDataTableAsync ( "select payment_mode_id,payment_mode_name from payment_mode order by display_order asc" ) ;
if ( oldPaymentModeList . Rows . Count > 0 )
{
foreach ( DataRow row in oldPaymentModeList . Rows )
{
using ( var uow = _unitOfWorkManager . Begin ( requiresNew : true , isTransactional : true ) )
{
var data = new PayMode ( )
{
Id = row [ "payment_mode_id" ] . ToString ( ) ,
DisplayName = row [ "payment_mode_name" ] . ToString ( ) ,
DisplayOrder = oldPaymentModeList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "payment_mode_name" ] . ToString ( ) ) ,
IsActive = 'Y'
} ;
await _payModeRepository . InsertAsync ( data ) ;
await uow . CompleteAsync ( ) ;
}
}
}
_logger . LogInformation ( $"收费方式数据处理完毕,处理数量{oldPaymentModeList.Rows.Count}" ) ;
}
else
{
_logger . LogInformation ( "收费方式数据已存在,未处理" ) ;
}
}
#endregion
@ -2450,6 +2766,7 @@ namespace Shentun.Peis.CCTJExportDatas
/// <param name="isGo">是否继续处理</param>
/// <returns></returns>
[HttpPost("api/app/CCTJExportData/TransferPatientRegisterWithDetailData")]
[RemoteService(false)]
public async Task TransferPatientRegisterWithDetailData ( int handCount , string startdate , string enddate , bool isGo = false )
{
Stopwatch stopwatch = new Stopwatch ( ) ;
@ -2474,7 +2791,7 @@ namespace Shentun.Peis.CCTJExportDatas
DataTable oldPatientRegisterList = await oldDb . Ado . GetDataTableAsync ( sqlPatientRegister ) ;
stopwatch . Stop ( ) ;
_logger . LogInformation ( $"获取要导入的人员总数耗时:{stopwatch.ElapsedMilliseconds}" + $"共{oldPatientRegisterList.Rows.Count}条" ) ;
_logger . LogInformation ( $"获取要导入的人员总数耗时:{stopwatch.ElapsedMilliseconds}" + $"共{oldPatientRegisterList.Rows.Count}条" ) ;
if ( oldPatientRegisterList . Rows . Count > 0 )
{
Stopwatch stopwatch2 = new Stopwatch ( ) ;
@ -2516,14 +2833,38 @@ namespace Shentun.Peis.CCTJExportDatas
}
/// <summary>
/// 人员信息导入
/// </summary>
/// <param name="patientRegisterIdFrom"></param>
/// <param name="patientRegisterIdTo"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost("api/app/CCTJExportData/TransferPatientRegisterWithDetailDataById")]
public async Task TransferPatientRegisterWithDetailDataById ( long patientRegisterIdFrom , long patientRegisterIdTo )
public async Task TransferPatientRegisterWithDetailDataById ( long patientRegisterIdFrom , long patientRegisterIdTo )
{
#region 初始数据
if ( fieldComparisonTempList . Count = = 0 )
{
fieldComparisonTempList = ( await _fieldComparisonRepository . GetQueryableAsync ( ) ) . Where ( m = > m . TableName ! = "patient_register" ) . ToList ( ) ;
asbitemFieldComparisonTempList = fieldComparisonTempList . Where ( o = > o . TableName = = "asbitem" ) . ToList ( ) ;
itemFieldComparisonTempList = fieldComparisonTempList . Where ( o = > o . TableName = = "item" ) . ToList ( ) ;
}
if ( ! _customerOrgRegisterList . Any ( ) )
_customerOrgRegisterList = await _customerOrgRegisterRepository . GetListAsync ( ) ;
if ( ! _userList . Any ( ) )
_userList = await _identityUserRepository . GetListAsync ( ) ;
_logger . LogInformation ( $"组合项目数:{asbitemFieldComparisonTempList.Count},项目数:{itemFieldComparisonTempList.Count}" ) ;
#endregion
Stopwatch stopwatch = new Stopwatch ( ) ;
stopwatch . Start ( ) ;
_logger . LogInformation ( $"开始导入数据" ) ;
//当前导入的ID
string nextKeyValue = oldDb . Ado . GetString ( "select keyvalue from tb_export_key where tablename='patient_register' " ) ;
//string nextKeyValue = oldDb.Ado.GetString( "select keyvalue from tb_export_key where tablename='patient_register' ");
string sqlPatientRegister = "" ;
if ( patientRegisterIdFrom > = patientRegisterIdTo )
@ -2579,7 +2920,7 @@ namespace Shentun.Peis.CCTJExportDatas
}
private async Task ImportSingle ( List < CustomerOrgRegister > customerOrgRegisterList , List < IdentityUser > userList , DataRow row )
private async Task ImportSingle ( List < CustomerOrgRegister > customerOrgRegisterList , List < IdentityUser > userList , DataRow row )
{
try
{
@ -2847,7 +3188,7 @@ namespace Shentun.Peis.CCTJExportDatas
if ( oldRegisterAsbitemList . Rows . Count > 0 )
{
var oldRegisterCheckItemListAll = await oldDb . Ado . GetDataTableAsync ( $"select * from register_item where patient_register_id='{row[" patient_register_id "].ToString()}'" ) ;
var oldRegisterCheckItemListAll = await oldDb . Ado . GetDataTableAsync ( $"select * from register_item where patient_register_id='{row[" patient_register_id "].ToString()}'" ) ;
var registerCheckList = new List < RegisterCheck > ( ) ;
var registerCheckAsbitemList = new List < RegisterCheckAsbitem > ( ) ;
@ -3853,6 +4194,7 @@ namespace Shentun.Peis.CCTJExportDatas
/// <param name="handCount">每次处理的人员数量</param>
/// <param name="isGo">是否继续处理</param>
/// <returns></returns>
[RemoteService(false)]
[HttpPost("api/app/CCTJExportData/TransferPatientRegisterWithDetailReverseData")]
public async Task TransferPatientRegisterWithDetailReverseData ( int handCount , bool isGo = false )
{
@ -4434,7 +4776,7 @@ namespace Shentun.Peis.CCTJExportDatas
/// <returns></returns>
public async Task TranferItemColumnReferenceData ( )
{
var oldColumnReferenceList = await oldDb . Ado . GetDataTableAsync ( $"select code_value,interface_code_value from column_reference_detail where column_reference_id=004 and interface_code_value!=''" ) ;
var oldColumnReferenceList = await oldDb . Ado . GetDataTableAsync ( $"select code_value,interface_code_value from column_reference_detail where column_reference_id=001 and interface_code_value!=''" ) ;
foreach ( DataRow item in oldColumnReferenceList . Rows )
{
var fieldComparisonEnt = await _fieldComparisonRepository . FirstOrDefaultAsync ( f = > f . TableName = = "item" & & f . OldKeyValue = = item [ "code_value" ] . ToString ( ) . Trim ( ) ) ;
@ -4449,7 +4791,7 @@ namespace Shentun.Peis.CCTJExportDatas
var inputDto = new UpdateColumnReferenceInterfaceDto
{
ColumnReferenceId = Guid . Parse ( "3a125a29-ae4d-1ba8-db69-cffd0c629fc0 " ) ,
ColumnReferenceId = Guid . Parse ( "3a1cfe80-ab99-509b-5447-8cf83c25fba6 " ) ,
AppCode = new UpdateColumnReferenceCodeDto { CodeValue = newItemId . ToString ( ) } ,
InterfaceCodes = oldInterfaceCodeValues . Select ( s = > new UpdateColumnReferenceInterfaceCodeDto
{
@ -4463,6 +4805,49 @@ namespace Shentun.Peis.CCTJExportDatas
}
}
/// <summary>
/// 迁移迪安项目对照数据
/// </summary>
/// <returns></returns>
public async Task TranferDAItemColumnReferenceData ( )
{
List < CommonTable > commonTables = new List < CommonTable > ( ) ;
var oldColumnReferenceList = await oldDb . Ado . GetDataTableAsync ( $"select code_value,interface_code_value from column_reference_detail where column_reference_id=002 and interface_code_value!=''" ) ;
foreach ( DataRow item in oldColumnReferenceList . Rows )
{
var fieldComparisonEnt = await _fieldComparisonRepository . FirstOrDefaultAsync ( f = > f . TableName = = "item" & & f . OldKeyValue = = item [ "code_value" ] . ToString ( ) . Trim ( ) ) ;
if ( fieldComparisonEnt ! = null )
{
var newItemId = Guid . Parse ( fieldComparisonEnt . NewKeyValue ) ;
string oldInterfaceCodeValue = item [ "interface_code_value" ] . ToString ( ) ;
string [ ] oldInterfaceCodeValues = oldInterfaceCodeValue . Split ( ',' ) ;
foreach ( var codeValue in oldInterfaceCodeValues )
{
commonTables . Add ( new CommonTable
{
CommonTableTypeId = "100" ,
DataCode = codeValue ,
DisplayName = newItemId . ToString ( ) ,
DisplayOrder = oldColumnReferenceList . Rows . IndexOf ( item ) + 1 ,
SimpleCode = ""
} ) ;
}
}
}
await _commonTableRepository . InsertManyAsync ( commonTables ) ;
}
#region 会员卡相关
/// <summary>
/// 迁移会员卡相关数据 金额后面统计
/// </summary>
@ -4591,7 +4976,7 @@ namespace Shentun.Peis.CCTJExportDatas
_logger . LogInformation ( $"会员卡数据已存在,未处理" ) ;
}
}
#endregion
#region 私有方法
@ -4665,45 +5050,325 @@ namespace Shentun.Peis.CCTJExportDatas
var oldUserList = await oldDb . Ado . GetDataTableAsync ( "select * from users" ) ;
if ( oldUserList . Rows . Count > 0 )
{
foreach ( DataRow row in oldUserList . Rows )
if ( await _identityUserRepository . CountAsync ( ) = = 1 )
{
using ( var uow = _unitOfWorkManager . Begin ( requiresNew : true , isTransactional : true ) )
foreach ( DataRow row in oldUserList . Rows )
{
string newUserName = LanguageConverter . GetPYSimpleCode ( row [ "user_id" ] . ToString ( ) . Trim ( ) ) ;
var isUserName = await _identityUserRepository . FirstOrDefaultAsync ( m = > m . UserName = = newUserName ) ;
if ( isUserName ! = null )
{
newUserName + = "2" ;
}
var userEnt = new IdentityUserCreateNoEmailDto
using ( var uow = _unitOfWorkManager . Begin ( requiresNew : true , isTransactional : true ) )
{
Email = "" ,
IsActive = row [ "valid_flag" ] . ToString ( ) = = "Y" ? true : false ,
LockoutEnabled = false ,
Name = row [ "user_name" ] . ToString ( ) . Trim ( ) ,
Password = string . IsNullOrWhiteSpace ( row [ "password" ] . ToString ( ) ) ? "888888" : row [ "password" ] . ToString ( ) ,
PhoneNumber = "" ,
RoleNames = new string [ ] { "admin" } ,
Surname = "" ,
UserName = newUserName ,
UserPhoto = "" ,
UserSign = ""
} ;
string newUserName = LanguageConverter . GetPYSimpleCode ( row [ "user_id" ] . ToString ( ) . Trim ( ) ) ;
await _myUserAppService . CreateAsync ( userEnt ) ;
var isUserName = await _identityUserRepository . FirstOrDefaultAsync ( m = > m . UserName = = newUserName ) ;
if ( isUserName ! = null )
{
newUserName + = "2" ;
}
var userEnt = new IdentityUserCreateNoEmailDto
{
Email = "" ,
IsActive = row [ "valid_flag" ] . ToString ( ) = = "Y" ? true : false ,
LockoutEnabled = false ,
Name = "" ,
Password = string . IsNullOrWhiteSpace ( row [ "password" ] . ToString ( ) ) ? "888888" : row [ "password" ] . ToString ( ) ,
PhoneNumber = "" ,
RoleNames = new string [ ] { "admin" } ,
Surname = row [ "user_name" ] . ToString ( ) . Trim ( ) ,
UserName = newUserName ,
UserPhoto = "" ,
UserSign = ""
} ;
await uow . CompleteAsync ( ) ;
await _myUserAppService . CreateAsync ( userEnt ) ;
await uow . CompleteAsync ( ) ;
}
}
}
else
{
_logger . LogInformation ( "用户数据已存在,未处理" ) ;
}
}
}
#endregion
#region 默认数据
/// <summary>
/// 生成性别表基础数据
/// </summary>
/// <returns></returns>
private async Task CreateSexAsync ( )
{
if ( await _sexRepository . GetCountAsync ( ) = = 0 )
{
List < Sex > sexes = new List < Sex > ( ) ;
sexes . Add ( new Sex
{
DisplayName = "未知" ,
Id = 'U' ,
DisplayOrder = 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "未知" )
} ) ;
sexes . Add ( new Sex
{
DisplayName = "男" ,
Id = 'M' ,
DisplayOrder = 2 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "男" )
} ) ;
sexes . Add ( new Sex
{
DisplayName = "女" ,
Id = 'F' ,
DisplayOrder = 3 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "女" )
} ) ;
await _sexRepository . InsertManyAsync ( sexes ) ;
}
}
/// <summary>
/// 生成适用性别表基础数据
/// </summary>
/// <returns></returns>
private async Task CreateForSexAsync ( )
{
if ( await _forSexRepository . GetCountAsync ( ) = = 0 )
{
List < ForSex > forSexes = new List < ForSex > ( ) ;
forSexes . Add ( new ForSex
{
DisplayName = "全部" ,
Id = 'A' ,
DisplayOrder = 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "全部" )
} ) ;
forSexes . Add ( new ForSex
{
DisplayName = "男" ,
Id = 'M' ,
DisplayOrder = 2 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "男" )
} ) ;
forSexes . Add ( new ForSex
{
DisplayName = "女" ,
Id = 'F' ,
DisplayOrder = 3 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "女" )
} ) ;
await _forSexRepository . InsertManyAsync ( forSexes ) ;
}
}
/// <summary>
/// 生成婚姻状况表基础数据
/// </summary>
/// <returns></returns>
private async Task CreateMaritalStatusAsync ( )
{
if ( await _maritalStatusRepository . GetCountAsync ( ) = = 0 )
{
List < MaritalStatus > maritalStatuses = new List < MaritalStatus > ( ) ;
maritalStatuses . Add ( new MaritalStatus
{
DisplayName = "未婚" ,
Id = '0' ,
DisplayOrder = 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "未婚" )
} ) ;
maritalStatuses . Add ( new MaritalStatus
{
DisplayName = "已婚" ,
Id = '1' ,
DisplayOrder = 2 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "已婚" )
} ) ;
maritalStatuses . Add ( new MaritalStatus
{
DisplayName = "离异" ,
Id = '2' ,
DisplayOrder = 3 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "离异" )
} ) ;
maritalStatuses . Add ( new MaritalStatus
{
DisplayName = "丧偶" ,
Id = '3' ,
DisplayOrder = 4 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "丧偶" )
} ) ;
maritalStatuses . Add ( new MaritalStatus
{
DisplayName = "离异或丧偶" ,
Id = '4' ,
DisplayOrder = 5 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "离异或丧偶" )
} ) ;
maritalStatuses . Add ( new MaritalStatus
{
DisplayName = "未知" ,
Id = '9' ,
DisplayOrder = 6 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( "未知" )
} ) ;
await _maritalStatusRepository . InsertManyAsync ( maritalStatuses ) ;
}
}
/// <summary>
/// 生成结果状态
/// </summary>
/// <returns></returns>
private async Task CreateResultStatusAsync ( )
{
if ( await _resultStatusRepository . GetCountAsync ( ) = = 0 )
{
#region 数据
List < ResultStatus > resultStatuses = new List < ResultStatus > ( ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "01" ,
DisplayName = "正常" ,
ReportPrompt = "" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 0 ,
DataInputPrompt = "" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 0 ,
DisplayOrder = 1
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "02" ,
DisplayName = "错误" ,
ReportPrompt = "×" ,
ReportBackgroundColor = 1 6 7 1 1 6 8 0 ,
ReportFontColor = 2 5 5 ,
DataInputPrompt = "×" ,
DataInputBackgroundColor = 1 6 7 1 1 8 0 8 ,
DataInputFontColor = 2 5 5 ,
DisplayOrder = 2
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "03" ,
DisplayName = "阴性" ,
ReportPrompt = "-" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 0 ,
DataInputPrompt = "-" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 0 ,
DisplayOrder = 3
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "04" ,
DisplayName = "阳性" ,
ReportPrompt = "+" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 0 ,
DataInputPrompt = "+" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 0 ,
DisplayOrder = 4
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "05" ,
DisplayName = "弱阳性" ,
ReportPrompt = "±" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 0 ,
DataInputPrompt = "±" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 0 ,
DisplayOrder = 5
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "06" ,
DisplayName = "偏低" ,
ReportPrompt = "↓" ,
ReportBackgroundColor = 6 5 5 3 5 ,
ReportFontColor = 1 6 7 1 1 6 8 0 ,
DataInputPrompt = "↓" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 1 6 7 1 1 6 8 0 ,
DisplayOrder = 6
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "07" ,
DisplayName = "偏高" ,
ReportPrompt = "↑" ,
ReportBackgroundColor = 8 4 5 4 1 4 3 ,
ReportFontColor = 2 5 5 ,
DataInputPrompt = "↑" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 2 5 5 ,
DisplayOrder = 7
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "08" ,
DisplayName = "危急值下限" ,
ReportPrompt = "↓" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 8 4 2 1 3 7 6 ,
DataInputPrompt = "↓" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 8 4 2 1 3 7 6 ,
DisplayOrder = 8
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "09" ,
DisplayName = "危急值上限" ,
ReportPrompt = "↑" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 1 6 7 1 1 9 3 5 ,
DataInputPrompt = "↑" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 1 6 7 1 1 9 3 5 ,
DisplayOrder = 9
} ) ;
resultStatuses . Add ( new ResultStatus
{
Id = "10" ,
DisplayName = "危急值" ,
ReportPrompt = "×" ,
ReportBackgroundColor = 1 6 7 7 7 2 1 5 ,
ReportFontColor = 1 6 7 1 1 9 3 5 ,
DataInputPrompt = "×" ,
DataInputBackgroundColor = 1 6 7 7 7 2 1 5 ,
DataInputFontColor = 1 6 7 1 1 9 3 5 ,
DisplayOrder = 1 0
} ) ;
#endregion
await _resultStatusRepository . InsertManyAsync ( resultStatuses ) ;
}
}
#endregion
}
}