From 4b60afbb9fe35115958a3560c55b2ae08e267d71 Mon Sep 17 00:00:00 2001
From: yanweiyuan3 <yanweiyuan3@gmail.com>
Date: 星期四, 14 九月 2023 20:25:16 +0800
Subject: [PATCH] Data input & output add

---
 _Main/BL/EDI/Broker_Broker_OTD_VersionControlToDB.qbl                                                                               |  133 +++++++++++
 _Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl                                                                        |   46 +++
 _Main/BL/Type_Scenario/Attribute_VersionID.qbl                                                                                      |    8 
 _Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl                                                                      |    4 
 _Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def   |    2 
 _Main/BL/Type_Scenario/DefaultValue_VersionID.qbl                                                                                   |    6 
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def                                                      |    9 
 _Main/BL/Type_MappingVersionControl/Attribute_Qty.qbl                                                                               |    8 
 _Main/BL/Type_VersionControl/StaticMethod_ReleaseLatestVersion.qbl                                                                  |   10 
 _Main/BL/Type_MappingVersionControl/Attribute_EndTime.qbl                                                                           |    9 
 _Main/BL/Type_MappingVersionControl/Attribute_ReleaseTime.qbl                                                                       |    8 
 _Main/BL/Type_MappingVersionControl/Attribute_VersionName.qbl                                                                       |    8 
 _Main/BL/Type_MappingVersionControl/Attribute_ProductID.qbl                                                                         |    9 
 _Main/BL/Relations/Relation_MappingVersionControl_GlobalOTDTable_GlobalOTDTable_MappingVersionC.qbl                                 |   23 +
 _Main/BL/Type_MappingVersionControl/Attribute_DataFrom.qbl                                                                          |    8 
 _Main/BL/Type_VersionControl/StaticMethod_FindByFullVersionID.qbl                                                                   |   17 +
 _Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl                                                                 |   35 ++
 _Main/BL/EDI/Broker_Broker_OTD_VersionControl.qbl                                                                                   |  133 +++++++++++
 _var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties                                                       |    6 
 _Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl                                                               |    7 
 _Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl                                                                  |   71 +++++
 _Main/BL/Type_MappingVersionControl/Attribute_StartTime.qbl                                                                         |    9 
 _Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderRelease_OnClick.def |    2 
 _Main/BL/Type_MappingVersionControl/Attribute_User.qbl                                                                              |    8 
 _Main/BL/Type_MappingVersionControl/_ROOT_Type_MappingVersionControl.qbl                                                            |   10 
 _Main/BL/Type_Scenario/Attribute_IsCreateNewVersion.qbl                                                                             |    8 
 _Main/BL/Type_MappingVersionControl/Attribute_DataTo.qbl                                                                            |    8 
 _Main/BL/Type_MappingVersionControl/TypeIndex_TypeIndexVersionControl.qbl                                                           |   28 ++
 _Main/BL/Type_MappingVersionControl/Attribute_CreateTime.qbl                                                                        |    8 
 _Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_PanelGeneral#549.def                                       |   11 
 _Main/BL/Type_MappingVersionControl/Attribute_StockingPointID.qbl                                                                   |    9 
 _Main/BL/Type_MappingVersionControl/Attribute_VersionID.qbl                                                                         |    9 
 32 files changed, 664 insertions(+), 6 deletions(-)

