hour_of_daily_effort.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * 按系统统计的每日日志记录的工时总数。
  4. * Hour of daily effort.
  5. *
  6. * 范围:system
  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 hour_of_daily_effort extends baseCalc
  22. {
  23. public $dataset = 'getEfforts';
  24. public $fieldList = array('t1.date', 't1.consumed');
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. $date = $row->date;
  29. $year = $this->getYear($date);
  30. if(!$year) return false;
  31. $month = substr($date, 5, 2);
  32. $day = substr($date, 8, 2);
  33. $consumed = $row->consumed;
  34. if(!isset($this->result[$year])) $this->result[$year] = array();
  35. if(!isset($this->result[$year][$month])) $this->result[$year][$month] = array();
  36. if(!isset($this->result[$year][$month][$day])) $this->result[$year][$month][$day] = 0;
  37. $this->result[$year][$month][$day] += $consumed;
  38. }
  39. public function getResult($options = array())
  40. {
  41. $records = $this->getRecords(array('year', 'month', 'day', 'value'));
  42. return $this->filterByOptions($records, $options);
  43. }
  44. }