yanweiyuan3
2023-09-21 a43f01cebe400883d31dbd3a1f1b593c61aa2a0d
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Quintiq file version 2.0
#parent: #root
StaticMethod GetOutputVersionData (
  GlobalOTDTable owner,
  MacroPlan macroplan,
  String businessname
)
{
  Description: '形成并发送版本数据'
  TextBody:
  [*
    // Administrator Sep-14-2023 (created)
    businesstype := GlobalOTDTable::GetBusinessTypeName( businessname );
    
    // Clean exist data
    traverse( owner, MappingVersionControl, mpc, true ){
      mpc.Delete();
    }
    
    // Get Latest version
    latestversion := VersionControl::FindLatestUpdateVersion( owner, businesstype );
    createtime := latestversion.CreateTime();
    datafrom := businesstype;
    releasetime := latestversion.ReleaseTime();
    versionid := latestversion.VersionID() + "-" + latestversion.CalType();
    info( versionid );
    versionname := latestversion.LongVersionName();
    user := latestversion.User();
    
    // Get Data list to deal
    listtodeal := selectset( macroplan, 
                              Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, 
                              pispip, 
                              pispip.SalesDemandQuantity() > 0 );
    
    if( latestversion.CalType() = "TM_SOP_R1" ){
      listtodeal := selectset( macroplan, 
                               Product_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriod, 
                               pispip, 
                               pispip.ProductInStockingPoint_MP().ProductID().StartsWith( "C1" ) );
      }
    
    traverse( listtodeal, Elements, item, true ){
      endtime := item.End();
      productid := item.ProductInStockingPoint_MP().ProductID();
      qty := item.SalesDemandQuantity();
      starttime := item.Start();
      stockingpointid := item.StockingPointInPeriod().StockingPointID();
      datato := "TM";
      if( businesstype <> "TM" ){
        datato := "TM";
        }
      owner.MappingVersionControl( relnew, 
                                   CreateTime := createtime, 
                                   DataFrom := datafrom, 
                                   DataTo := datato,
                                   EndTime := endtime, 
                                   ProductID := productid, 
                                   Qty := qty, 
                                   ReleaseTime := releasetime, 
                                   StartTime := starttime, 
                                   StockingPointID := stockingpointid, 
                                   User := user, 
                                   VersionID := versionid, 
                                   VersionName := versionname )
      }
    
    // Send Data To DB
    owner.Broker_OTD_VersionControlToDB().Execute();
  *]
}