admin
2024-10-19 9e75417aab6ab66f28a2e1bc93c7e4b412b40990
_Main/BL/Type_CC_EngineRackCell/StaticMethod_CreateData.qbl
@@ -9,15 +9,6 @@
    macroPlan.CC_EngineRackRow( relflush );
    macroPlan.CC_EngineRackColumn( relflush );
    
    sumNumberOfEmptyShelves                       := 0.0;
    sumStorageFeesForRentedWarehouses             := 0.0;
    sumOutboundExpensesForRentedWarehouses        := 0.0;
    sumExternalRentalWarehouseTransportationCosts := 0.0;
    sumRentalWarehouseStorageFees                 := 0.0;
    sumCleaningCost                               := 0.0;
    sumEstimatedTotalCost                         := 0.0;
    sumTotalCost                                  := 0.0;
    // 创建行
    genrations := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.Generation().TrimBoth() <> "", tempPMP.Generation() );
    mqbmlbs    := selectuniquevalues( macroPlan, Product_MP, tempPMP, tempPMP.MQBMLB().TrimBoth() <> "", tempPMP.MQBMLB() );
@@ -67,7 +58,6 @@
        cell.PackagingCapacity( guard( lce.PackagingCapacity(), 1 ) );
        cell.PlannedInventory( plannedInventory );
        cell.NumberOfEmptyShelves( guard( [Number] ( cell.TotalQuantityOfMaterialRacks() - ( plannedInventory / lce.PackagingCapacity() ) ), 0 ) );
        sumNumberOfEmptyShelves := sumNumberOfEmptyShelves + cell.NumberOfEmptyShelves();
        
        // 外租库入库费用(发动机销量 / 包装容量[向上取整] * 料架入库单价)
        engineSales := sum( macroPlan, FSImportData, tempFSID, 
@@ -78,7 +68,6 @@
                            tempFSID.StartDate().Month() = ccerc.StartDate().Month(),
                            tempFSID.Quantity() );
        cell.StorageFeesForRentedWarehouses( [Number] ( engineSales / guard( lce.PackagingCapacity(), 1 ) * guard( lcmr.WarehousingPrice(), 1 ) ) );
        sumStorageFeesForRentedWarehouses := sumStorageFeesForRentedWarehouses + cell.StorageFeesForRentedWarehouses();
             
        // 外租库出库费用(发动机产量 / 包装容量[向上取整] * 料架出库单价)
        engineProductions := sum( macroPlan, FPImportData, tempFPID, 
@@ -88,8 +77,7 @@
                                  tempFPID.StartDate().Year()  = ccerc.StartDate().Year()                      and
                                  tempFPID.StartDate().Month() = ccerc.StartDate().Month(),
                                  tempFPID.Quantity() );
        cell.OutboundExpensesForRentedWarehouses( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) ) * guard( lcmr.OutboundPrice(), 1 ) );
        sumOutboundExpensesForRentedWarehouses := sumOutboundExpensesForRentedWarehouses + cell.OutboundExpensesForRentedWarehouses();
        cell.OutboundExpensesForRentedWarehouses( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) * guard( lcmr.OutboundPrice(), 1 ) ) );
        
        // 外租库运输费用:发动机运输量 / 包装容量 / 装载容量(向上取整) * 料架运输单价
        transportationQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
