* Fix bug#25004.

This commit is contained in:
xieqiyu
2022-07-27 21:38:28 +08:00
parent cd8247954c
commit 0ec68feb10
4 changed files with 37 additions and 31 deletions
+2 -2
View File
@@ -1271,14 +1271,14 @@ class productModel extends model
}
/* Compute totalReal and progress. */
$this->loadModel('project');
$progressList = $this->loadModel('project')->getWaterfallProgress(array_keys($hours));
foreach($hours as $projectID => $hour)
{
$hour->totalEstimate = round($hour->totalEstimate, 1) ;
$hour->totalConsumed = round($hour->totalConsumed, 1);
$hour->totalLeft = round($hour->totalLeft, 1);
$hour->totalReal = $hour->totalConsumed + $hour->totalLeft;
$hour->progress = $projects[$projectID]->model == 'waterfall' ? $this->project->getWaterfallProgress($projectID) : ($hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 2) * 100 : 0);
$hour->progress = $projects[$projectID]->model == 'waterfall' ? $progressList[$projectID] : ($hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 2) * 100 : 0);
}
/* Get the number of project teams. */
+2 -2
View File
@@ -96,8 +96,8 @@
<td class="text-right" title="<?php echo $project->hours->totalEstimate . ' ' . $lang->execution->workHour;?>"><?php echo $project->hours->totalEstimate . $lang->execution->workHourUnit;?></td>
<td class="text-right" title="<?php echo $project->hours->totalConsumed . ' ' . $lang->execution->workHour;?>"><?php echo $project->hours->totalConsumed . $lang->execution->workHourUnit;?></td>
<td>
<div class='progress-pie' data-doughnut-size='90' data-color='#3CB371' data-value='<?php echo $project->hours->progress;?>' data-width='24' data-height='24' data-back-color='#e8edf3'>
<div class='progress-info'><?php echo $project->hours->progress;?></div>
<div class='progress-pie' data-doughnut-size='90' data-color='#3CB371' data-value='<?php echo round($project->hours->progress);?>' data-width='24' data-height='24' data-back-color='#e8edf3'>
<div class='progress-info'><?php echo round($project->hours->progress);?></div>
</div>
</td>
</tr>
+2 -2
View File
@@ -1434,14 +1434,14 @@ class programModel extends model
}
/* Compute totalReal and progress. */
$this->loadModel('project');
$progressList = $this->loadModel('project')->getWaterfallProgress(array_keys($hours));
foreach($hours as $projectID => $hour)
{
$hour->totalEstimate = round($hour->totalEstimate, 1) ;
$hour->totalConsumed = round($hour->totalConsumed, 1);
$hour->totalLeft = round($hour->totalLeft, 1);
$hour->totalReal = $hour->totalConsumed + $hour->totalLeft;
$hour->progress = $projects[$projectID]->model == 'waterfall' ? $this->project->getWaterfallProgress($projectID) : ($hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 2) * 100 : 0);
$hour->progress = $projects[$projectID]->model == 'waterfall' ? $progressList[$projectID] : ($hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 2) * 100 : 0);
}
/* Get the number of left tasks. */
+31 -25
View File
@@ -396,42 +396,48 @@ class projectModel extends model
/**
* Get waterfall project progress.
*
* @param int $projectID
* @param array $projectIDList
* @access public
* @return int
*/
public function getWaterfallProgress($projectID)
public function getWaterfallProgress($projectIDList)
{
$executions = $this->loadModel('execution')->getByProject($projectID);
$projectList = $this->dao->select('t1.*')->from(TABLE_EXECUTION)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.type')->in('stage')
->andWhere('t1.deleted')->eq('0')
->andWhere('t1.vision')->eq($this->config->vision)
->andWhere('t1.project')->in($projectIDList)
->andWhere('t2.model')->eq('waterfall')
->fetchGroup('project', 'id');
$totalHour = $this->dao->select('execution, ROUND(SUM(`left`), 2) AS totalLeft, ROUND(SUM(consumed), 1) AS totalConsumed')->from(TABLE_TASK)
->where('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->andWhere('parent')->lt(1)
->groupBy('execution')
->fetchAll('execution');
$totalHour = $this->dao->select('t1.project, t1.execution, ROUND(SUM(if(t1.status !="closed" && t1.status !="cancel", `left`, 0)), 2) AS totalLeft, ROUND(SUM(consumed), 1) AS totalConsumed')->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id')
->where('t2.project')->in(array_keys($projectList))
->andWhere('t1.deleted')->eq(0)
->andWhere('t1.parent')->lt(1)
->groupBy('t1.execution')
->fetchGroup('project', 'execution');
$closedTotalLeft = $this->dao->select('execution, ROUND(SUM(`left`), 2) AS totalLeft')->from(TABLE_TASK)
->where('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->andWhere('parent')->lt(1)
->andWhere('status')->in('closed,cancel')
->groupBy('execution')
->fetchPairs('execution');
$progress = 0;
foreach($executions as $executionID => $execution)
$progressList = array();
foreach($projectList as $projectID => $stageList)
{
$executionClosedLeft = isset($closedTotalLeft[$executionID]) ? $closedTotalLeft[$executionID] : 0;
$executionTotalConsumed = isset($totalHour[$executionID]) ? $totalHour[$executionID]->totalConsumed : 0;
$executionTotalLeft = isset($totalHour[$executionID]) ? round($totalHour[$executionID]->totalLeft - $executionClosedLeft, 1) : 0;
$progress = 0;
foreach($stageList as $stageID => $stage)
{
if($stage->project != $projectID) continue;
$executionProgress = ($executionTotalConsumed + $executionTotalLeft) ? floor($executionTotalConsumed / ($executionTotalConsumed + $executionTotalLeft) * 1000) / 1000 * 100 : 0;
$stageTotalConsumed = isset($totalHour[$projectID][$stageID]) ? $totalHour[$projectID][$stageID]->totalConsumed : 0;
$stageTotalLeft = isset($totalHour[$projectID][$stageID]) ? round($totalHour[$projectID][$stageID]->totalLeft, 1) : 0;
$progress += $executionProgress * ($execution->percent / 100);
$stageProgress = ($stageTotalConsumed + $stageTotalLeft) ? floor($stageTotalConsumed / ($stageTotalConsumed + $stageTotalLeft) * 1000) / 1000 * 100 : 0;
$progress += $stageProgress * ($stage->percent / 100);
}
$progressList[$projectID] = $progress;
}
return $progress;
return is_numeric($projectIDList) ? $progressList[$projectIDList] : $progressList;
}
/**