lihongji
2024-07-18 28a800b62eb8098f7266081272d21c33f4ffcf1e
_Main/BL/Type_OfflinePlanCell/StaticMethod_RefreshOfflinePlan.qbl
@@ -11,7 +11,7 @@
    opt := macroPlan.OfflinePlanTable( relnew, SaveDateTime := DateTime::ActualTime() );
    
    // 生成下线计划表
    traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() /*and u.Name() = "Spider Assy Line 1"*/ ) {
    traverse ( macroPlan, Unit, u, u.HasCapacityTypeTime() /*and u.Name() = "Body in White Line 1"*/ ) {
      // 创建产线行
      opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "", Type := "0" );
      
@@ -45,6 +45,10 @@
      opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "3" );
      // 创建班次行
      opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "4" );
      // 创建班次开始时间行
      opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "5" );
      // 创建班次结束时间行
      opt.OfflinePlanRow( relnew, ProductionLine := u.ID(), ProductID := "Z", Type := "6" );
    }
    
    // 创建产品列&类型列
@@ -70,12 +74,20 @@
      } else if ( opr.Type() = "4" ) {
        shiftCell := typeOPC.OfflinePlanCell( relnew, Value :=  "班次" );
        shiftCell.OfflinePlanRow( relset, opr );
      } else if ( opr.Type() = "5" ) {
        shiftStartDateCell := typeOPC.OfflinePlanCell( relnew, Value :=  "班次开始时间" );
        shiftStartDateCell.OfflinePlanRow( relset, opr );
      } else if ( opr.Type() = "6" ) {
        shiftEndDateCell := typeOPC.OfflinePlanCell( relnew, Value :=  "班次结束时间" );
        shiftEndDateCell.OfflinePlanRow( relset, opr );
      }
    }
    
    // 补全总量和班次
    totalOPRs := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "3" );
    shiftOPRs := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "4" );
    // 补全总量&班次&班次开始时间&班次结束时间
    totalOPRs          := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "3" );
    shiftOPRs          := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "4" );
    shiftStartDateOPRs := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "5" );
    shiftEndDateOPRs   := selectset( opt, OfflinePlanRow, tempOPR, tempOPR.Type() = "6" );
    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() );
@@ -90,6 +102,24 @@
          shiftCell.OfflinePlanRow( relset, shiftOPR );
        }
      }
      traverse ( shiftStartDateOPRs, Elements, ssdOPR ) {
        shift := select( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow().ProductionLine() = ssdOPR.ProductionLine() and tempOPC.OfflinePlanRow().Type() = "1" );
        if ( not isnull( shift ) ) {
          startDate     := guard( minselect( macroPlan, ShiftPattern.ShiftDay.ShiftDayTime, tempSDT, tempSDT.ShiftDay().ShiftPatternName() = shift.Shift(), tempSDT.Sequence() ).StartDateTime().Format( "H:m" ), "" );
          startDateCell := opc.OfflinePlanCell( relnew, Value := startDate );
          startDateCell.OfflinePlanRow( relset, ssdOPR );
        }
      }
      traverse ( shiftEndDateOPRs, Elements, sedOPR ) {
        shift := select( opc, OfflinePlanCell, tempOPC, tempOPC.OfflinePlanRow().ProductionLine() = sedOPR.ProductionLine() and tempOPC.OfflinePlanRow().Type() = "1" );
        if ( not isnull( shift ) ) {
          endDate     := guard( maxselect( macroPlan, ShiftPattern.ShiftDay.ShiftDayTime, tempSDT, tempSDT.ShiftDay().ShiftPatternName() = shift.Shift(), tempSDT.Sequence() ).EndDateTIme().Format( "H:m" ), "" );
          endDateCell := opc.OfflinePlanCell( relnew, Value := endDate );
          endDateCell.OfflinePlanRow( relset, sedOPR );
        }
      }
    }
    
    // 补全时间列