diff --git a/src/Shentun.Peis.Application/BeiJingMZAKExportDatas/BeiJingMZAKExportDataAppService.cs b/src/Shentun.Peis.Application/BeiJingMZAKExportDatas/BeiJingMZAKExportDataAppService.cs index cf6ea7d..b56b3ac 100644 --- a/src/Shentun.Peis.Application/BeiJingMZAKExportDatas/BeiJingMZAKExportDataAppService.cs +++ b/src/Shentun.Peis.Application/BeiJingMZAKExportDatas/BeiJingMZAKExportDataAppService.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using Shentun.Peis.ColumnReferences; using Shentun.Peis.CustomerOrgs; using Shentun.Peis.DataMigrations; using Shentun.Peis.Enums; @@ -116,6 +117,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas private readonly IConfiguration _configuration; private readonly MyUserAppService _myUserAppService; + private readonly ColumnReferenceAppService _columnReferenceAppService; public BeiJingMZAKExportDataAppService( UnitOfWorkManager unitOfWorkManager, IRepository deviceTypeRepository, @@ -167,7 +169,8 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas IRepository sumSummaryContentRepository, IRepository sumDiagnosisRepository, IConfiguration configuration, - MyUserAppService myUserAppService) + MyUserAppService myUserAppService, + ColumnReferenceAppService columnReferenceAppService) { _unitOfWorkManager = unitOfWorkManager; _deviceTypeRepository = deviceTypeRepository; @@ -220,6 +223,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas _sumDiagnosisRepository = sumDiagnosisRepository; _configuration = configuration; _myUserAppService = myUserAppService; + _columnReferenceAppService = columnReferenceAppService; } @@ -2406,7 +2410,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas continue; } - + //档案ID Guid patientId = Guid.Empty; @@ -2981,7 +2985,7 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas continue; } - + //档案ID Guid patientId = Guid.Empty; @@ -3523,169 +3527,43 @@ namespace Shentun.Peis.BeiJingMZAKExportDatas #endregion - //#region 临时处理 - - //private int hangPatientRegisterUserCount = 0; - - ///// - ///// 临时处理人员相关医生数据 - ///// - ///// - ///// - ///// - //[HttpPost("api/app/BeiJingMZAKExportData/TransferPatientRegisterUserData")] - //public async Task TransferPatientRegisterUserData(int handCount, bool isGo = false) - //{ - // //处理 人员表 审核医生 总检医生 - // //处理 RegisterCheck 审核医生 检查医生 - - // //当前导入的ID - // string nextKeyValue = oldDb.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register_user' "); - - // var oldPatientRegisterList = await oldDb.Ado.GetDataTableAsync($"select top {handCount} * from patient_register where patient_register_id>'{nextKeyValue}' and patient_register_id<='20160523011706' order by patient_register_id asc"); - - // if (oldPatientRegisterList.Rows.Count > 0) - // { - // var userList = await _identityUserRepository.GetListAsync(); - - - // foreach (DataRow row in oldPatientRegisterList.Rows) - // { - // hangPatientRegisterUserCount++; - // using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) - // { - // string oldPatientRegisterId = row["patient_register_id"].ToString(); - - // var isDZPatientRegisterTemp = (await _fieldComparisonRepository.GetListAsync(f => f.TableName == "patient_register" - // && f.OldKeyValue == oldPatientRegisterId)); - // var isDZPatientRegister = isDZPatientRegisterTemp.OrderByDescending(o => o.NewKeyValue).FirstOrDefault(); - // if (isDZPatientRegister != null) - // { - // Guid newPatientRegisterId = Guid.Parse(isDZPatientRegister.NewKeyValue); //新ID - - // var isPatientRegister = await _patientRegisterRepository.FirstOrDefaultAsync(f => f.Id == newPatientRegisterId); - - - // #region 转换审核医生ID - // Guid? AuditDoctorId = null; - // if (!string.IsNullOrWhiteSpace(row["audit_doctor"].ToString())) - // { - // var userEnt = userList.Where(m => m.Name == row["audit_doctor"].ToString().Trim()).FirstOrDefault(); - // if (userEnt != null) - // { - // AuditDoctorId = userEnt.Id; - // } - // } - // #endregion - - // #region 转换总检医生ID - // Guid? summaryDoctorId = null; - // if (!string.IsNullOrWhiteSpace(row["summary_doctor"].ToString())) - // { - // var userEnt = userList.Where(m => m.Name == row["summary_doctor"].ToString().Trim()).FirstOrDefault(); - // if (userEnt != null) - // { - // summaryDoctorId = userEnt.Id; - // } - // } - // #endregion - - // isPatientRegister.AuditDoctorId = AuditDoctorId; - // isPatientRegister.SummaryDoctorId = summaryDoctorId; - - // await _patientRegisterRepository.UpdateAsync(isPatientRegister); - - - - // #region 处理registercheck - - // var oldRegisterAsbitemList = await oldDb.Ado.GetDataTableAsync($"select * from register_asbitem where patient_register_id='{oldPatientRegisterId}'"); - - // if (oldRegisterAsbitemList.Rows.Count > 0) - // { - // foreach (DataRow rowAsbitem in oldRegisterAsbitemList.Rows) - // { - // #region 转换审核医生ID - // Guid? auditorUserId = null; - // if (!string.IsNullOrWhiteSpace(rowAsbitem["audit_doctor"].ToString())) - // { - // var userEnt = userList.Where(m => m.Name == rowAsbitem["audit_doctor"].ToString().Trim()).FirstOrDefault(); - // if (userEnt != null) - // { - // auditorUserId = userEnt.Id; - // } - // } - // #endregion - - // #region 转换检查医生ID - // string checkDoctorId = null; - // if (!string.IsNullOrWhiteSpace(rowAsbitem["check_doctor"].ToString())) - // { - // var userEnt = userList.Where(m => m.Name == rowAsbitem["check_doctor"].ToString().Trim()).FirstOrDefault(); - // if (userEnt != null) - // { - // checkDoctorId = userEnt.Id.ToString(); - // } - // else - // { - // checkDoctorId = rowAsbitem["check_doctor"].ToString().Trim(); - // } - // } - // #endregion - - // #region 转换组合项目ID - // Guid newAsbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()) - // .Where(m => m.TableName == "asbitem" && m.OldKeyValue == rowAsbitem["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue); - // #endregion - - // //需要处理的ID - // var newRegisterCheckId = (from registerCheck in await _registerCheckRepository.GetQueryableAsync() - // join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() - // on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId - // where registerCheck.PatientRegisterId == newPatientRegisterId && registerCheckAsbitem.AsbitemId == newAsbitemId - // select registerCheck.Id).FirstOrDefault(); - - - // var isRegisterCheck = await _registerCheckRepository.FirstOrDefaultAsync(f => f.Id == newRegisterCheckId); - - // if (isRegisterCheck != null) - // { - // isRegisterCheck.CheckDoctorId = checkDoctorId; - // isRegisterCheck.AuditorUserId = auditorUserId; - - // await _registerCheckRepository.UpdateAsync(isRegisterCheck); - - // } - - // } - // } - - // #endregion - // } + /// + /// 迁移子项目对照数据 + /// + /// + 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!=''"); + 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(','); + + var inputDto = new UpdateColumnReferenceInterfaceDto + { + ColumnReferenceId = Guid.Parse("3a125a29-ae4d-1ba8-db69-cffd0c629fc0"), + AppCode = new UpdateColumnReferenceCodeDto { CodeValue = newItemId.ToString() }, + InterfaceCodes = oldInterfaceCodeValues.Select(s => new UpdateColumnReferenceInterfaceCodeDto + { + CodeValue = s + }).ToList() + }; + await _columnReferenceAppService.UpdateInterfaceCodeValuesAsync(inputDto); + } + + } + } - // await oldDb.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{row["patient_register_id"].ToString()}',addtime=getdate(),handlecount+=1 where tablename='patient_register_user' "); - - // await uow.CompleteAsync(); - - // } - // } - - // _logger.LogInformation($"临时处理人员相关医生数据{oldPatientRegisterList.Rows.Count}条,当前总数{hangPatientRegisterUserCount}"); - // if (isGo) - // await TransferPatientRegisterUserData(handCount, isGo); - // } - // else - // { - // _logger.LogInformation("临时处理人员相关医生数据已处理完"); - // } - //} - - - //#endregion - #region 私有方法