计算数字字段的Jira错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算数字字段的Jira错误相关的知识,希望对你有一定的参考价值。

我们尝试根据7个变量计算问题内部优先级的WSJF数,这些变量可以在下拉列表中选择(自定义字段)。

计算有效,可以看到带有wsjf数的计算数字字段。但该公式似乎在某种程度上在日志中产生不断的错误,我们的jira实例甚至因为日志文件变得如此大而崩溃。

计算公式为:

 <!-- @@Formula:

    //Constants
    var a = 0.3; // Strategical alignment (sa) and Revenue potential (rp) are weighted 30%
    var b = 0.2; // Saving potential (sp) and competitive advantage (ca) are weighted 20%
    var x = 2; // Is the factor for the weight of "business value" (bv) in the model
    var y = 1; // Is the factor for the weight of the "loss of value" (lv) in the model
    var z = 1; // Is the factor for the weight of the "capacity increase" (ci) in the model

    //Variables for business value
    var sa = Integer.parseInt(issue.get("customfield_11631") != null ? issue.get("customfield_11631") : 0);
    var rp = Integer.parseInt(issue.get("customfield_11632") != null ? issue.get("customfield_11632") : 0);
    var sp = Integer.parseInt(issue.get("customfield_11633") != null ? issue.get("customfield_11633") : 0);
    var ca = Integer.parseInt(issue.get("customfield_11634") != null ? issue.get("customfield_11634"): 0);
    var bv = (sa+rp)*a + (sp+ca)*b;

    //Variables for loss of value over time
    var lv = Integer.parseInt(issue.get("customfield_11635") != null ? issue.get("customfield_11635") : 0);

    //Variables for capacity increase
    var ci = Integer.parseInt(issue.get("customfield_11636") != null ? issue.get("customfield_11636") : 0);

    //Variables for investment
    var in = Integer.parseInt(issue.get("customfield_11637") != null ? (issue.get("customfield_11637") : 0);

    //WSJF calculation
    var wsjf = (x*bv+y*lv+z*ci)/in;

       return wsjf;

    -->

日志文件中的错误如下所示:

2015-05-06 14:16:40,133 http-bio-443-exec-866 ERROR Andreas Kundert 856x2705040x1 41jq3d 192.168.37.39:63202,192.168.211.105 /secure/AjaxIssueAction.jspa [innovalog.jmcf.fields.CalculatedNumberField] CalculatedNumberField: error evaluating formula of field "WSJF (automated)" of issue BI-24: 
Sourced file: inline evaluation of: ``    //Constants  var a = 0.3; // Strategical alignment (s) and Revenue potential . . . '' : Typed variable declaration : Method Invocation Integer.parseInt : at Line: 11 : in file: inline evaluation of: ``    //Constants  var a = 0.3; // Strategical alignment (s) and Revenue potential . . . '' : Integer .parseInt ( issue .get ( "customfield_11631" ) ) 

要么

CalculatedNumberField: error evaluating formula of field "WSJF (automated)" of issue LIAR-101: 
Sourced file: inline evaluation of: ``    //Constants  var a = 0.3; // Strategical alignment (s) and Revenue potential . . . '' : Typed variable declaration : Error in method invocation: Static method parseInt( int ) not found in class'java.lang.Integer' : at Line: 11 : in file: inline evaluation of: ``    //Constants  var a = 0.3; // Strategical alignment (s) and Revenue potential . . . '' : Integer .parseInt ( issue .get ( "customfield_11631" ) != null ? issue .get ( "customfield_11631" ) : 0 ) 
答案

int i = (issue.get("customfield_11631") != null ? Integer.parseInt(issue.get("customfield_11631").toString()) : 0)让它发挥作用。非常感谢@ThePavolC

以上是关于计算数字字段的Jira错误的主要内容,如果未能解决你的问题,请参考以下文章

jira增加字段选项出错

使用 JQL 执行搜索时,Jira REST 错误“字段 'project' 的值 'XXX' 不存在。”]

获取 JIRA 中问题的自定义/默认字段的 Java 程序

Jira Api对接:提交缺陷

使用 jira 中的 REST api 修改自定义字段名称后,CustomFieldManager 未获取自定义字段

10个JavaScript代码片段,使你更加容易前端开发。