admin
2024-10-10 2a2008e78e050e8c25d8b40453c962eb15c0ab84
包装计划优化
已修改6个文件
已添加2个文件
177 ■■■■■ 文件已修改
_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanRow/Function_CalcName.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanRow/Method_FilterProduct.qbl 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_dhSelectedFactory_OnCreated.def 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_MatrixEditor493.def 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Response_pHeader_ddslFactorySelection_OnUserSelectionChanged.def 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_PackagingPlanCell/StaticMethod_GenerateReport.qbl
@@ -13,21 +13,23 @@
    planPre     := macroPlan.PackagingPlanColumn( relnew, StartDate := macroPlan.StartOfPlanning().Date() - 1 );
    
    // ç”ŸæˆæŠ¥è¡¨
    traverse ( macroPlan, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() ) {
      // åˆ›å»ºè¡Œ
      ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.StockingPointID() = pisp.StockingPointID() );
      if ( isnull( ppr ) ) {
        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Factory := "大连工厂", Category := "ZKG" );
      }
    traverse ( macroPlan, Product_MP.ProductInStockingPoint_MP, pisp, pisp.IsLeaf() and not pisp.IsSystem() and
               ( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "DL" ) or pisp.StockingPointID().Regex( "大连" ) or pisp.StockingPointID().Regex( "长春" ) ) ) {
      // å½“前pisp所处地点
      factory := ifexpr( pisp.StockingPointID().Regex( "CC" ) or pisp.StockingPointID().Regex( "长春" ), "长春工厂", "大连工厂" );
      
      // åˆ›å»ºè®¡åˆ’前一天格子
      planPreCell      := ppr.PackagingPlanCell( relnew, PackagingPlanColumn := planPre, InitialPackagingInventory := 200 );
      // åˆ›å»ºè¡Œ
      ppr := select( macroPlan, PackagingPlanRow, tempPPR, tempPPR.ProductID() = pisp.ProductID() and tempPPR.Factory() = factory );
      if ( isnull( ppr ) ) {
        ppr := macroPlan.PackagingPlanRow( relnew, ProductID := pisp.ProductID(), StockingPointID := pisp.StockingPointID(), Factory := factory, Category := guard( pisp.Product_MP().ParentID(), "" ) );
      }
      
      // å‡ºå‘地库存点Trip
      originTrips      := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID() = pisp.StockingPointID() );
      // ç›®çš„地库存点Trip
      destinationTrips := selectset( macroPlan, Unit.Lane.LaneLeg.Trip, tempT, tempT.LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID() = pisp.StockingPointID() );
      
      // åˆ›å»ºå•元格
      traverse ( pisp, ProductInStockingPointInPeriodPlanning.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispipl, not pispipl.IsPeriodFrozen() ) {
        // åˆ›å»ºåˆ—
        ppc := select( macroPlan, PackagingPlanColumn, tempPPC, tempPPC.StartDate() = pispipl.Start().Date() );
@@ -38,16 +40,22 @@
        // åˆ›å»ºå•元格
        cell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = ppc );
        if ( isnull( cell ) ) {
          cell := ppr.PackagingPlanCell( relnew, NetDemand := pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity(), EndingInventory := pispipl.InventoryLevelEnd() );
          cell := ppr.PackagingPlanCell( relnew );
          cell.NetDemand( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() );
          cell.EndingInventory( pispipl.InventoryLevelEnd() );
          cell.PackagingPlanColumn( relset, ppc );
        } else {
          cell.NetDemand( cell.NetDemand() + ( pispipl.DependentDemandAndSalesDemandQuantity() - pispipl.NewSupplyQuantity() ) );
          cell.EndingInventory( cell.EndingInventory() + pispipl.InventoryLevelEnd() );
        }
        
        // è®¾ç½®è°ƒå‡º&调进
        // è®¾ç½®è°ƒå‡º
        outs := selectset( originTrips, Elements, tempT, tempT.Departure().Date() = pispipl.Start().Date() );
        traverse ( outs, Elements, out ) {
          cell.Out( cell.Out() + out.Quantity() );
        }
        
        // è®¾ç½®è°ƒè¿›
        transferIns := selectset( destinationTrips, Elements, tempT, tempT.Arrival().Date() = pispipl.Start().Date() );
        traverse ( transferIns, Elements, ti ) {
          cell.TransferIn( cell.TransferIn() + ti.Quantity() );
@@ -55,8 +63,16 @@
        
        // è®¾ç½®å‰ä¸€å¤©åº“å­˜
        if ( pispipl.Start().Date() = macroPlan.StartOfPlanning().Date() ) {
    //      prePISPIPL := pispipl.PreviousPlanningPISPIP().astype( ProductInStockingPointInPeriodPlanningLeaf );
          planPreCell.EndingInventory( 2000 );
          prePISPIPL  := pispipl.PreviousPlanningPISPIP().astype( ProductInStockingPointInPeriodPlanningLeaf ); // å‰ä¸€ä¸ªpispippl
          // åˆ›å»ºè®¡åˆ’前一天格子
          preCell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn() = planPre );
          if ( isnull( preCell ) ) {
            preCell := ppr.PackagingPlanCell( relnew );
            preCell.EndingInventory( prePISPIPL.InventoryLevelEnd() );
            preCell.PackagingPlanColumn( relset, planPre );
          } else {
            preCell.EndingInventory( preCell.EndingInventory() + prePISPIPL.InventoryLevelEnd() );
          }
        }
      }
    }
