diff --git a/module/metric/calc/global/scale/count_of_annual_closed_top_program.php.tmp b/module/metric/calc/global/scale/count_of_annual_closed_top_program.php similarity index 58% rename from module/metric/calc/global/scale/count_of_annual_closed_top_program.php.tmp rename to module/metric/calc/global/scale/count_of_annual_closed_top_program.php index 30bdc2feb6..6629e42ea9 100644 --- a/module/metric/calc/global/scale/count_of_annual_closed_top_program.php.tmp +++ b/module/metric/calc/global/scale/count_of_annual_closed_top_program.php @@ -10,14 +10,14 @@ * 单位:个 * 描述:按全局统计的年度关闭一级项目集数表示每年结束并关闭的一级项目集的数量。此度量项反映了组织每年关闭的一级项目集数量,可以用于评估组织的项目管理的绩效和成果。 * 定义:所有的一级项目集的个数求和 -关闭时间为某年 -状态为已关闭 -过滤已删除的项目集 + * 关闭时间为某年 + * 状态为已关闭 + * 过滤已删除的项目集 * 度量库: * 收集方式:realtime * * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net) - * @author qixinzhi + * @author zhouxin * @package * @uses func * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) @@ -25,20 +25,25 @@ */ class count_of_annual_closed_top_program extends baseCalc { - public $dataset = null; + public $dataset = 'getTopPrograms'; - public $fieldList = array(); + public $fieldList = array('status', 'closedDate'); - //public funtion getStatement($dao) - //{ - //} - - public function calculate($data) + public function calculate($row) { + if(empty($row->closedDate) or $row->status != 'closed') return; + + $year = substr($row->closedDate, 0, 4); + if($year == '0000') return; + + if(!isset($this->result[$year])) $this->result[$year] = 0; + $this->result[$year] += 1; } public function getResult($options = array()) { - return $this->filterByOptions($this->result, $options); + $records = array(); + foreach($this->result as $year => $value) $records[] = array('year' => $year, 'value' => $value); + return $this->filterByOptions($records, $options); } -} \ No newline at end of file +} diff --git a/module/metric/calc/global/scale/count_of_annual_created_top_program.php.tmp b/module/metric/calc/global/scale/count_of_annual_created_top_program.php similarity index 61% rename from module/metric/calc/global/scale/count_of_annual_created_top_program.php.tmp rename to module/metric/calc/global/scale/count_of_annual_created_top_program.php index 5e5f5a5973..dc3c47b401 100644 --- a/module/metric/calc/global/scale/count_of_annual_created_top_program.php.tmp +++ b/module/metric/calc/global/scale/count_of_annual_created_top_program.php @@ -10,13 +10,13 @@ * 单位:个 * 描述:按全局统计的年度新增一级项目集数表示每年新建立的一级项目集的数量。此度量项反映了组织每年新开展的重要项目集数量,可以用于评估组织的项目管理的扩张和战略规划情况。 * 定义:所有的一级项目集的个数求和 -创建时间为某年 -过滤已删除的项目集 + * 创建时间为某年 + * 过滤已删除的项目集 * 度量库: * 收集方式:realtime * * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net) - * @author qixinzhi + * @author zhouxin * @package * @uses func * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) @@ -24,20 +24,25 @@ */ class count_of_annual_created_top_program extends baseCalc { - public $dataset = null; + public $dataset = 'getTopPrograms'; - public $fieldList = array(); + public $fieldList = array('openedDate'); - //public funtion getStatement($dao) - //{ - //} - - public function calculate($data) + public function calculate($row) { + if(empty($row->openedDate)) return; + + $year = substr($row->openedDate, 0, 4); + if($year == '0000') return; + + if(!isset($this->result[$year])) $this->result[$year] = 0; + $this->result[$year] += 1; } public function getResult($options = array()) { - return $this->filterByOptions($this->result, $options); + $records = array(); + foreach($this->result as $year => $value) $records[] = array('year' => $year, 'value' => $value); + return $this->filterByOptions($records, $options); } -} \ No newline at end of file +}