From e8b679e12df4ee7fb3a4eaa8e0b38bb83fabc4a1 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Sun, 9 Jun 2024 15:52:18 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../TransToWebPeisAppService.cs | 81 +++++++++++++++----
1 file changed, 66 insertions(+), 15 deletions(-)
diff --git a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
index 5aaf7d5..b94350f 100644
--- a/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
+++ b/src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
@@ -59,7 +59,7 @@ namespace Shentun.Peis.TransToWebPeis
private readonly SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{
- ConnectionString = "server=.;uid=sa;pwd=123;database=mypeis0513;Encrypt=false;",
+ ConnectionString = "server=135.191.65.102;uid=sa;pwd=123;database=mypeis0513;Encrypt=false;",
DbType = SqlSugar.DbType.SqlServer,
IsAutoCloseConnection = true
});
@@ -1267,7 +1267,7 @@ namespace Shentun.Peis.TransToWebPeis
///
public async Task ExportPatientRegisterWithDetailData()
{
- var connectString = @"Host=62.156.10.86;Port=5432;Database=WebPeis0520;User ID=postgres;Password=st123;";
+ var connectString = @"Host=10.1.12.138;Port=5432;Database=WebPeis0520;User ID=postgres;Password=st123;";
SqlSugarClient WebDb = new SqlSugarClient(new ConnectionConfig()
{
@@ -1283,31 +1283,82 @@ namespace Shentun.Peis.TransToWebPeis
.Where(m => string.Compare(m.Id.ToString(), string.IsNullOrEmpty(nextKeyValue) ? "" : nextKeyValue) > 0).OrderBy(o => o.Id).Select(s => s.Id).Take(1000).ToList();
-
-
- foreach (var patientRegisterId in patientRegisterIds)
+ if (patientRegisterIds.Any())
{
- sumCount++;
- using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
+ foreach (var patientRegisterId in patientRegisterIds)
{
- var IsPatient = (await WebDb.Ado.GetDataTableAsync($"select patient_register_id from patient_register where patient_register_id='{patientRegisterId}'")).Rows.Count;
- if (IsPatient == 0)
+ sumCount++;
+ using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
{
- await TransPatientRegisterWithDetailAsync(WebDb, patientRegisterId);
- handCount++;
+ var IsPatient = (await WebDb.Ado.GetDataTableAsync($"select patient_register_id from patient_register where patient_register_id='{patientRegisterId}'")).Rows.Count;
+ if (IsPatient == 0)
+ {
+ await TransPatientRegisterWithDetailAsync(WebDb, patientRegisterId);
+ handCount++;
+ }
+
+ nextKeyValue = patientRegisterId.ToString();
}
- nextKeyValue = patientRegisterId.ToString();
+ await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{patientRegisterId}',addtime=getdate(),handlecount+=1 where tablename='patient_register_web' ");
}
-
- await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{patientRegisterId}',addtime=getdate(),handlecount+=1 where tablename='patient_register_web' ");
}
-
_logger.LogInformation($"当前查询数据:{sumCount},新增数据:{handCount}");
await ExportPatientRegisterWithDetailData();
}
+
+
+
+ ///
+ /// 反向导入 导入体检数据到web 全部导入 2024-06-07
+ ///
+ ///
+ public async Task ExportPatientRegisterWithDetailReverseData()
+ {
+ //var connectString = @"Host=10.1.12.138;Port=5432;Database=WebPeis0520;User ID=postgres;Password=st123;";
+ var connectString = @"Host=62.156.10.86;Port=5432;Database=WebPeis0520;User ID=postgres;Password=st123;";
+
+ SqlSugarClient WebDb = new SqlSugarClient(new ConnectionConfig()
+ {
+ ConnectionString = connectString,
+ DbType = SqlSugar.DbType.PostgreSQL,
+ IsAutoCloseConnection = true
+ });
+
+
+ string nextKeyValue = Db.Ado.GetString("select keyvalue from tb_export_key where tablename='patient_register_web_reverse' ");
+
+ var patientRegisterIds = (await _patientRegisterRepository.GetQueryableAsync())
+ .Where(m => string.Compare(string.IsNullOrEmpty(nextKeyValue) ? "" : nextKeyValue, m.Id.ToString()) > 0).OrderByDescending(o => o.Id).Select(s => s.Id).Take(1000).ToList();
+
+ if (patientRegisterIds.Any())
+ {
+ foreach (var patientRegisterId in patientRegisterIds)
+ {
+ sumCount++;
+ using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
+ {
+ var IsPatient = (await WebDb.Ado.GetDataTableAsync($"select patient_register_id from patient_register where patient_register_id='{patientRegisterId}'")).Rows.Count;
+ if (IsPatient == 0)
+ {
+ await TransPatientRegisterWithDetailAsync(WebDb, patientRegisterId);
+ handCount++;
+ }
+
+ nextKeyValue = patientRegisterId.ToString();
+ }
+
+ await Db.Ado.ExecuteCommandAsync($"update tb_export_key set keyvalue='{patientRegisterId}',addtime=getdate(),handlecount+=1 where tablename='patient_register_web_reverse' ");
+ }
+ }
+
+ _logger.LogInformation($"当前降序查询数据:{sumCount},新增数据:{handCount}");
+
+ await ExportPatientRegisterWithDetailReverseData();
+ }
+
}
}