@@ -103,16 +91,13 @@
                                      );
    //    info( "时间:", ccerc.StartDate().Format( "Y-M2-D2" ), "    运输数据:", transportationQuantity, "     运输单价:", lct.TransportPrice() );
        cell.ExternalRentalWarehouseTransportationCosts( [Number] ( transportationQuantity / guard( lce.PackagingCapacity(), 1 ) / guard( lct.LoadingCapacity(), 1 ) * guard( lct.TransportPrice(), 1 ) ) );
        sumExternalRentalWarehouseTransportationCosts := sumExternalRentalWarehouseTransportationCosts + cell.ExternalRentalWarehouseTransportationCosts();
             
        // 外租库仓储费用:料架总数量 - 发动机库存 / 包装容量(向上取整),再乘以空料架仓储单价得到空料架仓储费用。发动机库存取Actual inventories里取到长春外租库该发动机的仓储量,料架总数量需要手动维护。
        cell.UnitPriceOfEmptyShelfStorage( lcmr.StoragePrice() );
        cell.RentalWarehouseStorageFees( [Number] ( guard( ( cell.TotalQuantityOfMaterialRacks() - [Number]( plannedInventory / lce.PackagingCapacity() ) ) * lcmr.StoragePrice(), 0 ) ) );
        sumRentalWarehouseStorageFees := sumRentalWarehouseStorageFees + cell.RentalWarehouseStorageFees();
        
        // 清洗费用:发动机入库量 / 包装容量 * 料架清洗单价。发动机入库量取发动机销量,包装容量取自发动机成本表。料架清洗单价取料架成本表。
        cell.CleaningCost( [Number] ( engineProductions / guard( lce.PackagingCapacity(), 1 ) * lcmr.CleanPrice() ) );
        sumCleaningCost := sumCleaningCost + cell.CleaningCost();
        
        // 预计总费用
        cell.EstimatedTotalCost( cell.StorageFeesForRentedWarehouses()             + 
@@ -121,34 +106,49 @@
                                 cell.RentalWarehouseStorageFees()                 +
                                 cell.CleaningCost()
                                );
        sumEstimatedTotalCost := sumEstimatedTotalCost + cell.EstimatedTotalCost();
                                
        // 系数
        cell.Coefficient( 1.05 );
        
        // 总费用
        cell.TotalCost( cell.EstimatedTotalCost() * cell.Coefficient() );
        sumTotalCost := sumTotalCost + cell.TotalCost();
        cell.TotalCost( [Number] ( cell.EstimatedTotalCost() * cell.Coefficient() ) );
        
        cell.CC_EngineRackColumn( relset, ccerc );
      }
    }
    
    // 创建SUM行
    sumR := macroPlan.CC_EngineRackRow( relnew, Generation := "SUM", MLB_MQB := "", Index := 2 );
    sumR   := macroPlan.CC_EngineRackRow( relnew, Generation := "SUM", MLB_MQB := "", Index := 2 );
    traverse ( macroPlan, CC_EngineRackColumn, ccerc ) {
      cell := sumR.CC_EngineRackCell( relnew );
      cell.NumberOfEmptyShelves( sumNumberOfEmptyShelves );
      cell.StorageFeesForRentedWarehouses( sumStorageFeesForRentedWarehouses );
      cell.OutboundExpensesForRentedWarehouses( sumOutboundExpensesForRentedWarehouses );
      cell.ExternalRentalWarehouseTransportationCosts( sumExternalRentalWarehouseTransportationCosts );
      cell.RentalWarehouseStorageFees( sumRentalWarehouseStorageFees );
      cell.CleaningCost( sumCleaningCost );
      cell.EstimatedTotalCost( sumEstimatedTotalCost );
      cell.TotalCost( sumTotalCost );
      cell.CC_EngineRackColumn( relset, ccerc );
      cell.NumberOfEmptyShelves( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.NumberOfEmptyShelves() ) );
      cell.StorageFeesForRentedWarehouses( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.StorageFeesForRentedWarehouses() ) );
      cell.OutboundExpensesForRentedWarehouses( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.OutboundExpensesForRentedWarehouses() ) );
      cell.ExternalRentalWarehouseTransportationCosts( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.ExternalRentalWarehouseTransportationCosts() ) );
      cell.RentalWarehouseStorageFees( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.RentalWarehouseStorageFees() ) );
      cell.CleaningCost( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.CleaningCost() ) );
      cell.EstimatedTotalCost( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.EstimatedTotalCost() ) );
      cell.Coefficient( 1.05 );
      cell.TotalCost( sum( ccerc, CC_EngineRackCell, tempCCERCell, tempCCERCell.CC_EngineRackRow().Generation() <> "SUM", tempCCERCell.TotalCost() ) );
    }
    // 创建SUM列
    sumC   := macroPlan.CC_EngineRackColumn( relnew, StartDate := Date::MaxDate() );
    traverse ( macroPlan, CC_EngineRackRow, ccerr ) {
      cell := ccerr.CC_EngineRackCell( relnew );
      cell.CC_EngineRackColumn( relset, sumC );
      cell.NumberOfEmptyShelves( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.NumberOfEmptyShelves() ) );
      cell.StorageFeesForRentedWarehouses( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.StorageFeesForRentedWarehouses() ) );
      cell.OutboundExpensesForRentedWarehouses( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.OutboundExpensesForRentedWarehouses() ) );
      cell.ExternalRentalWarehouseTransportationCosts( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.ExternalRentalWarehouseTransportationCosts() ) );
      cell.RentalWarehouseStorageFees( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.RentalWarehouseStorageFees() ) );
      cell.CleaningCost( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.CleaningCost() ) );
      cell.EstimatedTotalCost( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.EstimatedTotalCost() ) );
      cell.Coefficient( 1.05 );
      cell.TotalCost( sum( ccerr, CC_EngineRackCell, tempCCERCell, not tempCCERCell.CC_EngineRackColumn().StartDate().IsMaxInfinity(), tempCCERCell.TotalCost() ) );
    }
  *]
}