diff --git a/_Main/BL/EDI/Broker_Broker_OTD_VersionControl.qbl b/_Main/BL/EDI/Broker_Broker_OTD_VersionControl.qbl
new file mode 100644
index 0000000..b3723db
--- /dev/null
+++ b/_Main/BL/EDI/Broker_Broker_OTD_VersionControl.qbl
@@ -0,0 +1,133 @@
+Quintiq file version 2.0
+#parent: #root
+EDIBroker Broker_OTD_VersionControl
+{
+  MDSDefinition: GlobalOTDTable
+  TimeZone: 'ACT'
+  UseOSTimeZone: false
+  EDIModelLink.Destination MappingVersionControl
+  {
+    EDIMLTable MappingVersionControl
+    {
+      PrimaryKeyColumns: EndTime
+      PrimaryKeyColumns: ProductID
+      PrimaryKeyColumns: StartTime
+      PrimaryKeyColumns: StockingPointID
+      PrimaryKeyColumns: VersionID
+      TargetType: MappingVersionControl
+      TypeIndex: TypeIndexVersionControl
+      EDIMLColumn CreateTime { Attribute: CreateTime ValueType: DateTime }
+      EDIMLColumn DataFrom { Attribute: DataFrom ValueType: String }
+      EDIMLColumn DataTo { Attribute: DataTo ValueType: String }
+      EDIMLColumn EndTime { Attribute: EndTime ValueType: DateTime }
+      EDIMLColumn ProductID { Attribute: ProductID ValueType: String }
+      EDIMLColumn Qty { Attribute: Qty ValueType: Real }
+      EDIMLColumn ReleaseTime { Attribute: ReleaseTime ValueType: DateTime }
+      EDIMLColumn StartTime { Attribute: StartTime ValueType: DateTime }
+      EDIMLColumn StockingPointID { Attribute: StockingPointID ValueType: String }
+      EDIMLColumn User { Attribute: User ValueType: String }
+      EDIMLColumn VersionID { Attribute: VersionID ValueType: String }
+      EDIMLColumn VersionName { Attribute: VersionName ValueType: String }
+    }
+  }
+  EDIODBCLink.Source MID_VERSIONCONTROL
+  {
+    DataIntegrityStrategy: 'Disabled'
+    SettingsEngineLink: 'domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle'
+    EDIODBCLinkTable MID_VERSIONCONTROL
+    {
+      OthersMayCreateTable: true
+      OthersMayDeleteRow: true
+      OthersMayDropTable: true
+      OthersMayFlushTable: true
+      OthersMayInsertRow: true
+      Parameters: '/owner="TIANMA"'
+      PrimaryKeyColumns: ENDTIME
+      PrimaryKeyColumns: ID
+      PrimaryKeyColumns: PRODUCTID
+      PrimaryKeyColumns: STARTTIME
+      PrimaryKeyColumns: STOCKINGPOINTID
+      RecordModificationHintStrategy: 'None'
+      EDIODBCLinkColumn CREATETIME
+      {
+        OthersMayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn DATAFROM
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn DATATO
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn ENDTIME
+      {
+        OthersMayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn ID
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn NAME
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn PRODUCTID
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn QTY
+      {
+        OthersMayUpdateColumn: true
+        ValueType: Real
+      }
+      EDIODBCLinkColumn RELEASETIME
+      {
+        OthersMayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn STARTTIME
+      {
+        OthersMayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn STOCKINGPOINTID
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn USER
+      {
+        OthersMayUpdateColumn: true
+        ValueType: String
+      }
+    }
+  }
+  EDITransformation.Transformation TransformationVersionControl
+  {
+    EDITableTransformation
+    {
+      InputTable: MID_VERSIONCONTROL
+      OutputTable: MappingVersionControl
+      EDIColumnMatch { InputColumn: CREATETIME OutputColumn: CreateTime }
+      EDIColumnMatch { InputColumn: DATAFROM OutputColumn: DataFrom }
+      EDIColumnMatch { InputColumn: DATATO OutputColumn: DataTo }
+      EDIColumnMatch { InputColumn: ENDTIME OutputColumn: EndTime }
+      EDIColumnMatch { InputColumn: ID OutputColumn: VersionID }
+      EDIColumnMatch { InputColumn: NAME OutputColumn: VersionName }
+      EDIColumnMatch { InputColumn: PRODUCTID OutputColumn: ProductID }
+      EDIColumnMatch { InputColumn: QTY OutputColumn: Qty }
+      EDIColumnMatch { InputColumn: RELEASETIME OutputColumn: ReleaseTime }
+      EDIColumnMatch { InputColumn: STARTTIME OutputColumn: StartTime }
+      EDIColumnMatch { InputColumn: STOCKINGPOINTID OutputColumn: StockingPointID }
+      EDIColumnMatch { InputColumn: USER OutputColumn: User }
+    }
+  }
+}
diff --git a/_Main/BL/EDI/Broker_Broker_OTD_VersionControlToDB.qbl b/_Main/BL/EDI/Broker_Broker_OTD_VersionControlToDB.qbl
new file mode 100644
index 0000000..f767cde
--- /dev/null
+++ b/_Main/BL/EDI/Broker_Broker_OTD_VersionControlToDB.qbl
@@ -0,0 +1,133 @@
+Quintiq file version 2.0
+#parent: #root
+EDIBroker Broker_OTD_VersionControlToDB
+{
+  MDSDefinition: GlobalOTDTable
+  TimeZone: 'ACT'
+  UseOSTimeZone: false
+  EDIModelLink.Source MappingVersionControlToDB
+  {
+    EDIMLTable MappingVersionControl
+    {
+      PrimaryKeyColumns: EndTime
+      PrimaryKeyColumns: ProductID
+      PrimaryKeyColumns: StartTime
+      PrimaryKeyColumns: StockingPointID
+      PrimaryKeyColumns: VersionID
+      TargetType: MappingVersionControl
+      TypeIndex: TypeIndexVersionControl
+      EDIMLColumn CreateTime { Attribute: CreateTime ValueType: DateTime }
+      EDIMLColumn DataFrom { Attribute: DataFrom ValueType: String }
+      EDIMLColumn DataTo { Attribute: DataTo ValueType: String }
+      EDIMLColumn EndTime { Attribute: EndTime ValueType: DateTime }
+      EDIMLColumn ProductID { Attribute: ProductID ValueType: String }
+      EDIMLColumn Qty { Attribute: Qty ValueType: Real }
+      EDIMLColumn ReleaseTime { Attribute: ReleaseTime ValueType: DateTime }
+      EDIMLColumn StartTime { Attribute: StartTime ValueType: DateTime }
+      EDIMLColumn StockingPointID { Attribute: StockingPointID ValueType: String }
+      EDIMLColumn User { Attribute: User ValueType: String }
+      EDIMLColumn VersionID { Attribute: VersionID ValueType: String }
+      EDIMLColumn VersionName { Attribute: VersionName ValueType: String }
+    }
+  }
+  EDIODBCLink.Destination MID_VERSIONCONTROLTODB
+  {
+    DataIntegrityStrategy: 'Disabled'
+    SettingsEngineLink: 'domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle'
+    EDIODBCLinkTable MID_VERSIONCONTROL
+    {
+      MayCreateTable: true
+      MayDeleteRow: true
+      MayDropTable: true
+      MayFlushTable: true
+      MayInsertRow: true
+      Parameters: '/owner="TIANMA"'
+      PrimaryKeyColumns: ENDTIME
+      PrimaryKeyColumns: ID
+      PrimaryKeyColumns: PRODUCTID
+      PrimaryKeyColumns: STARTTIME
+      PrimaryKeyColumns: STOCKINGPOINTID
+      RecordModificationHintStrategy: 'None'
+      EDIODBCLinkColumn CREATETIME
+      {
+        MayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn DATAFROM
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn DATATO
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn ENDTIME
+      {
+        MayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn ID
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn NAME
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn PRODUCTID
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn QTY
+      {
+        MayUpdateColumn: true
+        ValueType: Real
+      }
+      EDIODBCLinkColumn RELEASETIME
+      {
+        MayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn STARTTIME
+      {
+        MayUpdateColumn: true
+        ValueType: DateTime
+      }
+      EDIODBCLinkColumn STOCKINGPOINTID
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+      EDIODBCLinkColumn USER
+      {
+        MayUpdateColumn: true
+        ValueType: String
+      }
+    }
+  }
+  EDITransformation.Transformation TransformationVersionControlToDB
+  {
+    EDITableTransformation
+    {
+      InputTable: MappingVersionControl
+      OutputTable: MID_VERSIONCONTROL
+      EDIColumnMatch { InputColumn: CreateTime OutputColumn: CREATETIME }
+      EDIColumnMatch { InputColumn: DataFrom OutputColumn: DATAFROM }
+      EDIColumnMatch { InputColumn: DataTo OutputColumn: DATATO }
+      EDIColumnMatch { InputColumn: EndTime OutputColumn: ENDTIME }
+      EDIColumnMatch { InputColumn: ProductID OutputColumn: PRODUCTID }
+      EDIColumnMatch { InputColumn: Qty OutputColumn: QTY }
+      EDIColumnMatch { InputColumn: ReleaseTime OutputColumn: RELEASETIME }
+      EDIColumnMatch { InputColumn: StartTime OutputColumn: STARTTIME }
+      EDIColumnMatch { InputColumn: StockingPointID OutputColumn: STOCKINGPOINTID }
+      EDIColumnMatch { InputColumn: User OutputColumn: USER }
+      EDIColumnMatch { InputColumn: VersionID OutputColumn: ID }
+      EDIColumnMatch { InputColumn: VersionName OutputColumn: NAME }
+    }
+  }
+}
diff --git a/_Main/BL/Relations/Relation_MappingVersionControl_GlobalOTDTable_GlobalOTDTable_MappingVersionC.qbl b/_Main/BL/Relations/Relation_MappingVersionControl_GlobalOTDTable_GlobalOTDTable_MappingVersionC.qbl
new file mode 100644
index 0000000..39dd1eb
--- /dev/null
+++ b/_Main/BL/Relations/Relation_MappingVersionControl_GlobalOTDTable_GlobalOTDTable_MappingVersionC.qbl
@@ -0,0 +1,23 @@
+Quintiq file version 2.0
+#parent: #root
+Relation MappingVersionControl_GlobalOTDTable_GlobalOTDTable_MappingVersionControl
+{
+  #keys: '1[412960.0.150120043]'
+  DefaultRelationStrategy
+  {
+  }
+  RelationSide.LeftSide GlobalOTDTable
+  {
+    #keys: '3[412960.0.150120045][412960.0.150120044][412960.0.150120046]'
+    Cardinality: '0to1'
+    ObjectDefinition: MappingVersionControl
+    OwningSide: 'Reference'
+  }
+  RelationSide.RightSide MappingVersionControl
+  {
+    #keys: '3[412960.0.150120048][412960.0.150120047][412960.0.150120049]'
+    Cardinality: '1toN'
+    ObjectDefinition: GlobalOTDTable
+    OwningSide: 'Owned'
+  }
+}
diff --git a/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl
new file mode 100644
index 0000000..5e79d99
--- /dev/null
+++ b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetOutputVersionData.qbl
@@ -0,0 +1,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, 
+                              true );
+    
+    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();
+  *]
+}
diff --git a/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl
new file mode 100644
index 0000000..0cba7c5
--- /dev/null
+++ b/_Main/BL/Type_GlobalDTOTable/StaticMethod_GetVersionData.qbl
@@ -0,0 +1,46 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod GetVersionData (
+  GlobalOTDTable owner,
+  String businessname
+)
+{
+  Description: '鎶藉彇骞跺鐞嗙増鏈暟鎹�'
+  TextBody:
+  [*
+    // Administrator Sep-14-2023 (created)
+    businesstype := GlobalOTDTable::GetBusinessTypeName( businessname );
+    
+    // Clean exist data
+    traverse( owner, MappingVersionControl, mpc, true ){
+      mpc.Delete();
+    }
+    
+    // Get Data From DB
+    owner.Broker_OTD_VersionControl().Execute();
+    
+    // Get Data list to deal
+    listtodeal := selectset( owner, MappingVersionControl, item, item.DataTo() = businesstype );
+    
+    traverse( listtodeal, Elements, item, true ){
+      versionid := item.VersionID();
+      existversion := VersionControl::FindByFullVersionID( owner, versionid );
+      if( isnull( existversion ) ){
+        longversionname := item.VersionName();
+        longversionnamelist := longversionname.Tokenize( "-" );
+        shortversionname := longversionnamelist.Element( longversionnamelist.Size() );
+        caltype := shortversionname.SubString( 0, 10 );
+        shortversionid := versionid.ReplaceAll( "-" + caltype, "" );
+        newversioncontrol := VersionControl::Create( owner, 
+                                                     item.DataFrom(), 
+                                                     caltype, 
+                                                     item.CreateTime(), 
+                                                     shortversionid, 
+                                                     longversionname, 
+                                                     shortversionname, 
+                                                     item.User() );
+        newversioncontrol.IsReleased( true );
+        } 
+      }
+  *]
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_CreateTime.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_CreateTime.qbl
new file mode 100644
index 0000000..412204a
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_CreateTime.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute CreateTime
+{
+  #keys: '3[412960.0.150120147][412960.0.150120146][412960.0.150120148]'
+  Description: '鍒涘缓鏃堕棿'
+  ValueType: DateTime
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_DataFrom.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_DataFrom.qbl
new file mode 100644
index 0000000..d35de79
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_DataFrom.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute DataFrom
+{
+  #keys: '3[412960.0.150120067][412960.0.150120066][412960.0.150120068]'
+  Description: '鏁版嵁鍙戝嚭鐨勯儴闂ㄥ悕绉�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_DataTo.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_DataTo.qbl
new file mode 100644
index 0000000..c08ce30
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_DataTo.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute DataTo
+{
+  #keys: '3[412960.0.150120077][412960.0.150120076][412960.0.150120078]'
+  Description: '鎺ユ敹鏁版嵁鐨勯儴闂ㄥ悕绉�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_EndTime.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_EndTime.qbl
new file mode 100644
index 0000000..bd00968
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_EndTime.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute EndTime
+{
+  #keys: '3[412960.0.150120127][412960.0.150120126][412960.0.150120128]'
+  Description: '缁撴潫鏃堕棿'
+  IsReadOnly: true
+  ValueType: DateTime
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_ProductID.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_ProductID.qbl
new file mode 100644
index 0000000..8806689
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_ProductID.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ProductID
+{
+  #keys: '3[412960.0.150120087][412960.0.150120086][412960.0.150120088]'
+  Description: '鐗╂枡缂栫爜'
+  IsReadOnly: true
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_Qty.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_Qty.qbl
new file mode 100644
index 0000000..572c5c9
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_Qty.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute Qty
+{
+  #keys: '3[412960.0.150120097][412960.0.150120096][412960.0.150120098]'
+  Description: '鏁伴噺'
+  ValueType: Real
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_ReleaseTime.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_ReleaseTime.qbl
new file mode 100644
index 0000000..9bab647
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_ReleaseTime.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute ReleaseTime
+{
+  #keys: '3[412960.0.150120157][412960.0.150120156][412960.0.150120158]'
+  Description: '鍙戝竷鏃堕棿'
+  ValueType: DateTime
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_StartTime.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_StartTime.qbl
new file mode 100644
index 0000000..270b408
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_StartTime.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute StartTime
+{
+  #keys: '3[412960.0.150120117][412960.0.150120116][412960.0.150120118]'
+  Description: '寮�濮嬫椂闂�'
+  IsReadOnly: true
+  ValueType: DateTime
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_StockingPointID.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_StockingPointID.qbl
new file mode 100644
index 0000000..b8f18c4
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_StockingPointID.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute StockingPointID
+{
+  #keys: '3[412960.0.150120107][412960.0.150120106][412960.0.150120108]'
+  Description: '搴撳瓨鐐圭紪鐮�'
+  IsReadOnly: true
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_User.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_User.qbl
new file mode 100644
index 0000000..484ce50
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_User.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute User
+{
+  #keys: '3[412960.0.150120137][412960.0.150120136][412960.0.150120138]'
+  Description: '鐢ㄦ埛鍚嶇О'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_VersionID.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_VersionID.qbl
new file mode 100644
index 0000000..c64363f
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_VersionID.qbl
@@ -0,0 +1,9 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute VersionID
+{
+  #keys: '3[412960.0.150120057][412960.0.150120056][412960.0.150120058]'
+  Description: '鏁版嵁搴撴娊鍙栫殑鍏ㄩ噺鐗堟湰鍙�'
+  IsReadOnly: true
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/Attribute_VersionName.qbl b/_Main/BL/Type_MappingVersionControl/Attribute_VersionName.qbl
new file mode 100644
index 0000000..e6417f2
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/Attribute_VersionName.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute VersionName
+{
+  #keys: '3[412960.0.150124918][412960.0.150124917][412960.0.150124919]'
+  Description: '鐗堟湰鍚嶇О'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_MappingVersionControl/TypeIndex_TypeIndexVersionControl.qbl b/_Main/BL/Type_MappingVersionControl/TypeIndex_TypeIndexVersionControl.qbl
new file mode 100644
index 0000000..b1b5794
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/TypeIndex_TypeIndexVersionControl.qbl
@@ -0,0 +1,28 @@
+Quintiq file version 2.0
+#parent: #root
+TypeIndex TypeIndexVersionControl
+{
+  Attributes:
+  [
+    TypeIndexAttribute
+    {
+      ModelElement: VersionID
+    }
+    TypeIndexAttribute
+    {
+      ModelElement: EndTime
+    }
+    TypeIndexAttribute
+    {
+      ModelElement: StockingPointID
+    }
+    TypeIndexAttribute
+    {
+      ModelElement: StartTime
+    }
+    TypeIndexAttribute
+    {
+      ModelElement: ProductID
+    }
+  ]
+}
diff --git a/_Main/BL/Type_MappingVersionControl/_ROOT_Type_MappingVersionControl.qbl b/_Main/BL/Type_MappingVersionControl/_ROOT_Type_MappingVersionControl.qbl
new file mode 100644
index 0000000..ff148d7
--- /dev/null
+++ b/_Main/BL/Type_MappingVersionControl/_ROOT_Type_MappingVersionControl.qbl
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+#root
+#parent: #DomainModel
+Type MappingVersionControl
+{
+  #keys: '5[412960.0.150120040][412960.0.150120038][0.0.0][412960.0.150120039][412960.0.150120041]'
+  BaseType: Object
+  Description: '鐗堟湰鎺у埗涓棿琛�'
+  StructuredName: 'MappingVersionControls'
+}
diff --git a/_Main/BL/Type_Scenario/Attribute_IsCreateNewVersion.qbl b/_Main/BL/Type_Scenario/Attribute_IsCreateNewVersion.qbl
new file mode 100644
index 0000000..9f65a98
--- /dev/null
+++ b/_Main/BL/Type_Scenario/Attribute_IsCreateNewVersion.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute IsCreateNewVersion
+{
+  #keys: '3[412960.0.155630021][412960.0.155630020][412960.0.155630022]'
+  Description: '鏄惁鍒涘缓浠庨泦鍥OP寮�濮嬬殑鍏ㄦ柊鐗堟湰'
+  ValueType: Boolean
+}
diff --git a/_Main/BL/Type_Scenario/Attribute_VersionID.qbl b/_Main/BL/Type_Scenario/Attribute_VersionID.qbl
new file mode 100644
index 0000000..9acdd4a
--- /dev/null
+++ b/_Main/BL/Type_Scenario/Attribute_VersionID.qbl
@@ -0,0 +1,8 @@
+Quintiq file version 2.0
+#parent: #root
+Attribute VersionID
+{
+  #keys: '3[412960.0.150120035][412960.0.150120034][412960.0.150120036]'
+  Description: '褰撳墠鍦烘櫙瀵瑰簲鐨勭増鏈彿锛屼簬鍒涘缓鐗堟湰鏃剁‘瀹�'
+  ValueType: String
+}
diff --git a/_Main/BL/Type_Scenario/DefaultValue_VersionID.qbl b/_Main/BL/Type_Scenario/DefaultValue_VersionID.qbl
new file mode 100644
index 0000000..b1c7729
--- /dev/null
+++ b/_Main/BL/Type_Scenario/DefaultValue_VersionID.qbl
@@ -0,0 +1,6 @@
+Quintiq file version 2.0
+#parent: #root
+DefaultValue
+{
+  TargetAttribute: VersionID
+}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl
new file mode 100644
index 0000000..7030997
--- /dev/null
+++ b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewSceneVersion.qbl
@@ -0,0 +1,35 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod CreateNewSceneVersion (
+  GlobalOTDTable owner,
+  String businessname
+) as VersionControl
+{
+  Description: '闅忓垱寤哄満鏅繘琛岀増鏈垱寤�'
+  TextBody:
+  [*
+    // Administrator Sep-13-2023 (created)
+    createtime := DateTime::ActualTime();
+    user := QuintiqUser::CurrentUser().Username();
+    starttime := DateTime::Construct(1970,1,1,0,0,0);
+    // Get the local scenario businesstype
+    businesstype := GlobalOTDTable::GetBusinessTypeName( businessname );
+    
+    // Get the older version info
+    oldversion_id := "";
+    oldversion_name := "";
+    oldcaltype := "";
+    
+    // Calculate new version info
+    additionversionid := ( createtime.MinutesAsReal( starttime ) * 60 * 10 + createtime.SecondOfMinute() ).Round( 0 );
+    newversionid := oldversion_id + [String]additionversionid;
+    newcaltype := GlobalOTDTable::GetNextCalType( oldcaltype, businesstype );
+    newsingleversionname := newcaltype + "(" + createtime.Format( "Y-M2-D2 H:m:s" ) + ")";
+    newversionname := oldversion_name + newsingleversionname;
+    
+    // Create new version
+    newversion := VersionControl::Create( owner, businesstype, newcaltype, createtime, newversionid, newversionname, newsingleversionname, user );
+    
+    return newversion;
+  *]
+}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl
index c5d5ef1..9c93bdf 100644
--- a/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl
+++ b/_Main/BL/Type_VersionControl/StaticMethod_CreateNewVersion.qbl
@@ -33,8 +33,8 @@
     
     
     // Calculate new version info
-    additionversionid := [Number]( createtime.MinutesAsReal( starttime ) * 60 );
-    newversionid := oldversion_id + additionversionid.AsQUILL();
+    additionversionid := ( createtime.MinutesAsReal( starttime ) * 60 * 10 + createtime.SecondOfMinute() ).Round( 0 );
+    newversionid := oldversion_id + [String]additionversionid;
     newcaltype := GlobalOTDTable::GetNextCalType( oldcaltype, businesstype );
     newsingleversionname := newcaltype + "(" + createtime.Format( "Y-M2-D2 H:m:s" ) + ")";
     newversionname := oldversion_name + newsingleversionname;
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_FindByFullVersionID.qbl b/_Main/BL/Type_VersionControl/StaticMethod_FindByFullVersionID.qbl
new file mode 100644
index 0000000..a281109
--- /dev/null
+++ b/_Main/BL/Type_VersionControl/StaticMethod_FindByFullVersionID.qbl
@@ -0,0 +1,17 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod FindByFullVersionID (
+  GlobalOTDTable owner,
+  String versionid
+) as VersionControl
+{
+  Description: '閫氳繃鍏ㄩ噺鐗堟湰鍙疯繘琛屾煡鎵�'
+  TextBody:
+  [*
+    // Administrator Sep-14-2023 (created)
+    // Get the version data 
+    resultversion :=  select( owner, VersionControl, version, version.VersionID() + "-" + version.CalType() = versionid );
+    
+    return resultversion;
+  *]
+}
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl
index 063a069..1b2ab3f 100644
--- a/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl
+++ b/_Main/BL/Type_VersionControl/StaticMethod_FindLatestUpdateVersion.qbl
@@ -11,7 +11,12 @@
     // Administrator Sep-13-2023 (created)
     
     // Get the latest version data 
-    latestversion := maxselect( globalotdtable, VersionControl, version, version.BusinessType()=businesstype and version.IsReleased()=true, version.CreateTime() );
+    latestversion := maxselect( globalotdtable, 
+                                VersionControl, 
+                                version, 
+                                version.BusinessType()=businesstype, 
+    //                             and version.IsReleased()=true, 
+                                version.CreateTime() );
     
     return latestversion;
   *]
diff --git a/_Main/BL/Type_VersionControl/StaticMethod_ReleaseLatestVersion.qbl b/_Main/BL/Type_VersionControl/StaticMethod_ReleaseLatestVersion.qbl
new file mode 100644
index 0000000..43541f1
--- /dev/null
+++ b/_Main/BL/Type_VersionControl/StaticMethod_ReleaseLatestVersion.qbl
@@ -0,0 +1,10 @@
+Quintiq file version 2.0
+#parent: #root
+StaticMethod ReleaseLatestVersion
+{
+  Description: '鍙戝竷褰撳墠鐗堟湰锛屽緟缂栧啓'
+  TextBody:
+  [*
+    // Administrator Sep-14-2023 (created)
+  *]
+}
diff --git "a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_PanelGeneral\043549.def" "b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_PanelGeneral\043549.def"
index 13a5531..f8a1684 100644
--- "a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_PanelGeneral\043549.def"
+++ "b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Component_PanelGeneral\043549.def"
@@ -51,5 +51,16 @@
         Taborder: 4
       ]
     }
+    Component CheckboxIsCreateNewVersion
+    {
+      #keys: '[412960.0.157150313]'
+      BaseType: 'WebCheckbox'
+      Properties:
+      [
+        DataBinding: 'DataHolderDialogData.Data.IsCreateNewVersion'
+        Label: 'Create a new version'
+        Taborder: 7
+      ]
+    }
   ]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def
index e97d405..1d0ed83 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_DialogCreateEditScenario/Method_OnOk.def
@@ -96,6 +96,15 @@
                            data.BusinessType(), data.IsKeyProduct(), data.CreatePurchaseSupplyMaterial() );
     }
     
+    // New version
+    globalotdtable := GlobalOTDTable;
+    testbusinesstype := "闆嗗洟";
+    if( data.IsCreateNewVersion() ){
+      VersionControl::CreateNewSceneVersion( globalotdtable, testbusinesstype );
+      }else{
+        VersionControl::CreateNewVersion( globalotdtable, testbusinesstype );
+        }
+    
     this.Close();
   *]
 }
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def
index 44e9fb8..9fea94f 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderFresh_OnClick.def
@@ -10,6 +10,8 @@
     Body:
     [*
       owner := GlobalOTDTable;
+      testbusinesstype := "闆嗗洟";
+      GlobalOTDTable::GetVersionData( owner, testbusinesstype );
       rootversionid := VersionControl::GetSOPVersionInfo( owner ).Element( 0 );
       DataExtractorVersionOfSOPDetails.FixedFilter( "object.VersionID().FindString( " + rootversionid.AsQUILL() + ", 0 ) = 0" );
       rootversionname := VersionControl::GetSOPVersionInfo( owner ).Element( 1 );
diff --git a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderRelease_OnClick.def b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderRelease_OnClick.def
index aef7303..dc23ddf 100644
--- a/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderRelease_OnClick.def
+++ b/_Main/UI/MacroPlannerWebApp/Component_FormVersionOfSOP/Response_PanelVersionOfSOPHeader_ButtonVersionOfSOPHeaderRelease_OnClick.def
@@ -11,9 +11,11 @@
     Body:
     [*
       owner := GlobalOTDTable;
+      macroplan := MacroPlan;
       testbusinesstype := "闆嗗洟";
       
       VersionControl::ReleaseNewVersion( owner, testbusinesstype );
+      GlobalOTDTable::GetOutputVersionData( owner, macroplan, testbusinesstype );
     *]
   }
 }
diff --git a/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties b/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties
index 5ecdbaf..f6a69e4 100644
--- a/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties
+++ b/_var/_Main/ModelSettings/Common/Development/_ROOT_Role_Development.properties
@@ -204,11 +204,11 @@
 domainmodel.ediremotedatasourcedefinition.remotestorage.inputunitsfrommodel.parameters=
 domainmodel.ediremotedatasourcedefinition.remotestorage.inputunitsfrommodel.password=
 domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle=template:domainmodel.ediremotedatasourcedefinition
-domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.connection=
+domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.connection=dbodbc1
 domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.maxcolumnnamelength=0
 domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.maxtablenamelength=0
-domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.parameters=
-domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.password=
+domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.parameters=/datasource=orclpdb /owner=TIANMA /chardatatypeforstring /characterencoding=UTF-8 /appdatatypeforstring=wchar
+domainmodel.ediremotedatasourcedefinition.remotestorage.localoracle.password=1 E9FE769DABE91891284EBBA6CEA8F41B 479d6f99-cffb-41e6-94f1-d35bdf20703c
 domainmodel.ediremotedatasourcedefinition.remotestorage.oracle=template:domainmodel.ediremotedatasourcedefinition
 domainmodel.ediremotedatasourcedefinition.remotestorage.oracle.connection=dbodbc1
 domainmodel.ediremotedatasourcedefinition.remotestorage.oracle.maxcolumnnamelength=0

--
Gitblit v1.9.3