陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
51
52
Quintiq file version 2.0
#parent: #root
StaticMethod WriteBackTheTransferPlan (
  MacroPlan macroPlan,
  Product_MPs selectedProducts
)
{
  TextBody:
  [*
    traverse ( selectedProducts, Elements, p, p.IsLeaf() and exists( macroPlan, TransferPlanRow, tempTPR, tempTPR.ProductID() = p.ID() ) ) {
      tprs := selectset( macroPlan, TransferPlanRow, tempTPR, tempTPR.ProductID() = p.ID() );
      
      traverse ( tprs, Elements, tpr ) {
        tpcells := selectsortedset( tpr, TransferPlanCell, tempTPCell, guard( [Number]tempTPCell.Value(), 0 ) >= 0.0, tempTPCell.TransferPlanColumn().ColumnDate() );
        traverse ( tpcells, Elements, tpcell
    //               , tpcell.TransferPlanColumn().ColumnDate() = Date::Construct( 2025, 1, 11 )
                    ) {
    //      info( "时间:", tpcell.TransferPlanColumn().ColumnName(),                                                                 "    ", 
    //            tpcell.TransferPlanRow().SourceStockpoingPointID() + "  To  " + tpcell.TransferPlanRow().TargetStockpoingPointID(), "    ",
    //            tpcell.Value() );
        
          // selecte trip plan
          unitName := tpcell.TransferPlanRow().SourceStockpoingPointID() + " " + "to" + " " + tpcell.TransferPlanRow().TargetStockpoingPointID() + " " + tpcell.TransferPlanRow().Category() + " " + "Transport"
          pit      := select( macroPlan, Unit.Lane.LaneLeg.Trip.ProductInTrip, tempPIT, 
                              tempPIT.Trip().Departure().Date()             = tpcell.TransferPlanColumn().ColumnDate() and
                              tempPIT.Trip().LaneLeg().Lane().Unit().Name() = unitName                                 and
                              tempPIT.ProductID()                           = tpr.ProductID()
                             );
          if ( not isnull( pit ) ) { // 有Trip情况
    //        info( pit.Quantity() );
            if ( [Number]pit.Quantity() <> [Number]tpcell.Value() ) {
              pit.Update( [Real]tpcell.Value(), true );
            }
          } else { // 无Trip情况
    //        error( "no trip" );
    //        info( tpr.ProductID(), "    数量:", [Number]tpcell.Value() );
    //        
    //        t := select( macroPlan, Unit.Lane.LaneLeg.Trip, tempP, 
    //                     tempP.LaneLeg().Lane().Unit().Name() = unitName and
    //                     tempP.Departure().Date()             = tpcell.TransferPlanColumn().ColumnDate() );
    //        p := select( macroPlan, Product_MP, tempPMP, tempPMP.ID() = tpr.ProductID() );
    //        info( not isnull( t ) );
    //        if ( [Number]tpcell.Value() > 0 and not isnull( t ) and not isnull( p ) ) {
    //          ProductInTrip::CreateOrUpdateForTrip( t, p, [Real]tpcell.Value() );
    //          Transaction::Transaction().PropagateAll();
    //        }
          }
        }
      }
    }
  *]
}