consume_of_task_in_user.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * 按人员统计任务消耗工时数。
  4. * Count of consumed task in user.
  5. *
  6. * 范围:user
  7. * 对象:task
  8. * 目的:scale
  9. * 度量名称:按人员统计任务消耗工时数
  10. * 单位:小时
  11. * 描述:按人员统计任务消耗工时数表示每个人任务消耗工时数量之和。
  12. * 定义:所有任务消耗工时数求和;
  13. *
  14. * @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  15. * @author Yanyi Cao <caoyanyi@chandao.com>
  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 consume_of_task_in_user extends baseCalc
  22. {
  23. public $dataset = 'getTaskEfforts';
  24. public $fieldList = array();
  25. public $result = array();
  26. public function calculate($row)
  27. {
  28. $account = $row->account;
  29. $consumed = $row->consumed;
  30. if(!isset($this->result[$account])) $this->result[$account] = 0;
  31. $this->result[$account] += $consumed;
  32. }
  33. public function getResult($options = array())
  34. {
  35. foreach($this->result as $account => $consumed) $this->result[$account] = round($consumed, 2);
  36. $records = $this->getRecords(array('user', 'value'));
  37. return $this->filterByOptions($records, $options);
  38. }
  39. }