Quintiq file version 2.0
|
#parent: #root
|
StaticMethod Initialize (
|
MacroPlan owner,
|
InterfaceDataset interface
|
)
|
{
|
Description: '初始化'
|
TextBody:
|
[*
|
// 甄兰鸽 Jun-24-2024 (created)
|
//添加运输途中字段,取leadingtime》1的,以途中日期为准,比如1.8出发1.10到达,则日期为1.9,工厂按初始地计算
|
owner.InventorySummarySource( relflush );
|
productids := construct( Strings );
|
allunit := InventorySummaryReport::GetDefaultAllUnit();
|
ccunit := InventorySummaryReport::GetDefaultCCUnit();
|
dlunit := InventorySummaryReport::GetDefaultDLUnit();
|
|
source := owner.InventorySummarySource( relnew, ID := InventorySummaryReport::GetDefaultName(), Name := InventorySummaryReport::GetDefaultName() );
|
table := source.InventorySummaryReport( relnew, ID := source.Name(), Name := source.Name() );
|
showtable := source.InventorySummaryReport( relnew, ID := source.Name() + 'Show', Name := source.Name(), IsShow := true );
|
startofplanning := owner.StartOfPlanning();
|
startofyear := startofplanning.StartOfYear() - Duration::Days( 1 );
|
startofnextyear := startofplanning.StartOfNextYear();
|
|
search := owner.InventorySummarySearch( relnew, Unit := allunit, Generation := allunit, MqbMlb := allunit, Power := allunit, Category := Translations::MP_GlobalParameters_Day(), StartDate := Date::MinDate(), EndDate := Date::MaxDate() );
|
|
table.GenerateColumn( owner, Translations::MP_GlobalParameters_Day(), startofyear, startofnextyear );
|
//库存数量为Actual inventories里面的点Planned inventories字段库存量加总
|
traverse( owner, StockingPoint_MP, stockingpoint ){
|
unit := stockingpoint.Unit();
|
parentunits := unit.GetAllParent();
|
//是否属于长春工厂
|
iscc := exists( parentunits, Elements, punit, punit.ID().StartsWith( 'VWED CC' ) );
|
//是否属于大连工厂
|
isdl := exists( parentunits, Elements, punit, punit.ID().StartsWith( 'VWED DL' ) );
|
if( iscc or isdl ){
|
traverse( stockingpoint, ProductInStockingPoint_MP, pisp, pisp.Product_MP().IsLeaf() ){
|
productids.Add( pisp.ProductID() );
|
//获取工厂行
|
factoryrow := table.GetRow( ifexpr( iscc, ccunit, dlunit ), pisp.Product_MP() );
|
//获取合计行
|
allrow := table.GetRow( allunit, pisp.Product_MP() );
|
|
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 ){
|
period := pispip.Period_MP();
|
periodtime := period.Start().Date();
|
// periodname := periodtime.Format( "M2/D2/Y" );
|
|
//天,选择日颗粒度时,期末库存,最小库存,最大库存和平均库存的数值保持一致
|
daycolumn := selectobject( table, InventorySummaryColumn, column, column.StartDate() = periodtime, column.TimeUnit() = Translations::MP_GlobalParameters_Day() );
|
quantity := ifexpr( pispip.Period_MP().IsHistorical(), [Number]pispip.ActualInventoryLevelEnd(), [Number]pispip.PlannedInventoryLevelEnd() );
|
factoryrow.SetCellValue( daycolumn, quantity );
|
allrow.SetCellValue( daycolumn, quantity );
|
}
|
}
|
}
|
}
|
//首先在Entities里识别父级Unit为长春/大连的所有库存点
|
//长春库存点
|
ccsps := construct( Strings );
|
//大连库存点
|
dlsps := construct( Strings );
|
allsps := construct( Strings );
|
traverse( owner, Unit, unit, unit.ID() = ccunit or unit.ID() = dlunit ){
|
if( unit.ID() = ccunit ){
|
ccsps := selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() );
|
}
|
if( unit.ID() = dlunit ){
|
dlsps := selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() );
|
}
|
allsps := allsps.Union( selectuniquevalues( unit, StockingPoint_MP, sp, sp.ID() ) );
|
}
|
//再在库存更新的子界面库存点选择中找到这些库存点所关联的已勾选库位
|
selections := selectset( interface, InventoryPointSelection, selection, allsps.Find( selection.StockpoingPoint() ) >= 0 and selection.IsIncluded() );
|
productidset := selectuniquevalues( selections, Elements, selection, selection.ProductID() );
|
//最后将这些库位中零件号的数量进行加总
|
traverse( table, InventorySummaryColumn, column, column.TimeUnit() = Translations::MP_GlobalParameters_Day() and column.StartDate() < startofplanning.Date() ){
|
traverse( productidset, Elements, productid ){
|
productids.Add( productid );
|
product := selectobject( owner, Product_MP, product, product.ID() = productid );
|
column.GenerateCell( selections, ccsps, dlsps, table, column.StartDate(), column.EndaDate(), product, allunit, ccunit, dlunit );
|
}
|
}
|
|
//库存在途数据
|
traverse( owner, Unit.Lane.LaneLeg, laneleg ){
|
originspid := laneleg.OriginStockingPointID();
|
//起始地是长春
|
isccorigin := originspid.StartsWith( '长春' ) or originspid.StartsWith( 'CC' );
|
//起始地是大连
|
isdlorigin := originspid.StartsWith( '大连' ) or originspid.StartsWith( 'DL' );
|
if( isccorigin or isdlorigin ){
|
traverse( laneleg, Trip, trip, trip.LeadTime().Days() > 1 ){
|
for( transferdate := trip.Departure() + Duration::Days( 1 ); transferdate < trip.Arrival(); transferdate := transferdate + Duration::Days( 1 ) ){
|
daycolumn := selectobject( table, InventorySummaryColumn, column, column.StartDate() = transferdate.Date(), column.TimeUnit() = Translations::MP_GlobalParameters_Day() );
|
traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
|
//获取工厂行
|
factoryrow := table.GetRow( ifexpr( isccorigin, ccunit, dlunit ), pit.Product_MP() );
|
//获取合计行
|
allrow := table.GetRow( allunit, pit.Product_MP() );
|
quantity := [Number]pit.Quantity();
|
factoryrow.SetCellValue( daycolumn, quantity );
|
allrow.SetCellValue( daycolumn, quantity );
|
}
|
}
|
}
|
}
|
}
|
|
rows := selectsortedset( table, InventroySummaryRow, row, row.Name() );
|
i := 0;
|
traverse( rows, Elements, e ){
|
if( exists( e, InventorySummaryCell, cell, cell.AverageInventory() <> 0 or cell.EndingInventory() <> 0 or cell.MaximumInventory() <> 0 or cell.MinimumInventory() <> 0 ) ){
|
e.RowNr( i );
|
i := i + 1;
|
}else{
|
e.Delete();
|
}
|
}
|
|
factorys := selectset( owner, Factory, factory, factory.ID() = FinancialProductionReport::GetDefaultAllUnit() );
|
showtable.Generate( search, factorys, productids );
|
*]
|
}
|