xiaoding721
2024-09-06 4f70e746b6f75d748aa7635d528179ef8d811222
更新 StaticMethod_GenerateForecast.qbl
已修改1个文件
51 ■■■■■ 文件已修改
_Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_Archive/StaticMethod_GenerateForecast.qbl
@@ -11,10 +11,51 @@
      f.Delete();
    }
    
    productMPs := selectset( macroPlan,Product_MP,prod,not prod.IsSystem() );
    productMPIndexTree := NamedValueTree::Create();
    productMPIndexTreeNotes := NamedValueTree::Create();
    for( i := 0; i < productMPs.Size(); i++ ){
      productMP := productMPs.Element( i );
      productMPHandle := productMPIndexTree.GetHandle( productMP.ID() );
      productMPIndexTree.Root().AddChild( productMPHandle,i );
      productMPHandleNotes := productMPIndexTreeNotes.GetHandle( productMP.Notes() );
      productMPIndexTreeNotes.Root().AddChild( productMPHandleNotes,i );
    }
    stockingPoints := selectset( macroPlan,StockingPoint_MP,sotckingPoint,not sotckingPoint.IsSystem() );
    stockingPointIndexTree := NamedValueTree::Create();
    for( i := 0; i < stockingPoints.Size(); i++ ){
      stockingPoint := stockingPoints.Element( i );
      stockingPointHandle := stockingPointIndexTree.GetHandle( stockingPoint.ID() );
      stockingPointIndexTree.Root().AddChild( stockingPointHandle, i );
    }
    traverse ( archiveExecutionStatus, TemporaryDemandData, tdd ,tdd.Origin() = "" or tdd.StartDate() >= macroPlan.StartOfPlanning().Date()) {
      targetProduct_MP       := select( macroPlan, Product_MP, tempPMP, tempPMP.Notes() = tdd.ProductID() );
      targetProduct_MP := null( Product_MP );
      productMPHandleNotes := productMPIndexTreeNotes.GetHandle( tdd.ProductID());
      productMPIndexNotes := guard( productMPIndexTreeNotes.Root().Child( productMPHandleNotes ),null( NamedValue ));
      if( isnull( productMPIndexNotes )){
        productMPHandle := productMPIndexTree.GetHandle( tdd.ProductID());
        productMPIndex := guard( productMPIndexTree.Root().Child( productMPHandle ),null( NamedValue ));
        if( not isnull( productMPIndex )){
          targetProduct_MP := productMPs.Element( productMPIndex.GetValueAsNumber() );
        }
      }else{
        targetProduct_MP := productMPs.Element( productMPIndexNotes.GetValueAsNumber() );
      }
      targetStockingPoint_MP := null( StockingPoint_MP );
      stockingPointHandle := stockingPointIndexTree.GetHandle( tdd.StockingPointID() );
      stockingPointIndex := guard( stockingPointIndexTree.Root().Child( stockingPointHandle ),null( NamedValue ));
      if( not isnull( stockingPointIndex )){
        targetStockingPoint_MP := stockingPoints.Element( stockingPointIndex.GetValueAsNumber() );
      }
    //  targetProduct_MP       := select( macroPlan, Product_MP, tempPMP, tempPMP.Notes() = tdd.ProductID() );
      // targetProduct_MP       := select( macroPlan, Product_MP, tempPMP, tempPMP.ID() = tdd.ProductID() );
      targetStockingPoint_MP := select( macroPlan, StockingPoint_MP, tempSPMP, tempSPMP.ID() = tdd.StockingPointID() );
    //  targetStockingPoint_MP := select( macroPlan, StockingPoint_MP, tempSPMP, tempSPMP.ID() = tdd.StockingPointID() );
      // info( tdd.SalesSegmentName() );
      if ( not isnull( targetProduct_MP ) and not isnull( targetStockingPoint_MP ) ) {
        forcest := Forecast::Create( targetProduct_MP,
@@ -33,6 +74,12 @@
                          false );
        forcest.Origin( tdd.Origin() );
      }
      if( isnull( targetProduct_MP )){
        info( tdd.ProductID() + " -> 未找到Product_MP" );
      }
      if( isnull( targetStockingPoint_MP )){
        info( tdd.StockingPointID() + " -> 未找到StockingPoint_MP" );
      }
    }
  *]
}