diff --git a/module/bi/config/metrics.php b/module/bi/config/metrics.php index 37a5fb316e..5de74bcb60 100644 --- a/module/bi/config/metrics.php +++ b/module/bi/config/metrics.php @@ -4439,6 +4439,20 @@ $config->bi->builtin->metrics[] = array 'definition' => "执行中新增Bug个数求和\n解决方案为已解决,延期处理和不予解决或状态为激活\n过滤已删除的Bug\n过滤已删除的执行\n过滤已删除的项目\n过滤已删除的产品\n" ); +$config->bi->builtin->metrics[] = array +( + 'name' => '按执行统计的执行关闭时已交付的研发需求规模数', + 'alias' => '执行关闭时已交付研发需求规模数', + 'code' => 'scale_of_delivered_story_in_closed_execution', + 'purpose' => 'scale', + 'scope' => 'execution', + 'object' => 'story', + 'unit' => 'hour', + 'dateType' => 'nodate', + 'desc' => '按执行统计的执行关闭时已交付研发需求规模数表示执行关闭时需求阶段为已发布或状态为已关闭且关闭原因为已完成的研发需求的规模。该度量项反映了执行结束时能够交付给用户的研发需求的规模,可以用于评估执行团队的研发需求交付能力。', + 'definition' => "执行关闭时,满足以下条件的执行中研发需求规模数求和,条件是:所处阶段为已发布或关闭原因为已完成\n过滤已删除的研发需求\n过滤已删除的执行\n过滤已删除的项目\n过滤已删除的产品\n" +); + $config->bi->builtin->metrics[] = array ( 'name' => '按执行统计的来源Bug的任务消耗工时占比', diff --git a/module/metric/calc/execution/scale/scale_of_delivered_story_in_closed_execution.php b/module/metric/calc/execution/scale/scale_of_delivered_story_in_closed_execution.php new file mode 100644 index 0000000000..31b67f1374 --- /dev/null +++ b/module/metric/calc/execution/scale/scale_of_delivered_story_in_closed_execution.php @@ -0,0 +1,48 @@ + + * @package + * @uses func + * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) + * @Link https://www.zentao.net + */ +class scale_of_delivered_story_in_closed_execution extends baseCalc +{ + public $dataset = 'getDevStoriesWithExecution'; + + public $fieldList = array('t4.id as execution', 't1.id', 't1.estimate', 't4.closedDate as executionClosed', 't1.closedDate as storyClosedDate', 't1.releasedDate as storyReleasedDate', 't1.stage', 't1.closedReason'); + + public $result = array(); + + public function calculate($row) + { + // 如果项目的关闭时间大于等于需求的发布时间 + $condition1 = (!helper::isZeroDate($row->executionClosed) && !helper::isZeroDate($row->storyReleasedDate) && $row->executionClosed >= $row->storyReleasedDate); + // 如果项目的关闭时间大于等于需求的关闭时间且需求的关闭原因为已完成 + $condition2 = (!helper::isZeroDate($row->executionClosed) && !helper::isZeroDate($row->storyClosedDate) && $row->executionClosed >= $row->storyClosedDate && $row->closedReason == 'done'); + + if($condition1 || $condition2) + { + if(!isset($this->result[$row->execution])) $this->result[$row->execution] = 0; + $this->result[$row->execution] += $row->estimate; + } + } + + public function getResult($options = array()) + { + $records = $this->getRecords(array('execution', 'value')); + return $this->filterByOptions($records, $options); + } +} diff --git a/module/metric/test/calc/execution/scale/scale_of_delivered_story_in_closed_execution.php b/module/metric/test/calc/execution/scale/scale_of_delivered_story_in_closed_execution.php new file mode 100644 index 0000000000..0b02a66d5b --- /dev/null +++ b/module/metric/test/calc/execution/scale/scale_of_delivered_story_in_closed_execution.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +loadYaml('product', true, 4)->gen(10); +zendata('project')->loadYaml('project_type', true, 4)->gen(100); +zendata('story')->loadYaml('story_closeddate', true, 4)->gen(1000); +zendata('projectstory')->loadYaml('executionstory', true, 4)->gen(1000); + + +$metric = new metricTest(); +$calc = $metric->calcMetric(__FILE__); + +r(count($calc->getResult())) && p('') && e('6'); // 测试分组数。 + +r($calc->getResult(array('project' => '4'))) && p('0:value') && e('10'); // 测试项目4。 diff --git a/module/metric/test/yaml/story_closeddate.yaml b/module/metric/test/yaml/story_closeddate.yaml new file mode 100644 index 0000000000..1565d8a1aa --- /dev/null +++ b/module/metric/test/yaml/story_closeddate.yaml @@ -0,0 +1,28 @@ +--- +title: zt_story +author: qixinzhi +version: "1.0" +fields: +- field: id + range: 1-10000 +- field: product + range: 1-10{70} +- field: estimate + range: 1-10{70} +- field: openedDate + range: "20100101 000000-20120101 230000:10D" + type: timestamp + format: YYYY-MM-DD hh:mm:ss +- field: closedDate + range: "20110101 000000-20120101 230000:10D" + type: timestamp + format: YYYY-MM-DD hh:mm:ss +- field: closedReason + range: bydesign{1},cancel{1},done{1},duplicate{1},postponed{1},subdivided{1},willnotdo{1},done{1} +- field: status + range: changing{7},active{7},draft{7},reviewing{7},closed{7} +- field: type + range: story +- field: deleted + range: 0{35},1{35} +...