Merge branch dev/bug-62939 of zentao/zentaopms (#8954)

This commit is contained in:
刘刚
2025-05-28 13:42:18 +08:00
committed by Gitfox
5 changed files with 48 additions and 42 deletions
+10 -1
View File
@@ -614,7 +614,16 @@ class docZen extends doc
{
$execution = $this->loadModel('execution')->getByID($objectID);
$objects = $this->execution->getPairs($execution->project, 'all', "multiple,leaf,noprefix");
$objects = $this->execution->resetExecutionSorts($objects, array(), $execution->project);
$parentExecutions = $childExecutions = array();
$executions = $this->execution->fetchExecutionList($execution->project, 'all', 0, 0, 'order_asc');
foreach($executions as $execution)
{
if($execution->grade == 1) $parentExecutions[$execution->id] = $execution;
if($execution->grade > 1 && $execution->parent) $childExecutions[$execution->parent][$execution->id] = $execution;
}
$objects = $this->execution->resetExecutionSorts($objects, $parentExecutions, $childExecutions);
}
elseif($objectType == 'product')
{
+2 -2
View File
@@ -2753,11 +2753,11 @@ class execution extends control
foreach($executions as $execution)
{
if($execution->grade == 1) $topExecutions[$execution->id] = $execution->id;
if($execution->grade > 1 && $execution->parent) $parentExecutions[$execution->parent] = $execution->parent;
if($execution->grade > 1 && $execution->parent) $parentExecutions[$execution->parent][$execution->id] = $execution;
}
/* 获取排序后的执行列表,并给每个执行设置团队信息。*/
$executions = $this->execution->resetExecutionSorts($executions, $topExecutions);
$executions = $this->execution->resetExecutionSorts($executions, $topExecutions, $parentExecutions);
foreach($executions as $execution)
{
$execution->teams = zget($teams, $execution->id, array());
+10 -15
View File
@@ -5168,33 +5168,28 @@ class executionModel extends model
*
* @param array $executions
* @param array $parentExecutions
* @param int $projectID
* @param array $childExecutions
* @access public
* @return array
*/
public function resetExecutionSorts(array $executions, array $parentExecutions = array(), int $projectID = 0): array
public function resetExecutionSorts(array $executions, array $parentExecutions = array(), array $childExecutions = array()): array
{
if(empty($executions)) return array();
if(empty($parentExecutions))
if(empty($parentExecutions) && empty($childExecutions))
{
$execution = current($executions);
$projectID = isset($execution->project) ? $execution->project : $projectID;
$parentExecutions = $this->dao->select('*')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->andWhere('type')->in('kanban,sprint,stage')
->andWhere('grade')->eq(1)
->andWhere('project')->eq($projectID)
->orderBy('order_asc')
->fetchAll('id');
foreach($executions as $execution)
{
if($execution->grade == 1) $parentExecutions[$execution->id] = $execution;
if($execution->grade > 1 && $execution->parent) $childExecutions[$execution->parent][$execution->id] = $execution;
}
}
$sortedExecutions = array();
foreach($parentExecutions as $executionID => $execution)
{
if(!isset($sortedExecutions[$executionID]) and isset($executions[$executionID])) $sortedExecutions[$executionID] = $executions[$executionID];
$children = $this->getChildExecutions($executionID, 'order_asc');
if(!empty($children)) $sortedExecutions += $this->resetExecutionSorts($executions, $children);
if(!empty($childExecutions[$executionID])) $sortedExecutions += $this->resetExecutionSorts($executions, $childExecutions[$executionID], $childExecutions);
}
return $sortedExecutions;
}
@@ -2633,30 +2633,18 @@ class executionTest
* @access public
* @return string
*/
public function resetExecutionSortsTest(int $projectID, string $type = ''): string
public function resetExecutionSortsTest(int $projectID): string
{
$executions = array();
$executionIDList = '';
$firstGradeExecutions = array();
if($projectID)
{
$executions = $this->executionModel->dao->select('*')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->andWhere('project')->eq($projectID)
->andWhere('type')->in('sprint,stage,kanban')
->orderBy('order_asc')
->fetchAll('id');
$executions = $this->executionModel->dao->select('*')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->andWhere('project')->eq($projectID)
->andWhere('type')->in('sprint,stage,kanban')
->orderBy('order_asc')
->fetchAll('id');
if($type == 'hasParent')
{
foreach($executions as $execution)
{
if($execution->grade == 1) $firstGradeExecutions[$execution->id] = $execution->id;
}
}
}
$executions = $this->executionModel->resetExecutionSorts($executions, $firstGradeExecutions);
$executions = $this->executionModel->resetExecutionSorts($executions);
if(!empty($executions))
{
$executionIDList = array_keys($executions);
@@ -27,11 +27,25 @@ title=测试executionModel->resetExecutionSorts();
timeout=0
cid=1
- 检查没有执行时的排序 @0
- 检查项目 2 的执行排序 @3,5,7,8,6,4
- 检查项目 60 的执行排序 @106,112,107,113,108,114,109,115,110,116,111,117
- 检查项目 61 的执行排序 @118,119,120,121,122,123
- 检查项目 100 的执行排序 @124,125,126
*/
$projectList = array(0, 2);
$projectList = array(0, 2, 60, 61, 100);
$executionTester = new executionTest();
r($executionTester->resetExecutionSortsTest($projectList[0])) && p() && e('0'); // 检查没有执行时的排序
r($executionTester->resetExecutionSortsTest($projectList[1])) && p() && e('3,5,7,8,6,4'); // 检查有执行时的排序
r($executionTester->resetExecutionSortsTest($projectList[1], 'hasParent')) && p() && e('3,5,7,8,6,4'); // 检查有执行并且传parenExecutions时的排序
r($executionTester->resetExecutionSortsTest($projectList[0])) && p() && e('0'); // 检查没有执行时的排序
r($executionTester->resetExecutionSortsTest($projectList[1])) && p() && e('3,5,7,8,6,4'); // 检查项目 2 的执行排序
zenData('project')->loadYaml('execution')->gen('30');
r($executionTester->resetExecutionSortsTest($projectList[2])) && p() && e('106,112,107,113,108,114,109,115,110,116,111,117'); // 检查项目 60 的执行排序
r($executionTester->resetExecutionSortsTest($projectList[3])) && p() && e('118,119,120,121,122,123'); // 检查项目 61 的执行排序
r($executionTester->resetExecutionSortsTest($projectList[4])) && p() && e('124,125,126'); // 检查项目 100 的执行排序