diff --git a/module/metric/calc/system/hour/day_of_annual_closed_project.php b/module/metric/calc/system/hour/day_of_annual_closed_project.php index a7d655eec0..c5e87a5443 100755 --- a/module/metric/calc/system/hour/day_of_annual_closed_project.php +++ b/module/metric/calc/system/hour/day_of_annual_closed_project.php @@ -30,9 +30,9 @@ class day_of_annual_closed_project extends baseCalc { $project = $data->project; $year = substr($data->closedDate, 0, 4); - $consumed = $data->consumed; + $consumed = (float)$data->consumed; $status = $data->status; - $defaultHours = $data->defaultHours; + $defaultHours = (float)$data->defaultHours; if($status != 'closed') return false; if(empty($year) || $year == '0000') return false; @@ -40,7 +40,7 @@ class day_of_annual_closed_project extends baseCalc if(!isset($this->result[$year])) $this->result[$year] = array(); if(!isset($this->result[$year][$project])) $this->result[$year][$project] = 0; - $this->result[$year][$project] += $defaultHours ? $consumed / $defaultHours : 0; + $this->result[$year][$project] += $consumed / $defaultHours; } public function getResult($options = array()) diff --git a/module/metric/control.php b/module/metric/control.php index 51145cffd4..7e7bc86642 100755 --- a/module/metric/control.php +++ b/module/metric/control.php @@ -194,11 +194,11 @@ class metric extends control } catch(Exception $e) { - a($e->getMessage()); + a($this->metricZen->formatException($e)); } catch(Error $e) { - a($e->getMessage()); + a($this->metricZen->formatException($e)); } } diff --git a/module/metric/zen.php b/module/metric/zen.php index 4c9f2cb49a..380a57c4bc 100644 --- a/module/metric/zen.php +++ b/module/metric/zen.php @@ -181,7 +181,10 @@ class metricZen extends metric */ protected function prepareMetricRecord($calcList) { - $options = array('year' => date('Y'), 'month' => date('n'), 'week' => substr(date('oW'), -2), 'day' => date('j')); + $yesterday = strtotime('-1 day', strtotime('today')); + $yesterday = date('j', $yesterday); + $today = date('j'); + $options = array('year' => date('Y'), 'month' => date('n'), 'week' => substr(date('oW'), -2), 'day' => "$today,$yesterday"); $now = helper::now(); $dateValues = $this->metric->generateDateValues($now); @@ -195,24 +198,27 @@ class metricZen extends metric $initRecords = $this->initMetricRecords($recordCommon, $metric->scope); $results = $calc->getResult($options); - foreach($results as $record) + if(is_array($results)) { - $record = (object)$record; - if(empty($record->value)) continue; - - $record->metricID = $calc->id; - $record->metricCode = $code; - $record->date = $now; - $record->system = $metric->scope == 'system' ? 1 : 0; - - $uniqueKey = $this->getUniqueKeyByRecord($record); - if(!isset($initRecords[$uniqueKey])) + foreach($results as $record) { - $initRecords[$uniqueKey] = $record; - continue; - } + $record = (object)$record; + if(empty($record->value)) continue; - $initRecords[$uniqueKey]->value = $record->value; + $record->metricID = $calc->id; + $record->metricCode = $code; + $record->date = $now; + $record->system = $metric->scope == 'system' ? 1 : 0; + + $uniqueKey = $this->getUniqueKeyByRecord($record); + if(!isset($initRecords[$uniqueKey])) + { + $initRecords[$uniqueKey] = $record; + continue; + } + + $initRecords[$uniqueKey]->value = $record->value; + } } $records[$code] = array_values($initRecords); @@ -496,6 +502,15 @@ class metricZen extends metric return ($tableWidth > 300) ? '' : 'shortPageSize'; } + public function formatException($e) + { + $message = $e->getMessage(); + $line = $e->getLine(); + $file = $e->getFile(); + + return "Error: $message in $file on line $line"; + } + /** * 根据后台配置的估算单位对列表赋值。 * Assign unitList['measure'] by custom hourPoint. diff --git a/module/screen/model.php b/module/screen/model.php index 61594e2ee3..ead1379c67 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -2077,7 +2077,7 @@ class screenModel extends model else { $setting = json_decode($chart->settings, true)[0]; - $options = $this->loadModel('chart')->genWaterPolo(json_decode($chart->fieldSettings, true), $setting, $chart->sql, $filters); + $options = $this->loadModel('chart')->genWaterPolo(json_decode($chart->fields, true), $setting, $chart->sql, $filters); $component->option->dataset = $options['series'][0]['data'][0]; return $this->setComponentDefaults($component); @@ -2956,7 +2956,8 @@ class screenModel extends model ->andWhere('month(t2.closedDate)')->eq($month) ->fetchPairs(); - $deliveredStoryCount = count(array_merge($finishedStoryList, (array)$releasedStoryGroups[$productID])); + $releasedStoryList = isset($releasedStoryGroups[$productID]) ? $releasedStoryGroups[$productID] : array(); + $deliveredStoryCount = count(array_merge($finishedStoryList, (array)$releasedStoryList)); $row = new stdclass(); $row->id = $productID; @@ -3035,7 +3036,8 @@ class screenModel extends model ->andWhere('month(t3.closedDate)')->eq($month) ->fetchPairs(); - $deliveredStoryCount = count(array_merge($finishedStoryList, (array)$releasedStoryGroups[$projectID])); + $releasedStoryList = isset($releasedStoryGroups[$projectID]) ? $releasedStoryGroups[$projectID] : array(); + $deliveredStoryCount = count(array_merge($finishedStoryList, (array)$releasedStoryList)); $row = new stdclass(); $row->id = $projectID;