Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod RefreshData ( 
 | 
  MacroPlan macroPlan, 
 | 
  NewOfflinePlanTable nopt 
 | 
) 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    macroPlan.NewAssemblyOnlinePlanRow( relflush ); 
 | 
    macroPlan.NewAssemblyOnlinePlanColumn( relflush ); 
 | 
     
 | 
    aopplns := macroPlan.A_AssemblyOnlinePlanProductionLineName().Tokenize( ";" ); 
 | 
     
 | 
    traverse ( nopt, NewOfflinePlanRow, nopr, exists( aopplns, Elements, aoppl, aoppl = nopr.ProductionLine() ) and nopr.Type() = "1" ) { 
 | 
      // 上线计划合计行 
 | 
      totalNAOPR   := select( macroPlan, NewAssemblyOnlinePlanRow, tempNAOPR, tempNAOPR.ProductID() = "All" and tempNAOPR.ProductionLine() = nopr.ProductionLine() and tempNAOPR.Type() = "2" ); 
 | 
      if ( isnull( totalNAOPR ) ) { 
 | 
        totalNAOPR := macroPlan.NewAssemblyOnlinePlanRow( relnew, ProductID := "All", ProductionLine := nopr.ProductionLine(), Type := "2" ); 
 | 
      } 
 | 
      // 上线计划详细行 
 | 
      detailNAOPR   := select( macroPlan, NewAssemblyOnlinePlanRow, tempNAOPR, tempNAOPR.ProductID() = nopr.ProductID() and tempNAOPR.ProductionLine() = nopr.ProductionLine() and tempNAOPR.Type() = "1" ); 
 | 
      if ( isnull( detailNAOPR ) ) { 
 | 
        detailNAOPR := macroPlan.NewAssemblyOnlinePlanRow( relnew, OperationID := nopr.OperationID(), ProductID := nopr.ProductID(), ProductionLine := nopr.ProductionLine(), Type := "1" ); 
 | 
      } 
 | 
       
 | 
      // 创建单元格 
 | 
      traverse ( nopr, NewOfflinePlanCell, nopcell ) { 
 | 
        // 上线计划列 
 | 
        naopc   := select( macroPlan, NewAssemblyOnlinePlanColumn, tempNAOPC, tempNAOPC.StartDate() = nopcell.NewOfflinePlanColumn().StartDate() and tempNAOPC.EndDate() = nopcell.NewOfflinePlanColumn().EndDate() ); 
 | 
        if ( isnull( naopc ) ) { 
 | 
          naopc := macroPlan.NewAssemblyOnlinePlanColumn( relnew, StartDate := nopcell.NewOfflinePlanColumn().StartDate(), EndDate := nopcell.NewOfflinePlanColumn().EndDate() ); 
 | 
        } 
 | 
         
 | 
        // 设置上线计划合计单元格 
 | 
        totalNAOPCell   := select( totalNAOPR, NewAssemblyOnlinePlanCell, tempNAOPCell, tempNAOPCell.NewAssemblyOnlinePlanColumn() = naopc ); 
 | 
        if ( isnull( totalNAOPCell ) ) { 
 | 
          totalNAOPCell := totalNAOPR.NewAssemblyOnlinePlanCell( relnew, ShiftPatternName := nopcell.Total().ShiftPatternName(), ShiftPatternStart := nopcell.Total().ShiftPatternStart(), 
 | 
                                                                 ShiftPatternEnd := nopcell.Total().ShiftPatternEnd() ); 
 | 
          totalNAOPCell.NewAssemblyOnlinePlanColumn( relset, naopc ); 
 | 
        } 
 | 
         
 | 
        // 设置上线计划详细单元格 
 | 
        detailNAOPCell   := select( detailNAOPR, NewAssemblyOnlinePlanCell, tempNAOPCell, tempNAOPCell.NewAssemblyOnlinePlanColumn() = naopc ); 
 | 
        if ( isnull( detailNAOPCell ) ) { 
 | 
          detailNAOPCell := detailNAOPR.NewAssemblyOnlinePlanCell( relnew, InventoryWeight := nopcell.InventoryWeight(), Order := nopcell.Order(), OrderNr := nopcell.OrderNr(), Quantity := nopcell.Quantity(), 
 | 
                                                                   ShiftPatternEnd := nopcell.ShiftPatternEnd(), ShiftPatternName := nopcell.ShiftPatternName(), ShiftPatternStart := nopcell.ShiftPatternStart() ); 
 | 
          detailNAOPCell.NewAssemblyOnlinePlanColumn( relset, naopc ); 
 | 
        } 
 | 
         
 | 
        // 设置合计单元格的详细单元格 
 | 
        totalNAOPCell.Detailed( relinsert, detailNAOPCell ); 
 | 
      } 
 | 
    } 
 | 
     
 | 
    // 处理日历事件 
 | 
    pls := selectuniquevalues( macroPlan, NewAssemblyOnlinePlanRow, tempNAOPR, true, tempNAOPR.ProductionLine() ); 
 | 
    traverse ( pls, Elements, pl ) { 
 | 
      targetQuantity := ifexpr( pl = "CC MoMo", guard( macroPlan.AssemblyOnlineQuantity().CCMoMo(), 0 ), 
 | 
                                ifexpr( pl = "DL MoMo", guard( macroPlan.AssemblyOnlineQuantity().DLMoMo(), 0 ), guard( macroPlan.AssemblyOnlineQuantity().DLZKM(), 0 ) ) 
 | 
                               ); 
 | 
       
 | 
      u           := select( macroPlan, Unit, tempU, tempU.ID() = pl ); 
 | 
      drainPs     := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "拉空" ) or tempP.Event().Subject().Regex( "排空" ), false ) ); 
 | 
      lineLyingPs := selectset( u, UnitCalendar.Participation, tempP, guard( tempP.Event().Subject().Regex( "铺线" ), false ) ); 
 | 
       
 | 
      // 处理拉空 
 | 
    //  info( "当前产线:", pl, "    处理拉空--------------------------" ); 
 | 
      traverse ( drainPs, Elements, p ) { 
 | 
        traverse ( p, ExplicitTimeInterval, eti ) { 
 | 
          // 设置单元格为拉空 
 | 
          NewAssemblyOnlinePlanCell::SetLineLayingOrEmptyingStatus( macroPlan, eti.Start().Date(), "拉空", pl ); 
 | 
           
 | 
    //      info( "开始时间:", eti.Start().Format( "Y-M2-D2" ), "    结束时间:", eti.End().Format( "Y-M2-D2" ) ); 
 | 
          naopc := select( macroPlan, NewAssemblyOnlinePlanColumn, tempNAOPC, tempNAOPC.StartDate() = ( eti.Start().Date() - 1 ) ); 
 | 
           
 | 
          cell  := maxselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell,  
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl    and  
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanColumn()               = naopc and 
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1"   and 
 | 
                              tempNAOPCell.Quantity()                                  > 0, 
 | 
                              tempNAOPCell.OrderNr() );  
 | 
          while ( isnull( cell ) and not isnull( naopc ) ){ 
 | 
            naopc := naopc.PreviousNAOPColumn(); 
 | 
             
 | 
            cell  := maxselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell,  
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl    and  
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanColumn()               = naopc and 
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1"   and 
 | 
                              tempNAOPCell.Quantity()                                  > 0, 
 | 
                              tempNAOPCell.OrderNr() ); 
 | 
          } 
 | 
          if ( not isnull( cell ) ) { 
 | 
            cell.Quantity( cell.Quantity() - targetQuantity ); 
 | 
          } 
 | 
        } 
 | 
      } 
 | 
       
 | 
      info( "当前产线:", pl, "    处理铺线--------------------------" ); 
 | 
      // 处理铺线 
 | 
      traverse ( lineLyingPs, Elements, p ) { 
 | 
        traverse ( p, ExplicitTimeInterval, eti ) { 
 | 
          // 设置单元格为拉空 
 | 
          NewAssemblyOnlinePlanCell::SetLineLayingOrEmptyingStatus( macroPlan, eti.Start().Date(), "铺线", pl ); 
 | 
           
 | 
          info( "开始时间:", eti.Start().Format( "Y-M2-D2" ), "    结束时间:", eti.End().Format( "Y-M2-D2" ) ); 
 | 
           
 | 
          cell  := minselect( macroPlan, NewAssemblyOnlinePlanRow.NewAssemblyOnlinePlanCell, tempNAOPCell,  
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanRow().ProductionLine() = pl                 and  
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanColumn().StartDate()   = eti.Start().Date() and 
 | 
                              tempNAOPCell.NewAssemblyOnlinePlanRow().Type()           = "1"                and 
 | 
                              tempNAOPCell.OrderNr()                                   > 0, 
 | 
                              tempNAOPCell.OrderNr() ); 
 | 
          if ( not isnull( cell ) ) { 
 | 
            cell.Quantity( cell.Quantity() + targetQuantity ); 
 | 
          } 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
     
 | 
    // 处理铺线后续处理 
 | 
    info( "处理铺线后续处理-----------------------------" ); 
 | 
    NewAssemblyOnlinePlanCell::PostLayingProcessing( macroPlan ); 
 | 
  *] 
 | 
} 
 |