lazhen
2024-10-09 ed070d695972cadcf9b6bbfe9e779aa5a0850125
_Main/BL/Type_CCEngineLogisticsCostReport/StaticMethod_Initialize.qbl
@@ -13,7 +13,7 @@
    allunit                   := CCEngineLogisticsCostReport::GetDefaultAllUnit();
    ccfactory                 := CCEngineLogisticsCostReport::GetCCFactory();
    ccunit                    := CCEngineLogisticsCostReport::GetDefaultCCUnit();
    ccline                    := CCEngineLogisticsCostReport::GetStockingPointCCLine();
    //ccline                    := CCEngineLogisticsCostReport::GetStockingPointCCLine();
    ccrent                    := CCEngineLogisticsCostReport::GetStockingPointCCRent();
    
    startofplanning           := owner.StartOfPlanning().Date();
@@ -30,23 +30,23 @@
    //外租库入库费用:取自财务产量报表的产量,在产品表根据发动机号找到对应的Generation 和横纵制,在发动机成本参数表里找到对应的包装容量和入库单价,用公式计算,月度进行汇总
    traverse( owner, FinancialProductionSource, source, not source.IsImport() ){//财务产量报表非导入
      traverse( source, FinancialProductionReport, report, not report.IsShow() ){//财务产量报表不显示
        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ) ){//财务产量报表里的长春产量, 不为0
        traverse( report, FinancialProductionRow, row, row.Unit() = ccunit and exists( row, FinancialProductionCell, cell, cell.Value() <> '0' and not cell.FinancialProductionColumn().IsDay() ) ){//财务产量报表里的长春产量, 不为0
          product             := row.Product_MP();
          productparents      := product.GetAllParent();
          if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//查询产品类型是发动机
            //查询对应的发动机成本
            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower()
            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccfactory );//ccunit
            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
              ccrow           := table.GetRow( row.Name() );
              products.Add( product );
              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' and cell.FinancialProductionColumn().IsDay() ){
              traverse( row, FinancialProductionCell, cell, cell.Value() <> '0' and not cell.FinancialProductionColumn().IsDay() ){
                cellcolumn    := cell.FinancialProductionColumn();
                enginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
                if( not isnull( enginecost ) ){
                  //入库量/包装容量*入库单价,入库量等于长春产量
                  quantity          := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                  quantity          := ceil( cell.Quantity() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                  column            := selectobject( table, Column, column, column.Name() = cell.FinancialProductionColumn().Name() );
                  //外租库入库费用 
                  ccrow.SetRentEnterCost( column, quantity );
@@ -60,23 +60,23 @@
    //外租库出库费用:出库量等于长春销量,取自财务销量报表的销量,在产品表根据发动机号找到对应的Generation 和横纵制,在发动机成本参数表里找到对应的包装容量和出库单价,用公式计算,月度进行汇总
    traverse( owner, FinancialSalesSource, source, not source.IsImport() ){//财务销量报表非导入
      traverse( source, FinancialSalesReport, report, not report.IsShow() ){//财务销量报表不显示
        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ) ){//财务销量报表里的长春产量, 不为0
        traverse( report, FinancialSalesRow, row, row.Unit() = ccunit and exists( row, FinancialSalesCell, cell, cell.Value() <> '0' and not cell.FinancialSalesColumn().IsDay() ) ){//财务销量报表里的长春产量, 不为0
          product             := row.Product_MP();
          productparents      := product.GetAllParent();
          if( exists( productparents, Elements, e, e.ID() = produtparent ) ){//查询产品类型是发动机
            //查询对应的发动机成本
            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower()
            enginecosts       := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccfactory );
            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){
              ccrow           := table.GetRow( row.Name() );
              products.Add( product );
              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' and cell.FinancialSalesColumn().IsDay() ){
              traverse( row, FinancialSalesCell, cell, cell.Value() <> '0' and not cell.FinancialSalesColumn().IsDay() ){
                cellcolumn    := cell.FinancialSalesColumn();
                enginecost    := selectobject( enginecosts, Elements, engine, engine.StartDate() <= cellcolumn.Period() and engine.EndDate() >= cellcolumn.Period() );
                if( not isnull( enginecost ) ){
                  //出库量/包装容量*出库单价,入库量等于长春销量
                  quantity    := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.WarehousingPrice();
                  quantity    := ceil( [Number]cell.Value() / enginecost.PackagingCapacity() ) * enginecost.OutboundPrice();
                  column      := selectobject( table, Column, column, column.Name() = cell.FinancialSalesColumn().Name() );
                  //外租库出库费用
                  ccrow.SetRentOutCost( column, quantity );
@@ -91,7 +91,7 @@
    traverse( owner, Unit.Lane.LaneLeg, laneleg ){
      //起始库存点是否是长春装配线边库
      originsp               := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.OriginStockingPointID() );
      isccspline             := table.IsInUnit( originsp, ccline );
      isccspline             := table.IsInUnit( originsp, 'CC 厂内库' );
      //目的地是否是长春外租库
      destisp                := selectobject( owner, StockingPoint_MP, sp, sp.ID() = laneleg.DestinationStockingPointID() );
      isccrent               := table.IsInUnit( destisp, ccrent );
@@ -101,8 +101,8 @@
          periodname         := periodtime.Format( "M2/D2/Y" );
          
          column             := selectobject( table, Column, column, column.Name() = periodname and column.StartDate() = periodtime );
          enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.StartDate() <= trip.Arrival().Date() and engine.EndDate() >= trip.Arrival().Date() );
          transcosts         := selectset( owner, LogisticsCostTransport, trans, trans.StartDate() <= trip.Arrival().Date() and trans.EndDate() >= trip.Arrival().Date() );
          enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.StartDate() <= trip.Arrival().Date() and engine.EndDate() >= trip.Arrival().Date() );
          transcosts         := selectset( owner, LogisticsCostTransport, trans, trans.LoadingCapacity() <> 0 and trans.StartDate() <= trip.Arrival().Date() and trans.EndDate() >= trip.Arrival().Date() );
          if( not isnull( enginecosts ) and enginecosts.Size() > 0 and not isnull( transcosts ) and transcosts.Size() > 0 ){
            traverse( trip, ProductInTrip, pit, pit.Quantity() <> 0 ){
              product          := pit.Product_MP();
@@ -113,7 +113,7 @@
                                                   and engine.MLB_MQB() = product.MQBMLB()
                                                   and engine.Factory() = ccfactory );
                //在运输成本参数表里找到发动机对应运输单价和装载容量
                transcost      := selectobject( transcosts, Elements, trans, trans.Origin() = ccline
                transcost      := selectobject( transcosts, Elements, trans, trans.Origin() = 'CC 厂内库'
                                                  and trans.Destination() = ccrent 
                                                  and exists( productparents, Elements, e, ifexpr( trans.Product().FindString( '发动机', 0 ) >= 0, e.ID() = produtparent,  e.ID() = trans.Product() ) ) );
                if( not isnull( enginecost ) and not isnull( transcost ) ){
@@ -142,7 +142,7 @@
          productparents       := product.GetAllParent();
          if( exists( productparents, Elements, e, e.ID() = produtparent ) ){////查询产品类型是发动机
            //查询对应的发动机成本
            enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.Generation().ToLower() = product.Generation().ToLower()
            enginecosts        := selectset( owner, LogisticsCostEngine, engine, engine.PackagingCapacity() <> 0 and engine.Generation().ToLower() = product.Generation().ToLower()
                                                 and engine.MLB_MQB() = product.MQBMLB()
                                                 and engine.Factory() = ccfactory );
            if( not isnull( enginecosts ) and enginecosts.Size() > 0 ){