* Finish task#99200.

This commit is contained in:
qixinzhi
2023-08-08 07:31:22 +00:00
parent 903e848d30
commit a9232f21b8
2 changed files with 49 additions and 9 deletions
@@ -1,7 +1,7 @@
<?php
/**
* 按项目统计的已投入人天。
* day_of_invested_in_project.
* Day of invested in project.
*
* 范围:project
* 对象:effort
@@ -9,7 +9,7 @@
* 度量名称:按项目统计的已投入人天
* 单位:人天
* 描述:按项目统计的已投入人天是指项目总共投入的工作天数。该度量项可以用来评估项目的人力资源投入情况。投入总人天的增加可能意味着项目投入的工作时间和资源的增加。
* 定义:复用:;按项目统计的日志记录的工时总数;公式:;按项目统计的已投入人天=按项目统计的项目内所有消耗工时数/后台配置的每日可用工时
* 定义:复用:;按项目统计的日志记录的工时总数;公式:;按项目统计的已投入人天=按项目统计的项目内所有消耗工时数/后台配置的每日可用工时;
* 度量库:
* 收集方式:realtime
*
@@ -22,21 +22,38 @@
*/
class day_of_invested_in_project extends baseCalc
{
public $dataset = null;
public $result = array();
public $fieldList = array();
public function getStatement()
{
$defaultHours = $this->dao->select('value')
->from(TABLE_CONFIG)
->where('module')->eq('execution')
->andWhere('key')->eq('defaultWorkhours')
->fetch('value');
//public funtion getStatement($dao)
//{
//}
return $this->dao->select("t3.id as project, SUM(t1.consumed) as consumed, $defaultHours as defaultHours")
->from(TABLE_EFFORT)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution=t2.id')
->leftJoin(TABLE_PROJECT)->alias('t3')->on('t2.project=t3.id')
->where('t3.deleted')->eq('0')
->andWhere('t3.type')->eq('project')
->groupBy('t3.id')
->query();
}
public function calculate($row)
{
$project = $row->project;
$consumed = $row->consumed;
$defaultHours = $row->defaultHours;
if(!isset($this->result[$project])) $this->result[$project] = round($consumed / $defaultHours, 2);
}
public function getResult($options = array())
{
$records = $this->getRecords(array('value'));
$records = $this->getRecords(array('project', 'value'));
return $this->filterByOptions($records, $options);
}
}
}
@@ -0,0 +1,23 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('project', $useCommon = true, $levels = 4)->gen(10);
zdTable('project')->config('sprint', $useCommon = true, $levels = 4)->gen(40, false);
zdTable('effort')->config('effort', $useCommon = true, $levels = 4)->gen(1000);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=day_of_invested_in_project
cid=1
pid=1
*/
r(count($calc->getResult())) && p('') && e('5'); // 测试分组数。
r($calc->getResult(array('project' => '7'))) && p('0:value') && e('27.87'); // 测试项目7。