Quintiq file version 2.0
|
#parent: #root
|
StaticMethod GenerateForecast (
|
ArchiveExecutionStatus archiveExecutionStatus,
|
MacroPlan macroPlan,
|
Boolean isClearForecast
|
)
|
{
|
TextBody:
|
[*
|
if( isClearForecast ){
|
traverse ( macroPlan, SalesDemand.astype( Forecast ), f ) {
|
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()) {
|
if( tdd.ProductID() = "6914" or tdd.ProductID() = "6916" or tdd.ProductID() = "6917" or tdd.ProductID() = "06S100010R" or tdd.ProductID() = "06S100010M" or tdd.ProductID() = "06S100010N" ){
|
tdd.StockingPointID( "大连发动机的长春外租库" );
|
}
|
|
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() );
|
// info( tdd.SalesSegmentName() );
|
if ( not isnull( targetProduct_MP ) and not isnull( targetStockingPoint_MP ) ) {
|
forcest := Forecast::Create( targetProduct_MP,
|
targetStockingPoint_MP,
|
IDHolder::GetGUID(),
|
tdd.StartDate(),
|
tdd.EndDate(),
|
tdd.Quantity(),
|
[Real]tdd.Price(),
|
tdd.PriorityName(),
|
tdd.SalesSegmentName(),
|
tdd.CurrencyID(),
|
tdd.UnitOfMeasureName(),
|
0.0,
|
false,
|
false );
|
forcest.Origin( tdd.Origin() );
|
}
|
if( isnull( targetProduct_MP )){
|
info( tdd.ProductID() + " -> 未找到Product_MP" );
|
}
|
if( isnull( targetStockingPoint_MP )){
|
info( tdd.StockingPointID() + " -> 未找到StockingPoint_MP" );
|
}
|
}
|
*]
|
}
|