From 6438fed0bcb1e5ecce656913fc3d099dbddf5dc2 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Wed, 8 May 2024 11:13:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=93=E6=A3=80=E5=8D=95=E4=BD=8D=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseDataHandleAppService.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs b/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs index 2912948..7531195 100644 --- a/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs +++ b/src/Shentun.Peis.Application/DataMigrations/BaseDataHandleAppService.cs @@ -315,6 +315,7 @@ namespace Shentun.Peis.DataMigrations await TransferThreeCustomerOrgData(); await TransferCustomerOrgRegisterData(); await TransferCustomerOrgGroupData(); + await TransferCustomerOrgGroupDetailData(); } #region 基础数据 @@ -2200,6 +2201,57 @@ namespace Shentun.Peis.DataMigrations } } + + /// + /// 迁移单位分组明细数据 + /// + /// + [RemoteService(false)] + public async Task TransferCustomerOrgGroupDetailData() + { + var count = await _customerOrgGroupDetailRepository.GetCountAsync(); + if (count == 0) + { + + var oldCustomerOrgGroupList = await Db.Ado.GetDataTableAsync("select * from org_group_detail "); + if (oldCustomerOrgGroupList.Rows.Count > 0) + { + + foreach (DataRow row in oldCustomerOrgGroupList.Rows) + { + using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) + { + //新系统单位分组ID + Guid customerOrgGroupId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()) + .Where(m => m.TableName == "customer_org_group" && m.OldKeyValue == row["org_group_id"].ToString()).FirstOrDefault().NewKeyValue); + Guid asbitemId = Guid.Parse((await _fieldComparisonRepository.GetQueryableAsync()) + .Where(m => m.TableName == "asbitem" && m.OldKeyValue == row["asbitem_id"].ToString()).FirstOrDefault().NewKeyValue); + + var data = new CustomerOrgGroupDetail + { + AsbitemId = asbitemId, + CustomerOrgGroupId = customerOrgGroupId, + Price = Convert.ToDecimal(row["price"].ToString()), + Amount = 1 + }; + + await _customerOrgGroupDetailRepository.InsertAsync(data); + + await uow.CompleteAsync(); + } + + } + + + } + _logger.LogInformation($"单位分组明细数据处理完毕,处理数量{oldCustomerOrgGroupList.Rows.Count}"); + } + else + { + _logger.LogInformation("单位分组明细数据已存在,未处理"); + } + } + #endregion