| 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(); | 
|   *] | 
| } |