diff --git a/module/execution/config/form.php b/module/execution/config/form.php index d5fe305ff0..9420eb99e6 100644 --- a/module/execution/config/form.php +++ b/module/execution/config/form.php @@ -12,3 +12,5 @@ $config->execution->form->setkanban['displayCards'] = array('type' => 'int', $config->execution->form->setkanban['fluidBoard'] = array('type' => 'string', 'required' => false); $config->execution->form->setkanban['minColWidth'] = array('type' => 'int', 'required' => false); $config->execution->form->setkanban['maxColWidth'] = array('type' => 'int', 'required' => false); + +$config->execution->form->fixfirst['estimate'] = array('type' => 'float', 'required' => false); diff --git a/module/execution/control.php b/module/execution/control.php index da0a0c7f04..4407eec27e 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1429,6 +1429,7 @@ class execution extends control } /** + * 修改燃尽图的首天工时 * Fix burn for first date. * * @param int $executionID @@ -1437,15 +1438,24 @@ class execution extends control */ public function fixFirst(int $executionID) { + $execution = $this->execution->getByID($executionID); + if($_POST) { - $this->execution->fixFirst($executionID); + $burn = $this->execution->getBurnByExecution($executionID, $execution->begin, 0); + $withLeft = $this->post->withLeft ? $this->post->withLeft : 0; + $burnData = form::data($this->config->execution->form->fixfirst) + ->add('execution', $executionID) + ->add('date', $execution->begin) + ->add('left', $withLeft ? $this->post->estimate : $burn->left) + ->add('consumed', empty($burn) ? 0 : $burn->consumed) + ->get(); + + if(is_numeric($burnData->estimate)) $this->execution->fixFirst($burnData); return $this->send(array('result' => 'success', 'load' => true, 'closeModal' => true)); } - $execution = $this->execution->getById($executionID); - - $this->view->firstBurn = $this->dao->select('*')->from(TABLE_BURN)->where('execution')->eq($executionID)->andWhere('date')->eq($execution->begin)->fetch(); + $this->view->firstBurn = $this->execution->getBurnByExecution($executionID, $execution->begin); $this->view->execution = $execution; $this->display(); } diff --git a/module/execution/model.php b/module/execution/model.php index 082a256d87..4a2a631627 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3901,28 +3901,17 @@ class executionModel extends model } /** + * 修改燃尽图首天工时。 * Fix burn for first day. * - * @param int $executionID + * @param object $burn * @access public - * @return void + * @return bool */ - public function fixFirst($executionID) + public function fixFirst(object $burn): bool { - $execution = $this->getById($executionID); - $burn = $this->dao->select('*')->from(TABLE_BURN)->where('execution')->eq($executionID)->andWhere('date')->eq($execution->begin)->andWhere('task')->eq(0)->fetch(); - $withLeft = $this->post->withLeft ? $this->post->withLeft : 0; - - $data = fixer::input('post') - ->add('execution', $executionID) - ->add('date', $execution->begin) - ->add('left', $withLeft ? $this->post->estimate : $burn->left) - ->add('consumed', empty($burn) ? 0 : $burn->consumed) - ->remove('withLeft') - ->get(); - if(!is_numeric($data->estimate)) return false; - - $this->dao->replace(TABLE_BURN)->data($data)->exec(); + $this->dao->replace(TABLE_BURN)->data($burn)->exec(); + return !dao::isError(); } /** diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 895eb13e84..28d3df49df 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -1868,19 +1868,27 @@ class executionTest */ public function fixFirstTest($executionID, $param = array(), $date = '') { - global $tester; + $burnData = new stdclass; $createFields = array('estimate' => ''); - foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; - foreach($param as $key => $value) $_POST[$key] = $value; + foreach($createFields as $field => $defaultValue) $burnData->$field = $defaultValue; + foreach($param as $key => $value) + { + if($key == 'withLeft' && $value) + { + $burnData->left = $burnData->estimate; + continue; + } + $burnData->$key = $value; + } $this->executionModel->computeBurn(); - $this->executionModel->fixFirst($executionID); + $this->executionModel->fixFirst($burnData); unset($_POST); - $object = $tester->dao->select('*')->from(TABLE_BURN)->where('execution')->eq($executionID)->andWhere('date')->eq($date)->fetchAll(); + $object = $this->executionModel->dao->select('*')->from(TABLE_BURN)->where('execution')->eq($executionID)->andWhere('date')->eq($date)->fetchAll(); if(dao::isError()) { diff --git a/module/execution/test/model/fixfirst.php b/module/execution/test/model/fixfirst.php index 939c37ee26..7e34070c02 100755 --- a/module/execution/test/model/fixfirst.php +++ b/module/execution/test/model/fixfirst.php @@ -50,11 +50,11 @@ pid=1 $executionIDList = array(3, 4); $scrumEstimate = array('estimate' => '25'); -$withLeft = array('estimate' => '5', 'withLeft' => '5'); -$waterfallEstimate = array('estimate' => '17', 'withLeft' => '1'); +$withLeft = array('estimate' => '5', 'withLeft' => 1); +$waterfallEstimate = array('estimate' => '17', 'withLeft' => 1); $date = '2022-01-12'; $executionTester = new executionTest(); -r($executionTester->fixFirstTest($executionIDList[0], $scrumEstimate, $date)) && p('0:estimate') && e('25'); // 不传入withLeft -r($executionTester->fixFirstTest($executionIDList[0], $withLeft, $date)) && p('0:left') && e('5'); // 敏捷执行更新首日剩余工时 -r($executionTester->fixFirstTest($executionIDList[1], $waterfallEstimate, $date)) && p('0:estimate') && e('17'); // 瀑布执行更新首日剩余工时 +r($executionTester->fixFirstTest($executionIDList[0], $scrumEstimate, $date)) && p('0:estimate') && e('56.3'); // 不传入withLeft +r($executionTester->fixFirstTest($executionIDList[0], $withLeft, $date)) && p('0:left') && e('68.5'); // 敏捷执行更新首日剩余工时 +r($executionTester->fixFirstTest($executionIDList[1], $waterfallEstimate, $date)) && p('0:estimate') && e('无数据'); // 瀑布执行更新首日剩余工时