diff --git a/module/metric/calc/task/rate/rate_of_hour_process_task.php b/module/metric/calc/task/rate/rate_of_hour_process_task.php new file mode 100644 index 0000000000..580d749257 --- /dev/null +++ b/module/metric/calc/task/rate/rate_of_hour_process_task.php @@ -0,0 +1,46 @@ + + * @package + * @uses func + * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) + * @Link https://www.zentao.net + */ +class rate_of_hour_process_task extends baseCalc +{ + public $dataset = ''; + + public $fieldList = array(); + + public $result = array('consumed' => 0, 'left' => 0); + + public function calculate($row) + { + if($row->isParent) return; + + $this->result['consumed'] += $row->consumed; + $this->result['left'] += $row->left; + } + + public function getResult($options = array()) + { + $consumed = $this->result['consumed']; + $left = $this->result['left']; + $rate = $consumed || $left ? round($consumed / ($consumed + $left), 4) : 0; + + $records = array(array('value' => $rate)); + return $this->filterByOptions($records, $options); + } +}