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