lazhen
2024-11-11 b3976ea2e22df28a4225377c1bf3f6fc1b27ec72
_Main/BL/Type_MachineLogisticsCostReportCell/StaticMethod_CreateData.qbl
@@ -26,19 +26,27 @@
    }
    
    // 创建单元格
    traverse ( macroPlan, MachineLogisticsCostReportRow, mlcrr ) { // 循环行
    traverse ( macroPlan, MachineLogisticsCostReportRow, mlcrr
    //           , mlcrr.Factory() = "长春工厂"
              ) { // 循环行
      info( "当前遍历的行:", mlcrr.Factory(), " ", mlcrr.Category() );
      traverse ( macroPlan, MachineLogisticsCostReportColumn, mlcrc ) { // 循环列
      
        // 机加成本参数
        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() );
        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() );
        
        // 运输成本参数
        lct  := select( macroPlan, LogisticsCostTransport, tempLCT,
                        tempLCT.Product()     = mlcrr.Category()                                                                                                                         and
                        tempLCT.Origin()      = ifexpr( mlcrr.Category() = "AGW", "DL AGW", ifexpr( mlcrr.Factory() = "大连工厂", "DL", "CC" ) + " " + mlcrr.Category() + "外租库" )     and
                        tempLCT.Destination() = ifexpr( mlcrr.Category() = "AGW", "CC AGW库房", ifexpr( mlcrr.Factory() = "大连工厂", "DL", "CC" ) + " " + mlcrr.Category() + "线边库" ) );
        lct   := select( macroPlan, LogisticsCostTransport, tempLCT,
                         tempLCT.Product()     = mlcrr.Category()                                                                                                                         and
                         tempLCT.Origin()      = ifexpr( mlcrr.Category() = "AGW", "DL AGW", ifexpr( mlcrr.Factory() = "大连工厂", "DL", "CC" ) + " " + mlcrr.Category() + "外租库" )     and
                         tempLCT.Destination() = ifexpr( mlcrr.Category() = "AGW", "CC AGW库房", ifexpr( mlcrr.Factory() = "大连工厂", "DL", "CC" ) + " " + mlcrr.Category() + "线边库" ) );
        // 运输成本参数(调拨费用)
        lct1  := select( macroPlan, LogisticsCostTransport, tempLCT,
                         tempLCT.Product()     = mlcrr.Category()                                                                                                                         and
                         tempLCT.Origin()      = ifexpr( mlcrr.Category() = "AGW", "DL AGW", ifexpr( mlcrr.Factory() = "大连工厂", "CC", "DL" ) + " " + mlcrr.Category() )                and
                         tempLCT.Destination() = ifexpr( mlcrr.Category() = "AGW", "CC AGW库房", ifexpr( mlcrr.Factory() = "大连工厂", "DL", "CC" ) + " " + mlcrr.Category() + "外租库" ) );
    
         // 当前月末最后一天日期
        lastDayOfThisMonth := mlcrc.StartDate().StartOfNextMonth() - 1;
@@ -76,7 +84,8 @@
                                 guard( tempTPC.TransferPlanColumn().ColumnDate().Year()   = mlcrc.StartDate().Year(), false )                              and
                                 guard(  tempTPC.TransferPlanColumn().ColumnDate().Month() = mlcrc.StartDate().Month(), false ),
                                 [Number]tempTPC.Value() );
        cell.TransferCost( [Number] ( [Number] ( transferQuantity / guard( lcm.PackagingCapacity(), 1 ) ) / guard( lct.LoadingCapacity(), 1 ) ) * guard( lct.TransportPrice(), 1 ) );
    //    info( "调拨数量:", transferQuantity, "    包装容量:", guard( lcm.PackagingCapacity(), 1 ), "    装载容量:", guard( lct1.LoadingCapacity(), 1 ), "    运输单价:",guard( lct1.TransportPrice(), 1 )  );
        cell.TransferCost( [Number] ( ceil( ceil( transferQuantity / guard( lcm.PackagingCapacity(), 1 ) ) / guard( lct1.LoadingCapacity(), 1 ) ) * guard( lct1.TransportPrice(), 1 ) ) );
    
        // 外租库入库费用(入库量[包装量] / 包装容量 * 入库单价)
        cell.StorageFeesForRentedWarehouses( packageQuantity / guard( lcm.PackagingCapacity(), 1 ) * guard( lcm.WarehousingPrice(), 1 ) );