| | |
| | | firstAlterRow := alterRows.Element( 0 ); |
| | | // 检查主料 |
| | | component := Product_MP::FindById( this, firstAlterRow.ComponentCode() ); |
| | | if( isnull( component ) ) { |
| | | error( "component : " + firstAlterRow.ComponentCode() + " not found" ); |
| | | } |
| | | traverse( routingStep, Operation, toLink ) { |
| | | // 连接产品与operation |
| | | pisp := ProductInStockingPoint_MP::CreateIfNotFound( component, stockingPoint ); |
| | | trash := construct( OperationBOMs ); |
| | | mainBOM := toLink.LinkProduct( component, true, BaseOperationLink::GetGroupID( toLink, true, false ), pisp, |
| | | true, trash ); |
| | | mainBOM.Quantity( firstAlterRow.UnitUsageOfComponents() / firstAlterRow.ComponentOutputRate() ); |
| | | mainBOM.MaxQuantityInGroup( firstAlterRow.UnitUsageOfComponents() / firstAlterRow.ComponentOutputRate() ); |
| | | mainQty := mainBOM.Quantity(); |
| | | Transaction::Transaction().Propagate(); |
| | | // 添加辅料 |
| | | traverse( alterRows, Elements, alterRow ) { |
| | | alterProd := Product_MP::FindById( this, alterRow.AlternativeMaterialCode() ); |
| | | if( not isnull( alterProd ) ) { |
| | | // error( "alterProd : " + alterRow.AlternativeMaterialCode() + " not found" ); |
| | | stockingPointIdAlter := alterRow.OrganCode() + "_" + alterRow.ProductType() + "_STOCK"; |
| | | stockingPointAlter := StockingPoint_MP::FindById( this, stockingPointIdAlter ); |
| | | if( isnull( stockingPointAlter ) ) { |
| | | error( "stockingPoint : " + stockingPointIdAlter + " not found" ); |
| | | } |
| | | pispAlter := ProductInStockingPoint_MP::CreateIfNotFound( alterProd, stockingPointAlter ); |
| | | mainInput := toLink.LastOperationInput(); |
| | | trash := construct( OperationBOMs ); |
| | | if( not isnull( mainInput ) ) { |
| | | alterBom := mainInput.Operation().LinkPISP( pispAlter, true, mainInput.OperationLinkGroupID(), trash ); |
| | | alterBom.Quantity( mainBOM.MaxQuantityInGroup() * alterRow.AlternativeRate() ); |
| | | alterBom.MaxQuantityInGroup( mainBOM.MaxQuantityInGroup() ); |
| | | info( "Quantity" + [String]alterBom.Quantity() ) |
| | | info( "MaxQuantityInGroup" + [String]alterBom.MaxQuantityInGroup() ) |
| | | mainQty := mainQty - alterBom.Quantity(); |
| | | } |
| | | } |
| | | mainBOM.Quantity( mainQty ); |
| | | } |
| | | if( not isnull( component ) ) { |
| | | // error( "component : " + firstAlterRow.ComponentCode() + " not found" ); |
| | | // } |
| | | traverse( routingStep, Operation, toLink ) { |
| | | // 连接产品与operation |
| | | pisp := ProductInStockingPoint_MP::CreateIfNotFound( component, stockingPoint ); |
| | | trash := construct( OperationBOMs ); |
| | | mainBOM := toLink.LinkProduct( component, true, BaseOperationLink::GetGroupID( toLink, true, false ), pisp, |
| | | true, trash ); |
| | | mainBOM.Quantity( firstAlterRow.UnitUsageOfComponents() / firstAlterRow.ComponentOutputRate() ); |
| | | mainBOM.MaxQuantityInGroup( firstAlterRow.UnitUsageOfComponents() / firstAlterRow.ComponentOutputRate() ); |
| | | mainQty := mainBOM.Quantity(); |
| | | Transaction::Transaction().Propagate(); |
| | | // 添加辅料 |
| | | traverse( alterRows, Elements, alterRow ) { |
| | | alterProd := Product_MP::FindById( this, alterRow.AlternativeMaterialCode() ); |
| | | if( not isnull( alterProd ) ) { |
| | | // error( "alterProd : " + alterRow.AlternativeMaterialCode() + " not found" ); |
| | | stockingPointIdAlter := alterRow.OrganCode() + "_" + alterRow.ProductType() + "_STOCK"; |
| | | stockingPointAlter := StockingPoint_MP::FindById( this, stockingPointIdAlter ); |
| | | if( isnull( stockingPointAlter ) ) { |
| | | error( "stockingPoint : " + stockingPointIdAlter + " not found" ); |
| | | } |
| | | pispAlter := ProductInStockingPoint_MP::CreateIfNotFound( alterProd, stockingPointAlter ); |
| | | mainInput := toLink.LastOperationInput(); |
| | | trash := construct( OperationBOMs ); |
| | | if( not isnull( mainInput ) ) { |
| | | alterBom := mainInput.Operation().LinkPISP( pispAlter, true, mainInput.OperationLinkGroupID(), trash ); |
| | | alterBom.Quantity( mainBOM.MaxQuantityInGroup() * alterRow.AlternativeRate() ); |
| | | alterBom.MaxQuantityInGroup( mainBOM.MaxQuantityInGroup() ); |
| | | info( "Quantity" + [String]alterBom.Quantity() ) |
| | | info( "MaxQuantityInGroup" + [String]alterBom.MaxQuantityInGroup() ) |
| | | mainQty := mainQty - alterBom.Quantity(); |
| | | } |
| | | } |
| | | mainBOM.Quantity( mainQty ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |