@ -6,7 +6,9 @@ using SqlSugar;
using System ;
using System ;
using System.Collections.Generic ;
using System.Collections.Generic ;
using System.Data ;
using System.Data ;
using System.Linq ;
using System.Threading.Tasks ;
using System.Threading.Tasks ;
using TencentCloud.Ame.V20190916.Models ;
using Volo.Abp ;
using Volo.Abp ;
using Volo.Abp.Application.Services ;
using Volo.Abp.Application.Services ;
using Volo.Abp.Domain.Repositories ;
using Volo.Abp.Domain.Repositories ;
@ -36,6 +38,7 @@ namespace Shentun.Peis.DataMigrations
private readonly IRepository < MedicalType , Guid > _medicalTypeRepository ;
private readonly IRepository < MedicalType , Guid > _medicalTypeRepository ;
private readonly IRepository < PersonnelType , Guid > _personnelTypeRepository ;
private readonly IRepository < PersonnelType , Guid > _personnelTypeRepository ;
private readonly IRepository < InvoiceItemType , Guid > _invoiceItemTypeRepository ;
private readonly IRepository < InvoiceItemType , Guid > _invoiceItemTypeRepository ;
private readonly IRepository < FieldComparison , Guid > _fieldComparisonRepository ;
public BaseDataHandleAppService (
public BaseDataHandleAppService (
IRepository < DeviceType , Guid > deviceTypeRepository ,
IRepository < DeviceType , Guid > deviceTypeRepository ,
@ -44,7 +47,8 @@ namespace Shentun.Peis.DataMigrations
IRepository < Unit , Guid > unitRepository ,
IRepository < Unit , Guid > unitRepository ,
IRepository < MedicalType , Guid > medicalTypeRepository ,
IRepository < MedicalType , Guid > medicalTypeRepository ,
IRepository < PersonnelType , Guid > personnelTypeRepository ,
IRepository < PersonnelType , Guid > personnelTypeRepository ,
IRepository < InvoiceItemType , Guid > invoiceItemTypeRepository )
IRepository < InvoiceItemType , Guid > invoiceItemTypeRepository ,
IRepository < FieldComparison , Guid > fieldComparisonRepository )
{
{
_deviceTypeRepository = deviceTypeRepository ;
_deviceTypeRepository = deviceTypeRepository ;
_itemTypeRepository = itemTypeRepository ;
_itemTypeRepository = itemTypeRepository ;
@ -53,6 +57,7 @@ namespace Shentun.Peis.DataMigrations
_medicalTypeRepository = medicalTypeRepository ;
_medicalTypeRepository = medicalTypeRepository ;
_personnelTypeRepository = personnelTypeRepository ;
_personnelTypeRepository = personnelTypeRepository ;
_invoiceItemTypeRepository = invoiceItemTypeRepository ;
_invoiceItemTypeRepository = invoiceItemTypeRepository ;
_fieldComparisonRepository = fieldComparisonRepository ;
}
}
/// <summary>
/// <summary>
@ -64,21 +69,34 @@ namespace Shentun.Peis.DataMigrations
var count = await _deviceTypeRepository . GetCountAsync ( ) ;
var count = await _deviceTypeRepository . GetCountAsync ( ) ;
if ( count = = 0 )
if ( count = = 0 )
{
{
List < DeviceType > dataList = new List < DeviceType > ( ) ;
var oldDeviceTypeList = await Db . Ado . GetDataTableAsync ( "select device_type_name from device_type order by display_order asc" ) ;
var oldDeviceTypeList = await Db . Ado . GetDataTableAsync ( "select device_type_id,device_type_name from device_type order by display_order asc" ) ;
if ( oldDeviceTypeList . Rows . Count > 0 )
if ( oldDeviceTypeList . Rows . Count > 0 )
{
{
List < FieldComparison > fieldComparisons = new List < FieldComparison > ( ) ;
foreach ( DataRow row in oldDeviceTypeList . Rows )
foreach ( DataRow row in oldDeviceTypeList . Rows )
{
{
dataList . Add ( new DeviceType
var data = new DeviceType
{
{
CheckTypeFlag = '0' ,
CheckTypeFlag = '0' ,
DisplayName = row [ "device_type_name" ] . ToString ( ) ,
DisplayName = row [ "device_type_name" ] . ToString ( ) ,
DisplayOrder = oldDeviceTypeList . Rows . IndexOf ( row ) + 1 ,
DisplayOrder = oldDeviceTypeList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "device_type_name" ] . ToString ( ) )
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "device_type_name" ] . ToString ( ) )
} ;
var ent = await _deviceTypeRepository . InsertAsync ( data , true ) ;
fieldComparisons . Add ( new FieldComparison
{
TableName = "device_type" ,
FieldName = "id" ,
NewKeyValue = ent . Id . ToString ( ) ,
OldKeyValue = row [ "device_type_id" ] . ToString ( )
} ) ;
} ) ;
}
}
await _deviceTypeRepository . InsertManyAsync ( dataList ) ;
await _fieldComparisonRepository . InsertManyAsync ( fieldComparisons ) ;
}
}
}
}
}
}
@ -93,20 +111,34 @@ namespace Shentun.Peis.DataMigrations
var count = await _unitRepository . GetCountAsync ( ) ;
var count = await _unitRepository . GetCountAsync ( ) ;
if ( count = = 0 )
if ( count = = 0 )
{
{
List < Unit > dataList = new List < Unit > ( ) ;
var oldUnitList = await Db . Ado . GetDataTableAsync ( "select unit_name from unit order by display_order asc" ) ;
var oldUnitList = await Db . Ado . GetDataTableAsync ( "select unit_id,unit_ name from unit order by display_order asc" ) ;
if ( oldUnitList . Rows . Count > 0 )
if ( oldUnitList . Rows . Count > 0 )
{
{
List < FieldComparison > fieldComparisons = new List < FieldComparison > ( ) ;
foreach ( DataRow row in oldUnitList . Rows )
foreach ( DataRow row in oldUnitList . Rows )
{
{
dataList . Add ( new Unit
var data = new Unit
{
{
DisplayName = row [ "unit_name" ] . ToString ( ) ,
DisplayName = row [ "unit_name" ] . ToString ( ) ,
DisplayOrder = oldUnitList . Rows . IndexOf ( row ) + 1 ,
DisplayOrder = oldUnitList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "unit_name" ] . ToString ( ) )
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "unit_name" ] . ToString ( ) )
} ;
var ent = await _unitRepository . InsertAsync ( data , true ) ;
fieldComparisons . Add ( new FieldComparison
{
TableName = "unit" ,
FieldName = "id" ,
NewKeyValue = ent . Id . ToString ( ) ,
OldKeyValue = row [ "unit_id" ] . ToString ( )
} ) ;
} ) ;
}
}
await _unitRepository . InsertManyAsync ( dataList ) ;
await _fieldComparisonRepository . InsertManyAsync ( fieldComparisons ) ;
}
}
}
}
}
}
@ -120,20 +152,33 @@ namespace Shentun.Peis.DataMigrations
var count = await _medicalTypeRepository . GetCountAsync ( ) ;
var count = await _medicalTypeRepository . GetCountAsync ( ) ;
if ( count = = 0 )
if ( count = = 0 )
{
{
List < MedicalType > dataList = new List < MedicalType > ( ) ;
var oldMedicalTypeList = await Db . Ado . GetDataTableAsync ( "select medical_type_name from medical_type order by display_order asc" ) ;
var oldMedicalTypeList = await Db . Ado . GetDataTableAsync ( "select medical_type_id,medical_type_ name from medical_type order by display_order asc" ) ;
if ( oldMedicalTypeList . Rows . Count > 0 )
if ( oldMedicalTypeList . Rows . Count > 0 )
{
{
List < FieldComparison > fieldComparisons = new List < FieldComparison > ( ) ;
foreach ( DataRow row in oldMedicalTypeList . Rows )
foreach ( DataRow row in oldMedicalTypeList . Rows )
{
{
dataList . Add ( new MedicalType
var data = new MedicalType
{
{
DisplayName = row [ "medical_type_name" ] . ToString ( ) ,
DisplayName = row [ "medical_type_name" ] . ToString ( ) ,
DisplayOrder = oldMedicalTypeList . Rows . IndexOf ( row ) + 1 ,
DisplayOrder = oldMedicalTypeList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "medical_type_name" ] . ToString ( ) )
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "medical_type_name" ] . ToString ( ) )
} ;
var ent = await _medicalTypeRepository . InsertAsync ( data , true ) ;
fieldComparisons . Add ( new FieldComparison
{
TableName = "medical_type" ,
FieldName = "id" ,
NewKeyValue = ent . Id . ToString ( ) ,
OldKeyValue = row [ "medical_type_id" ] . ToString ( )
} ) ;
} ) ;
}
}
await _medicalTypeRepository . InsertManyAsync ( dataList ) ;
await _fieldComparisonRepository . InsertManyAsync ( fieldComparisons ) ;
}
}
}
}
}
}
@ -148,20 +193,33 @@ namespace Shentun.Peis.DataMigrations
var count = await _personnelTypeRepository . GetCountAsync ( ) ;
var count = await _personnelTypeRepository . GetCountAsync ( ) ;
if ( count = = 0 )
if ( count = = 0 )
{
{
List < PersonnelType > dataList = new List < PersonnelType > ( ) ;
var oldPersonnelTypeList = await Db . Ado . GetDataTableAsync ( "select personnel_type_name from personnel_type order by display_order asc" ) ;
var oldPersonnelTypeList = await Db . Ado . GetDataTableAsync ( "select personnel_type_id,personnel_type_ name from personnel_type order by display_order asc" ) ;
if ( oldPersonnelTypeList . Rows . Count > 0 )
if ( oldPersonnelTypeList . Rows . Count > 0 )
{
{
List < FieldComparison > fieldComparisons = new List < FieldComparison > ( ) ;
foreach ( DataRow row in oldPersonnelTypeList . Rows )
foreach ( DataRow row in oldPersonnelTypeList . Rows )
{
{
dataList . Add ( new PersonnelType
var data = new PersonnelType
{
{
DisplayName = row [ "personnel_type_name" ] . ToString ( ) ,
DisplayName = row [ "personnel_type_name" ] . ToString ( ) ,
DisplayOrder = oldPersonnelTypeList . Rows . IndexOf ( row ) + 1 ,
DisplayOrder = oldPersonnelTypeList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "personnel_type_name" ] . ToString ( ) )
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "personnel_type_name" ] . ToString ( ) )
} ;
var ent = await _personnelTypeRepository . InsertAsync ( data , true ) ;
fieldComparisons . Add ( new FieldComparison
{
TableName = "personnel_type" ,
FieldName = "id" ,
NewKeyValue = ent . Id . ToString ( ) ,
OldKeyValue = row [ "personnel_type_id" ] . ToString ( )
} ) ;
} ) ;
}
}
await _personnelTypeRepository . InsertManyAsync ( dataList ) ;
await _fieldComparisonRepository . InsertManyAsync ( fieldComparisons ) ;
}
}
}
}
}
}
@ -177,20 +235,32 @@ namespace Shentun.Peis.DataMigrations
var count = await _invoiceItemTypeRepository . GetCountAsync ( ) ;
var count = await _invoiceItemTypeRepository . GetCountAsync ( ) ;
if ( count = = 0 )
if ( count = = 0 )
{
{
List < InvoiceItemType > dataList = new List < InvoiceItemType > ( ) ;
var oldInvoiceItemTypeList = await Db . Ado . GetDataTableAsync ( "select invoice_item_type_name from invoice_item_type order by display_order asc" ) ;
var oldInvoiceItemTypeList = await Db . Ado . GetDataTableAsync ( "select invoice_item_type_id,invoice_item_type_ name from invoice_item_type order by display_order asc" ) ;
if ( oldInvoiceItemTypeList . Rows . Count > 0 )
if ( oldInvoiceItemTypeList . Rows . Count > 0 )
{
{
List < FieldComparison > fieldComparisons = new List < FieldComparison > ( ) ;
foreach ( DataRow row in oldInvoiceItemTypeList . Rows )
foreach ( DataRow row in oldInvoiceItemTypeList . Rows )
{
{
dataList . Add ( new InvoiceItemType
var data = new InvoiceItemType
{
{
DisplayName = row [ "invoice_item_type_name" ] . ToString ( ) ,
DisplayName = row [ "invoice_item_type_name" ] . ToString ( ) ,
DisplayOrder = oldInvoiceItemTypeList . Rows . IndexOf ( row ) + 1 ,
DisplayOrder = oldInvoiceItemTypeList . Rows . IndexOf ( row ) + 1 ,
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "invoice_item_type_name" ] . ToString ( ) )
SimpleCode = LanguageConverter . GetPYSimpleCode ( row [ "invoice_item_type_name" ] . ToString ( ) )
} ;
var ent = await _invoiceItemTypeRepository . InsertAsync ( data , true ) ;
fieldComparisons . Add ( new FieldComparison
{
TableName = "invoice_item_type" ,
FieldName = "id" ,
NewKeyValue = ent . Id . ToString ( ) ,
OldKeyValue = row [ "invoice_item_type_id" ] . ToString ( )
} ) ;
} ) ;
}
}
await _invoiceItemTypeRepository . InsertManyAsync ( dataList ) ;
await _fieldComparisonRepository . InsertManyAsync ( fieldComparisons ) ;
}
}
}
}
}
}