From d4a08c8d814543094e3ac1f1288c9a3820c210c1 Mon Sep 17 00:00:00 2001
From: xiaoding721 <33130084+xiaoding721@users.noreply.github.com>
Date: 星期二, 24 十二月 2024 17:38:57 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_LibCal_SubscriberEventTable/Method_GetColumnByTimeUnit.qbl                           |    2 
 _Main/UI/MacroPlannerWebApp/Component_FormCalendarUnavailableEvent/Component_MatrixEditorTable.def |    2 
 _Main/BL/Type_LibCal_SubscriberEventRow/Method_InitializeDate.qbl                                  |   39 +++++++++++++++++--
 /dev/null                                                                                          |   13 ------
 _Main/BL/Type_CustomerDemandPPAIDS/Attribute_StockingPoint.qbl                                     |    7 +++
 _Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl                                        |    1 
 _Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateDataNew.qbl                                |    1 
 _Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl                                |    2 
 _Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl                                   |    2 
 _Main/BL/Type_LibCal_SubscriberEventTable/StaticMethod_InitializeTable.qbl                         |    8 +---
 _Main/BL/Type_LibCal_SubscriberEventRow/Attribute_RowNr.qbl                                        |    1 
 _Main/BL/Type_LibCal_SubscriberEventTable/Method_InitializeTable.qbl                               |   40 ++++++++-----------
 12 files changed, 66 insertions(+), 52 deletions(-)

diff --git a/_Main/BL/Type_CustomerDemandPPAIDS/Attribute_StockingPoint.qbl b/_Main/BL/Type_CustomerDemandPPAIDS/Attribute_StockingPoint.qbl
new file mode 100644
index 0000000..fb46a8a
--- /dev/null
+++ b/_Main/BL/Type_CustomerDemandPPAIDS/Attribute_StockingPoint.qbl
@@ -0,0 +1,7 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute StockingPoint
+{
+  #keys: '3[415136.0.1367364685][415136.0.1367364684][415136.0.1367364686]'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateDataNew.qbl b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateDataNew.qbl
index 8b39a46..f083fc5 100644
--- a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateDataNew.qbl
+++ b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_GenerateDataNew.qbl
@@ -34,6 +34,7 @@
                                                                      , DemandQty               := [Number]archivedata.Quantity()
                                                                      , VersionName             := macroplan.ScenarioName()
                                                                      , InterfaceTime           := nowdate
+                                                                     , StockingPoint           := archivedata.StockingPointID() 
                                                                      , FactoryName             := archivedata.FactoryName()
                                                                      , Fac                     := ifexpr( archivedata.FactoryName() = FinancialProductionReport::GetDefaultCCUnit(), 'CC', 'DL' )  
     //                                                                 , VersionFlag             := versionflag
diff --git a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl
index 21112d4..c576ddc 100644
--- a/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl
+++ b/_Main/BL/Type_CustomerDemandPPAIDS/StaticMethod_Publish.qbl
@@ -13,6 +13,7 @@
       idsjson          := JSON::Object().Add( "product", ids.Product() ).Add( "demandDate", ids.DemandDate().Format( 'Y-M2-D2' ) )//"2024-10-01" )
                                     .Add( "demandQty", ids.DemandQty() )
                                     .Add( "versionName", ids.VersionName() )
+                                    .Add( "stockingPoint", ids.StockingPoint() )
                                     .Add( "interfaceTime", ids.InterfaceTime().Format( 'Y-M2-D2 H:m:s' ) ).Build();/*"2024-10-01 12:00:00" )*/
       jsonarray.Add( idsjson );
     }
diff --git a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
index eb8bc0a..d182f43 100644
--- a/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_FinancialProductionSource/StaticMethod_Initialize.qbl
@@ -24,7 +24,7 @@
     //鍙栧綋鍓嶇増鏈殑product planning閲宯ew supply瀛楁锛屽垎澶ц繛鍜岄暱鏄ュ伐鍘傜殑浜х嚎锛岃繘琛屽姞鎬�
     traverse( owner, StockingPoint_MP, stockingpoint, stockingpoint.ID().EndsWith( '鍘傚唴搴�' ) or stockingpoint.ID() = '澶ц繛澶栫搴�' ){
       iscc                    := stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '闀挎槬' );
