admin
2024-10-17 c34ffd86b7001f7ea39aa33f8c938a2c1b5a22ac
机加物流成本优化
已添加1个文件
已修改1个文件
85 ■■■■■ 文件已修改
_Main/BL/Type_MachineLogisticsCostReportCell/Attribute_WoodenCratePriceReal.qbl 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MachineLogisticsCostReportCell/Attribute_WoodenCratePriceReal.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
Quintiq file version 2.0
#parent: #root
Attribute WoodenCratePriceReal
{
  #keys: '3[415754.0.434001070][415754.0.434001069][415754.0.434001071]'
  Description: '木箱单价(Real)'
  ValueType: Real
}
_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
@@ -10,72 +10,77 @@
    macroPlan.MachineLogisticsCostReportRow( relflush );
    macroPlan.MachineLogisticsCostReportColumn( relflush );
    
    // åˆå§‹åŒ–一年数据列
    // åˆ›å»ºè¡Œ
    categories := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.IsLeaf()                           and
                                      exists( tempPMP, AllParent.AsParent, tempPMP1, tempPMP1.ID() = "机加件" ),
                                      tempPMP.ParentID() );
    traverse ( categories, Elements, c ) {
      macroPlan.MachineLogisticsCostReportRow( relnew, Factory := "大连工厂", Category := c  );
      macroPlan.MachineLogisticsCostReportRow( relnew, Factory := "长春工厂", Category := c );
    }
    // åˆ›å»ºåˆ—
    indexDate := macroPlan.StartOfPlanning().Date().StartOfMonth();
    for ( i := 0; i < 12; i++ ) {
      macroPlan.MachineLogisticsCostReportColumn( relnew, StartDate := indexDate );
      indexDate := indexDate.StartOfNextMonth();
    }
    
    // æ‰¾å‡ºæ‰€æœ‰å¤§ç±»ï¼Œåˆ›å»ºæ•°æ®
    categories := selectuniquevalues( macroPlan, PackagingPlanRow, tempPPR, true, tempPPR.Category() );
    traverse ( categories, Elements, c ) {
    // åˆ›å»ºå•元格
    traverse ( macroPlan, MachineLogisticsCostReportRow, mlcrr ) { // å¾ªçŽ¯è¡Œ
      info( "当前遍历的行:", mlcrr.Factory(), " ", mlcrr.Category() );
      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) { // å¾ªçŽ¯åˆ—
      
      // æœºåŠ æˆæœ¬å‚æ•°
      lcm := select( macroPlan, LogisticsCostMachining, tempLCM, tempLCM.Factory() = factory and tempLCM.Product() = c );
      // è¿è¾“成本参数
      lct := select( macroPlan, LogisticsCostTransport, tempLCT, tempLCT.Origin()      = ifexpr( factory = "大连工厂", "CC", "DL" ) and
                                                                 tempLCT.Destination() = ifexpr( factory = "大连工厂", "DL", "CC" ) and
                                                                 tempLCT.Product()     = c );
      // åˆå§‹åŒ–机加成本参数报表行
      mlcrr := macroPlan.MachineLogisticsCostReportRow( relnew, Category := c, Factory := factory );
      // å¾ªçŽ¯æ‰€æœ‰æ—¶é—´åˆ—åˆ›å»ºæ•°æ®
      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) {
        cell := mlcrr.MachineLogisticsCostReportCell( relnew );
        // æœºåŠ æˆæœ¬å‚æ•°
        lcm  := select( macroPlan, LogisticsCostMachining, tempLCM, tempLCM.Factory() = mlcrr.Factory() and tempLCM.Product() = mlcrr.Category()
                        and tempLCM.StartDate() <= mlcrc.StartDate() and tempLCM.EndDate() >= mlcrc.StartDate().StartOfNextMonth() );
        
        // è¿è¾“成本参数
        // å½“前月末最后一天日期
        lastDayOfThisMonth := mlcrc.StartDate().StartOfNextMonth() - 1;
        cell := mlcrr.MachineLogisticsCostReportCell( relnew );
        // è®¾ç½®åŒ…装费用(包装量 * åŒ…装单价)
        packageQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
                                tempPPC.PackagingPlanRow().Category()             = c                         and
                                tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          and
                                tempPPC.PackagingPlanRow().Factory()              = factory                   and
                                tempPPC.PackagingPlanColumn().StartDate().Year()  = mlcrc.StartDate().Year()  and
                                tempPPC.PackagingPlanColumn().StartDate().Month() = mlcrc.StartDate().Month(),
                                tempPPC.Package() );
    //    cell.PackingCharges( packageQuantity * guard( lcm.PackagePrice(), 1 ) );
        cell.PackingCharges( packageQuantity * guard( lcm.PackagePrice(), 1 ) );
        // è®¾ç½®æ‹†åŒ…费用(拆包量 * æ‹†åŒ…单价)
        unpackingQuantity := sum( macroPlan, PackagingPlanRow.PackagingPlanCell, tempPPC, 
                                  tempPPC.PackagingPlanRow().Category()             = c                         and
                                  tempPPC.PackagingPlanRow().Category()             = mlcrr.Category()          and
                                  tempPPC.PackagingPlanRow().Factory()              = factory                   and
                                  tempPPC.PackagingPlanColumn().StartDate().Year()  = mlcrc.StartDate().Year()  and
                                  tempPPC.PackagingPlanColumn().StartDate().Month() = mlcrc.StartDate().Month(),
                                  tempPPC.Unpacking() );
    //    cell.UnpackingCost( unpackingQuantity * guard( lcm.UnpackingPrice(), 1 ) );
        cell.UnpackingCost( unpackingQuantity * guard( lcm.UnpackingPrice(), 1 ) );
        // è®¾ç½®ç¼“冲纸费用(包装类 * ç¼“冲纸单价)
    //    cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
        // è®¾ç½®æœ¨ç®±å•ä»·
    //    cell.UnitPriceOfWoodenCrate( guard( lcm.WoodenCratePrice(), 1 ) );
        cell.BufferPaperCost( packageQuantity * guard( lcm.BufferPaperPrice(), 1 ) );
          // è®¾ç½®æœ¨ç®±å•ä»·
        cell.WoodenCratePriceReal( guard( lcm.WoodenCratePrice(), 1 ) );
        // è®¾ç½®è°ƒæ‹¨è´¹ç”¨ï¼ˆè°ƒæ‹¨æ•°é‡ / åŒ…装容量 / è£…载容量 * è¿è¾“单价)
        transferQuantity := sum( macroPlan, TransferPlanRow.TransferPlanCell, tempTPC,
                                 tempTPC.TransferPlanRow().Category()              = c                                                      and
                                 tempTPC.TransferPlanRow().Category()              = mlcrr.Category()                                       and
                                 tempTPC.TransferPlanRow().Name()                  = ifexpr( factory = "大连工厂", "CC to DL", "DL to CC" ) and
                                 tempTPC.TransferPlanColumn().ColumnDate().Year()  = mlcrc.StartDate().Year()                               and
                                 tempTPC.TransferPlanColumn().ColumnDate().Month() = mlcrc.StartDate().Month(),
                                 [Number]tempTPC.Value() );
    //    cell.TransferCost( transferQuantity / guard( lcm.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) );
        // å¤–租库入库费用(入库量[包装量] / åŒ…装容量 * å…¥åº“单价)
    //    cell.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );
      //  cell.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );
        // å¤–租库出库费用(出库量[拆包量] / åŒ…装容量 * å‡ºåº“单价)
    //    cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
      //  cell.OutboundExpensesForRentedWarehouses( unpackingQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.OutboundPrice(), 1 ) );
        // å¤–租库运输费用(运输数量 / åŒ…装容量 / è£…载容量 * è¿è¾“单价)
        
        cell.MachineLogisticsCostReportColumn( relset, mlcrc );