* Adjust data to metric data.
This commit is contained in:
@@ -324,7 +324,7 @@ class block extends control
|
||||
if(isset($block->params->num) && !isset($block->params->count)) $block->params->count = $block->params->num;
|
||||
|
||||
$code = $block->code;
|
||||
if($code == 'statistic' || $code == 'list' || $code == 'overview') $code = $block->module . ucfirst($code);
|
||||
if($code == 'statistic' || $code == 'list' || $code == 'overview' || $code == 'team') $code = $block->module . ucfirst($code);
|
||||
|
||||
$function = 'print' . ucfirst($code) . 'Block';
|
||||
if(method_exists('blockZen', $function)) $this->blockZen->$function($block, (array)$params);
|
||||
|
||||
@@ -524,7 +524,7 @@ $lang->block->productstatistic->delivered = 'Delivered';
|
||||
$lang->block->productstatistic->unclosed = 'unclosed';
|
||||
$lang->block->productstatistic->storyStatistics = 'Story Statistics';
|
||||
$lang->block->productstatistic->monthDone = 'Completed this month <span class="text-success font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = 'Added this month <span class="text-black font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = 'Added this month <span class="text-primary font-bold">%s</span>';
|
||||
$lang->block->productstatistic->news = 'Latest product advancements';
|
||||
$lang->block->productstatistic->newPlan = 'Latest Plan';
|
||||
$lang->block->productstatistic->newExecution = 'Latest Execution';
|
||||
|
||||
@@ -524,7 +524,7 @@ $lang->block->productstatistic->delivered = 'Delivered';
|
||||
$lang->block->productstatistic->unclosed = 'unclosed';
|
||||
$lang->block->productstatistic->storyStatistics = 'Story Statistics';
|
||||
$lang->block->productstatistic->monthDone = 'Completed this month <span class="text-success font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = 'Added this month <span class="text-black font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = 'Added this month <span class="text-primary font-bold">%s</span>';
|
||||
$lang->block->productstatistic->news = 'Latest product advancements';
|
||||
$lang->block->productstatistic->newPlan = 'Latest Plan';
|
||||
$lang->block->productstatistic->newExecution = 'Latest Execution';
|
||||
|
||||
@@ -524,7 +524,7 @@ $lang->block->productstatistic->delivered = 'Delivered';
|
||||
$lang->block->productstatistic->unclosed = 'unclosed';
|
||||
$lang->block->productstatistic->storyStatistics = 'Story Statistics';
|
||||
$lang->block->productstatistic->monthDone = 'Completed this month <span class="text-success font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = 'Added this month <span class="text-black font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = 'Added this month <span class="text-primary font-bold">%s</span>';
|
||||
$lang->block->productstatistic->news = 'Latest product advancements';
|
||||
$lang->block->productstatistic->newPlan = 'Latest Plan';
|
||||
$lang->block->productstatistic->newExecution = 'Latest Execution';
|
||||
|
||||
@@ -536,7 +536,7 @@ $lang->block->productstatistic->delivered = '已交付';
|
||||
$lang->block->productstatistic->unclosed = '未关闭';
|
||||
$lang->block->productstatistic->storyStatistics = '需求统计';
|
||||
$lang->block->productstatistic->monthDone = '本月完成 <span class="text-success font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = '本月新增 <span class="text-black font-bold">%s</span>';
|
||||
$lang->block->productstatistic->monthOpened = '本月新增 <span class="text-primary font-bold">%s</span>';
|
||||
$lang->block->productstatistic->opened = '新增';
|
||||
$lang->block->productstatistic->done = '完成';
|
||||
$lang->block->productstatistic->news = '产品最新推进';
|
||||
|
||||
@@ -89,30 +89,29 @@ $getProductInfo = function(array $products, string $blockNavID, bool $longBlock)
|
||||
$tabItems = array();
|
||||
foreach($products as $product)
|
||||
{
|
||||
$product->storyDeliveryRate = rand(0, 100);
|
||||
$product->monthStories = array();
|
||||
$product->monthStories[date('Y-m')] = array('done' => rand(0, 100), 'opened' => rand(0, 100));
|
||||
$product->monthStories[date('Y-m', strtotime('first day of -1 month'))] = array('done' => rand(0, 100), 'opened' => rand(0, 100));
|
||||
$product->monthStories[date('Y-m', strtotime('first day of -2 month'))] = array('done' => rand(0, 100), 'opened' => rand(0, 100));
|
||||
$product->monthStories[date('Y-m', strtotime('first day of -3 month'))] = array('done' => rand(0, 100), 'opened' => rand(0, 100));
|
||||
$product->monthStories[date('Y-m', strtotime('first day of -4 month'))] = array('done' => rand(0, 100), 'opened' => rand(0, 100));
|
||||
$product->monthStories[date('Y-m', strtotime('first day of -5 month'))] = array('done' => rand(0, 100), 'opened' => rand(0, 100));
|
||||
|
||||
$doneData = array();
|
||||
$openedData = array();
|
||||
foreach($product->monthStories as $date => $monthStories)
|
||||
foreach($product->monthFinish as $date => $count)
|
||||
{
|
||||
if($date == date('Y-m'))
|
||||
{
|
||||
$product->monthStories[$lang->datepicker->dpText->TEXT_THIS_MONTH] = $monthStories;
|
||||
unset($product->monthStories[$date]);
|
||||
$product->monthFinish[$lang->datepicker->dpText->TEXT_THIS_MONTH] = $count;
|
||||
unset($product->monthFinish[$date]);
|
||||
}
|
||||
$doneData[] = $monthStories['done'];
|
||||
$openedData[] = $monthStories['opened'];
|
||||
$doneData[] = $count;
|
||||
}
|
||||
foreach($product->monthCreated as $date => $count)
|
||||
{
|
||||
if($date == date('Y-m'))
|
||||
{
|
||||
$product->monthCreated[$lang->datepicker->dpText->TEXT_THIS_MONTH] = $count;
|
||||
unset($product->monthCreated[$date]);
|
||||
}
|
||||
$openedData[] = $count;
|
||||
}
|
||||
|
||||
$stories = $product->stories;
|
||||
$monthStories = $product->monthStories;
|
||||
$monthFinish = $product->monthFinish;
|
||||
$monthCreated = $product->monthCreated;
|
||||
$tabItems[] = div
|
||||
(
|
||||
set('class', 'tab-pane h-full' . ($product->id == $selected ? ' active' : '')),
|
||||
@@ -167,15 +166,13 @@ $getProductInfo = function(array $products, string $blockNavID, bool $longBlock)
|
||||
set('class', 'flex-1 text-center'),
|
||||
div
|
||||
(
|
||||
common::hasPriv('product', 'browse') ? a
|
||||
common::hasPriv('product', 'browse') && $product->totalStories ? a
|
||||
(
|
||||
set('href', helper::createLink('product', 'browse', "productID={$product->id}&branch=all&browseType=allStory¶m=0&storyType=story")),
|
||||
set('class', 'text-black'),
|
||||
$stories ? $stories['total'] : 0
|
||||
$product->totalStories
|
||||
) : span
|
||||
(
|
||||
set('class', 'text-black'),
|
||||
$stories ? $stories['total'] : 0
|
||||
$product->totalStories
|
||||
)
|
||||
),
|
||||
div
|
||||
@@ -192,15 +189,13 @@ $getProductInfo = function(array $products, string $blockNavID, bool $longBlock)
|
||||
set('class', 'flex-1 text-center'),
|
||||
div
|
||||
(
|
||||
common::hasPriv('product', 'browse') ? a
|
||||
common::hasPriv('product', 'browse') && $product->closedStories ? a
|
||||
(
|
||||
set('href', helper::createLink('product', 'browse', "productID={$product->id}&branch=all&browseType=closedstory¶m=0&storyType=story")),
|
||||
set('class', 'text-black'),
|
||||
$stories ? $stories['closed'] : 0
|
||||
$product->closedStories
|
||||
) : span
|
||||
(
|
||||
set('class', 'text-black'),
|
||||
$stories ? $stories['closed'] : 0
|
||||
$product->closedStories
|
||||
)
|
||||
),
|
||||
div
|
||||
@@ -217,15 +212,13 @@ $getProductInfo = function(array $products, string $blockNavID, bool $longBlock)
|
||||
set('class', 'flex-1 text-center'),
|
||||
div
|
||||
(
|
||||
common::hasPriv('product', 'browse') ? a
|
||||
common::hasPriv('product', 'browse') && $product->unclosedStories ? a
|
||||
(
|
||||
set('href', helper::createLink('product', 'browse', "productID={$product->id}&branch=all&browseType=unclosed¶m=0&storyType=story")),
|
||||
set('class', 'text-black'),
|
||||
$stories ? $stories['unclosed'] : 0
|
||||
$product->unclosedStories
|
||||
) : span
|
||||
(
|
||||
set('class', 'text-black'),
|
||||
$stories ? $stories['unclosed'] : 0
|
||||
$product->unclosedStories
|
||||
)
|
||||
),
|
||||
div
|
||||
@@ -257,12 +250,12 @@ $getProductInfo = function(array $products, string $blockNavID, bool $longBlock)
|
||||
span
|
||||
(
|
||||
set('class', 'border-r pr-2 text-sm text-gray'),
|
||||
html(sprintf($lang->block->productstatistic->monthDone, !empty($monthStories[$lang->datepicker->dpText->TEXT_THIS_MONTH]['done']) ? $monthStories[$lang->datepicker->dpText->TEXT_THIS_MONTH]['done'] : 0))
|
||||
html(sprintf($lang->block->productstatistic->monthDone, !empty($monthFinish[$lang->datepicker->dpText->TEXT_THIS_MONTH]) ? $monthFinish[$lang->datepicker->dpText->TEXT_THIS_MONTH] : 0))
|
||||
),
|
||||
span
|
||||
(
|
||||
set('class', 'pl-2 text-sm text-gray'),
|
||||
html(sprintf($lang->block->productstatistic->monthOpened, !empty($monthStories[$lang->datepicker->dpText->TEXT_THIS_MONTH]['opened']) ? $monthStories[$lang->datepicker->dpText->TEXT_THIS_MONTH]['opened'] : 0))
|
||||
html(sprintf($lang->block->productstatistic->monthOpened, !empty($monthCreated[$lang->datepicker->dpText->TEXT_THIS_MONTH]) ? $monthCreated[$lang->datepicker->dpText->TEXT_THIS_MONTH] : 0))
|
||||
)
|
||||
),
|
||||
div
|
||||
@@ -273,7 +266,7 @@ $getProductInfo = function(array $products, string $blockNavID, bool $longBlock)
|
||||
set::color(array('#2B80FF', '#17CE97')),
|
||||
set::grid(array('left' => '10px', 'top' => '30px', 'right' => '0', 'bottom' => '0', 'containLabel' => true)),
|
||||
set::legend(array('show' => true, 'right' => '0')),
|
||||
set::xAxis(array('type' => 'category', 'data' => array_keys($monthStories), 'splitLine' => array('show' => false), 'axisTick' => array('alignWithLabel' => true, 'interval' => '0'))),
|
||||
set::xAxis(array('type' => 'category', 'data' => array_keys($monthFinish), 'splitLine' => array('show' => false), 'axisTick' => array('alignWithLabel' => true, 'interval' => '0'))),
|
||||
set::yAxis(array('type' => 'value', 'name' => '个', 'splitLine' => array('show' => false), 'axisLine' => array('show' => true, 'color' => '#DDD'))),
|
||||
set::series
|
||||
(
|
||||
|
||||
+44
-45
@@ -871,49 +871,32 @@ class blockZen extends block
|
||||
$products = $this->loadModel('product')->getOrderedProducts($status, (int)$count);
|
||||
$productIdList = array_keys($products);
|
||||
|
||||
/* 根据产品列表获取产品下不同阶段的需求数量。 */
|
||||
/* Obtain the required quantity for different stages of the product based on the product list. */
|
||||
$productStories = $this->dao->select('product, stage, COUNT(status) AS count')->from(TABLE_STORY)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('product')->in($productIdList)
|
||||
->andWhere('type')->eq('story')
|
||||
->groupBy('product, stage')
|
||||
->fetchGroup('product', 'stage');
|
||||
$storyDeliveryRate = $this->loadModel('metric')->getResultByCode('rate_of_delivery_story_in_product', array('product' => join(',', $productIdList)));
|
||||
$storyDeliveryRate = json_decode(json_encode($storyDeliveryRate), true);
|
||||
$storyDeliveryRate = array_column($storyDeliveryRate, null, 'product');
|
||||
|
||||
/* 计算出各产品总需求数、关闭的需求数、未关闭的需求数。 */
|
||||
/* Calculate the total demand, closed demand, and unclosed demand for each product. */
|
||||
$stories = array();
|
||||
foreach($productStories as $product => $stageStories)
|
||||
$totalStories = $this->metric->getResultByCode('count_of_valid_story_in_product', array('product' => join(',', $productIdList)));
|
||||
$totalStories = json_decode(json_encode($totalStories), true);
|
||||
$totalStories = array_column($totalStories, null, 'product');
|
||||
|
||||
$closedStories = $this->metric->getResultByCode('count_of_delivered_story_in_product', array('product' => join(',', $productIdList)));
|
||||
$closedStories = json_decode(json_encode($closedStories), true);
|
||||
$closedStories = array_column($closedStories, null, 'product');
|
||||
|
||||
$unclosedStories = $this->metric->getResultByCode('count_of_unclosed_story_in_product', array('product' => join(',', $productIdList)));
|
||||
$unclosedStories = json_decode(json_encode($unclosedStories), true);
|
||||
$unclosedStories = array_column($unclosedStories, null, 'product');
|
||||
|
||||
$years = array();
|
||||
$months = array();
|
||||
for($i = 0; $i <= 5; $i ++)
|
||||
{
|
||||
$stories[$product] = array('closed' => 0, 'unclosed' => 0, 'total' => 0);
|
||||
foreach($stageStories as $stage => $story)
|
||||
{
|
||||
if($stage == 'closed') $stories[$product]['closed'] += $story->count;
|
||||
if($stage != 'closed') $stories[$product]['unclosed'] += $story->count;
|
||||
$stories[$product]['total'] += $story->count;
|
||||
}
|
||||
}
|
||||
|
||||
/* 根据产品列表获取前6个月的数据,数据按照年月分组。 */
|
||||
/* Obtain data from the first 6 months based on the product list, and group the data by month, month, and year. */
|
||||
$monthStories = $this->dao->select("DATE_FORMAT(openedDate, '%Y-%m') AS date, product, COUNT(id) as opened, COUNT(IF(stage = 'closed' and closedReason = 'done', 1, null)) AS done")->from(TABLE_STORY)
|
||||
->where('deleted')->eq('0')
|
||||
->andWhere('product')->in($productIdList)
|
||||
->andWhere('type')->eq('story')
|
||||
->andWhere('openedDate')->ge(date('Y-m-01', strtotime('-5 month')))
|
||||
->groupBy('date, product')
|
||||
->fetchGroup('date', 'product');
|
||||
|
||||
/* 将按照年月分组的需求列表调整为按照产品和年月分组。 */
|
||||
/* Adjust the demand list grouped by year and year to be grouped by product and year and year. */
|
||||
foreach($monthStories as $month => $productStories)
|
||||
{
|
||||
foreach($productStories as $product => $story)
|
||||
{
|
||||
$monthStories[$product][$month] = $story;
|
||||
}
|
||||
unset($monthStories[$month]);
|
||||
$years[date('Y', strtotime("first day of -{$i} month"))] = date('Y', strtotime("first day of -{$i} month"));
|
||||
$months[date('m', strtotime("first day of -{$i} month"))] = date('m', strtotime("first day of -{$i} month"));
|
||||
$groups[date('Y-m', strtotime("first day of -{$i} month"))] = date('Y-m', strtotime("first day of -{$i} month"));
|
||||
}
|
||||
$monthFinish = $this->metric->getResultByCode('count_of_monthly_finished_story_in_product', array('product' => join(',', $productIdList), 'year' => join(',', $years), 'month' => join(',', $months)));
|
||||
$monthCreated = $this->metric->getResultByCode('count_of_monthly_created_story_in_product', array('product' => join(',', $productIdList), 'year' => join(',', $years), 'month' => join(',', $months)));
|
||||
|
||||
/* 根据产品列表获取预计开始日期距离现在最近且预计开始日期大于当前日期的未开始状态计划。 */
|
||||
/* Obtain an unstarted status plan based on the product list, with an expected start date closest to the current date and an expected start date greater than the current date. */
|
||||
@@ -949,11 +932,27 @@ class blockZen extends block
|
||||
/* Place statistical data grouped by product into the product list. */
|
||||
foreach($products as $productID => $product)
|
||||
{
|
||||
$product->stories = isset($stories[$productID]) ? $stories[$productID] : 0;
|
||||
$product->monthStories = isset($monthStories[$productID]) ? $monthStories[$productID] : '';
|
||||
$product->newPlan = isset($newPlan[$productID][$productID]) ? $newPlan[$productID][$productID] : '';
|
||||
$product->newExecution = isset($newExecution[$productID][$productID]) ? $newExecution[$productID][$productID] : '';
|
||||
$product->newRelease = isset($newRelease[$productID][$productID]) ? $newRelease[$productID][$productID] : '';
|
||||
$product->storyDeliveryRate = isset($storyDeliveryRate[$productID]['value']) ? $storyDeliveryRate[$productID]['value'] : 0;
|
||||
$product->totalStories = isset($totalStories[$productID]['value']) ? $totalStories[$productID]['value'] : 0;
|
||||
$product->closedStories = isset($closedStories[$productID]['value']) ? $closedStories[$productID]['value'] : 0;
|
||||
$product->unclosedStories = isset($unclosedStories[$productID]['value']) ? $unclosedStories[$productID]['value'] : 0;
|
||||
$product->newPlan = isset($newPlan[$productID][$productID]) ? $newPlan[$productID][$productID] : '';
|
||||
$product->newExecution = isset($newExecution[$productID][$productID]) ? $newExecution[$productID][$productID] : '';
|
||||
$product->newRelease = isset($newRelease[$productID][$productID]) ? $newRelease[$productID][$productID] : '';
|
||||
|
||||
foreach($groups as $group)
|
||||
{
|
||||
$product->monthFinish[$group] = 0;
|
||||
$product->monthCreated[$group] = 0;
|
||||
foreach($monthFinish as $story)
|
||||
{
|
||||
if($group == "{$story->year}-{$story->month}" && $productID == $story->product) $product->monthFinish[$group] = $story->value;
|
||||
}
|
||||
foreach($monthCreated as $story)
|
||||
{
|
||||
if($group == "{$story->year}-{$story->month}" && $productID == $story->product) $product->monthCreated[$group] = $story->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->products = $products;
|
||||
|
||||
Reference in New Issue
Block a user