hongjli
2025-01-14 386cb9a858f89d881acea3fd3a0d7c65945542ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Quintiq file version 2.0
#parent: #root
StaticMethod SetPackagingAndUnpackingValuesCC (
  MacroPlan macroPlan
)
{
  TextBody:
  [*
    traverse ( macroPlan, PackagingPlanRow, ppr, ppr.Factory() = "长春工厂" /*and ppr.Category() = "ZKG" and ppr.ProductID() = "06K103011CP"*/ ) {
      
      u  := select( macroPlan, Unit, tempU, tempU.ID() = "CC " + ppr.Category() + " 线边和外租库间");
      
      ts := selectset( u, Lane.LaneLeg.Trip, tempT, 
                       guard( select( tempT, ProductInTrip, tempPIT, tempPIT.ProductID() = ppr.ProductID() ).Quantity() > 0, false ) );
                       
      traverse ( ts, Elements.ProductInTrip, pit, pit.Quantity() > 0 and pit.ProductID() = ppr.ProductID() ) {
        ppcell := select( ppr, PackagingPlanCell, tempPPCell, tempPPCell.PackagingPlanColumn().StartDate() = pit.Trip().Departure().Date() );
        
        if ( not isnull( ppcell ) ) {
          if ( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( "外租库" ) and pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( "线边库" ) ) {
            ppcell.Unpacking( pit.Quantity() );
          }
          
          if ( pit.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( "线边库" ) and pit.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( "外租库" ) ) {
            ppcell.Package( pit.Quantity() );
          }
        }
      }
    //  traverse ( ppr, PackagingPlanCell, ppcell/*, ppcell.StartDate() <= Date::Construct( 2025, 1, 4 )*/ ) {
    //    unpackagedQuantity := sum( u, Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
    //                               tempPIT.ProductID()          = ppcell.PackagingPlanRow().ProductID()                               and
    //                               tempPIT.Trip().Departure().Date() = ppcell.StartDate()                                             and
    //                               tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( "外租库" )      and
    //                               tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( "线边库" ),
    //                               tempPIT.Quantity()
    //                              );
    //    ppcell.Unpacking( unpackagedQuantity );
    //    
    //    packagedQuantity := sum( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
    //                             tempPIT.ProductID()          = ppcell.PackagingPlanRow().ProductID()                               and
    //                             tempPIT.Trip().Departure().Date() = ppcell.StartDate()                                             and
    //                             tempPIT.Trip().LaneLeg().AsOriginStockingPointLeg().StockingPoint_MP().ID().Regex( "线边库" )      and
    //                             tempPIT.Trip().LaneLeg().AsDestinationStockingPointLeg().StockingPoint_MP().ID().Regex( "外租库" ),
    //                             tempPIT.Quantity()
    //                            );
    //    ppcell.Package( packagedQuantity );
    //  }
    }
  *]
}