From ea1c035b2abbbf99b05eb95ccc5293b8490412cf Mon Sep 17 00:00:00 2001
From: lazhen <17772815105@139.com>
Date: 星期四, 15 八月 2024 16:44:52 +0800
Subject: [PATCH] 涉及到调拨计划的报表调整

---
 _Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl |   52 +++++++++++++++-----------
 _Main/BL/Type_MachiningPipelineRow/Method_SetCellTransferValue.qbl     |   20 ++++++++++
 _Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl     |   48 +++++++++++++----------
 3 files changed, 77 insertions(+), 43 deletions(-)

diff --git a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl
index 04845a1..bfe5f3d 100644
--- a/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_CCEngineLogisticsCostReport0/StaticMethod_Initialize.qbl
@@ -146,28 +146,36 @@
       product                 := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() );
       productparents          := product.GetAllParent();
       if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
-        //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
-         enginecost           := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation() 
-                                               and engine.MLB_MQB() = product.MQBMLB()
-                                               and engine.Factory() = ccunit
-                                               and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
-         //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
-         transcost            := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = dlline 
-                                                and trans.Destination() = dlrent 
-                                                and exists( productparents, Elements, e, e.ID() = trans.Product() ) );
-         if( not isnull( enginecost ) and not isnull( transcost ) ){
-           row                := table.GetRow( product.ID() );
-           products.Add( product );
-           traverse( tprow,TransferPlanCell, tpcell ){
-             periodtime       := tpcell.TransferPlanColumn().ColumnDate().StartOfMonth();
-             periodname       := periodtime.Format( "M2/D2/Y" );
-             column           := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
-             
-             cost             := ceil( ceil( [Number]tpcell.Value() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();
-             cell             := selectobject( row, Cell, cell, cell.Column() = column );
-             cell.CCLongTransCoat( cell.CCLongTransCoat() + cost );
-           }
-         }
+        //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛
+        originsp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.SourceStockpoingPointID() );
+        isdl                   := table.IsInUnit( originsp, dlunit );
+        //鐩殑鍦板簱瀛樼偣鏄惁鏄暱鏄�
+        destisp                := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.TargetStockpoingPointID() );
+        iscc                   := table.IsInUnit( destisp, ccunit );
+        if( isdl and iscc ){
+          //鏌ヨ瀵瑰簲鐨勫彂鍔ㄦ満鎴愭湰
+          enginecost           := selectobject( owner, LogisticsCostEngine, engine, engine.Generation() = product.Generation() 
+                                                 and engine.MLB_MQB() = product.MQBMLB()
+                                                 and engine.Factory() = ccunit
+                                                 and exists( productparents, Elements, e, e.ID() = engine.Product() ) );
+          //鍦ㄨ繍杈撴垚鏈弬鏁拌〃閲屾壘鍒板彂鍔ㄦ満瀵瑰簲杩愯緭鍗曚环鍜岃杞藉閲�
+          transcost            := selectobject( owner, LogisticsCostTransport, trans, trans.Origin() = dlline 
+                                                  and trans.Destination() = dlrent 
+                                                  and exists( productparents, Elements, e, e.ID() = trans.Product() ) );
+          if( not isnull( enginecost ) and not isnull( transcost ) ){
+            row                := table.GetRow( product.ID() );
+            products.Add( product );
+            traverse( tprow,TransferPlanCell, tpcell ){
+              periodtime       := tpcell.TransferPlanColumn().ColumnDate().StartOfMonth();
+              periodname       := periodtime.Format( "M2/D2/Y" );
+              column           := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
+               
+              cost             := ceil( ceil( [Number]tpcell.Value() / enginecost.PackagingCapacity() ) / transcost.LoadingCapacity() ) * transcost.TransportPrice();
+              cell             := selectobject( row, Cell, cell, cell.Column() = column );
+              cell.CCLongTransCoat( cell.CCLongTransCoat() + cost );
+            }
+          }
+        }
       }
     }
     //闀挎槬鐭�旇繍杈撹垂鐢細瀹㈡埛闇�姹傛暟閲�/鍖呰瀹归噺/瑁呰浇瀹归噺*杩愯緭鍗曚环锛屽鎴烽渶姹傛暟閲忓彇鑷猣orecast閲宻ales segment涓洪暱鏄ョ殑鏁伴噺姹囨�伙紝鍐嶇敤鍏紡璁$畻锛屾湀搴﹁繘琛屾眹鎬伙紙鍙栧鎴烽渶姹傛暟閲忔崲绠楁垚杞︽锛�
