Quintiq file version 2.0
|
#parent: #root
|
StaticMethod GenerateData (
|
MacroPlan macroPlan,
|
InterfaceDataset interfaceDataset
|
)
|
{
|
Description: '生成计划库存存档数据'
|
TextBody:
|
[*
|
//interfaceDataset.InventoryPlanArchiveVersion( relflush );
|
info( '-------------------------Start---------------------' );
|
//machineproductparent := MachiningPipelineReport::GetDefaultProductParent(); // 机加件
|
//engineproductparent := EnginePipelineReport::GetDefaultProductParent(); // 发动机
|
allunit := AssemblyOnlinePlanVersion::GetDefaultAllUnit(); // <All>
|
name := InventoryPlanArchiveVersion::GetDefaultName(); // Inventory plan archive
|
interfaceDataset.InventoryPlanArchiveVersionSearch( relnew,
|
Product := allunit,
|
Unit := allunit,
|
StartDate := Date::MinDate(),
|
EndDate := Date::MaxDate() );//, TimeUnit := Translations::MP_GlobalParameters_Day()
|
|
// 创建显示表格
|
table := selectobject( interfaceDataset, InventoryPlanArchiveVersion, version, not version.IsShow() );
|
if( isnull( table ) ){
|
table := interfaceDataset.InventoryPlanArchiveVersion( relnew, ID := name, Name := name );
|
}
|
|
//showtable := selectobject( interfaceDataset, InventoryPlanArchiveVersion, version, version.IsShow() );
|
//if( isnull( showtable ) ){
|
// showtable := interfaceDataset.InventoryPlanArchiveVersion( relnew, ID := name, Name := name, IsShow := true );
|
//}
|
|
// 创建不存在列
|
periods := selectuniquevalues( macroPlan, Period_MP, period, not period.IsHistorical() and period.TimeUnit() = Translations::MP_GlobalParameters_Day()
|
and not exists( table, Column, column, column.StartDate() = period.StartDate() ), period.StartDate() );//column.TimeUnit() = Translations::MP_GlobalParameters_Day() and
|
if( periods.Size() > 0 ){
|
table.GenerateColumn( periods, false );
|
}
|
|
// 最小时间
|
minDate := minselect( table, Column, tempC, true, tempC.StartDate() ).StartDate();
|
maxDate := maxselect( table, Column, tempC, true, tempC.StartDate() ).StartDate();
|
info( "最小时间:", minDate.Format( "Y-M2-D2" ), " 最大时间:", maxDate.Format( "Y-M2-D2" ) );
|
|
actinventorytree := NamedValueTree::Create();
|
// 机加实际库存
|
traverse ( interfaceDataset,InterfaceLoginfo.MachineStockData, actinventory,
|
// actinventory.Fac() = "CC" and actinventory.MaterialNo() = "06U105101A" and actinventory.DDay() = Date::Construct( 2025, 4, 9 ) and// 测试过滤(生产需要注释)
|
actinventory.DDay() >= minDate and actinventory.DDay() <= maxDate ) {
|
// 库位是否绑定库存点
|
iid := select( interfaceDataset, InventoryInterfaceData, tempIID, tempIID.Date() = actinventory.DDay() and
|
tempIID.PartNumber() = actinventory.MaterialNo() );
|
iidd := select( iid, InventoryInterfaceDataDetail, tempIIDD, tempIIDD.InventoryPoint() = actinventory.Lgort() and
|
tempIIDD.Fac() = actinventory.Fac() );
|
flag := guard( iidd.InventoryPointSelection().IsIncluded(), false );
|
// info( "是否被库存点选择:", flag, " 数量:", actinventory.Total() );
|
actinventoryKey := ifexpr( actinventory.Fac() = "DL", FinancialProductionReport::GetDefaultDLUnit(), FinancialProductionReport::GetDefaultCCUnit() ) +
|
actinventory.MaterialNo() +
|
actinventory.DDay().Format( "Y-M2-D2" );
|
actinventoryhandle := actinventorytree.GetHandle( actinventoryKey );
|
if ( guard( actinventorytree.Root().Child( actinventoryhandle ).GetValueAsReal() > 0, false ) ) { // 判断是否存在,存在
|
if ( flag ) {
|
targetNV := actinventorytree.Root().Child( actinventoryhandle );
|
targetNV.SetValue( targetNV.GetValueAsReal() + actinventory.Total() );
|
}
|
} else { // 不存在
|
if ( flag ) {
|
actinventorytree.Root().AddChild( actinventoryhandle, actinventory.Total() );
|
}
|
}
|
}
|
// 发动机实际库存
|
traverse ( interfaceDataset, InterfaceLoginfo.FinishedEngineInventory, actinventory,
|
// actinventory.Fac() = "CC" and actinventory.FourCode() = "6908" and actinventory.DDay() = Date::Construct( 2025, 4, 2 ) and// 测试过滤(生产需要注释)
|
actinventory.DDay() >= minDate and actinventory.DDay() <= maxDate ) {
|
// 库位是否绑定库存点
|
iid := select( interfaceDataset, InventoryInterfaceData, tempIID, tempIID.Date() = actinventory.DDay() and
|
tempIID.PartNumber() = actinventory.FourCode() );
|
iidd := select( iid, InventoryInterfaceDataDetail, tempIIDD, tempIIDD.InventoryPoint() = actinventory.BIPlace() and
|
tempIIDD.Fac() = actinventory.Fac() );
|
flag := guard( iidd.InventoryPointSelection().IsIncluded(), false );
|
|
product := selectobject( macroPlan, Product_MP, product, product.ID() = actinventory.FourCode() );
|
if ( not isnull( product ) ) {
|
actinventoryKey := ifexpr( actinventory.Fac() = "DL", FinancialProductionReport::GetDefaultDLUnit(), FinancialProductionReport::GetDefaultCCUnit() ) +
|
actinventory.FourCode() +
|
actinventory.DDay().Format( "Y-M2-D2" );
|
actinventoryhandle := actinventorytree.GetHandle( actinventoryKey );
|
if ( guard( actinventorytree.Root().Child( actinventoryhandle ).GetValueAsReal() > 0, false ) ) { // 判断是否存在,存在
|
if ( flag ) {
|
targetNV := actinventorytree.Root().Child( actinventoryhandle );
|
targetNV.SetValue( targetNV.GetValueAsReal() + actinventory.Total() );
|
}
|
} else { // 不存在
|
if ( flag ) {
|
actinventorytree.Root().AddChild( actinventoryhandle, actinventory.Total() );
|
}
|
}
|
}
|
}
|
|
//handle := actinventorytree.GetHandle( "VWED CC06U105101A2025-04-09" );
|
//info( "数量:", guard( actinventorytree.Root().Child( handle ).GetValueAsReal(), 0 ) );
|
|
// 保存已重置0的产品
|
resetNVT := NamedValueTree::Create();
|
|
traverse ( macroPlan, Product_MP, product
|
// ,product.ID() = "6909"
|
) {
|
traverse ( product, ProductInStockingPoint_MP, pispmp, not pispmp.IsSystem() and pispmp.IsLeaf() ) {
|
unit := ifexpr( pispmp.StockingPointID().Regex( "大连" ) or pispmp.StockingPointID().Regex( "DL" ),
|
FinancialProductionReport::GetDefaultDLUnit(),
|
FinancialProductionReport::GetDefaultCCUnit() ); // 工厂
|
inventoryrow := table.GetRowByUnit( pispmp.Product_MP(), unit ); // 创建库存存档行
|
// info( pispmp.Name() );
|
|
traverse ( pispmp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispippl,
|
// pispmp.ProductID() = "6909" and pispippl.Start().Date() = Date::Construct( 2025, 3, 31 ) and // 测试过滤(生产需要注释)
|
not pispippl.IsPeriodFrozen() ) {
|
startdate := pispippl.Start().Date();
|
daycolumn := table.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Day(), startdate ); // 获取库存存档列
|
// weekcolumn := table.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Week(), startdate );
|
// monthcolumn := table.GetColumnByTimeUnit( Translations::MP_GlobalParameters_Month(), startdate );
|
actinventoryKey := unit + pispmp.ProductID() + startdate.Format( "Y-M2-D2" );
|
actinventoryhandle := actinventorytree.GetHandle( actinventoryKey );
|
actinventoryQty := guard( actinventorytree.Root().Child( actinventoryhandle ).GetValueAsReal(), 0 );
|
// info( "数量:", actinventoryQty );
|
inventoryrow.SetQuantity( daycolumn, pispippl.InventoryLevelEnd(), actinventoryQty, resetNVT );
|
// inventoryrow.SetQuantity( weekcolumn, pispippl.InventoryLevelEnd(), actinventoryqty );
|
// inventoryrow.SetQuantity( monthcolumn, pispippl.InventoryLevelEnd(), actinventoryqty );
|
|
}
|
}
|
}
|
|
info( '-------------------------End---------------------' );
|
//productids := selectuniquevalues( table, Row, row, row.Name() );
|
//productlines := selectuniquevalues( table, Row, row, row.Unit() );
|
//showtable.Generate( search, productids, productlines );
|
*]
|
}
|