From eb96b6574adb7b04d0c077b14f63ac5ec94103a2 Mon Sep 17 00:00:00 2001
From: yypsybs <yypsybs@foxmail.com>
Date: 星期一, 16 十月 2023 18:05:29 +0800
Subject: [PATCH] PR推送与PR历史导出bug

---
 _Main/BL/Type_PRHistoryData/StaticMethod_Export#527.qbl                                                                 |  199 ++++++++++++++++++++++
 _Main/UI/MacroPlannerWebApp/Component_Form633/Response_PanelPRDataButton_ButtonExportPR_OnClick.def                     |    3 
 /dev/null                                                                                                               |   72 --------
 _Main/BL/Type_PRData/StaticMethod_Export#346.qbl                                                                        |  209 +++++++++++++++++++++++
 _Main/UI/MacroPlannerWebApp/Component_FormPRHistoryData/Response_PanelPRHistoryButton_ButtonExportPRHistory_OnClick.def |    3 
 _Main/BL/Type_PRData/StaticMethod_Export.qbl                                                                            |   13 +
 _Main/BL/Type_PRData/StaticMethod_FromSupplyPlanning.qbl                                                                |    5 
 _Main/BL/Type_PRHistoryData/StaticMethod_Export.qbl                                                                     |   13 +
 8 files changed, 441 insertions(+), 76 deletions(-)

