diff --git a/module/execution/model.php b/module/execution/model.php index c8a3345f79..5a1818f3a3 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1947,13 +1947,13 @@ class executionModel extends model $burns = $this->getBurnData($executions); foreach($executions as $execution) { - $execution->productName = isset($productList[$execution->id]) ? $productList[$execution->id]->productName : ''; + $execution->productName = isset($productList[$execution->id]) ? trim($productList[$execution->id]->productName, ',') : ''; $execution->end = date(DT_DATE1, strtotime($execution->end)); $execution->hours = isset($hours[$execution->id]) ? $hours[$execution->id] : (object)$emptyHour; $execution->teamCount = isset($memberGroup[$execution->id]) ? $memberGroup[$execution->id]->teams : 0; if(isset($executions[$execution->parent])) $executions[$execution->parent]->isParent = 1; - if(empty($productID) && !empty($productList[$execution->id])) $execution->product = $productList[$execution->id]->product; + if(empty($productID) && !empty($productList[$execution->id])) $execution->product = trim($productList[$execution->id]->product, ','); /* Judge whether the execution is delayed. */ if($execution->status != 'done' && $execution->status != 'closed' && $execution->status != 'suspended') diff --git a/module/execution/tao.php b/module/execution/tao.php index e543a4eb45..42f75c43f4 100644 --- a/module/execution/tao.php +++ b/module/execution/tao.php @@ -54,11 +54,25 @@ class executionTao extends executionModel */ protected function getProductList(int $projectID): array { - return $this->dao->select('t1.id,GROUP_CONCAT(product) as product,GROUP_CONCAT(t3.`name`) as productName')->from(TABLE_EXECUTION)->alias('t1') + $executions = $this->dao->select('t1.id,t2.product,t3.name')->from(TABLE_EXECUTION)->alias('t1') ->leftjoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.id=t2.project') ->leftjoin(TABLE_PRODUCT)->alias('t3')->on('t2.product=t3.id') ->where('t1.project')->eq($projectID) ->andWhere('t1.type')->in('kanban,sprint,stage') - ->fetchAll('id'); + ->fetchAll(); + + $productList = array(); + foreach($executions as $execution) + { + if(!isset($productList[$execution->id])) + { + $productList[$execution->id] = new stdclass(); + $productList[$execution->id]->product = ''; + $productList[$execution->id]->productName = ''; + } + $productList[$execution->id]->product .= $execution->product . ','; + $productList[$execution->id]->productName .= $execution->name . ','; + } + return $productList; } } diff --git a/module/execution/test/tao/getproductlist.php b/module/execution/test/tao/getproductlist.php index 81e7c81310..255050ac7b 100755 --- a/module/execution/test/tao/getproductlist.php +++ b/module/execution/test/tao/getproductlist.php @@ -19,5 +19,7 @@ cid=1 global $tester; $executionModel = $tester->loadModel('execution'); -r(count($executionModel->getProductList(11))) && p() && e('1'); // 测试获取敏捷项目下执行的产品个数 -r(current($executionModel->getProductList(11))) && p('id') && e('101'); // 测试获取敏捷项目下执行的产品 +r($executionModel->getProductList(0)) && p() && e('0'); // 测试空数据 +r(count($executionModel->getProductList(11))) && p() && e('5'); // 测试获取敏捷项目下执行的产品个数 +r(current($executionModel->getProductList(11))) && p('product', ';') && e('5,'); // 测试获取敏捷项目下执行的产品 +r($executionModel->getProductList(1)) && p() && e('0'); // 测试获取不存在项目下执行的产品