|
...
|
...
|
@@ -64,8 +64,24 @@ class MonthProjectCount extends Command |
|
|
|
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
|
|
|
|
->orderBy('month', 'asc')
|
|
|
|
->groupBy('month')->get()->toArray();
|
|
|
|
foreach ($list as $v){
|
|
|
|
$data[] = $v->month;
|
|
|
|
$data = [];
|
|
|
|
if (!empty($list)) {
|
|
|
|
// 提取已有月份
|
|
|
|
foreach ($list as $v) {
|
|
|
|
$data[] = $v->month;
|
|
|
|
}
|
|
|
|
// 生成连续月份
|
|
|
|
$startMonth = $data[0];
|
|
|
|
$endMonth = end($data);
|
|
|
|
$fullMonths = [];
|
|
|
|
$current = $startMonth;
|
|
|
|
while ($current <= $endMonth) {
|
|
|
|
$fullMonths[] = $current;
|
|
|
|
$current = date('Y-m', strtotime($current . ' +1 month'));
|
|
|
|
}
|
|
|
|
$data = $fullMonths;
|
|
|
|
} else {
|
|
|
|
$data = [];
|
|
|
|
}
|
|
|
|
$list = $this->fillMissingMonths($data);
|
|
|
|
foreach ($list as $v){
|
|
...
|
...
|
@@ -86,6 +102,7 @@ class MonthProjectCount extends Command |
|
|
|
//获取上一个的count
|
|
|
|
$previousMonth = date('Y-m', strtotime($v . ' -1 month'));
|
|
|
|
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
|
|
|
|
|
|
|
|
if($previousInfo === false){
|
|
|
|
$arr['total'] = $arr['month_total'];
|
|
|
|
}else{
|
...
|
...
|
|