renhao
2023-09-20 110846d23e6d86ad6fb883836640dc32b39ea86e
Merge branch 'dev_release'

Conflicts:
_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
已修改21个文件
已添加3个文件
373 ■■■■ 文件已修改
_Main/BL/EDI/Broker_Broker_OTD_BaseConversionFactor.qbl 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/EDI/Broker_Broker_OTD_Operation.qbl 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/EDI/Broker_Broker_OTD_Product.qbl 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_ApiLanesData.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_DeleteSnaityCheck.qbl 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl 110 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting#576.qbl 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MappingOperation/Attribute_SequenceNumber.qbl 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MappingOperation/TypeIndex_MappingOperationTypeIndex.qbl 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MappingProduct/Attribute_BusinessType.qbl 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_MappingProduct/TypeIndex_MappingProductTypeIndex.qbl 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_Product_MP/Attribute_BusinessTypeCommon.qbl 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_Product_MP/Attribute_KeyProduct.qbl 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/Type_Product_MP/StaticMethod_CreateOrUpdate.qbl 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
_Main/BL/EDI/Broker_Broker_OTD_BaseConversionFactor.qbl
@@ -34,10 +34,6 @@
      OthersMayFlushTable: true
      OthersMayInsertRow: true
      Parameters: '/owner="YUXTEST"'
      PrimaryKeyColumns: ISENABLED
      PrimaryKeyColumns: PRODUCTID
      PrimaryKeyColumns: SOURCEUNITOFMEASURENAME
      PrimaryKeyColumns: TARGETUNITOFMEASURENAME
      RecordModificationHintStrategy: 'None'
      EDIODBCLinkColumn FACTOR
      {
_Main/BL/EDI/Broker_Broker_OTD_Operation.qbl
@@ -15,6 +15,7 @@
      PrimaryKeyColumns: PlantName
      PrimaryKeyColumns: ProcessSection
      PrimaryKeyColumns: ProductID
      PrimaryKeyColumns: SequenceNumber
      TargetType: MappingOperation
      TypeIndex: MappingOperationTypeIndex
      EDIMLColumn ActualCapacity { Attribute: ActualCapacity ValueType: Real }
_Main/BL/EDI/Broker_Broker_OTD_Product.qbl
@@ -9,6 +9,7 @@
  {
    EDIMLTable MappingProduct
    {
      PrimaryKeyColumns: BusinessType
      PrimaryKeyColumns: ID
      TargetType: MappingProduct
      TypeIndex: MappingProductTypeIndex
_Main/BL/Type_Lane/StaticMethod_CreateLaneFromJson.qbl
@@ -1,7 +1,8 @@
Quintiq file version 2.0
#parent: #root
StaticMethod CreateLaneFromJson (
  JSON datarow
  JSON datarow,
  MacroPlan macroplan
) as Lane
{
  Description: 'Read the json data and use it to create lane data'
@@ -14,6 +15,11 @@
    userleadtime := datarow.Get( "userleadtime" );
    processingtime := Duration::Zero();
    
    unitofmeasurename := "PCS";
    currencyid := "CNY";
    startdate := Date::Date( 1900, 1, 1 );
    enddate := Date::Date( 9999, 12, 31 );
    capacitytype := "Transport quantity";
    if( userleadtime.IsNull() )
    {
      processingtime := Duration::Zero(); 
@@ -24,6 +30,16 @@
      };
    
    unit := Unit::FindUnitTypeIndex( unitid );
    if( isnull( unit)){
      unit :=macroplan.Unit( relnew,
                 ID := unitid,
                 Name := unitid,
                 UnitOfMeasureName := unitofmeasurename,
                 CurrencyID := currencyid,
                 StartDate := startdate,
                 EndDate := enddate,
                 CapacityType := capacitytype );
    }
    
    result := Lane::CreateLane( unit, id, name, processingtime);
    
_Main/BL/Type_MacroPlan/Method_ApiLanesData.qbl
@@ -14,7 +14,7 @@
    for( i:=0; i<data_length; i++ )
    {
      datarow := data.Get( i );
      a := Lane::CreateLaneFromJson( datarow );
      a := Lane::CreateLaneFromJson( datarow ,this);
      updates.Add( a );
      }
    origindataset := selectset( this, Unit.Lane, l, true );
_Main/BL/Type_MacroPlan/Method_DeleteSnaityCheck.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
Quintiq file version 2.0
#parent: #root
Method DeleteSnaityCheck
{
  TextBody:
  [*
    // renhao Sep-13-2023 (created)
    //删除没有汇率的货币
    traverse(  this,Currency_MP,currency,not currency.IsBase() and currency.CurrencyRate_MP( relsize ) = 0 ){
      currency.Delete();
    }
    //删除没有产品的车道
    traverse( this,Unit.Lane,lane,not isnull( lane) and lane.ProductInLane(relsize )=0 ){
      lane.Delete();
    }
    //删除没有用到产品和lane的库存点
    traverse( this,StockingPoint_MP,stock,stock.ProductInStockingPoint_MP(relsize ) = 0 ){
      stock.Delete();
    }
  *]
}
_Main/BL/Type_MacroPlan/Method_InitialUnitAndStockingPoint.qbl
@@ -6,51 +6,111 @@
  [*
    // Administrator Sep-1-2023 (created)
    
    unitOfMeasure_MP := UnitOfMeasure_MP::FindByName( this, "PCS" );
    if ( isnull( unitOfMeasure_MP ) ) {
      unitOfMeasure_MP := UnitOfMeasure_MP::Create( this, "PCS", false, false );
    }
    //Set the Default values
    unitofmeasurename := "PCS";
    currencyid := "CNY";
    startdate := Date::Date( 1900, 1, 1 );
    enddate := Date::Date( 9999, 12, 31 );
    capacitytype := "Transport quantity";
    
    if ( isnull( Unit::FindById( this, "空运" ) ) ) {
      Unit::Create( "空运", this, "空运", unitOfMeasure_MP, null( Unit ), capacitytype, "", null( SupplyChainView ), 0, 0, false );
    }
    if( isnull( Unit::FindById( this, "空运" ) ) ){
      this.Unit( relnew,
                 ID := "空运",
                 Name := "空运",
                 UnitOfMeasureName := unitofmeasurename,
                 CurrencyID := currencyid,
                 StartDate := startdate,
                 EndDate := enddate,
                 CapacityType := capacitytype );
      }
    
    if ( isnull( Unit::FindById( this, "库存事务处理" ) ) ) {
      Unit::Create( "库存事务处理", this, "库存事务处理", unitOfMeasure_MP, null( Unit ), capacitytype, "", null( SupplyChainView ), 0, 0, false );
    if( isnull( Unit::FindById( this, "库存事务处理" ) ) ){
      this.Unit( relnew,
                 ID := "库存事务处理",
                 Name := "库存事务处理",
                 UnitOfMeasureName := unitofmeasurename,
                 CurrencyID := currencyid,
                 StartDate := startdate,
                 EndDate := enddate,
                 CapacityType := capacitytype );
    }
    
    unitofmeasurename := "PCS";
    name := "手动创建库存点";
    currencyname := "CNY";
    isplannedinfinite := false;
    datestart := Date::Construct(1900, 1, 1) ;
    dateend := Date::Construct(9999, 12, 31);
    groupname := " ";
    description := " ";
    isfromdb := true;
    
    if ( isnull( StockingPoint_MP::FindById( this, "F13_FG_STOCK" ) ) ) {
      StockingPoint_MP::Create( "F13_FG_STOCK", this, null( Unit ), "F13_FG_STOCK", null( SupplyChainView ), 0, 0, false );
    if( isnull( StockingPoint_MP::FindById( this, "F13_FG_STOCK" ) ) ){
      StockingPoint_MP::Create( this,
                                "F13_FG_STOCK",
                                "F13",
                                name,
                                unitofmeasurename,
                                currencyname,
                                isplannedinfinite,
                                datestart,
                                dateend,
                                groupname,
                                description,
                                isfromdb );
    }
    
    if ( isnull( StockingPoint_MP::FindById( this, "H10_SA_STOCK" ) ) ) {
      StockingPoint_MP::Create( "H10_SA_STOCK", this, null( Unit ), "H10_SA_STOCK", null( SupplyChainView ), 0, 0, false );
    if( isnull( StockingPoint_MP::FindById( this, "H10_SA_STOCK" ) ) ){
      StockingPoint_MP::Create( this,
                                "H10_SA_STOCK",
                                "H10",
                                name,
                                unitofmeasurename,
                                currencyname,
                                isplannedinfinite,
                                datestart,
                                dateend,
                                groupname,
                                description,
                                isfromdb );
    }
    
    if ( isnull( StockingPoint_MP::FindById( this, "Q10_FG_STOCK" ) ) ) {
      StockingPoint_MP::Create( "Q10_FG_STOCK", this, null( Unit ), "Q10_FG_STOCK", null( SupplyChainView ), 0, 0, false );
    if( isnull( StockingPoint_MP::FindById( this, "Q10_FG_STOCK" ) ) ){
      StockingPoint_MP::Create( this,
                                "Q10_FG_STOCK",
                                "Q10",
                                name,
                                unitofmeasurename,
                                currencyname,
                                isplannedinfinite,
                                datestart,
                                dateend,
                                groupname,
                                description,
                                isfromdb );
    }
    
    if ( isnull( Currency_MP::FindById( this, "CNY" ) ) ) {
      Currency_MP::Create( "CNY", this, "CNY", "", false, false );
    }
    existcurrency := Currency_MP::FindById( this, "CNY" );
    if( isnull( existcurrency ) ){
      Currency_MP::CreateCurrency( this, "CNY", "CNY", "", true );
      currency := Currency_MP::FindById( this, "EUR" );
      currency.IsBase(false);
      Transaction::Transaction().Propagate();
      }
    
    isproductcatagory := false;
    isfromdb := false;
    if ( isnull( ProductLevel_MP::FindProductLevelTypeIndex( "1" ) ) ) {
    existproductlevel := ProductLevel_MP::FindProductLevelTypeIndex( "2" );
    if( isnull( existproductlevel ) ){
      ProductLevel_MP::Create( "1", isproductcatagory, this, isfromdb );
    }
    if ( isnull( ProductLevel_MP::FindProductLevelTypeIndex( "2" ) ) ) {
      ProductLevel_MP::Create( "2", isproductcatagory, this, isfromdb );
    }
    if ( isnull( ProductLevel_MP::FindProductLevelTypeIndex( "3" ) ) ) {
      ProductLevel_MP::Create( "3", isproductcatagory, this, isfromdb );
    }
      }
    existsalestlevel := SalesLevel_MP::FindSalesLevelTypeIndex( "2")
    if( isnull( existsalestlevel ) ){
        SalesLevel_MP::Create( "1",this,isfromdb);
        SalesLevel_MP::Create( "2",this,isfromdb);
      }
  *]
}
_Main/BL/Type_MacroPlan/Method_MappingCustomerOrderData.qbl
@@ -17,12 +17,13 @@
    }
    queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
    queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate and item.OrderDate() <= queryEndDate, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
    listToDeal := selectset( listToDeal, Elements, item, item.OrderDate() >= queryStartDate /*and item.OrderDate() <= queryEndDate*/, not isnull( Product_MP::FindById( this, item.ProductID() ) ) and not isnull( StockingPoint_MP::FindById( this, item.StockPointID() ) ) and not isnull( SalesSegment_MP::FindByName( this, item.SalesSegmentName() ) ) );
    
    totalcount := listToDeal.Size();
    info( "CustomerOrder has " + totalcount.AsQUILL() + " rows in total" );
    
    count := 0;
    priorityName :="Normal";
    // å¤„理
    traverse( listToDeal, Elements, item ) {
      count := count + 1;
@@ -33,7 +34,7 @@
    //    info( item.ProductID().AsQUILL() );
      CustomerOrder::CreateOrUpdate( this, item.CurrencyID(), item.Customer(), item.CustomerID(), item.ID(), 
                                     item.OrderDate(), item.OrderID(), item.OrderLineID(), item.Price(), 
                                     item.PriorityName(), item.ProductID(),
                                     priorityName, item.ProductID(),
                                     item.StockPointID(), 
                                     item.SalesSegmentName(), 
                                     item.Quantity(), item.UnitOfMeasureName(), item.OrderType(), item.IsAvailable());
_Main/BL/Type_MacroPlan/Method_MappingExternalSupplyData.qbl
@@ -8,9 +8,11 @@
  TextBody:
  [*
    // renhao Aug-14-2023 (created)
    listtodeal := selectset( this,MappingExternalSupply,externalSupply, true );
    queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
    queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
    listtodeal := selectset( this,MappingExternalSupply,externalSupply, externalSupply.UserQuantity()>0 and externalSupply.Date() >= queryStartDate /*and externalSupply.Date() <= queryEndDate*/);
    totalcount := listtodeal.Size();
    description := "在途在制";
    info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" );
    
    count := 0;
@@ -18,12 +20,14 @@
      count := count + 1;
      if( count - [Number](count/1000) * 1000 = 0 or count = totalcount ){
        info( "Now is dealing with the " + count.AsQUILL() + "ExternalSupply " + "( " + count.AsQUILL() + "/" + totalcount.AsQUILL() + " ) " + (count/totalcount*100).Round( 1 ).AsQUILL() + "%" );
        }
      product := select( this,MappingProduct,product,product.ID() = externalSupply.ProductID() and product.KeyProduct() = nuclear,true);
       }
      product := select( this,MappingProduct,product,product.ID() = externalSupply.ProductID(),true);
      
      if( not isnull( product)){
        productMP :=  select( this,Product_MP,productMP,productMP.ID() = externalSupply.ProductID() ,true);
        productMP :=  Product_MP :: FindProductTypeIndex( externalSupply.ProductID());
        stockingpoint := select( this,StockingPoint_MP,st,st.ID() = externalSupply.StockingPointID(),true);
        if( not isnull( stockingpoint) and not isnull( productMP)){
        if( not isnull(businessTypes)){
        
          for( i :=0 ;i < businessTypes.Size();i++ ){
@@ -34,25 +38,23 @@
                                               stockingpoint,
                                               externalSupply.Date(),
                                               externalSupply.ManufacturedDate(),
                                               externalSupply.UserQuantity(),"在途在制");
                                               externalSupply.UserQuantity(),description);
            }
          }
          
        }else{
        if( not isnull( stockingpoint) and not isnull( productMP)){
          InventorySupply::CreateOrUpdate( externalSupply.ID(),
            InventorySupply::CreateOrUpdate( externalSupply.ID(),
                                           productMP,
                                           stockingpoint,
                                           externalSupply.Date(),
                                           externalSupply.ManufacturedDate(),
                                           externalSupply.UserQuantity(),"在途在制");
        }
                                           externalSupply.UserQuantity(),description);
          }
      
        }
        
      }else{
        info( "Invaild product" );
        }
      }
    }
  *]
}
_Main/BL/Type_MacroPlan/Method_MappingForecastData.qbl
@@ -11,9 +11,9 @@
    // å¾…处理数据
    listToDeal := construct( structured[MappingForecast] );
    if( isnull( businessTypes ) or businessTypes.Size() = 0 ) {
        listToDeal := selectset( this, MappingForecast, item, true );
        listToDeal := selectset( this, MappingForecast, item, item.Quantity() > 0 );
    } else {
        listToDeal := selectset( this, MappingForecast, item, businessTypes.Find( item.BusinessType() ) <> -1 );
        listToDeal := selectset( this, MappingForecast, item, businessTypes.Find( item.BusinessType() ) <> -1 and item.Quantity()>0 );
    }
    queryStartDate := guard( min( this, Period_MP, item, true, item.StartDate() ) - Duration::Days( 30 ), DateTime::MinDateTime() ).Date();
    queryEndDate := guard( max( this, Period_MP, item, true, item.EndDate() ), Date::MaxDate() );
