diff --git a/module/report/config.php b/module/report/config.php index 6b621dcec7..6e11da1270 100644 --- a/module/report/config.php +++ b/module/report/config.php @@ -20,7 +20,7 @@ $config->report->annualData['dev']['block4'] = array('title' => 'devData', 'data $config->report->annualData['dev']['block5'] = array('title' => 'devStatistics', 'data' => array('effortMonth')); $config->report->annualData['qa']['block1'] = array('title' => 'baseInfo', 'data' => array('logins', 'actions', 'foundBugs', 'createdCases')); -$config->report->annualData['qa']['block2'] = array('title' => 'projectOverview', 'data' => array('doneProject', 'doingProject', 'suspendProject')); +$config->report->annualData['qa']['block2'] = array('title' => 'qaOverview', 'data' => array()); $config->report->annualData['qa']['block3'] = array('title' => '', 'data' => array('projects')); $config->report->annualData['qa']['block4'] = array('title' => 'qaData', 'data' => array('bugPri', 'casePri')); $config->report->annualData['qa']['block5'] = array('title' => 'qaStatistics', 'data' => array('bugMonth', 'caseMonth')); diff --git a/module/report/control.php b/module/report/control.php index 9145eb585b..92b5d1f60a 100644 --- a/module/report/control.php +++ b/module/report/control.php @@ -260,7 +260,7 @@ class report extends control $products = $this->report->getUserYearProducts($account, $year); $data['involvedProducts'] = count($products); - $planGroups = $this->report->getPlansByProducts($products, $year); + $planGroups = $this->report->getPlansByProducts($products, $account, $year); $planCount = 0; foreach($planGroups as $plans) $planCount += $plans; $data['createdPlans'] = $planCount; @@ -272,7 +272,7 @@ class report extends control $data['storyStage'] = $storyInfo['stage']; $data['storyMonth'] = $storyInfo['month']; - $storyGroups = $this->report->getStoriesByProducts($products, $year); + $storyGroups = $this->report->getStoriesByProducts($products, $account, $year); foreach($products as $productID => $product) { $product->plans = zget($planGroups, $productID, 0); @@ -288,7 +288,7 @@ class report extends control $data['efforts'] = $efforts->count; $data['consumed'] = $efforts->consumed; - $projects = $this->report->getUserYearProjects($account, $year, $role); + $projects = $this->report->getUserYearProjects($account, $year); $projectStat = $this->report->getStatByProjects($projects); $tasks = $this->report->getUserYearFinishedTasks($account, $year); @@ -297,7 +297,7 @@ class report extends control $data['resolvedBugPri'] = $bugs['pri']; $data['effortMonth'] = $this->report->getEffort4Month($account, $year);; - $stories = $this->report->getFinishedStoryByProjects($projects, $year); + $stories = $this->report->getFinishedStoryByProjects($projects, $account, $year); $tasks = $this->report->getFinishedTaskByProjects($projects, $account, $year); $bugs = $this->report->getResolvedBugByProjects($projects, $account, $year); foreach($projects as $projectID => $project) @@ -323,14 +323,14 @@ class report extends control $data['casePri'] = $caseInfo['pri']; $data['caseMonth'] = $caseInfo['month']; - $projects = $this->report->getUserYearProjects($account, $year, $role); - $projectStat = $this->report->getStatByProjects($projects); + $products = $this->report->getUserYearProducts4QA($account, $year); + $productStat = $this->report->getBugStatByProducts($products, $account, $year); - $bugs = $this->report->getCreatedBugByProjects($projects, $year); - foreach($projects as $projectID => $project) $project->bugs = zget($bugs, $projectID, 0); + $bugs = $this->report->getCreatedBugByProducts($products, $account, $year); + foreach($products as $productID => $product) $product->bugs = zget($bugs, $productID, 0); - $data['projects'] = $projects; - $data['projectStat'] = $projectStat; + $data['products'] = $products; + $data['productStat'] = $productStat; } $firstAction = $this->dao->select('*')->from(TABLE_ACTION)->orderBy('id')->limit(1)->fetch(); diff --git a/module/report/lang/zh-cn.php b/module/report/lang/zh-cn.php index bd4a810467..eff38b1dbb 100644 --- a/module/report/lang/zh-cn.php +++ b/module/report/lang/zh-cn.php @@ -116,6 +116,7 @@ $lang->report->annualData->createdPlans = "累计创建计划数"; $lang->report->annualData->createdStories = "累计创建需求数"; $lang->report->annualData->productOverview = "产品创建的需求数及占比"; +$lang->report->annualData->qaOverview = "产品创建的Bug数及占比"; $lang->report->annualData->projectOverview = "参与项目概览"; $lang->report->annualData->doneProject = "已完成的项目"; $lang->report->annualData->doingProject = "正在进行的项目"; @@ -142,7 +143,7 @@ $lang->report->annualData->poData = "所创建的需求数对应的优 $lang->report->annualData->totalStoryPri = "创建需求优先级分布"; $lang->report->annualData->totalStoryStage = "创建需求阶段分布"; -$lang->report->annualData->qaStatistics = "完成任务与解决bug工时统计"; +$lang->report->annualData->qaStatistics = "完成任务与解决Bug工时统计"; $lang->report->annualData->poStatistics = "月创建需求数"; $lang->report->annualData->devStatistics = "月完成任务累计工时"; diff --git a/module/report/model.php b/module/report/model.php index e15e7ba577..05cece1e6f 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -647,29 +647,31 @@ class reportModel extends model return $products; } - public function getPlansByProducts($products, $year) + public function getPlansByProducts($products, $account, $year) { return $this->dao->select('t1.product, count(DISTINCT t1.id) as plans')->from(TABLE_PRODUCTPLAN)->alias('t1') ->leftJoin(TABLE_ACTION)->alias('t2')->on("t1.id=t2.objectID and t2.objectType='productplan'") ->where('t1.deleted')->eq(0) ->andWhere('t1.product')->in(array_keys($products)) ->andWhere('LEFT(t2.date, 4)')->eq($year) + ->andWhere('t2.actor')->eq($account) ->andWhere('t2.action')->eq('opened') ->groupBy('t1.product') ->fetchPairs('product', 'plans'); } - public function getStoriesByProducts($products, $year) + public function getStoriesByProducts($products, $account, $year) { return $this->dao->select('product, count(*) as stories')->from(TABLE_STORY) ->where('deleted')->eq(0) ->andWhere('product')->in(array_keys($products)) ->andWhere('LEFT(openedDate, 4)')->eq($year) + ->andWhere('openedBy')->eq($account) ->groupBy('product') ->fetchPairs('product', 'stories'); } - public function getUserYearProjects($account, $year, $role = 'dev') + public function getUserYearProjects($account, $year) { $projects = $this->dao->select('id,name,status')->from(TABLE_PROJECT)->where('deleted')->eq(0) ->andWhere('LEFT(begin, 4)', true)->eq($year) @@ -682,32 +684,26 @@ class reportModel extends model ->orWhere('RD')->eq($account) ->markRight(1) ->fetchAll('id'); + $teamProjects = $this->dao->select('*')->from(TABLE_TEAM)->where('type')->eq('project')->andWhere('account')->eq($account)->andWhere('LEFT(`join`, 4)')->eq($year)->fetchPairs('root', 'root'); - $taskProjects = array(); - if($role == 'dev') $taskProjects = $this->dao->select('project')->from(TABLE_TASK)->where('finishedBy')->eq($account)->andWhere('LEFT(finishedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('project', 'project'); + $taskProjects = $this->dao->select('project')->from(TABLE_TASK)->where('finishedBy')->eq($account)->andWhere('LEFT(finishedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('project', 'project'); + $projects += $this->dao->select('id,name,status')->from(TABLE_PROJECT)->where('deleted')->eq(0) ->andWhere('id')->in($teamProjects + $taskProjects) ->fetchAll('id'); return $projects; } - public function getCreatedBugByProjects($projects, $year) - { - return $this->dao->select('project, count(*) as bugs')->from(TABLE_BUG) - ->where('deleted')->eq(0) - ->andWhere('project')->in(array_keys($projects)) - ->andWhere('LEFT(openedDate, 4)')->eq($year) - ->groupBy('project') - ->fetchPairs('project', 'bugs'); - } - - public function getFinishedStoryByProjects($projects, $year) + public function getFinishedStoryByProjects($projects, $account, $year) { return $this->dao->select('t1.project, count(DISTINCT t1.story) as stories')->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id') + ->leftJoin(TABLE_TASK)->alias('t3')->on('t1.story=t3.story') ->where('t2.deleted')->eq(0) + ->andWhere('t3.deleted')->eq(0) ->andWhere('t1.project')->in(array_keys($projects)) - ->andWhere('LEFT(t2.closedDate, 4)')->eq($year) + ->andWhere('LEFT(t3.finishedDate, 4)')->eq($year) + ->andWhere('t3.finishedBy')->eq($account) ->groupBy('t1.project') ->fetchPairs('project', 'stories'); } @@ -791,6 +787,54 @@ class reportModel extends model } return $months; } + + public function getUserYearProducts4QA($account, $year) + { + $bugProducts = $this->dao->select('product')->from(TABLE_BUG)->where('openedBy')->eq($account)->andWhere('LEFT(openedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('product', 'product'); + $caseProducts = $this->dao->select('product')->from(TABLE_CASE)->where('openedBy')->eq($account)->andWhere('LEFT(openedDate, 4)')->eq($year)->andWhere('deleted')->eq(0)->fetchPairs('product', 'product'); + + $products = $this->dao->select('id,name,status')->from(TABLE_PRODUCT) + ->where('deleted')->eq(0) + ->andWhere('id')->in($bugProducts + $caseProducts) + ->fetchAll('id'); + return $products; + } + + public function getBugStatByProducts($products, $account, $year) + { + $allBugs = $this->dao->select('product, count(*) as count')->from(TABLE_BUG)->where('deleted')->eq(0) + ->andWhere('product')->in(array_keys($products)) + ->andWhere('LEFT(openedDate, 4)')->eq($year) + ->groupBy('product') + ->fetchPairs('product', 'count'); + $mineBugs = $this->dao->select('product, count(*) as count')->from(TABLE_BUG)->where('deleted')->eq(0) + ->andWhere('product')->in(array_keys($products)) + ->andWhere('openedBy')->eq($account) + ->andWhere('LEFT(openedDate, 4)')->eq($year) + ->groupBy('product') + ->fetchPairs('product', 'count'); + + $productStat = array(); + foreach($products as $productID => $product) + { + $productStat[$productID]['name'] = $product->name; + $productStat[$productID]['count'] = zget($allBugs, $productID, 0); + $productStat[$productID]['mine'] = zget($mineBugs, $productID, 0); + } + + return $productStat; + } + + public function getCreatedBugByProducts($products, $account, $year) + { + return $this->dao->select('product, count(*) as bugs')->from(TABLE_BUG) + ->where('deleted')->eq(0) + ->andWhere('product')->in(array_keys($products)) + ->andWhere('LEFT(openedDate, 4)')->eq($year) + ->andWhere('openedBy')->eq($account) + ->groupBy('product') + ->fetchPairs('product', 'bugs'); + } } /** diff --git a/module/report/view/annualdata.html.php b/module/report/view/annualdata.html.php index 7f7ed65284..2160f7878d 100644 --- a/module/report/view/annualdata.html.php +++ b/module/report/view/annualdata.html.php @@ -69,7 +69,7 @@
@@ -96,7 +96,7 @@ var annualData = elseif($blockKey == 'block2') { echo "unit: '" . $lang->report->annualData->unit . "',"; - if($role == 'qa' or $role == 'dev') + if($role == 'dev') { $count = $data['projectStat']['count']; $blockData[] = array('title' => $lang->report->annualData->doneProject, 'value' => $data['projectStat']['done'], 'percent' => (empty($count) ? 0 : round($data['projectStat']['done'] / $count, 4) * 100 . '%')); @@ -113,6 +113,15 @@ var annualData = } echo "data: " . json_encode($blockData); } + elseif($role == 'qa') + { + foreach($data['productStat'] as $productStat) + { + $count = $productStat['count']; + $blockData[] = array('title' => $productStat['name'], 'value' => (int)$productStat['mine'], 'percent' => (empty($count) ? '0' : round($productStat['mine'] / $count, 3) * 100 . '%')); + } + echo "data: " . json_encode($blockData); + } } elseif($blockKey == 'block3') { @@ -137,10 +146,10 @@ var annualData = } elseif($role == 'qa') { - $cols[] = array('title' => $lang->report->annualData->projectName, 'width' => 'auto', 'align' => 'left'); + $cols[] = array('title' => $lang->report->annualData->productName, 'width' => 'auto', 'align' => 'left'); $cols[] = array('title' => $lang->report->annualData->foundBug, 'width' => '80', 'align' => 'center'); - foreach($data['projects'] as $project) $rows[] = array($project->name, $project->bugs); + foreach($data['products'] as $product) $rows[] = array($product->name, $product->bugs); } echo "cols: " . json_encode($cols) . ',';