diff --git "a/_Main/BL/Type_PRData/StaticMethod_Export\043346.qbl" "b/_Main/BL/Type_PRData/StaticMethod_Export\043346.qbl"
new file mode 100644
index 0000000..e699b8c
--- /dev/null
+++ "b/_Main/BL/Type_PRData/StaticMethod_Export\043346.qbl"
@@ -0,0 +1,209 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Export (
+  PRDatas toExportList
+) as String
+{
+  TextBody:
+  [*
+    // generate by generate_export_method.py
+    xmlTemplate := '<?xml version="1.0" encoding="UTF-16"?>
+    <table>
+      <name>PRData</name>
+    ';
+    convDateToString := DateToString::StandardConverter();
+    convDateToString.SetCustomConversion();
+    convDateToString.CustomFormatString( 'yyyy-MM-dd' );
+    
+    debuginfo( "export start" );
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鐗╂枡缂栫爜</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      productID := toExportItem.ProductID();
+      cellStr := '<cell value="' + productID + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鐗╂枡鍚嶇О</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      productName := toExportItem.ProductName();
+      cellStr := '<cell value="' + productName + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>闈㈡澘鐗╂枡鏍囪瘑</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      isPanelMaterial := toExportItem.IsPanelMaterial();
+      cellStr := '<cell value="' + isPanelMaterial + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>浜よ揣鏃ユ湡</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      deliveryDate := toExportItem.DeliveryDate();
+      cellStr := '<cell value="' + ifexpr( deliveryDate = Date::MinDate(), "", convDateToString.Convert( deliveryDate )) + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>PR寤鸿鏃ユ湡</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      pRSuggestionDate := toExportItem.PRSuggestionDate();
+      cellStr := '<cell value="' + ifexpr( pRSuggestionDate = Date::MinDate(), "", convDateToString.Convert( pRSuggestionDate )) + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>浜よ揣鏁伴噺</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      quantity := toExportItem.Quantity();
+      cellStr := '<cell value="' + [String]quantity + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>MRP璁$畻鐗堟湰鍙�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      mRPCalverNo := toExportItem.MRPCalverNo();
+      cellStr := '<cell value="' + mRPCalverNo + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>涓氬姟绫诲瀷</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      businessType := toExportItem.BusinessType();
+      cellStr := '<cell value="' + businessType + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>缁勭粐缂栫爜</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      organCode := toExportItem.OrganCode();
+      cellStr := '<cell value="' + organCode + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鏄惁闀垮懆鏈�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      isLongLeadItem := toExportItem.IsLongLeadItem();
+      cellStr := '<cell value="' + isLongLeadItem + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鏄惁涓撶敤鏂�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      isGenericMaterial := toExportItem.IsGenericMaterial();
+      cellStr := '<cell value="' + isGenericMaterial + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鐗╂枡璁″垝绛栫暐</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      materialMRPType := toExportItem.MaterialMRPType();
+      cellStr := '<cell value="' + materialMRPType + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鎻愬墠鏈�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      leadTime := toExportItem.LeadTime();
+      cellStr := '<cell value="' + [String]leadTime + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>渚涘簲鍟嗕唬鐮�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      providerCode := toExportItem.ProviderCode();
+      cellStr := '<cell value="' + providerCode + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>渚涘簲鍟嗗悕绉�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      providerName := toExportItem.ProviderName();
+      cellStr := '<cell value="' + providerName + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鏀惰揣搴撳瓨鐐�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      stockingPointID := toExportItem.StockingPointID();
+      cellStr := '<cell value="' + stockingPointID + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>璁¢噺鍗曚綅</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      unitOfMeasure := toExportItem.UnitOfMeasure();
+      cellStr := '<cell value="' + unitOfMeasure + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>PR鏁版嵁鍙戦�佺姸鎬�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      pRReleaseStatus := toExportItem.PRReleaseStatus();
+      cellStr := '<cell value="' + pRReleaseStatus + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鍙戦�佹椂闂�</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      createTimeString := toExportItem.CreateTimeString();
+      cellStr := '<cell value="' + createTimeString + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鍙戦�佷汉</name><type>String</type>";
+    traverse( toExportList, Elements, toExportItem ) {
+      createBy := toExportItem.CreateBy();
+      cellStr := '<cell value="' + createBy + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    xmlTemplate := xmlTemplate + "</table>";
+    tableHandle := TableHandle::ImportXML( BinaryValue::Construct( xmlTemplate ) );
+    XLS::SaveTable( tableHandle, OS::TempPath() + "PRData.xlsx" );
+    file := OSFile::Construct();
+    file.Open( OS::TempPath() + "PRData.xlsx", "Read", true );
+    data := file.ReadBinary()
+    debuginfo( "export end" );
+    return data.AsBase64EncodedString();
+  *]
+}
diff --git a/_Main/BL/Type_PRData/StaticMethod_Export.qbl b/_Main/BL/Type_PRData/StaticMethod_Export.qbl
new file mode 100644
index 0000000..46ff06e
--- /dev/null
+++ b/_Main/BL/Type_PRData/StaticMethod_Export.qbl
@@ -0,0 +1,13 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Export (
+  MacroPlan parent
+) as String
+{
+  TextBody:
+  [*
+    // generate by generate_export_method.py
+    toExportList := selectset( parent, PRData, item, true );
+    return PRData::Export( toExportList );
+  *]
+}
diff --git "a/_Main/BL/Type_PRData/StaticMethod_ExportTheFileStream\043595.qbl" "b/_Main/BL/Type_PRData/StaticMethod_ExportTheFileStream\043595.qbl"
deleted file mode 100644
index 540295e..0000000
--- "a/_Main/BL/Type_PRData/StaticMethod_ExportTheFileStream\043595.qbl"
+++ /dev/null
@@ -1,12 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod ExportTheFileStream (
-  MacroPlan parent
-) as BinaryValue
-{
-  TextBody:
-  [*
-    // yypsybs Sep-20-2023 (created)
-    return PRData::ExportTheFileStream( selectset( parent, PRData, item, true ) );
-  *]
-}
diff --git a/_Main/BL/Type_PRData/StaticMethod_ExportTheFileStream.qbl b/_Main/BL/Type_PRData/StaticMethod_ExportTheFileStream.qbl
deleted file mode 100644
index 1b706e0..0000000
--- a/_Main/BL/Type_PRData/StaticMethod_ExportTheFileStream.qbl
+++ /dev/null
@@ -1,78 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod ExportTheFileStream (
-  PRDatas toExportList
-) as BinaryValue
-{
-  TextBody:
-  [*
-    // generate by generate_export.py
-    dateTimeToString := DateTimeToString::StandardConverter();
-    dateTimeToString.SetCustomConversion();
-    dateTimeToString.CustomFormatString( "yyyy/MM/dd H:mm:ss" );
-    
-    dateToString := DateToString::StandardConverter();
-    dateToString.SetCustomConversion();
-    dateToString.CustomFormatString( "yyyy/MM/dd" );
-    
-    text:= '<?xml version="1.0" encoding="utf-8" standalone="yes"?><table><name>PR</name>
-    <column><name>鐗╂枡缂栫爜</name><type>String</type></column>
-    <column><name>鐗╂枡鍚嶇О</name><type>String</type></column>
-    <column><name>闈㈡澘鐗╂枡鏍囪瘑</name><type>String</type></column>
-    <column><name>浜よ揣鏃ユ湡</name><type>String</type></column>
-    <column><name>PR寤鸿鏃ユ湡</name><type>String</type></column>
-    <column><name>浜よ揣鏁伴噺</name><type>Number</type></column>
-    <column><name>MRP璁$畻鐗堟湰鍙�</name><type>String</type></column>
-    <column><name>涓氬姟绫诲瀷</name><type>String</type></column>
-    <column><name>缁勭粐缂栫爜</name><type>String</type></column>
-    <column><name>鏄惁闀垮懆鏈�</name><type>String</type></column>
-    <column><name>鏄惁涓撶敤鏂�</name><type>String</type></column>
-    <column><name>鐗╂枡璁″垝绛栫暐</name><type>String</type></column>
-    <column><name>鎻愬墠鏈�</name><type>Number</type></column>
-    <column><name>渚涘簲鍟嗕唬鐮�</name><type>String</type></column>
-    <column><name>渚涘簲鍟嗗悕绉�</name><type>String</type></column>
-    <column><name>鏀惰揣搴撳瓨鐐�</name><type>String</type></column>
-    <column><name>璁¢噺鍗曚綅</name><type>String</type></column>
-    <column><name>PR鏁版嵁鍙戦�佺姸鎬�</name><type>String</type></column>
-    <column><name>鍙戦�佹椂闂�</name><type>String</type></column>
-    <column><name>鍙戦�佷汉</name><type>String</type></column>
-    </table>';
-    xmlDOMImplementation := XMLDOMImplementation::Create();
-    xmlDOMDocument := xmlDOMImplementation.CreateDocumentFromString( text );
-    
-    tableElement:= xmlDOMDocument.GetElementByTagName( "table", 0 );
-    
-    traverse ( toExportList, Elements, toExport ) {
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProductID(), "鐗╂枡缂栫爜" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProductName(), "鐗╂枡鍚嶇О" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.IsPanelMaterial(), "闈㈡澘鐗╂枡鏍囪瘑" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, ifexpr( toExport.DeliveryDate() = Date::MinDate(), "", dateToString.Convert( toExport.DeliveryDate() ) ), "浜よ揣鏃ユ湡" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, ifexpr( toExport.PRSuggestionDate() = Date::MinDate(), "", dateToString.Convert( toExport.PRSuggestionDate() ) ), "PR寤鸿鏃ユ湡" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, [String]toExport.Quantity(), "浜よ揣鏁伴噺" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.MRPCalverNo(), "MRP璁$畻鐗堟湰鍙�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.BusinessType(), "涓氬姟绫诲瀷" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.OrganCode(), "缁勭粐缂栫爜" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.IsLongLeadItem(), "鏄惁闀垮懆鏈�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.IsGenericMaterial(), "鏄惁涓撶敤鏂�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.MaterialMRPType(), "鐗╂枡璁″垝绛栫暐" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, [String]toExport.LeadTime(), "鎻愬墠鏈�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProviderCode(), "渚涘簲鍟嗕唬鐮�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProviderName(), "渚涘簲鍟嗗悕绉�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.StockingPointID(), "鏀惰揣搴撳瓨鐐�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.UnitOfMeasure(), "璁¢噺鍗曚綅" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.PRReleaseStatus(), "PR鏁版嵁鍙戦�佺姸鎬�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.CreateTimeString(), "鍙戦�佹椂闂�" );
-      PRData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.CreateBy(), "鍙戦�佷汉" );
-    }
-    
-    xmlDOMSerializer := xmlDOMImplementation.CreateSerializer();
-    xmlTableString := xmlDOMSerializer.WriteToString( xmlDOMDocument );
-    
-    tableHandle := TableHandle::ImportXML( BinaryValue::Construct( xmlTableString ) );
-    tableGroupHandle := TableGroupHandle::Create( "PR" );
-    tableGroupHandle.Add( tableHandle );
-    tableBinaryData := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
-    
-    return tableBinaryData.AsBinaryValue();
-  *]
-}
diff --git a/_Main/BL/Type_PRData/StaticMethod_FromSupplyPlanning.qbl b/_Main/BL/Type_PRData/StaticMethod_FromSupplyPlanning.qbl
index 7c5d308..dff5567 100644
--- a/_Main/BL/Type_PRData/StaticMethod_FromSupplyPlanning.qbl
+++ b/_Main/BL/Type_PRData/StaticMethod_FromSupplyPlanning.qbl
@@ -14,10 +14,15 @@
     // 鎸塎RPCalverNo鏌ワ紝宸叉湁鏃ц褰曟椂涓嶅鐞�
     oldRecords := selectset( macroPlan, PRData, item,
                              item.MRPCalverNo() = mrpCalverNo );