@@ -23,6 +23,7 @@
    info( "Forecast has " + totalcount.AsQUILL() + " rows in total" );
    
    count := 0;
    priorityName := "Normal";
    // å¤„理
    traverse( listToDeal, Elements, item ) {
      count := count + 1;
@@ -31,7 +32,7 @@
        }
    //  if( not isnull( Product_MP::FindById( this, item.ProductID() ) ) ){
      Forecast::CreateOrUpdate( this, 
                                item.ProductID(), item.SalesSegmentName(), item.StockingPointID(), item.PriorityName(),
                                item.ProductID(), item.SalesSegmentName(), item.StockingPointID(), priorityName,
                                item.CurrencyID(), item.UnitOfMeasureName(),
                                item.ID(), item.StartDate(), item.EndDate(), item.Quantity(), item.Price());
    //  }else{
_Main/BL/Type_MacroPlan/Method_MappingOperationBOMData.qbl
@@ -12,16 +12,17 @@
    
    keyProductList := construct( Strings );
    if( isKeyProduct ) {
        keyProductList := selectuniquevalues( this, MappingProduct, item, item.KeyProduct(), item.ID() );
        keyProductList := selectuniquevalues( this, MappingProduct, item, item.ProductMajorType()="成品" or item.ProductMajorType()="半成品", item.ID() );
    }
    bomList := selectsortedset(  this, MappingBOM, item,
                                 ifexpr( isnull( businessTypes ) or businessTypes.Size() = 0, 
                                         true, 
    //                                     businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 )
                                         businessTypes.Find( item.BusinessType() ) >= 0 )
                                 and ifexpr( isKeyProduct,
                                             keyProductList.Size() > 0 and keyProductList.Find( item.ComponentCode() ) >= 0,
                                             true ),
    //                             and ifexpr( isKeyProduct,
    //                                         keyProductList.Size() > 0 and keyProductList.Find( item.ComponentCode() ) >= 0,
    //                                         true )
                                 ,
                                 item.OrganCode() + "_" + item.ProductCode() + "_" + item.ProcessSection() );
    // æŒ‰routing及routingStep分组
    routingIds := selectuniquevalues( bomList, Elements, item, true, item.OrganCode() + "_" + item.ProductCode() );
