rate_of_hour_process_task.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * 按系统统计的任务进度。
  4. * Rate of task process.
  5. *
  6. * 范围:system
  7. * 对象:task
  8. * 目的:rate
  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 rate_of_hour_process_task extends baseCalc
  22. {
  23. public $dataset = '';
  24. public $fieldList = array();
  25. public $result = array('consumed' => 0, 'left' => 0);
  26. public function calculate($row)
  27. {
  28. if($row->isParent) return;
  29. $this->result['consumed'] += $row->consumed;
  30. if($row->status != 'closed' && $row->status != 'cancel') $this->result['left'] += $row->left;
  31. }
  32. public function getResult($options = array())
  33. {
  34. $consumed = $this->result['consumed'];
  35. $left = $this->result['left'];
  36. $rate = $consumed || $left ? round($consumed / ($consumed + $left), 4) : 0;
  37. $records = array(array('value' => $rate));
  38. return $this->filterByOptions($records, $options);
  39. }
  40. }