diff --git a/_Main/BL/Type_MachiningPipelineRow/Method_SetCellTransferValue.qbl b/_Main/BL/Type_MachiningPipelineRow/Method_SetCellTransferValue.qbl
new file mode 100644
index 0000000..40d4b74
--- /dev/null
+++ b/_Main/BL/Type_MachiningPipelineRow/Method_SetCellTransferValue.qbl
@@ -0,0 +1,20 @@
+Quintiq file version 2.0
+#parent: #root
+Method SetCellTransferValue (
+  MachiningPipelineColumn column,
+  Boolean iscc,
+  Real quantity
+)
+{
+  TextBody:
+  [*
+    // 鐢勫叞楦� Jun-24-2024 (created)
+    cell := selectobject( this, Cell, cell, cell.Column() = column );
+    
+    if( iscc ){
+      cell.CCTransferQty( cell.CCTransferQty() + quantity );
+    } else {
+      cell.DLTransferQty( cell.DLTransferQty() + quantity );
+    }
+  *]
+}
diff --git a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
index c6a9c85..70676a9 100644
--- a/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
+++ b/_Main/BL/Type_MachiningPipelineSource0/StaticMethod_Initialize.qbl
@@ -76,8 +76,6 @@
               if( iscc or isdl ){
                 row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryquantity );
                 if( weekcolumn.EndDate() = pispip.Start().Date() or pispip.Period_MP() = endperiod ){
-    //            if( pispip.Start() = weekstart + Duration::Days( 6 ) or pispip.Period_MP() = endperiod ){
-    //              weekstart      := ( weekstart + Duration::Days( 7 ) ).Date();
                   row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryquantity );
                 }
               }
@@ -88,25 +86,33 @@
     }
     
     //鐢熸垚璋冩嫧鏁版嵁
-    traverse( owner, TransferPlanRow, tprow, ( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ) or ( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ) ){
-      row := selectobject( table, Row, row, row.Name() = tprow.Name() );
-      traverse( table, Column, column ){
-        cell := selectobject( row, Cell, cell, cell.Column() = column );
-        if( column.TimeUnit() = Translations::MP_GlobalParameters_Day() ){
-          tpcell := selectobject( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() = column.StartDate() );
-          if( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ){
-            cell.CCTransferQty( [Real]tpcell.Value() );
-          }else if( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ){
-            cell.DLTransferQty( [Real]tpcell.Value() );
-          }
-        }else if( column.TimeUnit() = Translations::MP_GlobalParameters_Week() ){
-          period := column.StartDate() + Duration::Days( 6 );
-          tpcell := selectobject( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() = period.Date() );
-          
-          if( tprow.SourceStockpoingPointID() = 'CC' and tprow.TargetStockpoingPointID() = 'DL' ){
-            cell.CCTransferQty( [Real]tpcell.Value() );
-          }else if( tprow.SourceStockpoingPointID() = 'DL' and tprow.TargetStockpoingPointID() = 'CC' ){
-            cell.DLTransferQty( [Real]tpcell.Value() );
+    traverse( owner, TransferPlanRow, tprow ){
+      product               := selectobject( owner, Product_MP, product, product.ID() = tprow.ProductID() );
+      productparents        := product.GetAllParent();
+      if( exists( productparents, Elements, e, e.ID() = productparent ) ){//鏌ヨ浜у搧绫诲瀷鏄彂鍔ㄦ満
+        //璧峰搴撳瓨鐐规槸鍚︽槸澶ц繛or闀挎槬
+        originsp              := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.SourceStockpoingPointID() );
+        originunit            := originsp.Unit();
+        originparentunits     := originunit.GetAllParent();
+        originiscc            := originsp.ID() = ccunit or originunit.ID() = ccunit or exists( originparentunits, Elements, punit, punit.ID() = ccunit );
+        originisdl            := originsp.ID() = dlunit or originunit.ID() = dlunit or exists( originparentunits, Elements, punit, punit.ID() = dlunit );
+        //鐩殑鍦版槸鍚︽槸闀挎槬澶栫搴�
+        destisp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = tprow.TargetStockpoingPointID() );
+        destiunit             := originsp.Unit();
+        destiparentunits      := destiunit.GetAllParent();
+        destiiscc             := destisp.ID() = ccunit or destiunit.ID() = ccunit or exists( destiparentunits, Elements, punit, punit.ID() = ccunit );
+        destiisdl             := destisp.ID() = dlunit or destiunit.ID() = dlunit or exists( destiparentunits, Elements, punit, punit.ID() = dlunit );
+        if( ( originiscc and destiisdl ) or ( originisdl and destiiscc ) ){
+          row := selectobject( table, Row, row, row.Name() = tprow.Name() );
+          traverse( tprow, TransferPlanCell, tpcell ){
+            //澶�
+            daycolumn        := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), tpcell.TransferPlanColumn().ColumnDate() );
+            //鍛�
+            weekcolumn       := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), tpcell.TransferPlanColumn().ColumnDate() );
+            quantity         := [Real]tpcell.Value();//鍥涜垗浜斿叆
+            
+            row.SetCellTransferValue( daycolumn, ( originiscc and destiisdl ), quantity );
+            row.SetCellTransferValue( weekcolumn, ( originiscc and destiisdl ), quantity );
           }
         }
       }

--
Gitblit v1.9.3