文档章节

setDefaultCompany,SysOperationProgress.hide

fandyx
 fandyx
发布于 2015/01/15 11:21
字数 917
阅读 43
收藏 0

当计算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端运行操作,否则进度条有可能不会自动消失。

加上

© 著作权归作者所有

共有 人打赏支持
上一篇: infolog
fandyx
粉丝 0
博文 39
码字总数 11111
作品 0
东莞
技术主管
私信 提问

暂无文章

centos安装confluence全攻略

https://blog.csdn.net/qwer026/article/details/51439076

happyeveryday32
11分钟前
1
0
30 行 Javascript 代码搞定智能家居系统

本文首发于『阿里云 IoT 开发者社区』,更多精彩物联网内容欢迎前往浏览。 智能家居可谓是今年物联网的热门领域,通过智能单品和智能音箱,人们已然把『智能』两个字变成了生活的理所应当。搭...

阿里云官方博客
14分钟前
1
0
sed插入和附加文本基础使用

对于编辑器来说,在数据中增加行算是很基本的操作吧,sed有以下两个操作: 插入(insert)命令(i)会在指定行前增加一个新行 附加(append)命令(a)会在指定行后增加一个新行 还是用下面的文本来测...

woshixin
22分钟前
1
0
HIVE数据倾斜总结

在做Shuffle阶段的优化过程中,遇到了数据倾斜的问题,造成了对一些情况下优化效果不明显。主要是因为在Job完成后的所得到的Counters是整个Job的总和,优化是基于这些Counters得出的平均值,...

瑞查德-Jack
32分钟前
0
0
Pure-ftpd搭建FTP

12月11日任务 15.4 xshell使用xftp传输文件 15.5 使用pure-ftpd搭建ftp服务 使用pure-ftpd搭建FTP服务 轻量的ftp软件 安装pure-ftpd并修改配置文件 # pure-ftpd为epel扩展库里的软件[root...

robertt15
41分钟前
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部