Update Dosync method for organcode
对可添加组织编码过滤的部分添加了过滤,值得数以的是对于部分无组织编码但有库存点ID的数据时也了库存点ID的前3位作为组织编码
| | |
| | | TextBody: |
| | | [* |
| | | // renhao Aug-14-2023 (created) |
| | | listtodeal := selectset( globalOTDTable,Global_MappingActualProductInStockingPointInPeriod,actual,actual.ActualInventoryLevelEnd() > 0 ); |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | listtodeal := selectset( globalOTDTable, |
| | | Global_MappingActualProductInStockingPointInPeriod, |
| | | actual, |
| | | ( actual.ActualInventoryLevelEnd() > 0 ) and |
| | | ( organcodelist.Find( actual.StockingPointID().SubString( 0, 3 ) ) >= 0 ) ); |
| | | totalcount := listtodeal.Size(); |
| | | info( "ActualPISPIP has " + totalcount.AsQUILL() + " rows in total" ); |
| | | |
| | |
| | | if( not isnull(businessTypes)){ |
| | | |
| | | for( i :=0 ;i < businessTypes.Size();i++ ){ |
| | | businessType := businessTypes.Element( i); |
| | | businessType := businessTypes.Element( i ); |
| | | if( product.BusinessType() = businessType and not product.IsCommon()){ |
| | | ActualProductInStockingPointInPeriod::CreateOrUpdate( this, |
| | | actual.ProductID(), |
| | |
| | | if( isnull( businessTypes ) or businessTypes.Size() = 0 ) { |
| | | listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, true ); |
| | | } else { |
| | | listToDeal := selectset( globalOTDTable, Global_MappingCustomOrder, item, businessTypes.Find( item.BusinessType() ) <> -1 ); |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | listToDeal := selectset( globalOTDTable, |
| | | Global_MappingCustomOrder, |
| | | item, |
| | | ( businessTypes.Find( item.BusinessType() ) <> -1 ) and |
| | | ( organcodelist.Find( item.StockingPointID().SubString( 0, 3 ) ) >= 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() ); |
| | |
| | | // renhao Aug-14-2023 (created) |
| | | 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( globalOTDTable,Global_MappingInventorySupply,externalSupply, externalSupply.UserQuantity()>0 and externalSupply.Date() >= queryStartDate /*and externalSupply.Date() <= queryEndDate*/); |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | listtodeal := selectset( globalOTDTable, |
| | | Global_MappingInventorySupply, |
| | | externalSupply, |
| | | ( externalSupply.UserQuantity()>0 ) and |
| | | ( externalSupply.Date() >= queryStartDate ) and |
| | | ( organcodelist.Find( externalSupply.StockingPointID().SubString( 0, 3 ) ) >= 0 )/*and externalSupply.Date() <= queryEndDate*/); |
| | | totalcount := listtodeal.Size(); |
| | | description := "在途在制"; |
| | | info( "ExternalSupply has " + totalcount.AsQUILL() + " rows in total" ); |
| | |
| | | if( not isnull(businessTypes)){ |
| | | |
| | | for( i :=0 ;i < businessTypes.Size();i++ ){ |
| | | businessType := businessTypes.Element( i); |
| | | businessType := businessTypes.Element( i ); |
| | | if( product.BusinessType() = businessType and not product.IsCommon()){ |
| | | InventorySupply::CreateOrUpdate( externalSupply.ID(), |
| | | productMP, |
| | |
| | | if( isnull( businessTypes ) or businessTypes.Size() = 0 ) { |
| | | listToDeal := selectset( globalOTDTable, Global_MappingForecast, item, item.Quantity() > 0 ); |
| | | } else { |
| | | listToDeal := selectset( globalOTDTable, Global_MappingForecast, item, businessTypes.Find( item.BusinessType() ) <> -1 and item.Quantity()>0 ); |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | listToDeal := selectset( globalOTDTable, |
| | | Global_MappingForecast, |
| | | item, |
| | | ( businessTypes.Find( item.BusinessType() ) <> -1 ) and |
| | | ( item.Quantity()>0 ) and |
| | | ( organcodelist.Find( item.StockingPointID().SubString( 0, 3 ) ) >= 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() ); |
| | |
| | | if( isKeyProduct ) { |
| | | keyProductList := selectuniquevalues( globalOTDTable, Global_MappingProduct_MP, item, item.ProductMajorType()="成品" or item.ProductMajorType()="半成品", item.ID() ); |
| | | } |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | bomList := selectsortedset( globalOTDTable, Global_MappingOperationBOM, item, |
| | | ifexpr( isnull( businessTypes ) or businessTypes.Size() = 0, |
| | | true, |
| | | // businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 ) |
| | | businessTypes.Find( item.BusinessType() ) >= 0 ) |
| | | ( businessTypes.Find( item.BusinessType() ) >= 0 ) and |
| | | ( organcodelist.Find( item.OrganCode() ) >= 0 ) ) |
| | | // and ifexpr( isKeyProduct, |
| | | // keyProductList.Size() > 0 and keyProductList.Find( item.ComponentCode() ) >= 0, |
| | | // true ) |
| | |
| | | Quintiq file version 2.0 |
| | | #parent: #root |
| | | Method MappingOperationCostData ( |
| | | GlobalOTDTable globalOTDTable, |
| | | Strings businesstypes |
| | | ) |
| | | { |
| | |
| | | if( isnull( businesstypes ) or businesstypes.Size() = 0 ) { |
| | | listtodeal := selectset( this, MappingOperation, item, true ); |
| | | } else { |
| | | listtodeal := selectset( this, MappingOperation, item, businesstypes.Find( item.BusinessType() ) <> -1 ); |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businesstypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | listtodeal := selectset( this, |
| | | MappingOperation, |
| | | item, |
| | | ( businesstypes.Find( item.BusinessType() ) <> -1 ) and |
| | | ( organcodelist.Find( item.OrganCode() ) >= 0 ) ); |
| | | } |
| | | |
| | | // Get the list to deal with max sequence number |
| | |
| | | // 获取有序的待处理记录 |
| | | toDealList := construct( Global_MappingOperations ) ; |
| | | if( not isnull( businessTypes ) and businessTypes.Size() > 0 ) { |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businessTypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | toDealList := selectsortedset( globalOTDTable, Global_MappingOperation, item, |
| | | businessTypes.Find( item.BusinessType() ) >= 0, |
| | | ( businessTypes.Find( item.BusinessType() ) >= 0 ) and |
| | | ( organcodelist.Find( item.OrganCode() ) >= 0 ), |
| | | // businessTypes.Difference( businessTypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0, |
| | | item.SequenceNumber() ); |
| | | } else { |
| | |
| | | } |
| | | } else { |
| | | if( iskeyproduct = true ){ |
| | | listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, item.KeyProduct() = true and businesstypes.Find( item.BusinessType()) >= 0 ); |
| | | listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, item.KeyProduct() = true and businesstypes.Find( item.BusinessType() ) >= 0 ); |
| | | } |
| | | else{ |
| | | listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, businesstypes.Find( item.BusinessType()) >= 0 ); |
| | | listToDeal := selectset( globalOTDTable, Global_MappingProduct_MP, item, businesstypes.Find( item.BusinessType() ) >= 0 ); |
| | | } |
| | | } |
| | | totalcount := listToDeal.Size(); |
| | |
| | | if( isnull( businessTypes ) or businessTypes.Size() = 0 ) { |
| | | listToDeal := selectset( globalOTDTable, Global_MappingSalesSegment_MP, item, true ); |
| | | } else { |
| | | listToDeal := selectset( globalOTDTable, Global_MappingSalesSegment_MP, item, businessTypes.Find( item.BusinessType() ) <> -1 ); |
| | | listToDeal := selectset( globalOTDTable, |
| | | Global_MappingSalesSegment_MP, |
| | | item, |
| | | businessTypes.Find( item.BusinessType() ) <> -1 ); |
| | | } |
| | | //nameList := construct( structured[String] ); |
| | | //nameList := selectvalues( listToDeal, Elements, item, true, item.Name() ); |
| | |
| | | if( isnull( businesstypes ) or businesstypes.Size() = 0 ) { |
| | | listtodeal := selectset( globalOTDTable, Global_MappingOperation, item, true ); |
| | | } else { |
| | | organcodelist := selectvalues( globalOTDTable, BusinessType.OrganCode, organ, businesstypes.Find( organ.BusinessType().BusinessTypeName() ) <> -1, organ.OrganCodeName() ); |
| | | listtodeal := selectset( globalOTDTable, Global_MappingOperation, item, |
| | | // businesstypes.Difference( businesstypes.Difference( item.BusinessType().Tokenize( ", " ) ) ).Size() > 0 |
| | | businesstypes.Find( item.BusinessType() ) >= 0 |
| | | ( businesstypes.Find( item.BusinessType() ) >= 0 ) and |
| | | ( organcodelist.Find( item.OrganCode() ) >= 0 ) |
| | | ); |
| | | } |
| | | |
| | |
| | | |
| | | // todo 制造成本-16 |
| | | info( "InventoryCost Finished, Start OperationCost Mapping" ); |
| | | macroPlan.MappingOperationCostData( businessTypes ); |
| | | macroPlan.MappingOperationCostData( globalOTDTable, businessTypes ); |
| | | |
| | | // 订单预测-17 |
| | | Forecast::DoSync( macroPlan, businessTypes ,globalOTDTable); |