-      isdl                    := stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '澶ц繛' );
+      isdl                    := stockingpoint.ID().StartsWith( '澶ц繛' );
       
       if( iscc or isdl ){
         traverse( stockingpoint, ProductInStockingPoint_MP, pisp,  pisp.Product_MP().IsLeaf() 
diff --git a/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl b/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
index 4d34c0d..0d5a523 100644
--- a/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_InventorySummarySource/StaticMethod_Initialize.qbl
@@ -42,7 +42,7 @@
           //鑾峰彇鍚堣琛�
           allrow              := table.GetRow( allunit, pisp.Product_MP() );
           
-          pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() < startofnextyear 
+          pispips             := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() < startofnextyear and pispip.Start() >= startofyear
                                                   and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day(), pispip.Start() );
     
           traverse( pispips, Elements, pispip ){
diff --git a/_Main/BL/Type_LibCal_SubscriberEventRow/Attribute_RowNr.qbl b/_Main/BL/Type_LibCal_SubscriberEventRow/Attribute_RowNr.qbl
index d1182a6..030c700 100644
--- a/_Main/BL/Type_LibCal_SubscriberEventRow/Attribute_RowNr.qbl
+++ b/_Main/BL/Type_LibCal_SubscriberEventRow/Attribute_RowNr.qbl
@@ -3,6 +3,5 @@
 Attribute RowNr
 {
   #keys: '3[415136.0.671975114][415136.0.671975113][415136.0.671975115]'
-  IsReadOnly: true
   ValueType: Number
 }
diff --git a/_Main/BL/Type_LibCal_SubscriberEventRow/Method_InitializeDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventRow/Method_InitializeDate.qbl
index fdff292..d715c17 100644
--- a/_Main/BL/Type_LibCal_SubscriberEventRow/Method_InitializeDate.qbl
+++ b/_Main/BL/Type_LibCal_SubscriberEventRow/Method_InitializeDate.qbl
@@ -10,15 +10,25 @@
   TextBody:
   [*
     // 鐢勫叞楦� May-29-2024 (created)
-    startTime     := starttime;
-    nextweektime  := starttime;
-    nextmonthtime := starttime;
+    startTime         := starttime;
+    nextweektime      := starttime;
+    nextmonthtime     := starttime;
     while( startTime < endtime ){
     //for(  startTime := starttime; startTime < endtime; startTime := startTime.StartOfNextDay() ){
       //澶�
       daytime         := this.GetTimeByTimeUnit( starttime, startTime, Translations::MP_GlobalParameters_Day() );
       daycolumn       := table.GetColumnByTimeUnit( table, daytime, Translations::MP_GlobalParameters_Day() );
       daycell         := daycolumn.GetCellByTimeUnit( this, desc );
+      if( table.MaxDayDate().IsInfinite() ){
+        table.MaxDayDate( daytime );
+      }else{
+        table.MaxDayDate( ifexpr( table.MaxDayDate() < daytime, daytime, table.MaxDayDate() ) );
+      }
+      if( table.MinDayDate().IsInfinite() ){
+        table.MinDayDate( daytime );
+      }else{
+        table.MinDayDate( ifexpr( table.MinDayDate() > daytime, daytime, table.MinDayDate() ) );
+      }
       
       dayvalue        := [Real]daycell.Value();
       if( startTime.StartOfNextDay() > endtime ){
@@ -36,7 +46,16 @@
         weektime      := this.GetTimeByTimeUnit( starttime, startTime, Translations::MP_GlobalParameters_Week() );
         weekcolumn    := table.GetColumnByTimeUnit( table, weektime, Translations::MP_GlobalParameters_Week() );
         weekcell      := weekcolumn.GetCellByTimeUnit( this, desc );
-        
+        if( table.MaxWeekDate().IsInfinite() ){
+          table.MaxWeekDate( weektime );
+        }else{
+          table.MaxWeekDate( ifexpr( table.MaxWeekDate() < weektime, weektime, table.MaxWeekDate() ) );
+        }
+        if( table.MinWeekDate().IsInfinite() ){
+          table.MinWeekDate( weektime );
+        }else{
+          table.MinWeekDate( ifexpr( table.MinWeekDate() > weektime, weektime, table.MinWeekDate() ) );
+        }
         weekvalue     := [Real]weekcell.Value();
         if( startTime.StartOfNextWeek() > endtime ){
           duration    := endtime - startTime;
@@ -56,7 +75,17 @@
         monthtime     := this.GetTimeByTimeUnit( starttime, startTime, Translations::MP_GlobalParameters_Month() );
         monthcolumn   := table.GetColumnByTimeUnit( table, monthtime, Translations::MP_GlobalParameters_Month() );
         monthcell     := monthcolumn.GetCellByTimeUnit( this, desc );
-        info( nextmonthtime, startTime, monthtime, isnull( monthcolumn ), isnull( monthcell ) );
+        if( table.MaxMonthDate().IsInfinite() ){
+          table.MaxMonthDate( monthtime );
+        }else{
+          table.MaxMonthDate( ifexpr( table.MaxMonthDate() < monthtime, monthtime, table.MaxMonthDate() ) );
+        }
+        if( table.MinMonthDate().IsInfinite() ){
+          table.MinMonthDate( monthtime );
+        }else{
+          table.MinMonthDate( ifexpr( table.MinMonthDate() > monthtime, monthtime, table.MinMonthDate() ) );
+        }
+    //    info( nextmonthtime, startTime, monthtime, isnull( monthcolumn ), isnull( monthcell ) );
         monthvalue    := [Real]monthcell.Value();
         if( startTime.StartOfNextMonth() > endtime ){
           duration    := endtime - startTime;
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxDayDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxDayDate.qbl
deleted file mode 100644
index 03052fe..0000000
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxDayDate.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcMaxDayDate
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Aug-1-2024 (created)
-    
-    value := maxobject( this,LibCal_SubscriberEventColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day(), column.Period() );
-    
-    this.MaxDayDate( value.Period() );
-  *]
-}
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxMonthDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxMonthDate.qbl
deleted file mode 100644
index ea3887c..0000000
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxMonthDate.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcMaxMonthDate
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Aug-1-2024 (created)
-    
-    value := maxobject( this,LibCal_SubscriberEventColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Month(), column.Period() );
-    
-    this.MaxMonthDate( value.Period() );
-  *]
-}
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxWeekDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxWeekDate.qbl
deleted file mode 100644
index ed0f2bd..0000000
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMaxWeekDate.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcMaxWeekDate
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Aug-1-2024 (created)
-    
-    value := maxobject( this,LibCal_SubscriberEventColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Week(), column.Period() );
-    
-    this.MaxWeekDate( value.Period() );
-  *]
-}
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinDayDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinDayDate.qbl
deleted file mode 100644
index 6965360..0000000
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinDayDate.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcMinDayDate
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Aug-1-2024 (created)
-    
-    value := minobject( this, LibCal_SubscriberEventColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day(), column.Period() );
-    
-    this.MinDayDate( value.Period() );
-  *]
-}
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinMonthDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinMonthDate.qbl
deleted file mode 100644
index 02cc12a..0000000
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinMonthDate.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcMinMonthDate
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Aug-1-2024 (created)
-    
-    value := minobject( this, LibCal_SubscriberEventColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Month(), column.Period() );
-    
-    this.MinMonthDate( value.Period() );
-  *]
-}
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinWeekDate.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinWeekDate.qbl
deleted file mode 100644
index e5564d3..0000000
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Function_CalcMinWeekDate.qbl
+++ /dev/null
@@ -1,13 +0,0 @@
-Quintiq file version 2.0
-#parent: #root
-Function CalcMinWeekDate
-{
-  TextBody:
-  [*
-    // 鐢勫叞楦� Aug-1-2024 (created)
-    
-    value := minobject( this, LibCal_SubscriberEventColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Week(), column.Period() );
-    
-    this.MinWeekDate( value.Period() );
-  *]
-}
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Method_GetColumnByTimeUnit.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Method_GetColumnByTimeUnit.qbl
index 00583cb..9131f6c 100644
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Method_GetColumnByTimeUnit.qbl
+++ b/_Main/BL/Type_LibCal_SubscriberEventTable/Method_GetColumnByTimeUnit.qbl
@@ -9,7 +9,7 @@
   TextBody:
   [*
     // 鐢勫叞楦� Jul-26-2024 (created)
-    column := selectobject( table, LibCal_SubscriberEventColumn, column, column.Name() = time.Format( 'M/D/Y' ), column.TimeUnit() = timeunit );
+    column := selectobject( table, LibCal_SubscriberEventColumn, column,  column.TimeUnit() = timeunit and column.Period() = time );
     if( isnull( column ) ){
       column := table.LibCal_SubscriberEventColumn( relnew, Name := time.Format( 'M/D/Y' ), Period := time, TimeUnit := timeunit );
     }
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/Method_InitializeTable.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/Method_InitializeTable.qbl
index 1171045..abd3094 100644
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/Method_InitializeTable.qbl
+++ b/_Main/BL/Type_LibCal_SubscriberEventTable/Method_InitializeTable.qbl
@@ -7,27 +7,21 @@
   TextBody:
   [*
     // 鐢勫叞楦� May-28-2024 (created)
-    rownr                 := this.LibCal_SubscriberEventRow( relsize );
-    
-    traverse( subscribers, Elements, subscriber ){
-    
-      traverse( subscriber,Participation.astype( LibCal_Subscription ).LeadingParticipation, participation, participation.Event().EventCategory().Name() = 'Unavailable' ){
-        event := participation.Event();
-        
-        row := selectobject( this, LibCal_SubscriberEventRow, row, row.Subscriber() = subscriber.CalendarID() 
-                             and row.Event() = event.Subject() 
-                             and row.EventType() = guard( event.EventType().Name(), '' )
-                             );
+    //rownr                 := this.LibCal_SubscriberEventRow( relsize );
+    traverse( this.LibCal_Calendar(), Event.LeadingParticipation, lp, lp.Event().EventCategory().Name() = 'Unavailable' ){
+      event               := lp.Event();
+      rows                := selectset( this, LibCal_SubscriberEventRow, row, row.Event() = event.Subject() and row.EventType() = guard( event.EventType().Name(), '' ) );
+      traverse( lp, Subscription, subscription ){
+        row               := selectobject( rows, Elements, row, row.Subscriber() = subscription.Calendar().CalendarID() );
         
         if( isnull( row ) ){
-          row := this.LibCal_SubscriberEventRow( relnew, RowNr := rownr, Subscriber := subscriber.CalendarID(), 
-                                                 Event := event.Subject(), 
-                                                 EventType := guard( event.EventType().Name(), '' ) );
+          row             := this.LibCal_SubscriberEventRow( relnew, Subscriber   := subscription.Calendar().CalendarID()
+                                                             , Event              := event.Subject()
+                                                             , EventType          := guard( event.EventType().Name(), '' ) );
           
-          rownr := rownr + 1;
         }
         
-        traverse( participation, ExplicitTimeInterval, eti ){
+        traverse( subscription, ExplicitTimeInterval, eti ){
           row.InitializeDate( this, eti.Start(), eti.End(), event.Description() );
         }
     
@@ -37,13 +31,13 @@
     //traverse( this, LibCal_SubscriberEventColumn, column ){
     //  info( '------------------------', column.Name(), column.Period(), column.TimeUnit() );
     //}
-            
-    Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MaxDayDate ) );
-    Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MaxWeekDate ) );
-    Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MaxMonthDate ) );
-    Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MinDayDate ) );
-    Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MinWeekDate ) );
-    Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MinMonthDate ) );
+    //        
+    //Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MaxDayDate ) );
+    //Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MaxWeekDate ) );
+    //Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MaxMonthDate ) );
+    //Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MinDayDate ) );
+    //Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MinWeekDate ) );
+    //Transaction::Transaction().Propagate( attribute( LibCal_SubscriberEventTable, MinMonthDate ) );
     this.ProcessColumnDay();
     this.ProcessColumnWeek();
     this.ProcessColumnMonth();
diff --git a/_Main/BL/Type_LibCal_SubscriberEventTable/StaticMethod_InitializeTable.qbl b/_Main/BL/Type_LibCal_SubscriberEventTable/StaticMethod_InitializeTable.qbl
index e95dfc4..f2ede4c 100644
--- a/_Main/BL/Type_LibCal_SubscriberEventTable/StaticMethod_InitializeTable.qbl
+++ b/_Main/BL/Type_LibCal_SubscriberEventTable/StaticMethod_InitializeTable.qbl
@@ -9,12 +9,8 @@
   [*
     // 鐢勫叞楦� May-28-2024 (created)
     owner.LibCal_SubscriberEventTable( relflush );
-    if( owner.LibCal_SubscriberEventTable( relsize ) < 1 ){
-      owner.LibCal_SubscriberEventTable( relnew, ID := LibCal_SubscriberEventTable::GetDefaultName(), Name := LibCal_SubscriberEventTable::GetDefaultName() );
-    }
+    table         := owner.LibCal_SubscriberEventTable( relnew, ID := LibCal_SubscriberEventTable::GetDefaultName(), Name := LibCal_SubscriberEventTable::GetDefaultName() );
     
-    traverse( owner, LibCal_SubscriberEventTable, table ){
-      table.InitializeTable( subscribers );
-    }
+    table.InitializeTable( subscribers );
   *]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormCalendarUnavailableEvent/Component_MatrixEditorTable.def b/_Main/UI/MacroPlannerWebApp/Component_FormCalendarUnavailableEvent/Component_MatrixEditorTable.def
index f0cf4a9..eacae66 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormCalendarUnavailableEvent/Component_MatrixEditorTable.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormCalendarUnavailableEvent/Component_MatrixEditorTable.def
@@ -54,7 +54,7 @@
       Properties:
       [
         Legend: 'Name'
-        SortCriteria: 'RowNr'
+        SortCriteria: 'Name'
         Taborder: 1
       ]
     }

--
Gitblit v1.9.3