文档章节

setDefaultCompany,SysOperationProgress.hide

fandyx
 fandyx
发布于 2015/01/15 11:21
字数 917
阅读 34
收藏 0
点赞 0
评论 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端运行操作,否则进度条有可能不会自动消失。

加上

© 著作权归作者所有

共有 人打赏支持
fandyx
粉丝 0
博文 39
码字总数 11111
作品 0
东莞
技术主管

暂无文章

32.filter表案例 nat表应用 (iptables)

10.15 iptables filter表案例 10.16/10.17/10.18 iptables nat表应用 10.15 iptables filter表案例: ~1. 写一个具体的iptables小案例,需求是把80端口、22端口、21 端口放行。但是,22端口我...

王鑫linux
今天
0
0
shell中的函数&shell中的数组&告警系统需求分析

20.16/20.17 shell中的函数 20.18 shell中的数组 20.19 告警系统需求分析

影夜Linux
今天
0
0
Linux网络基础、Linux防火墙

Linux网络基础 ip addr 命令 :查看网口信息 ifconfig命令:查看网口信息,要比ip addr更明了一些 centos 7默认没安装ifconfig命令,可以使用yum install -y net-tools命令来安装。 ifconfig...

李超小牛子
今天
1
0
[机器学习]回归--Decision Tree Regression

CART决策树又称分类回归树,当数据集的因变量为连续性数值时,该树算法就是一个回归树,可以用叶节点观察的均值作为预测值;当数据集的因变量为离散型数值时,该树算法就是一个分类树,可以很...

wangxuwei
昨天
1
0
Redis做分布式无锁CAS的问题

因为Redis本身是单线程的,具备原子性,所以可以用来做分布式无锁的操作,但会有一点小问题。 public interface OrderService { public String getOrderNo();} public class OrderRe...

算法之名
昨天
9
0
143. Reorder List - LeetCode

Question 143. Reorder List Solution 题目大意:给一个链表,将这个列表分成前后两部分,后半部分反转,再将这两分链表的节点交替连接成一个新的链表 思路 :先将链表分成前后两部分,将后部...

yysue
昨天
1
0
数据结构与算法1

第一个代码,描述一个被称为BankAccount的类,该类模拟了银行中的账户操作。程序建立了一个开户金额,显示金额,存款,取款并显示余额。 主要的知识点联系为类的含义,构造函数,公有和私有。...

沉迷于编程的小菜菜
昨天
1
0
从为什么别的队伍总比你的快说起

在机场候检排队的时候,大多数情况下,别的队伍都要比自己所在的队伍快,并常常懊悔当初怎么没去那个队。 其实,最快的队伍只能有一个,而排队之前并不知道那个队快。所以,如果有六个队伍你...

我是菜鸟我骄傲
昨天
1
0
分布式事务常见的解决方案

随着互联网的发展,越来越多的多服务相互之间的调用,这时候就产生了一个问题,在单项目情况下很容易实现的事务控制(通过数据库的acid控制),变得不那么容易。 这时候就产生了多种方案: ...

小海bug
昨天
3
0
python从零学——scrapy初体验

python从零学——scrapy初体验 近日因为一些事情,需要从网上爬取一些东西,故而想通过使用爬虫来顺便学习下强大的python。现将一些学习中遇到的问题记录下来,以便日后查询 1. 开发环境的准...

咾咔叽
昨天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部