@@ -29,14 +30,16 @@
        routingRows := selectset( bomList, Elements, item, true, routingId = item.OrganCode() + "_" + item.ProductCode() );
        if( routingRows.Size() > 0 ) {
            firstRow := routingRows.Element( 0 );
            stockingPointId := firstRow.OrganCode()  + "_" + firstRow.ProductType() + "_Stock";
            inputStockingPointId := firstRow.OrganCode()  + "_" + firstRow.ComponentType() + "_Stock";
    //        stockingPointId := firstRow.OrganCode()  + "_" + firstRow.ProductType() + "_Stock";
    //        inputStockingPointId := firstRow.OrganCode()  + "_" + firstRow.ComponentType() + "_Stock";
            stockingPointId := firstRow.OrganCode()  + "_Stock";
            // ========检查========
            product := Product_MP::FindProductTypeIndex( firstRow.ProductCode() );
            if( not isnull( product ) ) {
    //              error( "product : " + firstRow.ProductCode() + " not found" );
              stockingPoint := StockingPoint_MP::FindStockingPointTypeIndex( stockingPointId );
              inputStockingPoint := StockingPoint_MP::FindStockingPointTypeIndex(  inputStockingPointId );
    //          info( stockingPointId.AsQUILL() );
      //        if( isnull( stockingPoint ) ) {
      //            error( "stockingPoint : " + stockingPointId + " not found" );
@@ -55,8 +58,14 @@
                  // ========分组处理输入========
                  
                }
                if( not isnull( inputStockingPoint)){
                  this.MappingOperationBOMDataRouting( routing,routingRows,inputStockingPoint,keyProductList);
                if( not isnull( stockingPoint)){
                  if( isKeyProduct){
                      keyRows := selectset( routingRows,Elements,routingrow,keyProductList.Find( routingrow.ComponentCode())>=0);
                      this.MappingOperationBOMDataRouting( routing,keyRows);
                    }else{
                      this.MappingOperationBOMDataRouting( routing,routingRows);
                    }
                }
              }
           }
