Quintiq file version 2.0
|
#parent: #root
|
StaticMethod Initialize (
|
MacroPlan owner
|
)
|
{
|
TextBody:
|
[*
|
// 甄兰鸽 Jun-24-2024 (created)
|
owner.FinancialProductionSource( relflush );
|
startinventorydate := owner.StartOfPlanning() - Duration::Days( 1 );
|
productparent := MachiningPipelineReport::GetDefaultProductParent();
|
source := owner.MachiningPipelineSource( relnew, Name := MachiningPipelineReport::GetDefaultName() );
|
table := source.Report( relnew, ID := source.Name(), Name := source.Name() );
|
showtable := source.Report( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsShow := true );
|
|
search := owner.MachiningPipelineSearch( relnew, StartDate := Date::MinDate(), EndDate := Date::MaxDate(), TimeUnit := Translations::MP_GlobalParameters_Day() );
|
|
products := construct( Product_MPs );
|
//初始化列
|
table.GenerateColumn( owner, 'All', search.StartDate(), search.EndDate() );
|
//endperiod := maxobject( owner, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day(), period.StartDate() );
|
|
//生成装配(长内库)、生产(的DL和库存数据
|
traverse( owner, StockingPoint_MP, stockingpoint ){
|
unit := stockingpoint.Unit();
|
parentunits := unit.GetAllParent();
|
//是否属于长春工厂
|
iscc := stockingpoint.ID().StartsWith( 'CC' ) or unit.ID().StartsWith( 'CC' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'CC' ) );//unit.ID() = ccunit or exists( parentunits, Elements, punit, punit.ID() = ccunit );
|
//是否属于大连工厂
|
isdl := stockingpoint.ID().StartsWith( 'DL' ) or unit.ID().StartsWith( 'DL' ) or exists( parentunits, Elements, punit, punit.ID().StartsWith( 'DL' ) );//unit.ID() = dlunit or exists( parentunits, Elements, punit, punit.ID() = dlunit );
|
if( iscc or isdl ){
|
traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() and not pisp.IsSystem()// and pisp.ProductID() = '06K103011CM'
|
and exists( pisp.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent )
|
and exists( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical() and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.DependentDemandAndSalesDemandQuantity() <> 0 ) ) ){
|
isccassemnly := stockingpoint.ID().EndsWith( pisp.Product_MP().ParentID() + '线边库' ) and ( stockingpoint.ID().StartsWith( 'CC' ) or stockingpoint.ID().StartsWith( '长春' ) );
|
isdlassemnly := stockingpoint.ID().EndsWith( pisp.Product_MP().ParentID() ) and ( stockingpoint.ID().StartsWith( 'DL' ) or stockingpoint.ID().StartsWith( '大连' ) );
|
pispips := selectsortedset( pisp, ProductInStockingPointInPeriod, pispip, not pispip.Period_MP().IsHistorical()
|
and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and ( pispip.NewSupplyQuantity() <> 0 or pispip.DependentDemandAndSalesDemandQuantity() <> 0 ), pispip.Start() );
|
products.Add( pisp.Product_MP() );
|
row := table.GetRow( pisp.ProductID() );
|
inventoryqty := sum( pisp, ProductInStockingPointInPeriod, pispip, pispip.Start() = startinventorydate and pispip.Period_MP().TimeUnit() = Translations::MP_GlobalParameters_Day() and pispip.ActualInventoryLevelEnd() <> 0, pispip.ActualInventoryLevelEnd() );
|
if( isccassemnly ){
|
row.CCInventoryQty( row.CCInventoryQty() + inventoryqty );
|
}
|
if( isdlassemnly ){
|
row.DLInventoryQty( row.DLInventoryQty() + inventoryqty );
|
}
|
traverse( pispips, Elements, pispip){//, pispip.Start().Month() = 1 and pispip.Start().Day() = 2
|
|
//天
|
daycolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), pispip.Start().Date() );
|
//周
|
// weekcolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), pispip.Start().Date() );
|
|
if( isccassemnly or isdlassemnly ){
|
//装配线
|
quantity := [Number]pispip.DependentDemandAndSalesDemandQuantity();//四舍五入
|
row.SetAssemblyPlanValue( daycolumn, isccassemnly, [Real]quantity );
|
// row.SetAssemblyPlanValue( weekcolumn, isccassemnly, [Real]quantity );
|
//生产
|
supplyqty := [Number]pispip.NewSupplyQuantity();//四舍五入
|
// info( '****************', quantity, supplyqty );
|
row.SetCellProductionValue( daycolumn, isccassemnly, [Real]supplyqty );
|
// row.SetCellProductionValue( weekcolumn, isccassemnly, [Real]supplyqty );
|
}
|
|
//库存
|
// if( iscc or isdl ){
|
// inventoryqty := [Number]pispip.PlannedInventoryLevelEnd();//四舍五入
|
// row.SetCellInventoryValue( daycolumn, iscc, [Real]inventoryqty );
|
// if( weekcolumn.EndDate() = pispip.Start().Date() or pispip.Period_MP() = endperiod ){
|
// row.SetCellInventoryValue( weekcolumn, iscc, [Real]inventoryqty );
|
// }
|
// }
|
}
|
}
|
}
|
}
|
//生成调拨数据
|
traverse( owner, Unit.Lane.LaneLeg, laneleg ){
|
originspid := laneleg.OriginStockingPointID();
|
destinationspid := laneleg.DestinationStockingPointID();
|
//CC to DL 长春工厂到大连工厂
|
iscctodl := ( originspid.StartsWith( '长春' ) or originspid.StartsWith( 'CC' ) ) and ( destinationspid.StartsWith( '大连' ) or destinationspid.StartsWith( 'DL' ) );
|
//DL to CC 大连厂内库到大连发动机的长春外租库
|
isdltocc := originspid.EndsWith( '厂内库' ) and ( originspid.StartsWith( '大连' ) or originspid.StartsWith( 'DL' ) ) and destinationspid = '大连发动机的长春外租库';
|
if( iscctodl or isdltocc ){
|
// info( '------iscctodl------', originspid, destinationspid, iscctodl );
|
traverse( table, Column, column ){//, column.StartDate().Month() = 1
|
alltrips := selectset( laneleg, Trip, trip, trip.Arrival().Date() = column.StartDate()
|
or trip.Departure().Date() = column.StartDate() );
|
producttrips := selectuniquevalues( alltrips, Elements.ProductInTrip, pit, pit.Quantity() <> 0 and exists( pit.Product_MP().GetAllParent(), Elements, e, e.ID() = productparent ), pit.ProductID() );
|
// info( '---------Column----------', alltrips.Size(), producttrips.Size(), column.StartDate() );
|
traverse( producttrips, Elements, producttrip ){//, producttrip = '06K103011CP'
|
row := table.GetRow( producttrip );
|
product := selectobject( owner, Product_MP, product, product.ID() = producttrip );
|
products.Add( product );
|
departureqty := sum( alltrips, Elements.ProductInTrip, pit, pit.Trip().Departure().Date() = column.StartDate() and pit.Product_MP() = product, pit.Quantity() );
|
arrivalqty := sum( alltrips, Elements.ProductInTrip, pit, pit.Trip().Arrival().Date() = column.StartDate() and pit.Product_MP() = product, pit.Quantity() );
|
// info( '---------***************8---------', departureqty, arrivalqty, column.StartDate() );
|
row.SetDepartureAndArrivalValue( column, iscctodl, departureqty, arrivalqty );
|
}
|
}
|
}
|
}
|
//生成调拨数据
|
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 := tprow.SourceStockpoingPointID() = 'CC';//originsp.ID() = ccunit or originunit.ID() = ccunit or exists( originparentunits, Elements, punit, punit.ID() = ccunit );
|
originisdl := tprow.SourceStockpoingPointID() = 'DL';//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 := destisp.Unit();
|
// destiparentunits := destiunit.GetAllParent();
|
destiiscc := tprow.TargetStockpoingPointID() = 'CC';//destisp.ID() = ccunit or destiunit.ID() = ccunit or exists( destiparentunits, Elements, punit, punit.ID() = ccunit );
|
destiisdl := tprow.TargetStockpoingPointID() = 'DL';//destisp.ID() = dlunit or destiunit.ID() = dlunit or exists( destiparentunits, Elements, punit, punit.ID() = dlunit );
|
if( ( originiscc and destiisdl ) or ( originisdl and destiiscc ) ){
|
row := table.GetRow( tprow.ProductID() );
|
traverse( tprow, TransferPlanCell, tpcell, tpcell.TransferPlanColumn().ColumnDate() <> Date::MinDate() ){
|
//天
|
daycolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Day(), tpcell.TransferPlanColumn().ColumnDate() );
|
//周
|
// weekcolumn := table.GetColumnByUnit( Translations::MP_GlobalParameters_Week(), tpcell.TransferPlanColumn().ColumnDate() );
|
quantity := [Real]tpcell.Value();//四舍五入
|
if( not isnull( daycolumn ) ){
|
row.SetCellTransferValue( daycolumn, ( originiscc and destiisdl ), quantity );
|
}
|
// if( not isnull( weekcolumn ) ){
|
// row.SetCellTransferValue( weekcolumn, ( originiscc and destiisdl ), quantity );
|
// }
|
}
|
}
|
}
|
}
|
|
//rows := selectsortedset( table, Row, row, row.Name() );
|
//i := 0;
|
//traverse( rows, Elements, e ){
|
// e.RowNr( i );
|
// i := i + 1;
|
//}
|
showtable.Generate( search, products );
|
*]
|
}
|