+    nowNo := 1;
     if( isnull( oldRecords ) or oldRecords.Size() = 0 ) {
       pispips := ProductInStockingPointInPeriod::GetByMRPCalverNo( macroPlan, mrpCalverNo );
       traverse( pispips, Elements, item, item.NewSupplyQuantity() > 0 ) {
         PRData::FromSupplyPlanning( otdTable, macroPlan, item, userId );
+        nowNo := nowNo + 1;
+        if( nowNo mod 1000 = 0 ) {
+          info( "SupplyPlanning to prData : " + [String]nowNo );
+        }
       }
     }
   *]
diff --git "a/_Main/BL/Type_PRHistoryData/StaticMethod_Export\043527.qbl" "b/_Main/BL/Type_PRHistoryData/StaticMethod_Export\043527.qbl"
new file mode 100644
index 0000000..55d80be
--- /dev/null
+++ "b/_Main/BL/Type_PRHistoryData/StaticMethod_Export\043527.qbl"
@@ -0,0 +1,199 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Export (
+  PRHistoryDatas toExportList
+) as String
+{
+  TextBody:
+  [*
+    // generate by generate_export_method.py
+    xmlTemplate := '<?xml version="1.0" encoding="UTF-16"?>
+    <table>
+      <name>PRHistoryData</name>
+    ';
+    convDateToString := DateToString::StandardConverter();
+    convDateToString.SetCustomConversion();
+    convDateToString.CustomFormatString( 'yyyy-MM-dd' );
+    
+    debuginfo( "export start" );
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鐗╂枡缂栫爜</name><type>String</type>";
+    debuginfo( "export column ProductID" );
+    traverse( toExportList, Elements, toExportItem ) {
+      productID := toExportItem.ProductID();
+      cellStr := '<cell value="' + productID + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鐗╂枡鍚嶇О</name><type>String</type>";
+    debuginfo( "export column ProductName" );
+    traverse( toExportList, Elements, toExportItem ) {
+      productName := toExportItem.ProductName();
+      cellStr := '<cell value="' + productName + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>浜よ揣鏃ユ湡</name><type>String</type>";
+    debuginfo( "export column DeliveryDate" );
+    traverse( toExportList, Elements, toExportItem ) {
+      deliveryDate := toExportItem.DeliveryDate();
+      cellStr := '<cell value="' + ifexpr( deliveryDate = Date::MinDate(), "", convDateToString.Convert( deliveryDate )) + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>浜よ揣鏁伴噺</name><type>String</type>";
+    debuginfo( "export column Quantity" );
+    traverse( toExportList, Elements, toExportItem ) {
+      quantity := toExportItem.Quantity();
+      cellStr := '<cell value="' + [String]quantity + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>MRP璁$畻鐗堟湰鍙�</name><type>String</type>";
+    debuginfo( "export column MRPCalverNo" );
+    traverse( toExportList, Elements, toExportItem ) {
+      mRPCalverNo := toExportItem.MRPCalverNo();
+      cellStr := '<cell value="' + mRPCalverNo + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>涓氬姟绫诲瀷</name><type>String</type>";
+    debuginfo( "export column BusinessType" );
+    traverse( toExportList, Elements, toExportItem ) {
+      businessType := toExportItem.BusinessType();
+      cellStr := '<cell value="' + businessType + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>缁勭粐缂栫爜</name><type>String</type>";
+    debuginfo( "export column OrganCode" );
+    traverse( toExportList, Elements, toExportItem ) {
+      organCode := toExportItem.OrganCode();
+      cellStr := '<cell value="' + organCode + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>渚涘簲鍟嗕唬鐮�</name><type>String</type>";
+    debuginfo( "export column ProviderCode" );
+    traverse( toExportList, Elements, toExportItem ) {
+      providerCode := toExportItem.ProviderCode();
+      cellStr := '<cell value="' + providerCode + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>渚涘簲鍟嗗悕绉�</name><type>String</type>";
+    debuginfo( "export column ProviderName" );
+    traverse( toExportList, Elements, toExportItem ) {
+      providerName := toExportItem.ProviderName();
+      cellStr := '<cell value="' + providerName + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鏀惰揣搴撳瓨鐐�</name><type>String</type>";
+    debuginfo( "export column StockingPointID" );
+    traverse( toExportList, Elements, toExportItem ) {
+      stockingPointID := toExportItem.StockingPointID();
+      cellStr := '<cell value="' + stockingPointID + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>璁¢噺鍗曚綅</name><type>String</type>";
+    debuginfo( "export column UnitOfMeasure" );
+    traverse( toExportList, Elements, toExportItem ) {
+      unitOfMeasure := toExportItem.UnitOfMeasure();
+      cellStr := '<cell value="' + unitOfMeasure + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>PR鏁版嵁鍙戦�佺姸鎬�</name><type>String</type>";
+    debuginfo( "export column SendStatus" );
+    traverse( toExportList, Elements, toExportItem ) {
+      sendStatus := toExportItem.SendStatus();
+      cellStr := '<cell value="' + sendStatus + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鍙戦�佹椂闂�</name><type>String</type>";
+    debuginfo( "export column SendTimeString" );
+    traverse( toExportList, Elements, toExportItem ) {
+      sendTimeString := toExportItem.SendTimeString();
+      cellStr := '<cell value="' + sendTimeString + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>鍙戦�佷汉</name><type>String</type>";
+    debuginfo( "export column ReleaseBy" );
+    traverse( toExportList, Elements, toExportItem ) {
+      releaseBy := toExportItem.ReleaseBy();
+      cellStr := '<cell value="' + releaseBy + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>ERP鎺ユ敹鏃堕棿</name><type>String</type>";
+    debuginfo( "export column ReceiveTimeString" );
+    traverse( toExportList, Elements, toExportItem ) {
+      receiveTimeString := toExportItem.ReceiveTimeString();
+      cellStr := '<cell value="' + receiveTimeString + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>ERP鎺ユ敹鐘舵��</name><type>String</type>";
+    debuginfo( "export column ReceiveStatus" );
+    traverse( toExportList, Elements, toExportItem ) {
+      receiveStatus := toExportItem.ReceiveStatus();
+      cellStr := '<cell value="' + receiveStatus + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    columnStr := "<column><name>閿欒淇℃伅鎻忚堪</name><type>String</type>";
+    debuginfo( "export column ReceiveError" );
+    traverse( toExportList, Elements, toExportItem ) {
+      receiveError := toExportItem.ReceiveError();
+      cellStr := '<cell value="' + receiveError.ReplaceAll( '"', "'" ) + '"/>';
+      columnStr := columnStr + cellStr;
+    }
+    columnStr := columnStr + "</column>";
+    xmlTemplate := xmlTemplate + columnStr;
+    //---------------------------------------------------------------------------------------------
+    xmlTemplate := xmlTemplate + "</table>";
+    tableHandle := TableHandle::ImportXML( BinaryValue::Construct( xmlTemplate ) );
+    XLS::SaveTable( tableHandle, OS::TempPath() + "PRHistoryData.xlsx" );
+    file := OSFile::Construct();
+    file.Open( OS::TempPath() + "PRHistoryData.xlsx", "Read", true );
+    data := file.ReadBinary()
+    debuginfo( "export end" );
+    return data.AsBase64EncodedString();
+  *]
+}
diff --git a/_Main/BL/Type_PRHistoryData/StaticMethod_Export.qbl b/_Main/BL/Type_PRHistoryData/StaticMethod_Export.qbl
new file mode 100644
index 0000000..132c301
--- /dev/null
+++ b/_Main/BL/Type_PRHistoryData/StaticMethod_Export.qbl
@@ -0,0 +1,13 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod Export (
+  GlobalOTDTable parent
+) as String
+{
+  TextBody:
+  [*
+    // generate by generate_export_method.py
+    toExportList := selectset( parent, PRHistoryData, item, true );
+    return PRHistoryData::Export( toExportList );
+  *]
+}
diff --git "a/_Main/BL/Type_PRHistoryData/StaticMethod_ExportTheFileStream\04345.qbl" "b/_Main/BL/Type_PRHistoryData/StaticMethod_ExportTheFileStream\04345.qbl"
deleted file mode 100644
index a04fd41..0000000
--- "a/_Main/BL/Type_PRHistoryData/StaticMethod_ExportTheFileStream\04345.qbl"
+++ /dev/null
@@ -1,12 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod ExportTheFileStream (
-  GlobalOTDTable parent
-) as BinaryValue
-{
-  TextBody:
-  [*
-    // yypsybs Sep-20-2023 (created)
-    return PRHistoryData::ExportTheFileStream( selectset( parent, PRHistoryData, item, true ) );
-  *]
-}
diff --git a/_Main/BL/Type_PRHistoryData/StaticMethod_ExportTheFileStream.qbl b/_Main/BL/Type_PRHistoryData/StaticMethod_ExportTheFileStream.qbl
deleted file mode 100644
index edd753d..0000000
--- a/_Main/BL/Type_PRHistoryData/StaticMethod_ExportTheFileStream.qbl
+++ /dev/null
@@ -1,72 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-StaticMethod ExportTheFileStream (
-  PRHistoryDatas toExportList
-) as BinaryValue
-{
-  TextBody:
-  [*
-    // generate by generate_export.py
-    dateTimeToString := DateTimeToString::StandardConverter();
-    dateTimeToString.SetCustomConversion();
-    dateTimeToString.CustomFormatString( "yyyy/MM/dd H:mm:ss" );
-    
-    dateToString := DateToString::StandardConverter();
-    dateToString.SetCustomConversion();
-    dateToString.CustomFormatString( "yyyy/MM/dd" );
-    
-    text:= '<?xml version="1.0" encoding="utf-8" standalone="yes"?><table><name>PR</name>
-    <column><name>闆朵欢鍙�</name><type>String</type></column>
-    <column><name>闆朵欢鍚嶇О</name><type>String</type></column>
-    <column><name>浜よ揣鏃ユ湡</name><type>String</type></column>
-    <column><name>闇�姹傛暟閲�</name><type>Number</type></column>
-    <column><name>MRP璁$畻鐗堟湰鍙�</name><type>String</type></column>
-    <column><name>浜嬩笟閮�</name><type>String</type></column>
-    <column><name>缁勭粐缂栫爜</name><type>String</type></column>
-    <column><name>渚涘簲鍟嗕唬鐮�</name><type>String</type></column>
-    <column><name>渚涘簲鍟嗗悕绉�</name><type>String</type></column>
-    <column><name>鏀惰揣搴撳瓨鐐�</name><type>String</type></column>
-    <column><name>璁¢噺鍗曚綅</name><type>String</type></column>
-    <column><name>PR鏁版嵁鍙戦�佺姸鎬�</name><type>String</type></column>
-    <column><name>鍙戦�佹椂闂�</name><type>String</type></column>
-    <column><name>鍙戦�佷汉</name><type>String</type></column>
-    <column><name>ERP鎺ユ敹鏃堕棿</name><type>String</type></column>
-    <column><name>ERP鎺ユ敹鐘舵��</name><type>String</type></column>
-    <column><name>閿欒淇℃伅鎻忚堪</name><type>String</type></column>
-    </table>';
-    xmlDOMImplementation := XMLDOMImplementation::Create();
-    xmlDOMDocument := xmlDOMImplementation.CreateDocumentFromString( text );
-    
-    tableElement:= xmlDOMDocument.GetElementByTagName( "table", 0 );
-    
-    traverse ( toExportList, Elements, toExport ) {
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProductID(), "闆朵欢鍙�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProductName(), "闆朵欢鍚嶇О" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, ifexpr( toExport.DeliveryDate() = Date::MinDate(), "", dateToString.Convert( toExport.DeliveryDate() ) ), "浜よ揣鏃ユ湡" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, [String]toExport.Quantity(), "闇�姹傛暟閲�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.MRPCalverNo(), "MRP璁$畻鐗堟湰鍙�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.BusinessType(), "浜嬩笟閮�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.OrganCode(), "缁勭粐缂栫爜" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProviderCode(), "渚涘簲鍟嗕唬鐮�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ProviderName(), "渚涘簲鍟嗗悕绉�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.StockingPointID(), "鏀惰揣搴撳瓨鐐�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.UnitOfMeasure(), "璁¢噺鍗曚綅" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.SendStatus(), "PR鏁版嵁鍙戦�佺姸鎬�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.SendTimeString(), "鍙戦�佹椂闂�" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ReleaseBy(), "鍙戦�佷汉" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ReceiveTimeString(), "ERP鎺ユ敹鏃堕棿" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ReceiveStatus(), "ERP鎺ユ敹鐘舵��" );
-      PRHistoryData::GeneratesTheSpecifiedXMLColumn( xmlDOMDocument, tableElement, toExport.ReceiveError(), "閿欒淇℃伅鎻忚堪" );
-    }
-    
-    xmlDOMSerializer := xmlDOMImplementation.CreateSerializer();
-    xmlTableString := xmlDOMSerializer.WriteToString( xmlDOMDocument );
-    
-    tableHandle := TableHandle::ImportXML( BinaryValue::Construct( xmlTableString ) );
-    tableGroupHandle := TableGroupHandle::Create( "PR" );
-    tableGroupHandle.Add( tableHandle );
-    tableBinaryData := XLS::SaveTableGroupToBinaryData( tableGroupHandle, true );
-    
-    return tableBinaryData.AsBinaryValue();
-  *]
-}
diff --git a/_Main/UI/MacroPlannerWebApp/Component_Form633/Response_PanelPRDataButton_ButtonExportPR_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_Form633/Response_PanelPRDataButton_ButtonExportPR_OnClick.def
index 69a46cd..b9d8b6e 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_Form633/Response_PanelPRDataButton_ButtonExportPR_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_Form633/Response_PanelPRDataButton_ButtonExportPR_OnClick.def
@@ -13,8 +13,7 @@
   {
     Body:
     [*
-      tableBinaryData := PRData::ExportTheFileStream( MacroPlan ).AsBinaryData();
-      Application.Download( "PRData.xlsx", tableBinaryData );
+      Application.Download( "PRData.xlsx", PRData::Export( MacroPlan ) );
     *]
     GroupServerCalls: false
   }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormPRHistoryData/Response_PanelPRHistoryButton_ButtonExportPRHistory_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormPRHistoryData/Response_PanelPRHistoryButton_ButtonExportPRHistory_OnClick.def
index 9a9f95e..e83383e 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormPRHistoryData/Response_PanelPRHistoryButton_ButtonExportPRHistory_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormPRHistoryData/Response_PanelPRHistoryButton_ButtonExportPRHistory_OnClick.def
@@ -13,8 +13,7 @@
   {
     Body:
     [*
-      tableBinaryData := PRHistoryData::ExportTheFileStream( GlobalOTDTable ).AsBinaryData();
-      Application.Download( "PRData.xlsx", tableBinaryData );
+      Application.Download( "PRHistoryData.xlsx", PRHistoryData::Export( GlobalOTDTable ) );
     *]
     GroupServerCalls: false
   }

--
Gitblit v1.9.3