From 5ed2c2076e3b8a907ac2d271ea627cc9f9c9b3f4 Mon Sep 17 00:00:00 2001 From: lihongji <3117313295@qq.com> Date: 星期二, 09 七月 2024 13:19:13 +0800 Subject: [PATCH] 装配上线计划 --- _Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl | 103 ++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 81 insertions(+), 22 deletions(-) diff --git a/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl b/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl index 5e7cd09..75941d4 100644 --- a/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl +++ b/_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl @@ -6,48 +6,51 @@ { TextBody: [* - macroPlan.OfflinePlanRow( relflush ); - macroPlan.OfflinePlanColumn( relflush ); + macroPlan.OfflinePlanTable( relflush ); + + opt := macroPlan.OfflinePlanTable( relnew, SaveDateTime := DateTime::ActualTime() ); // 鐢熸垚涓嬬嚎璁″垝琛� - traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() and u.Name() = "ZP4-M3" ) { + traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() /*and u.Name() = "Spider Assy Line 1"*/ ) { // 鍒涘缓浜х嚎琛� - macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "", Type := "0" ); + opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "", Type := "0" ); traverse ( u, Operation, o ) { traverse ( o, PeriodTaskOperation.NewSupply, ns ) { // 鎵捐 - oprQuantity := OfflinePlanRow::FindOfflinePlanRowTypeIndex( u.ID(), ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), "1" ); - oprOrder := OfflinePlanRow::FindOfflinePlanRowTypeIndex( u.ID(), ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), "2" ); + oprQuantity := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = u.ID() and tempOPR.ProductID() = ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID() and tempOPR.Type() = "1" ); + oprOrder := select( opt, OfflinePlanRow, tempOPR, tempOPR.ProductionLine() = u.ID() and tempOPR.ProductID() = ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID() and tempOPR.Type() = "2" ); if ( isnull( oprQuantity ) and isnull( oprOrder ) ) { - oprQuantity := macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), Type := "1" ); - oprOrder := macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), Type := "2" ); + oprQuantity := opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), Type := "1" ); + oprOrder := opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := ns.AsProductionSupply().ProductInStockingPoint_MP().ProductID(), Type := "2" ); } // 鎵惧垪 - opc := OfflinePlanColumn::FindOfflinePlanColumnTypeIndex( ns.Start().Date() ); + opc := select( opt, OfflinePlanColumn, tempOPC, tempOPC.ColumnDate() = ns.Start().Date() ); if ( isnull( opc ) ) { - opc := macroPlan.OfflinePlanColumn( relnew, ColumnDate := ns.Start().Date() ); + opc := opt.OfflinePlanColumn( relnew, ColumnDate := ns.Start().Date() ); } // 璧嬪�煎崟鍏冩牸 - cellQuantity := opc.OfflinePlanCell( relnew, Value := [String]ns.Quantity().Round( 0 ), Shift := ns.PeriodTask_MP().UnitPeriod().astype( UnitPeriodTimeBase ).ShiftPattern().Name() ); + cellQuantity := opc.OfflinePlanCell( relnew, Value := [String]ns.Quantity().Round( 0 ), Shift := ns.PeriodTask_MP().UnitPeriod().astype( UnitPeriodTimeBase ).ShiftPattern().Name(), Quantity := ns.Quantity() ); cellQuantity.OfflinePlanRow( relset, oprQuantity ); - cellOrder := opc.OfflinePlanCell( relnew, Value := "鍗曞彿" ); + cellOrder := opc.OfflinePlanCell( relnew, Value := "鍗曞彿" + [String]ns.Quantity().Round( 0 ) + "_" + [String]( ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel() ), + Quantity := ns.Quantity(), + InventoryWeight := ns.ProductInStockingPointInPeriodPlanningLeaf().InventoryLevelEnd() - ns.ProductInStockingPointInPeriodPlanningLeaf().MinInventoryLevel() ); cellOrder.OfflinePlanRow( relset, oprOrder ); } } // 鍒涘缓鎬婚噺琛� - macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "3" ); + opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "3" ); // 鍒涘缓鐝琛� - macroPlan.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "4" ); + opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "4" ); } // 鍒涘缓浜у搧鍒�&绫诲瀷鍒� - productOPC := macroPlan.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 2 ); - typeOPC := macroPlan.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 1 ); - traverse ( macroPlan, OfflinePlanRow, opr ) { + productOPC := opt.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 2 ); + typeOPC := opt.OfflinePlanColumn( relnew, ColumnDate := macroPlan.StartOfPlanning().Date() - 1 ); + traverse ( opt, OfflinePlanRow, opr ) { if ( opr.Type() = "0" ) { productLineCell := productOPC.OfflinePlanCell( relnew, Value := opr.ProductionLine() ); productLineCell.OfflinePlanRow( relset, opr ); @@ -71,9 +74,9 @@ } // 琛ュ叏鎬婚噺鍜岀彮娆� - totalOPRs := selectset( macroPlan, OfflinePlanRow, tempOPR, tempOPR.Type() = "3" ); - shiftOPRs := selectset( macroPlan, OfflinePlanRow, tempOPR, tempOPR.Type() = "4" ); - traverse ( macroPlan, OfflinePlanColumn, opc, opc.OfflinePlanCell( relsize ) > 0 and opc.ColumnDate() >= macroPlan.StartOfPlanning().Date() ) { + totalOPRs := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "3" ); + shiftOPRs := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "4" ); + traverse ( opt, OfflinePlanColumn, opc, opc.OfflinePlanCell( relsize ) > 0 and opc.ColumnDate() >= macroPlan.StartOfPlanning().Date() ) { traverse ( totalOPRs, Elements, totalOPR ) { total := sum( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow().ProductionLine() = totalOPR.ProductionLine() and tempOPC.OfflinePlanRow().Type() = "1", [Real]tempOPC.Value() ); totalCell := opc.OfflinePlanCell( relnew, Value := [String]total ); @@ -93,11 +96,67 @@ indexDate := macroPlan.StartOfPlanning().Date(); endDate := Date::Construct( indexDate.Year(), 12, 31 ); while ( indexDate <= endDate ) { - opc := OfflinePlanColumn::FindOfflinePlanColumnTypeIndex( indexDate ); + opc := select( opt, OfflinePlanColumn, tempOPC, tempOPC.ColumnDate() = indexDate ); if ( isnull( opc ) ) { - opc := macroPlan.OfflinePlanColumn( relnew, ColumnDate := indexDate ); + opc := opt.OfflinePlanColumn( relnew, ColumnDate := indexDate ); } indexDate := indexDate + 1; } + + Transaction::Transaction().PropagateAll(); + + // 璁剧疆鐢熶骇椤哄簭 + productionLines := selectuniquevalues( opt, OfflinePlanRow, tempOPR, true, tempOPR.ProductionLine() ); + traverse ( productionLines, Elements, pl ) { + indexColumn := select( opt, OfflinePlanColumn, tempOPC, tempOPC.ColumnDate() = macroPlan.StartOfPlanning().Date() ); + previousColumn := indexColumn.PreviousColumn(); + nextColumn := indexColumn.NextColumn(); + + while ( not isnull( indexColumn.NextColumn() ) ) { + productionSerialNumber := 1; + opcs := selectsortedset( indexColumn, OfflinePlanCell, tempOPC, tempOPC.FindType( "2", pl ), tempOPC.InventoryWeight() ); + if ( opcs.Size() > 0 ) { + // 鍒ゅ畾1 + previousOPC := maxselect( previousColumn, OfflinePlanCell, tempOPC, tempOPC.FindType( "2", pl ), tempOPC.ProductionSerialNumber() ); + if ( isnull( previousOPC ) or indexColumn.ColumnDate() = macroPlan.StartOfPlanning().Date() ) { + opc := opcs.Element( 0 ); + opc.Value( "#" + productionSerialNumber.Format( "N(LPad0(2))" ) ); + opc.ProductionSerialNumber( productionSerialNumber ); + productionSerialNumber++; + opcs.Remove( opc ); + } else { + opc := select( opcs, Elements, tempOPC, tempOPC.OfflinePlanRow().ProductID() = previousOPC.OfflinePlanRow().ProductID() ); + if ( not isnull( opc ) ) { + opc.Value( "#" + productionSerialNumber.Format( "N(LPad0(2))" ) ); + opc.ProductionSerialNumber( productionSerialNumber ); + productionSerialNumber++; + opcs.Remove( opc ); + } + } + + // 鍒ゅ畾2 + nextOPCs := selectset( opcs, Elements, tempOPC, + exists( nextColumn, OfflinePlanCell, nextOPC, nextOPC.FindType( "2", pl ) and nextOPC.OfflinePlanRow().ProductID() = tempOPC.OfflinePlanRow().ProductID() ) ); + if ( nextOPCs.Size() = 1 ) { + opc := nextOPCs.Element( 0 ); + opc.Value( "#" + opcs.Size().Format( "N(LPad0(2))" ) ); + opc.ProductionSerialNumber( opcs.Size() ); + opcs.Remove( opc ); + } + + // 鍒ゅ畾3 + traverse ( opcs, Elements, opc ) { + opc.Value( "#" + productionSerialNumber.Format( "N(LPad0(2))" ) ); + opc.ProductionSerialNumber( productionSerialNumber ); + productionSerialNumber++; + opcs.Remove( opc ); + } + } + + indexColumn := indexColumn.NextColumn(); + previousColumn := indexColumn.PreviousColumn(); + nextColumn := indexColumn.NextColumn(); + } + } *] } -- Gitblit v1.9.3