day_of_invested_in_project.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * 按项目统计的已投入人天。
  4. * Day of invested in project.
  5. *
  6. * 范围:project
  7. * 对象:effort
  8. * 目的:hour
  9. * 度量名称:按项目统计的已投入人天
  10. * 单位:人天
  11. * 描述:按项目统计的已投入人天是指项目总共投入的工作天数。该度量项可以用来评估项目的人力资源投入情况。投入总人天的增加可能意味着项目投入的工作时间和资源的增加。
  12. * 定义:复用:;按项目统计的日志记录的工时总数;公式:;按项目统计的已投入人天=按项目统计的项目内所有消耗工时数/后台配置的每日可用工时;
  13. *
  14. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author qixinzhi <qixinzhi@easycorp.ltd>
  16. * @package
  17. * @uses func
  18. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  19. * @Link https://www.zentao.net
  20. */
  21. class day_of_invested_in_project extends baseCalc
  22. {
  23. public $dataset = 'getProjectEfforts';
  24. public $fieldList = array('t2.id as project', 't1.consumed');
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. $project = $row->project;
  29. $consumed = $row->consumed;
  30. $defaultHours = $row->defaultHours;
  31. if(!isset($this->result[$project])) $this->result[$project] = 0;
  32. $this->result[$project] += $defaultHours ? $consumed / $defaultHours : 0;
  33. }
  34. public function getResult($options = array())
  35. {
  36. foreach($this->result as $project => $days)
  37. {
  38. $this->result[$project] = round($days, 2);
  39. }
  40. $records = $this->getRecords(array('project', 'value'));
  41. return $this->filterByOptions($records, $options);
  42. }
  43. }