@@ -66,46 +82,46 @@
    Transaction::Transaction().Propagate( relation( PackagingPlanCell, Next ) );
    
    // è®¾ç½®åŒ…装&拆包-数量
    traverse ( macroPlan, PackagingPlanRow, ppr, ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Bosch" ) or ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Components (Spain)" ) ) {
      traverse ( ppr, PackagingPlanCell, ppc/*, ppc.StartDate() = Date::Construct( 2020, 4, 1 )*/ ) {
        // è®¾ç½®åŒ…装数量
        if ( ppc.PackagingInventory() < ppc.Out() ) { // åŒ…装库存是否小于调出
          prePPC                := ppc.Previous();
          needPackagingQuantity := ppc.Out() - prePPC.PackagingInventory();
          while ( not isnull( prePPC ) and needPackagingQuantity > 0.0 ) {
            // èŽ·å–åŒ…è£…lotsize
            ppls                   := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() =  ppc.PackagingPlanRow().Factory()    and
                                                                                        tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() );
            // èŽ·å–æœ€å¤§åŒ…è£…æ•°é‡
            maxPackageReflection   := Reflection::FindAttribute( "PackagingPlanCapability", ppc.PackagingPlanRow().FactoryAbbreviation() + "_" + ppc.PackagingPlanRow().Category() + "_Package" );
    //        maxPackageQuantity     := maxPackageReflection.GetNumber( macroPlan.PackagingPlanCapability() ); // æ­¤å¤„需要修改
            maxPackageQuantity     := 100000;
            // èŽ·å–æœ€ç»ˆåŒ…è£…æ•°é‡
            finalPackagingQuantity := minvalue( ceil( needPackagingQuantity / ppls.LotSize() ), ceil( ( maxPackageQuantity - prePPC.Package() ) / ppls.LotSize() ) ) * ppls.LotSize();
            needPackagingQuantity  := needPackagingQuantity - finalPackagingQuantity;
            // è®¾ç½®åŒ…装值
            prePPC.Package( prePPC.Package() + finalPackagingQuantity );
            //debuginfo( "需要包装数量:", needPackagingQuantity, "    lotsize: ", ppls.LotSize(), "    æœ€å¤§åŒ…装数量:", maxPackageQuantity, "    æœ€ç»ˆè¡¥çš„æ•°é‡ï¼š", finalPackagingQuantity );
            PackagingPlanCell::CalculationPackagingPlanProperties();
            prePPC := prePPC.Previous();
          }
        }
        // è®¾ç½®æ‹†åŒ…数量
        if ( ppc.TransferIn() > 0.0 ) { // æœ‰è°ƒå…¥æ•°é‡
          // èŽ·å–åŒ…è£…lotsize
          ppls                 := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() =  ppc.PackagingPlanRow().Factory()    and
                                                                                     tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() );
          // è®¾ç½®æ‹†åŒ…值
          ppc.Unpacking( ppc.TransferIn() );
        }
      }
    }
    //traverse ( macroPlan, PackagingPlanRow, ppr, ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Bosch" ) or ( ppr.ProductID() = "Windshield" and ppr.StockingPointID() = "Components (Spain)" ) ) {
    //  traverse ( ppr, PackagingPlanCell, ppc/*, ppc.StartDate() = Date::Construct( 2020, 4, 1 )*/ ) {
    //    // è®¾ç½®åŒ…装数量
    //    if ( ppc.PackagingInventory() < ppc.Out() ) { // åŒ…装库存是否小于调出
    //      prePPC                := ppc.Previous();
    //      needPackagingQuantity := ppc.Out() - prePPC.PackagingInventory();
    //      while ( not isnull( prePPC ) and needPackagingQuantity > 0.0 ) {
    //        // èŽ·å–åŒ…è£…lotsize
    //        ppls                   := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() =  ppc.PackagingPlanRow().Factory()    and
    //                                                                                    tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() );
    //
    //        // èŽ·å–æœ€å¤§åŒ…è£…æ•°é‡
    //        maxPackageReflection   := Reflection::FindAttribute( "PackagingPlanCapability", ppc.PackagingPlanRow().FactoryAbbreviation() + "_" + ppc.PackagingPlanRow().Category() + "_Package" );
    ////        maxPackageQuantity     := maxPackageReflection.GetNumber( macroPlan.PackagingPlanCapability() ); // æ­¤å¤„需要修改
    //        maxPackageQuantity     := 100000;
    //
    //        // èŽ·å–æœ€ç»ˆåŒ…è£…æ•°é‡
    //        finalPackagingQuantity := minvalue( ceil( needPackagingQuantity / ppls.LotSize() ), ceil( ( maxPackageQuantity - prePPC.Package() ) / ppls.LotSize() ) ) * ppls.LotSize();
    //        needPackagingQuantity  := needPackagingQuantity - finalPackagingQuantity;
    //
    //        // è®¾ç½®åŒ…装值
    //        prePPC.Package( prePPC.Package() + finalPackagingQuantity );
    //
    //        //debuginfo( "需要包装数量:", needPackagingQuantity, "    lotsize: ", ppls.LotSize(), "    æœ€å¤§åŒ…装数量:", maxPackageQuantity, "    æœ€ç»ˆè¡¥çš„æ•°é‡ï¼š", finalPackagingQuantity );
    //        PackagingPlanCell::CalculationPackagingPlanProperties();
    //
    //        prePPC := prePPC.Previous();
    //      }
    //    }
    //
    //    // è®¾ç½®æ‹†åŒ…数量
    //    if ( ppc.TransferIn() > 0.0 ) { // æœ‰è°ƒå…¥æ•°é‡
    //      // èŽ·å–åŒ…è£…lotsize
    //      ppls                 := select( macroPlan, PackagingPlanLotSize, tempPPLS, tempPPLS.Factory() =  ppc.PackagingPlanRow().Factory()    and
    //                                                                                 tempPPLS.ProductID() = ppc.PackagingPlanRow().ProductID() );
    //
    //      // è®¾ç½®æ‹†åŒ…值
    //      ppc.Unpacking( ppc.TransferIn() );
    //    }
    //  }
    //}
  *]
}
_Main/BL/Type_PackagingPlanRow/Function_CalcName.qbl
@@ -6,7 +6,7 @@
  [*
    // lihongji Jul-24-2024 (created)
    
    value := guard( this.ProductID() + " in " + this.StockingPointID(), this.ProductID() );
    value := guard( this.ProductID(), "" );
    
    this.Name( value );
  *]
