|
|
@@ -145,11 +145,31 @@ class ProductionInformationStatistics extends Api
|
|
|
}
|
|
|
|
|
|
$query = $this->parseQueryTime($time);
|
|
|
+ if (!$this->hasStatsInPeriod($query)) {
|
|
|
+ if ($query['type'] === 'day') {
|
|
|
+ $this->error(date('Y-m-d', strtotime($query['start'])) . '没有数据,请添加后查询');
|
|
|
+ }
|
|
|
+ $this->error($query['month'] . '没有数据,请添加后查询');
|
|
|
+ }
|
|
|
+
|
|
|
$list = $this->buildDisplayList($query);
|
|
|
|
|
|
$this->success('成功', $list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断指定时间段内是否存在统计数据
|
|
|
+ */
|
|
|
+ protected function hasStatsInPeriod(array $query)
|
|
|
+ {
|
|
|
+ $count = Db::name($this->tableName)
|
|
|
+ ->where('sczl_rq', '>=', $query['start'])
|
|
|
+ ->where('sczl_rq', '<=', $query['end'])
|
|
|
+ ->count();
|
|
|
+
|
|
|
+ return $count > 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 解析查询时间:Y-m-d 为日,Y-m 为月
|
|
|
*/
|