limj
2023-09-21 89c96171bb971dcaed7cf289b58ef44ca689523c
_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());
        }