当计算BOM成本结束时,偶尔进度条不会自动消失,用户以为一直还在计算,其实不然。为了修复这个bug, 我们要么在计算成本时禁用“进度条”功能,要么修改一下code。
调用进度条的隐藏方法,但是问题来了,调用hide方法系统会自动触发Appl.setDefaultCompany方法,这个方法会重置当前客户端的公司,造成计算BOM出问题。如何解决呢,我们修改一下计算方法BOMCalcItem.calc。代码如下:
1)参数控制是否显示进度条
A)BOMCalcJob\runBomCalculation
B)BOMCalcItem\newItem\bomCalcItem.parmShowProgress(_showProgress);
/// <summary> /// Runs the BOM calculation for this class. /// </summary> void runBomCalculation() { #OCCRetryCount ; setprefix(BOMCalcJob::description()); if (this.skipItem()) { return; } try { ttsbegin; bomCalcItem = BOMCalcItem::newItem(itemId, inventDimId, // VAR Changed by Colin - Begin BOMParameters::find().YIP_BOMCalcQty ? BOMParameters::find().YIP_BOMCalcQty : this.seriesSize(), // VAR Changed by Colin - End bomId, routeId, profitSet, bomCalcExplosionMode, '', calcDate, bomRouteVersionSelect, // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - Begin /* original !this.calculateAll(), */ false,// 需要参数控制 // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - End versionId ? BOMCalcType::Version : BOMCalcType::Order, versionId, calcCostingVersionUpdate, costPriceTransfer, salesPriceTransfer, bomCalcFallBack, fallBackVersionId, costPriceModel); if(overrideGroupWarnings) { bomCalcItem.parmOverrideGroupWarnings(overrideGroupWarnings); bomCalcItem.parmCheckNoBOM(checkNoBOM); bomCalcItem.parmCheckNoRoute(checkNoRoute); bomCalcItem.parmCheckNoConsump(checkNoConsump); bomCalcItem.parmCheckNoCostPrice(checkNoCostPrice); bomCalcItem.parmCheckAgeCostPrice(checkAgeCostPrice); bomCalcItem.parmCheckMinContribution(checkMinContribution); } bomCalcItem.parmExceptionType(this.parmExceptionType()); bomCalcItem.parmCheckMissingUpdates(checkMissingUpdates); bomCalcItem.parmCheckUseFallBack(checkUseFallBack); bomCalcItem.calc(); bomCalcItem.showInfolog(); // transfer calculation data to inventItemPrice if (bomCalcItem.parmBOMCalcTable()) { bomCalcUpdateItem = BOMCalcUpdateItem::construct(); bomCalcUpdateItem.initFromBuffer(bomCalcItem.parmBOMCalcTable()); bomCalcUpdateItem.initParameters(costPriceTransfer, costPriceInclInUnitPrice, costPriceRoundOff, salesPriceTransfer, salesPriceInclInUnitPrice, salesPriceRoundOff, versionId, calcDate, calcCostingVersionUpdate, siteId); bomCalcUpdateItem.run(); } this.updateParameters(); ttscommit; } catch (Exception::Deadlock) { retry; } catch (Exception::UpdateConflict) { if (appl.ttsLevel() == 0) { if (xSession::currentRetryCount() >= #RetryNum) { throw Exception::UpdateConflictNotRecovered; } else { retry; } } else { throw Exception::UpdateConflict; } } catch (Exception::Error) { if(this.calculateAll()) { throw error(strfmt("@SYS24365", itemId), '', InventTable::infoActionItemId(itemId, inventTable)); } else { throw error("@SYS21990"); } } } //------------------------------------------------------- server static BOMCalcItem newItem( ItemId _itemId, InventDimId _inventDimId, Qty _calcQty, BOMId _bomId, RouteId _routeId, CostProfitSet _profitSet, BOMCalcExplosionMode _bomCalcExplosionMode, PriceCalcId _priceCalcId = '', TransDate _calcDate = systemdateget(), BOMRouteVersionSelect _bomRouteVersionSelect = BOMRouteVersionSelect::Active, boolean _showProgress = false, BOMCalcType _bomCalcType = BOMCalcType::Order, CostingVersionId _costingVersionId = '', BOMCalcCostingVersionUpdate _calcCostingVersionUpdate = BOMCalcCostingVersionUpdate::Overwrite, NoYes _costPriceTransfer = NoYes::No, NoYes _salesPriceTransfer = NoYes::No, BOMCalcFallBack _bomCalcFallBack = BOMCalcFallBack::None, CostingVersionId _fallBackVersionId = '', BOMCostPriceModel _costPriceModel = BOMCostPriceModel::BOMCalcGroup ) { BOMCalcItem bomCalcItem = BOMCalcItem::construct(); InventDim foundInventDim; ; bomCalcItem.parmItemId(_itemId); bomCalcItem.parmInventTable(InventTable::find(_itemId)); foundInventDim = InventDim::find(_inventDimId); bomCalcItem.parmInventDimId(_inventDimId); bomCalcItem.parmInventDim(foundInventDim); if (foundInventDim) bomCalcItem.parmSiteId(foundInventDim.InventSiteId); bomCalcItem.parmCalcConsumptionInventQty(_calcQty); bomCalcItem.parmActualConsumptionInventQty(_calcQty); bomCalcItem.parmActualNetWeightConsumptionInventQty(_calcQty); bomCalcItem.parmBOMId(_bomId); bomCalcItem.parmRouteId(_routeId); bomCalcItem.parmProfitSet(_profitSet); bomCalcItem.parmBomCalcExplosionMode(_bomCalcExplosionMode); bomCalcItem.parmPriceCalcId(_priceCalcId); bomCalcItem.parmCalcDate(_calcDate); bomCalcItem.parmBOMRouteVersionSelect(_bomRouteVersionSelect); bomCalcItem.parmShowProgress(_showProgress); bomCalcItem.parmBOMCalcType(_bomCalcType); bomCalcItem.parmCostingVersionId(_costingVersionId); bomCalcItem.parmCalcCostingVersionUpdate(_calcCostingVersionUpdate); bomCalcItem.parmCostPriceTransfer(_costPriceTransfer); bomCalcItem.parmSalesPriceTransfer(_salesPriceTransfer); bomCalcItem.parmBOMCalcFallBack(_bomCalcFallBack); bomCalcItem.parmFallBackVersionId(_fallBackVersionId); bomCalcItem.parmCostPriceModel(_costPriceModel); return bomCalcItem; }
2)调用进度条的hide方法和重置hide前的公司
void calc() { ListEnumerator listEnumerator; // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - Begin companyId hideBeforeCompanyId, hideAfterCompanyId; // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - End ; try { setprefix(BOMCalcItem::description()); setprefix(strfmt("@SYS24300", itemId)); if(!this.validate()) { throw Exception::Error; } this.init(); //calc BOM setprefix("@SYS28550"); listEnumerator = listBOM.getEnumerator(); // Calculate BOM lines (do not insert transactions now) if(listEnumerator) { if(listEnumerator.moveNext()) { listEnumerator.current().calc(); while(listEnumerator.moveNext()) { listEnumerator.current().calc(); } } } if(level == 0) { if(this.parmExistTradeAgreements()) { this.calcTradeAgreements(); } this.setProgressTotals(); this.recalcBOM(); this.insertBOMCalcTable(); // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - Begin 20150115 if (this.parmShowProgress() && progressBar) { hideBeforeCompanyId = curExt(); progressBar.hide();//这段代码会触发Appl.setDefaultCompany方法重置公司 hideAfterCompanyId = curExt(); if (hideAfterCompanyId != hideBeforeCompanyId) { appl.setDefaultCompany(hideBeforeCompanyId, false); } } // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - End } } catch (Exception::Error) { throw error("@SYS19457"); } } server static BOMCalcItem newItem( ItemId _itemId, InventDimId _inventDimId, Qty _calcQty, BOMId _bomId, RouteId _routeId, CostProfitSet _profitSet, BOMCalcExplosionMode _bomCalcExplosionMode, PriceCalcId _priceCalcId = '', TransDate _calcDate = systemdateget(), BOMRouteVersionSelect _bomRouteVersionSelect = BOMRouteVersionSelect::Active, boolean _showProgress = false, BOMCalcType _bomCalcType = BOMCalcType::Order, CostingVersionId _costingVersionId = '', BOMCalcCostingVersionUpdate _calcCostingVersionUpdate = BOMCalcCostingVersionUpdate::Overwrite, NoYes _costPriceTransfer = NoYes::No, NoYes _salesPriceTransfer = NoYes::No, BOMCalcFallBack _bomCalcFallBack = BOMCalcFallBack::None, CostingVersionId _fallBackVersionId = '', BOMCostPriceModel _costPriceModel = BOMCostPriceModel::BOMCalcGroup ) { BOMCalcItem bomCalcItem = BOMCalcItem::construct(); InventDim foundInventDim; ; bomCalcItem.parmItemId(_itemId); bomCalcItem.parmInventTable(InventTable::find(_itemId)); foundInventDim = InventDim::find(_inventDimId); bomCalcItem.parmInventDimId(_inventDimId); bomCalcItem.parmInventDim(foundInventDim); if (foundInventDim) bomCalcItem.parmSiteId(foundInventDim.InventSiteId); bomCalcItem.parmCalcConsumptionInventQty(_calcQty); bomCalcItem.parmActualConsumptionInventQty(_calcQty); bomCalcItem.parmActualNetWeightConsumptionInventQty(_calcQty); bomCalcItem.parmBOMId(_bomId); bomCalcItem.parmRouteId(_routeId); bomCalcItem.parmProfitSet(_profitSet); bomCalcItem.parmBomCalcExplosionMode(_bomCalcExplosionMode); bomCalcItem.parmPriceCalcId(_priceCalcId); bomCalcItem.parmCalcDate(_calcDate); bomCalcItem.parmBOMRouteVersionSelect(_bomRouteVersionSelect); bomCalcItem.parmShowProgress(_showProgress); ... return bomCalcItem; }
禁用弹出"Changing company accounts to: <company>" infolog warning
boolean setDefaultCompany(selectableDataArea _selectableDataArea, boolean dialog = true) { selectableDataArea thisCompany = curext(); UserInfo userInfo; boolean ret; Currency currency; SysGlobalCache cache = appl.globalCache(); ret = super(_selectableDataArea); if (infolog && infolog.docu()) { infolog.docu().emptyTablesEnabledMap(); infolog.docu().updateFromParameters(); } if (infolog) { infolog.nationalCurrencyPrefix(''); infolog.nationalCurrencyPostfix(''); infolog.nationalCurrencyFactor(1); currency = Currency::find(CompanyInfo::find().CurrencyCode); if (currency) { infolog.isoCurrencyCode(CompanyInfo::find().CurrencyCode); } else { infolog.isoCurrencyCode(''); } } /* Original #define.WarnFlag(0x08) */ // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - Begin //Set the warn flag to 0 to disable the "Changing company accounts to: <company>" infolog warning #define.WarnFlag(0x00) // VAR Changed by Xie Yu Fan.Fandy 谢宇帆 - End if (dialog && new Session().clientKind() != ClientType::COMObject) { if (thisCompany != _selectableDataArea) { if (!cache.get(classstr(Info), identifierstr(Autologoff), false)) { select userInfo where userInfo.Id == curuserid(); if (userInfo && userInfo.GeneralInfo & #warnFlag) warning(strfmt("@SYS53441", _selectableDataArea)); } } } InventDim::findOrCreateBlank(); return ret; }
最后分析得出,其实成本计算时,所有的操作都要在server端运行操作,否则进度条有可能不会自动消失。
加上