From 70aa430bdb228d6193286faa437dd5b90366c6ea Mon Sep 17 00:00:00 2001
From: rislai <risheng.lai@capgemini.com>
Date: 星期六, 22 六月 2024 03:31:30 +0800
Subject: [PATCH] 添加需求版本对比功能

---
 _Main/BL/Type_ArchivePR/StaticMethod_Compared.qbl |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/_Main/BL/Type_ArchivePR/StaticMethod_Compared.qbl b/_Main/BL/Type_ArchivePR/StaticMethod_Compared.qbl
index a6be942..75469e5 100644
--- a/_Main/BL/Type_ArchivePR/StaticMethod_Compared.qbl
+++ b/_Main/BL/Type_ArchivePR/StaticMethod_Compared.qbl
@@ -9,13 +9,108 @@
   TextBody:
   [*
     // rislai Jun-20-2024 (created)
-    // archive := baseVersion.Archive(); // archive涓嶅彲璁剧疆涓哄彧璇�
+    localTable := recycleBin.LocalTable( relnew,Name := baseVersion.Name() + "__" + compareVersion.Name());
     
-    table := recycleBin.LocalTable( relnew );
+    baseVersionFile := OSFile::Construct();
+    compareVersionFile := OSFile::Construct();
     
-    baseVersion.Load( table ); 
-    compareVersion.Load( table ); 
+    try {
+      baseVersionFile.Open( baseVersion.FilePath(), "Read", false );
+      baseVersionDataSource := GeneralExcelImportAndExportDataSource::Upload( recycleBin, baseVersionFile.ReadBinary(), baseVersion.FilePath() );
+      baseVersionDataSource.ReadStructure();
+      
+      compareVersionFile.Open( compareVersion.FilePath(), "Read", false );
+      compareVersionDataSource := GeneralExcelImportAndExportDataSource::Upload( recycleBin, compareVersionFile.ReadBinary(), compareVersion.FilePath() );
+      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 );
+        baseVersionRowTree := NamedValueTree::Create();
+        baseVersionRows := construct( GeneralExcelImportAndExportDataRows ,constcontent);
+        compareVersionRowTree := NamedValueTree::Create();
+        compareVersionRows := construct( GeneralExcelImportAndExportDataRows ,constcontent);
+        ArchivePR::FillRows( baseVersionTable,rowKeys,baseVersionRowTree,baseVersionRows );
+        ArchivePR::FillRows( compareVersionTable,rowKeys,compareVersionRowTree,compareVersionRows );
+        
+        // 鐢熸垚鍒楁暟鎹�
+        columnTree := NamedValueTree::Create();
+        columns := construct( LocalColumns );
+        ArchivePR::GenerateColumnIndex( baseVersionTable,localTable,columnTree,columns );
+        ArchivePR::GenerateColumnIndex( compareVersionTable,localTable,columnTree,columns );
+        columnNames := selectvalues( columns,Elements,column,true,column.Name() );
+        
+        // 鐢熸垚鏁版嵁
+        
+        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);
+          
+          ArchivePR::FillCells( rowKey,baseVersionRowTree,baseVersionRows,baseVersionCellTree,baseVersionCells );
+          ArchivePR::FillCells( rowKey,compareVersionRowTree,compareVersionRows,compareVersionCellTree,compareVersionCells );
+          
+          row := localTable.LocalRow( relnew,Index := localTable.GetRowIndexCache()  );
+          
+          traverse( columnNames,Elements,columnName ){
+            columnHandle := columnTree.GetHandle( columnName );
+            columnIndex := columnTree.Root().Child( columnHandle ).GetValueAsNumber();
+            column := columns.Element( columnIndex );
+            
+            baseVersionCell := constnull( GeneralExcelImportAndExportDataCell );
+            baseVersionCellHandle := baseVersionCellTree.GetHandle( columnName );
+            try{
+              baseVersionCellIndex := baseVersionCellTree.Root().Child( baseVersionCellHandle ).GetValueAsNumber();
+              baseVersionCell := baseVersionCells.Element( baseVersionCellIndex );
+            }onerror{}
+            
+            compareVersionCell := constnull( GeneralExcelImportAndExportDataCell );
+            compareVersionCellHandle := compareVersionCellTree.GetHandle( columnName );
+            try{
+              compareVersionCellIndex := compareVersionCellTree.Root().Child( compareVersionCellHandle ).GetValueAsNumber();
+              compareVersionCell := compareVersionCells.Element( compareVersionCellIndex );
+            }onerror{}
+            
+            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 = "鍙戝姩鏈洪浂浠跺彿" ){
+                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() ));
+            }
+          }
+        }
+      }
+      // 鍚庣画鍒犻櫎
+      baseVersionDataSource.Delete();
+      compareVersionDataSource.Delete();
+      
+      baseVersionFile.Close();
+      compareVersionFile.Close();
+    } onerror {
+      if( not isnull( baseVersionFile )){
+        baseVersionFile.Close(); 
+      }
+      if( not isnull( compareVersionFile )){
+        compareVersionFile.Close(); 
+      }
+      error( e );
+    }
     
-    return table;
+    return localTable;
   *]
 }

--
Gitblit v1.9.3