@@ -64,9 +73,9 @@
    }
    if( createPurchaseSupplyMaterial ) {
        toCreateBomList := selectuniquevalues( bomList, Elements, item, 
                                               item.ProductType() = "P", item.OrganCode() + item.ComponentCode());
                                               item.ComponentType() = "P", item.OrganCode() + item.ComponentCode());
        traverse( toCreateBomList, Elements, key ) {
            boms := selectset( bomList, Elements, item, item.ProductType() = "P" and item.OrganCode() + item.ComponentCode() = key );
            boms := selectset( bomList, Elements, item, item.ComponentType() = "P" and item.OrganCode() + item.ComponentCode() = key );
            bom := boms.First();
            this.MappingOperationBOMDataSupplyPurchase( bom.OrganCode(), bom.ComponentCode(), bom.ComponentType());
        }
_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataRouting#576.qbl
@@ -2,9 +2,7 @@
#parent: #root
Method MappingOperationBOMDataRouting (
  Routing routing,
  MappingBOMs routingRows,
  StockingPoint_MP stockingPoint,
  Strings keyProductIds
  MappingBOMs routingRows
)
{
  TextBody:
@@ -32,6 +30,9 @@
                  if( not isnull( component ) ) {
    //                  error( "component : " + noAlterRow.ComponentCode() + " not found" );
                  // è¿žæŽ¥äº§å“ä¸Žoperation
    //              inputStockingPointId := noAlterRow.OrganCode()  + "_" + noAlterRow.ComponentType() + "_Stock";
                  inputStockingPointId := noAlterRow.OrganCode() + "_Stock";
                  stockingPoint := StockingPoint_MP::FindStockingPointTypeIndex( inputStockingPointId);
                  pisp := ProductInStockingPoint_MP::CreateIfNotFound( component, stockingPoint );
                  trash := construct( OperationBOMs );
                  operationBOM := toLink.LinkProduct( component, true, BaseOperationLink::GetGroupID( toLink, true, false ), pisp, 
@@ -54,6 +55,9 @@
    //          }
                traverse( routingStep, Operation, toLink ) {
                    // è¿žæŽ¥äº§å“ä¸Žoperation
    //                inputStockingPointId := firstAlterRow.OrganCode()  + "_" + firstAlterRow.ComponentType() + "_Stock";
                    inputStockingPointId := firstAlterRow.OrganCode() + "_Stock";
                    stockingPoint := StockingPoint_MP::FindStockingPointTypeIndex( inputStockingPointId);
                    pisp := ProductInStockingPoint_MP::CreateIfNotFound( component, stockingPoint );
                    trash := construct( OperationBOMs );
                    mainBOM := toLink.LinkProduct( component, true, BaseOperationLink::GetGroupID( toLink, true, false ), pisp, 
@@ -67,13 +71,15 @@
                        alterProd := Product_MP::FindById( this, alterRow.AlternativeMaterialCode() );
                        if( not isnull( alterProd ) ) {
        //                    error( "alterProd : " + alterRow.AlternativeMaterialCode() + " not found" );
                          stockingPointIdAlter := alterRow.OrganCode()  + "_" + alterRow.ProductType() + "_Stock";
    //                      stockingPointIdAlter := alterRow.OrganCode()  + "_" + alterRow.ComponentType() + "_Stock";
                          stockingPointIdAlter := alterRow.OrganCode() + "_Stock";
                          stockingPointAlter := StockingPoint_MP::FindById( this, stockingPointIdAlter );
                          if( isnull( stockingPointAlter ) ) {
                              error( "stockingPoint : " + stockingPointIdAlter + " not found" );
                          }
                          pispAlter := ProductInStockingPoint_MP::CreateIfNotFound( alterProd, stockingPointAlter );
                          mainInput := toLink.LastOperationInput();
                          //mainInput := toLink.LastOperationInput();
                          mainInput := select( toLink,OperationInput,operationInut,operationInut.ProductID()=alterRow.ComponentCode());
                          trash := construct( OperationBOMs );
                          if( not isnull( mainInput ) ) {
                              alterBom := mainInput.Operation().LinkPISP( pispAlter, true, mainInput.OperationLinkGroupID(), trash );
_Main/BL/Type_MacroPlan/Method_MappingOperationBOMDataSupplyPurchase.qbl
@@ -8,25 +8,26 @@
{
  TextBody:
  [*
    routingId := "PR_"+orgCode + "_" + productId;
    unitId := "供应商";
    routingStepName := "Purchase";
    operationId := orgCode + "_PR_" + productId;
    routing := Routing::CreateOrUpdate( this, routingId );
    toDeleteSteps := selectset( routing, RoutingStep, routingStep, true );
    RoutingStep::Delete( toDeleteSteps );
    routingStep := RoutingStep::Create( routing, routingStepName, "", true );
    product := Product_MP::FindById( this, productId );
    if( isnull( product ) ) {
        info(  "product : " + productId + " not found" );
    }
    stockingPointId := orgCode + "_" + productType + "_Stock";
    stockingPointId := orgCode + "_Stock";
    stockingPoint := StockingPoint_MP::FindById( this, stockingPointId );
    if( isnull( stockingPoint ) ) {
        info( "stockingPoint : " + stockingPointId + " not found" );
    }
    
    if( not isnull( product) and not isnull( stockingPoint)){
      routingId := "PR_"+orgCode + "_" + productId;
      unitId := "供应商";
      routingStepName := "Purchase";
      operationId := orgCode + "_PR_" + productId;
      routing := Routing::CreateOrUpdate( this, routingId );
      toDeleteSteps := selectset( routing, RoutingStep, routingStep, true );
      RoutingStep::Delete( toDeleteSteps );
      routingStep := RoutingStep::Create( routing, routingStepName, "", true );
      unit := Unit::FindById( this, unitId );
      if( isnull( unit ) ) {
        unit := this.Unit( relnew, 
_Main/BL/Type_MacroPlan/Method_MappingOperationCostData.qbl
@@ -27,7 +27,7 @@
                          moperation.ProductID() = item.ProductID(), 
                          moperation.SequenceNumber() ).SequenceNumber()
      if( item.SequenceNumber() = maxsn ){
        listtodealwithmaxsn.Add( item );
          listtodealwithmaxsn.Add( item );
        }
      }
    
_Main/BL/Type_MacroPlan/Method_MappingProductData.qbl
@@ -10,7 +10,7 @@
  [*
    // Administrator Aug-16-2023 (created)
    // list to deal
    //info( "Get list to deal of product" );
    info( "Get list to deal of product" );
    listToDeal := construct( structured[MappingProduct] );
    
    if( isnull( businesstypes ) or businesstypes.Size() = 0 ) {
@@ -22,10 +22,10 @@
          }
    } else {
        if( iskeyproduct = true ){
          listToDeal := selectset( this, MappingProduct, item, item.KeyProduct() = true,  businesstypes.Find(  item.BusinessType()) > 0 );
          }
          listToDeal := selectset( this, MappingProduct, item, item.KeyProduct() = true and businesstypes.Find(  item.BusinessType()) >= 0 );
         }
        else{
        listToDeal := selectset( this, MappingProduct, item, businesstypes.Find(  item.BusinessType()) > 0 );
          listToDeal := selectset( this, MappingProduct, item, businesstypes.Find(  item.BusinessType()) >= 0 );
        }
    }
    totalcount := listToDeal.Size();
@@ -38,7 +38,7 @@
                                "全部物料产品", 
                                "PCS", 
                                "全部物料产品",
                                0.0
                                0.0,false,false
                                );
    count := 0;
    // Get the ProductMajorType list & ProductSubclassType list
@@ -54,7 +54,7 @@
                                    item.ProductMajorType(), 
                                    "PCS", 
                                    item.ProductMajorType(),
                                    0.0
                                    0.0,false,false
                                    );
      }
      productmajortype := item.ProductMajorType();
@@ -62,29 +62,30 @@
        productmajortype := "全部物料产品";
        }
       
      if( not item.ProductSubclassType() = "" ){
        Product_MP::CreateOrUpdate( this,
                                    item.ProductSubclassType(),
                                    productmajortype,
                                    item.ProductSubclassType(),
                                    "PCS",
                                    item.ProductSubclassType(),
                                    0.0
                                    );
        }
      productsubclasstype := item.ProductSubclassType();
      if( productsubclasstype="" ){
        productsubclasstype := productmajortype;
        }
    //  if( not item.ProductSubclassType() = "" ){
    //    Product_MP::CreateOrUpdate( this,
    //                                item.ProductSubclassType(),
    //                                productmajortype,
    //                                item.ProductSubclassType(),
    //                                "PCS",
    //                                item.ProductSubclassType(),
    //                                0.0,false,false
    //                                );
    //    }
    //  productsubclasstype := item.ProductSubclassType();
    //  if( productsubclasstype="" ){
    //      productsubclasstype := productmajortype;
    //    }
      
      if( not item.ID() = "" ){
          Product_MP::CreateOrUpdate( this, 
                                      item.ID(), 
                                      productsubclasstype,
                                      productmajortype,
                                      item.ID(), 
                                      item.UnitOfMeasureName(), 
                                      item.Name(),
                                      item.ShelfLife()
                                      item.ShelfLife(),
                                      item.KeyProduct(),item.IsCommon()
                                      );
        }
      }
_Main/BL/Type_MacroPlan/Method_MappingUnitData.qbl
@@ -22,6 +22,7 @@
    
    //Set the Default values
    unitofmeasurename := "PCS";
    infinite := "Infinite";
    capacitytype := "Transport quantity";
    
    // Get the root data
@@ -29,7 +30,7 @@
                          "天马集团", 
                          "天马集团", 
                          "", 
                          capacitytype,
                          infinite,
                          unitofmeasurename );
    
    // Get the sub root data
@@ -37,14 +38,14 @@
                          "生产", 
                          "生产", 
                          "天马集团", 
                          capacitytype,
                          infinite,
                          unitofmeasurename );
    
    Unit::CreateOrUpdate( this, 
                          "供应商", 
                          "供应商", 
                          "天马集团", 
                          capacitytype,
                          infinite,
                          unitofmeasurename );
    
    Unit::CreateOrUpdate( this, 
@@ -65,7 +66,7 @@
                            item.OrganCode(), 
                            OrgName, 
                            "生产", 
                            capacitytype,
                            infinite,
                            unitofmeasurename );
                           
      //Get the second level unit
@@ -74,7 +75,7 @@
                            secondlevelid, 
                            secondlevelid, 
                            item.OrganCode(), 
                            capacitytype,
                            infinite,
                            unitofmeasurename );
        
      //Get the third level unit
_Main/BL/Type_MacroPlan/StaticMethod_DoSync0.qbl
@@ -140,6 +140,9 @@
    // è®¢å•需求-18
    CustomerOrder::DoSync( macroPlan, businessTypes );
    
    //删除多余报错数据-19
    macroPlan.DeleteSnaityCheck();
    //// todo ä¾›åº”商能力
    //info( "ProviderCapacity::DoSync" )
    
_Main/BL/Type_MappingOperation/Attribute_SequenceNumber.qbl
@@ -3,5 +3,6 @@
Attribute SequenceNumber
{
  #keys: '3[412960.0.86978408][412960.0.86978407][412960.0.86978409]'
  IsReadOnly: true
  ValueType: Number
}
_Main/BL/Type_MappingOperation/TypeIndex_MappingOperationTypeIndex.qbl
@@ -6,11 +6,7 @@
  [
    TypeIndexAttribute
    {
      ModelElement: Line
    }
    TypeIndexAttribute
    {
      ModelElement: BusinessType
      ModelElement: ProcessSection
    }
    TypeIndexAttribute
    {
@@ -18,7 +14,11 @@
    }
    TypeIndexAttribute
    {
      ModelElement: OrganCode
      ModelElement: BusinessType
    }
    TypeIndexAttribute
    {
      ModelElement: Line
    }
    TypeIndexAttribute
    {
@@ -26,7 +26,11 @@
    }
    TypeIndexAttribute
    {
      ModelElement: ProcessSection
      ModelElement: SequenceNumber
    }
    TypeIndexAttribute
    {
      ModelElement: OrganCode
    }
  ]
}
_Main/BL/Type_MappingProduct/Attribute_BusinessType.qbl
@@ -3,5 +3,6 @@
Attribute BusinessType
{
  #keys: '3[414480.0.61560268][414480.0.61560267][414480.0.61560269]'
  IsReadOnly: true
  ValueType: String
}
_Main/BL/Type_MappingProduct/TypeIndex_MappingProductTypeIndex.qbl
@@ -8,5 +8,9 @@
    {
      ModelElement: ID
    }
    TypeIndexAttribute
    {
      ModelElement: BusinessType
    }
  ]
}
_Main/BL/Type_Product_MP/Attribute_BusinessTypeCommon.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
Quintiq file version 2.0
#parent: #root
Attribute BusinessTypeCommon
{
  #keys: '3[414480.0.138606036][414480.0.138606035][414480.0.138606037]'
  ValueType: Boolean
}
_Main/BL/Type_Product_MP/Attribute_KeyProduct.qbl
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,7 @@
Quintiq file version 2.0
#parent: #root
Attribute KeyProduct
{
  #keys: '3[414480.0.138606008][414480.0.138606007][414480.0.138606009]'
  ValueType: Boolean
}
_Main/BL/Type_Product_MP/StaticMethod_CreateOrUpdate.qbl
@@ -7,7 +7,9 @@
  String name,
  String unitofmeasurename,
  String description,
  Real shelflife
  Real shelflife,
  Boolean keyproduct,
  Boolean businesstypecommon
)
{
  TextBody:
@@ -28,7 +30,7 @@
    //info( productid );
    
    if( isnull( product ) ){
      Product_MP::Create( owner,
      product := Product_MP::Create( owner,
                          productid, 
                          parentid, 
                          name, 
@@ -44,6 +46,9 @@
                          isexcludedfromfulfilmentkpis, 
                          isfromdb
                          );
        product.KeyProduct(keyproduct);
        product.BusinessTypeCommon(businesstypecommon);
      }else{
        product.Update( productid, 
                        name, 
@@ -60,6 +65,8 @@
                        isexcludedfromfulfilmentkpis, 
                        isfromdb
                        );
          product.KeyProduct(keyproduct);
          product.BusinessTypeCommon(businesstypecommon);
        }
  *]
}