_Main/BL/Type_PackagingPlanRow/Method_FilterProduct.qbl
@@ -1,12 +1,13 @@
Quintiq file version 2.0
#parent: #root
Method FilterProduct (
  Product_MPs products
  Product_MPs products,
  String factory
) declarative remote as Boolean
{
  TextBody:
  [*
    flag := exists( products, Elements, tempP, tempP.ID() = this.ProductID() );
    flag := exists( products, Elements, tempP, tempP.ID() = this.ProductID() ) and this.Factory() = factory;
    
    return flag;
  *]
_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/Response_MacroPlanner_dhSelectedFactory_OnCreated.def
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
Quintiq file version 2.0
#parent: dhSelectedFactory
Response OnCreated () id:Response_MacroPlanner_ApplicationMacroPlanner_dhSelectedFactory_OnCreated
{
  #keys: '[415754.0.350439844]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebComponent_OnCreated'
  QuillAction
  {
    Body:
    [*
      this.Data( "大连工厂" );
    *]
    GroupServerCalls: false
  }
}
_Main/UI/MacroPlannerWebApp/Component_ApplicationMacroPlanner/_ROOT_Component_ApplicationMacroPlanner.def
@@ -212,5 +212,16 @@
        Taborder: 58
      ]
    }
    Component dhSelectedFactory
    {
      #keys: '[415754.0.350439827]'
      BaseType: 'WebDataHolder'
      Databinding: 'String*'
      Properties:
      [
        Description: '包装计划所选工厂'
        Taborder: 59
      ]
    }
  ]
}
_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_MatrixEditor493.def
@@ -45,8 +45,8 @@
          Properties:
          [
            DataType: 'MacroPlan'
            FilterArguments: 'products:QLibMacroPlannerWebUI::ApplicationMacroPlanner.DataHolderCheckedProduct'
            FixedFilter: 'object.FilterProduct( products )'
            FilterArguments: 'products:QLibMacroPlannerWebUI::ApplicationMacroPlanner.DataHolderCheckedProduct;factory:QLibMacroPlannerWebUI::ApplicationMacroPlanner.dhSelectedFactory'
            FixedFilter: 'object.FilterProduct( products, factory )'
            Source: 'MacroPlan'
            Taborder: 0
            Transformation: 'PackagingPlanRow'
_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Component_pHeader.def
@@ -61,6 +61,7 @@
      BaseType: 'WebDropDownStringList'
      Properties:
      [
        InitialValue: '大连工厂'
        Label: '工厂'
        Sorting: 'none'
        Strings: '大连工厂;长春工厂'
_Main/UI/MacroPlannerWebApp/Component_FormPackagingPlan/Response_pHeader_ddslFactorySelection_OnUserSelectionChanged.def
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
Quintiq file version 2.0
#parent: pHeader/ddslFactorySelection
Response OnUserSelectionChanged () id:Response_pHeader_ddslFactorySelection_OnUserSelectionChanged
{
  #keys: '[415754.0.350720104]'
  CanBindMultiple: false
  DefinitionID: 'Responsedef_WebDropDownStringList_OnUserSelectionChanged'
  QuillAction
  {
    Body:
    [*
      dhSelectedFactory.Data( this.Text() );
    *]
    GroupServerCalls: false
  }
}