Quintiq file version 2.0
|
#parent: #root
|
StaticMethod Compared (
|
RecycleBin recycleBin,
|
const MacroPlan mactoPlan,
|
String baseVersionPath,
|
String compareVersionPath,
|
String baseVersionName,
|
String compareVersionName
|
) as LocalTable
|
{
|
TextBody:
|
[*
|
// rislai Jun-20-2024 (created)
|
localTable := recycleBin.LocalTable( relnew,Name := baseVersionName + "__" + compareVersionName );
|
|
products := selectset( mactoPlan,Product_MP,product,not product.IsSystem() and product.IsUsed() );
|
productIndexTree := NamedValueTree::Create();
|
try{
|
for( i := 0; i < products.Size(); i++){
|
product := products.Element( i );
|
productHandle := productIndexTree.GetHandle( product.Notes() );
|
productIndexTree.Root().AddChild( productHandle,i )
|
}
|
}onerror{}
|
|
|
baseVersionFile := OSFile::Construct();
|
compareVersionFile := OSFile::Construct();
|
|
try {
|
baseVersionFile.Open( baseVersionPath, "Read", false );
|
baseVersionDataSource := GeneralExcelImportAndExportDataSource::Upload( recycleBin, baseVersionFile.ReadBinary(), baseVersionPath );
|
baseVersionDataSource.ReadStructure();
|
|
compareVersionFile.Open( compareVersionPath, "Read", false );
|
compareVersionDataSource := GeneralExcelImportAndExportDataSource::Upload( recycleBin, compareVersionFile.ReadBinary(), compareVersionPath );
|
compareVersionDataSource.ReadStructure();
|
|
baseVersionTable := select( baseVersionDataSource, GeneralExcelImportAndExportDataTable, tempGEIAEDT, true );
|
compareVersionTable := select( compareVersionDataSource, GeneralExcelImportAndExportDataTable, tempGEIAEDT, true );
|
|
if( not isnull( baseVersionTable ) and not isnull( compareVersionTable )){
|
|
//生成行数据
|
rowKeys := construct( Strings );
|
rowKeyIndexTree := NamedValueTree::Create();
|
|
baseVersionRowTree := NamedValueTree::Create();
|
baseVersionRows := construct( GeneralExcelImportAndExportDataRows ,constcontent);
|
compareVersionRowTree := NamedValueTree::Create();
|
compareVersionRows := construct( GeneralExcelImportAndExportDataRows ,constcontent);
|
LocalCell_DemandComparison::FillRows( baseVersionTable,rowKeys,rowKeyIndexTree,baseVersionRowTree,baseVersionRows );
|
LocalCell_DemandComparison::FillRows( compareVersionTable,rowKeys,rowKeyIndexTree,compareVersionRowTree,compareVersionRows );
|
|
// 生成列数据
|
columnTree := NamedValueTree::Create();
|
columns := construct( LocalColumns );
|
LocalCell_DemandComparison::GenerateColumnIndex( baseVersionTable,localTable,columnTree,columns );
|
LocalCell_DemandComparison::GenerateColumnIndex( compareVersionTable,localTable,columnTree,columns );
|
columnNames := selectvalues( columns,Elements,column,true,column.CustomName());
|
|
// 生成数据
|
for ( rowIndex := 0; rowIndex < rowKeys.Size(); rowIndex++ ) {
|
rowKey := rowKeys.Element( rowIndex );
|
|
baseVersionCellTree := NamedValueTree::Create();
|
baseVersionCells := construct( GeneralExcelImportAndExportDataCells ,constcontent);
|
|
compareVersionCellTree := NamedValueTree::Create();
|
compareVersionCells := construct( GeneralExcelImportAndExportDataCells ,constcontent);
|
|
LocalCell_DemandComparison::FillCells( rowKey,baseVersionRowTree,baseVersionRows,baseVersionCellTree,baseVersionCells );
|
LocalCell_DemandComparison::FillCells( rowKey,compareVersionRowTree,compareVersionRows,compareVersionCellTree,compareVersionCells );
|
|
row := localTable.LocalRow( relnew,Index := localTable.GetRowIndexCache() );
|
|
traverse( columnNames,Elements,columnName ,columnName <> "" ){
|
columnHandle := columnTree.GetHandle( columnName );
|
columnIndex := guard( columnTree.Root().Child( columnHandle ) , null( NamedValue ));
|
column := null( LocalColumn );
|
if( not isnull( columnIndex )){
|
column := columns.Element( columnIndex.GetValueAsNumber() );
|
}
|
if( isnull( column )){
|
error( columnName + " is null." );
|
}
|
|
baseVersionCell := constnull( GeneralExcelImportAndExportDataCell );
|
baseVersionCellHandle := baseVersionCellTree.GetHandle( columnName );
|
baseVersionCellIndex := guard( baseVersionCellTree.Root().Child( baseVersionCellHandle ),null( NamedValue ));
|
if( not isnull( baseVersionCellIndex )){
|
baseVersionCell := baseVersionCells.Element( baseVersionCellIndex.GetValueAsNumber() );
|
}
|
|
compareVersionCell := constnull( GeneralExcelImportAndExportDataCell );
|
compareVersionCellHandle := compareVersionCellTree.GetHandle( columnName );
|
compareVersionCellIndex := guard( compareVersionCellTree.Root().Child( compareVersionCellHandle ),null( NamedValue ));
|
if( not isnull( compareVersionCellIndex )){
|
compareVersionCell := compareVersionCells.Element( compareVersionCellIndex.GetValueAsNumber() );
|
}
|
|
if( columnName = "产地" or columnName = "车型" or columnName = "发动机零件号" or columnName = "发动机四位码" ){
|
row.LocalCell( relnew,LocalCell_DemandComparison,LocalColumn := column,
|
BaseVersionValue := ifexpr( isnull( baseVersionCell ), "空", baseVersionCell.Value()),
|
CompareVersionValue := ifexpr( isnull( compareVersionCell ),"空",compareVersionCell.Value()));
|
column.IsAttrbuteColumn( true );
|
if( columnName = "发动机零件号" ){
|
productID := ifexpr( isnull( baseVersionCell ), ifexpr( isnull( compareVersionCell ),"空",compareVersionCell.Value()), baseVersionCell.Value());
|
|
productHanlde := productIndexTree.GetHandle( productID );
|
productIndex := guard( productIndexTree.Root().Child( productHanlde ), null( NamedValue ));
|
if( not isnull( productIndex )){
|
product := products.Element( productIndex.GetValueAsNumber() );
|
productID := product.ID();
|
}
|
|
row.ProductID( productID );
|
|
}
|
if( columnName = "车型" ){
|
row.CustomName( " > " + ifexpr( isnull( baseVersionCell ), ifexpr( isnull( compareVersionCell ),"空",compareVersionCell.Value()), baseVersionCell.Value()) );
|
}
|
}else{
|
row.LocalCell( relnew,LocalCell_DemandComparison,LocalColumn := column,
|
BaseVersion := ifexpr( isnull( baseVersionCell ),0,[Real]baseVersionCell.Value()),
|
CompareVersion := ifexpr( isnull( compareVersionCell ), 0 ,[Real]compareVersionCell.Value() ));
|
}
|
}
|
row.CustomName( row.ProductID() + row.CustomName() );
|
}
|
}
|
// 后续删除
|
baseVersionDataSource.Delete();
|
compareVersionDataSource.Delete();
|
|
baseVersionFile.Close();
|
compareVersionFile.Close();
|
} onerror {
|
if( not isnull( baseVersionFile )){
|
baseVersionFile.Close();
|
}
|
if( not isnull( compareVersionFile )){
|
compareVersionFile.Close();
|
}
|
error( e.GeneralInformation() );
|
}
|
|
return localTable;
|
*]
|
}
|