day_of_daily_effort.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * 按系统统计的每日投入总人天。
  4. * Day 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 day_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. $defaultHours = $row->defaultHours;
  35. $dayPerson = round($consumed / $defaultHours, 2);
  36. if(!isset($this->result[$year])) $this->result[$year] = array();
  37. if(!isset($this->result[$year][$month])) $this->result[$year][$month] = array();
  38. if(!isset($this->result[$year][$month][$day])) $this->result[$year][$month][$day] = 0;
  39. $this->result[$year][$month][$day] += $dayPerson;
  40. }
  41. public function getResult($options = array())
  42. {
  43. $records = $this->getRecords(array('year', 'month', 'day', 'value'));
  44. return $this->filterByOptions($records, $options);
  45. }
  46. }