From a548c8d8e1be1e6b129fb4f82d89b8f03294e2b5 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 21 Aug 2023 13:24:09 +0800 Subject: [PATCH] * Refactor mergeChartOption method. --- module/task/model.php | 8 +++--- module/task/test/model/mergechartoption.php | 30 +++++++++++++++++++++ module/task/test/task.class.php | 16 +++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100755 module/task/test/model/mergechartoption.php diff --git a/module/task/model.php b/module/task/model.php index 49def6ba5c..869c5c8a4a 100755 --- a/module/task/model.php +++ b/module/task/model.php @@ -2063,13 +2063,14 @@ class taskModel extends model } /** + * 将默认图表设置与当前图表设置合并。 * Merge the default chart settings and the settings of current chart. * - * @param string $chartType + * @param string $chartType * @access public * @return void */ - public function mergeChartOption($chartType) + public function mergeChartOption(string $chartType) { $chartOption = $this->lang->task->report->$chartType; $commonOption = $this->lang->task->report->options; @@ -2082,7 +2083,8 @@ class taskModel extends model /* merge configuration */ foreach($commonOption->graph as $key => $value) { - if(!isset($chartOption->graph->$key)) $chartOption->graph->$key = $value; + if(isset($chartOption->graph->$key)) continue; + $chartOption->graph->$key = $value; } } diff --git a/module/task/test/model/mergechartoption.php b/module/task/test/model/mergechartoption.php new file mode 100755 index 0000000000..0121b650a5 --- /dev/null +++ b/module/task/test/model/mergechartoption.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +mergeChartOption(); +timeout=0 +cid=1 + +*/ + +$chartTypeList = array('tasksPerExecution', 'tasksPerModule', 'tasksPerAssignedTo', 'tasksPerType', 'tasksPerPri', 'tasksPerStatus', 'tasksPerDeadline', 'tasksPerEstimate', 'tasksPerLeft', 'tasksPerConsumed', 'tasksPerFinishedBy', 'tasksPerClosedReason', 'finishedTasksPerDay'); + +$taskTester = new taskTest(); +r($taskTester->mergeChartOptionTest($chartTypeList[0])) && p('graph:xAxisName,caption') && e('迭代,按迭代任务数统计'); // 合并按迭代任务数统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[1])) && p('graph:xAxisName,caption') && e('模块,按模块任务数统计'); // 合并按模块任务数统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[2])) && p('graph:xAxisName,caption') && e('用户,按指派给统计'); // 合并按指派给统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[3])) && p('graph:xAxisName,caption') && e('类型,按任务类型统计'); // 合并按任务类型统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[4])) && p('graph:xAxisName,caption') && e('优先级,按优先级统计'); // 合并按优先级统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[5])) && p('graph:xAxisName,caption') && e('状态,按任务状态统计'); // 合并按任务状态统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[6])) && p('graph:xAxisName,caption') && e('日期,按截止日期统计'); // 合并按截止日期统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[7])) && p('graph:xAxisName,caption') && e('时间,按预计时间统计'); // 合并按预计时间统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[8])) && p('graph:xAxisName,caption') && e('时间,按剩余时间统计'); // 合并按剩余时间统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[9])) && p('graph:xAxisName,caption') && e('时间,按消耗时间统计'); // 合并按消耗时间统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[10])) && p('graph:xAxisName,caption') && e('用户,按由谁完成统计'); // 合并按由谁完成统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[11])) && p('graph:xAxisName,caption') && e('关闭原因,按关闭原因统计'); // 合并按关闭原因统计报表的配置 +r($taskTester->mergeChartOptionTest($chartTypeList[12])) && p('graph:xAxisName,caption') && e('日期,按每天完成统计'); // 合并按每天完成统计报表的配置 diff --git a/module/task/test/task.class.php b/module/task/test/task.class.php index d14172e25b..3982546a5d 100755 --- a/module/task/test/task.class.php +++ b/module/task/test/task.class.php @@ -1997,4 +1997,20 @@ class taskTest return $this->objectModel->reportCondition(); } + + /** + * 将默认图表设置与当前图表设置合并。 + * Merge the default chart settings and the settings of current chart. + * + * @param string $chartType + * @access public + * @return object + */ + public function mergeChartOptionTest(string $chartType): object + { + global $lang; + $this->objectModel->mergeChartOption($chartType); + + return $lang->task->report->$chartType; + } }