* Finish task#100384.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* 按全局统计的每日日志记录的工时总数。
|
||||
* Hour of daily effort.
|
||||
*
|
||||
* 范围:global
|
||||
* 对象:effort
|
||||
* 目的:hour
|
||||
* 度量名称:按全局统计的每日日志记录的工时总数
|
||||
* 单位:h
|
||||
* 描述:按全局统计的每日日志记录的工时总数是指组织每日实际花费的总工时数。该度量项可以用来评估组织的工时投入情况和对资源的利用效率。较高的消耗工时数可能需要审查工作流程和资源分配,以提高工作效率和进度控制。
|
||||
* 定义:所有日志记录的工时之和;记录时间在某日;
|
||||
* 度量库:
|
||||
* 收集方式:realtime
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @author qixinzhi <qixinzhi@easycorp.ltd>
|
||||
* @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 hour_of_daily_effort extends baseCalc
|
||||
{
|
||||
public $result = array();
|
||||
|
||||
public function getStatement()
|
||||
{
|
||||
return $this->dao->select("year(date) as year, month(date) as month, day(date) as day, sum(consumed) as consumed")
|
||||
->from(TABLE_EFFORT)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('year(date)')->ne('0000')
|
||||
->groupBy('`year`, `month`, `day`')
|
||||
->query();
|
||||
}
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
$year = $row->year;
|
||||
$month = $row->month;
|
||||
$day = $row->day;
|
||||
$consumed = $row->consumed;
|
||||
|
||||
$this->result[$year] = array();
|
||||
$this->result[$year][$month] = array();
|
||||
$this->result[$year][$month][$day] = $consumed;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = $this->getRecords(array('year', 'month', 'day', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('effort')->config('effort', $useCommon = true, $levels = 4)->gen(1000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=hour_of_daily_effort
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('11'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('year' => '2014'))) && p('0:value') && e('7.5'); // 测试2014年。
|
||||
r($calc->getResult(array('year' => '2016'))) && p('0:value') && e('2.5'); // 测试2016年。
|
||||
Reference in New Issue
Block a user