day_of_annual_closed_project.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * 按系统统计的年度已关闭项目投入总人天。
  4. * Day of annual closed project.
  5. *
  6. * 范围:system
  7. * 对象:project
  8. * 目的:hour
  9. * 度量名称:按系统统计的年度已关闭项目投入总人天
  10. * 单位:人天
  11. * 描述:按系统统计的年度已关闭项目投入总人天是指在某年度关闭项目投入的人天总数。该度量项可以用来评估项目的人力资源投入情况。投入总人天的增加可能意味着项目投入的工作时间和资源的增加。
  12. * 定义:复用:;按系统统计的年度关闭项目消耗工时数;公式:;按系统统计的年度关闭项目投入总人天=按系统统计的年度已关闭项目任务的消耗工时数/后台配置的每天可用工时;
  13. *
  14. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author zhouxin <zhouxin@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_annual_closed_project extends baseCalc
  22. {
  23. public $dataset = 'getProjectTasks';
  24. public $fieldList = array('t1.closedDate', 't2.consumed', 't1.id as project', 't1.status');
  25. public $result = array();
  26. public function calculate($data)
  27. {
  28. $project = $data->project;
  29. $consumed = (float)$data->consumed;
  30. $status = $data->status;
  31. $defaultHours = (float)$data->defaultHours;
  32. if($status != 'closed') return false;
  33. $year = $this->getYear($data->closedDate);
  34. if(!$year) return false;
  35. if(!isset($this->result[$year])) $this->result[$year] = array();
  36. if(!isset($this->result[$year][$project])) $this->result[$year][$project] = 0;
  37. $this->result[$year][$project] += $consumed / $defaultHours;
  38. }
  39. public function getResult($options = array())
  40. {
  41. foreach($this->result as $year => $projects)
  42. {
  43. foreach($projects as $project => $days)
  44. {
  45. $this->result[$year][$project] = round($days, 4);
  46. }
  47. }
  48. $records = $this->getRecords(array('year', 'project', 'value'));
  49. return $this->filterByOptions($records, $options);
  50. }
  51. }