diff --git a/module/metric/calc/project/time/left_period_of_project.php b/module/metric/calc/project/time/left_period_of_project.php index cb8b5595c1..7227ff6998 100644 --- a/module/metric/calc/project/time/left_period_of_project.php +++ b/module/metric/calc/project/time/left_period_of_project.php @@ -34,7 +34,7 @@ class left_period_of_project extends baseCalc } else { - $this->result[$row->id] = $row->end - date('Y-m-d'); + $this->result[$row->id] = strtotime($row->end) - strtotime(date('Y-m-d')); } } diff --git a/module/metric/calc/project/time/planned_period_of_project.php.tmp b/module/metric/calc/project/time/planned_period_of_project.php similarity index 81% rename from module/metric/calc/project/time/planned_period_of_project.php.tmp rename to module/metric/calc/project/time/planned_period_of_project.php index 1f6e278539..5e0924757c 100644 --- a/module/metric/calc/project/time/planned_period_of_project.php.tmp +++ b/module/metric/calc/project/time/planned_period_of_project.php @@ -14,7 +14,7 @@ * 收集方式: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) @@ -22,21 +22,18 @@ */ class planned_period_of_project extends baseCalc { - public $dataset = null; + public $dataset = 'getAllProjects'; - public $fieldList = array(); - - //public funtion getStatement($dao) - //{ - //} + public $fieldList = array('id', 'begin', 'end'); public function calculate($row) { + $this->result[$row->id] = (strtotime($row->end) - strtotime($row->begin))/86400; } public function getResult($options = array()) { - $records = $this->getRecords(array('value')); + $records = $this->getRecords(array('project', 'value')); return $this->filterByOptions($records, $options); } -} \ No newline at end of file +} diff --git a/module/metric/test/calc/project/time/planned_period_of_project.php b/module/metric/test/calc/project/time/planned_period_of_project.php new file mode 100644 index 0000000000..d9b06c6401 --- /dev/null +++ b/module/metric/test/calc/project/time/planned_period_of_project.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +config('project_status', $useCommon = true, $levels = 4)->gen(100); + +$metric = new metricTest(); +$calc = $metric->calcMetric(__FILE__); + +/** + +title=planed_period_of_project +cid=1 +pid=1 + +*/ + +r(count($calc->getResult())) && p('') && e('100'); // 测试分组数。 + +r($calc->getResult(array('project' => 1))) && p('0:value') && e('365'); // 测试项目1的计划工期 +r($calc->getResult(array('project' => 2))) && p('0:value') && e('365'); // 测试项目2的计划工期 +r($calc->getResult(array('project' => 3))) && p('0:value') && e('365'); // 测试项目3的计划工期 diff --git a/module/metric/test/yaml/project_status.yaml b/module/metric/test/yaml/project_status.yaml index 850095bf5e..22e41210b8 100644 --- a/module/metric/test/yaml/project_status.yaml +++ b/module/metric/test/yaml/project_status.yaml @@ -19,6 +19,14 @@ fields: range: "20110101 000000-20210101 230000:10D" type: timestamp format: YYYY-MM-DD hh:mm:ss +- field: begin + range: "20100101 000000-20210101 230000:10D" + type: timestamp + format: YYYY-MM-DD +- field: end + range: "20110101 000000-20210101 230000:10D" + type: timestamp + format: YYYY-MM-DD - field: deleted range: 0{100},1{100} ---