dev
vine_liutk 2023-03-22 21:16:36 +08:00
parent 85bddb4005
commit fb7866a54f
1 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,7 @@ use Illuminate\Support\Facades\DB;
use Peidikeji\Keywords\Models\Keywords;
use App\Services\OperationLogService;
use App\Enums\OperationType;
use App\Enums\BaseType;
class CropYieldController extends Controller
{
@ -197,6 +198,9 @@ class CropYieldController extends Controller
if ($baseId) {
$q->where('base_id', $baseId);
}else{
$baseIds = AgriculturalBase::where('type', BaseType::Town)->pluck('id')->toArray();
$q->whereIn('base_id', $baseIds);
}
$q1 = clone $q;
$sumSql = 'quarter, sum(yield) as yield_total, sum(cultivated) as cultivated_total, sum(output) as output_total ';
@ -228,6 +232,9 @@ class CropYieldController extends Controller
$q->where('time_year', $year);
if ($baseId) {
$q->where('base_id', $baseId);
}else{
$baseIds = AgriculturalBase::where('type', BaseType::Town)->pluck('id')->toArray();
$q->whereIn('base_id', $baseIds);
}
$q->groupBy('category_id');
$totalData = $q->select(DB::raw('category_id, sum(output) as output_total '))
@ -297,6 +304,9 @@ class CropYieldController extends Controller
$q = CropYield::query();
if ($baseId) {
$q->where('base_id', $baseId);
}else{
$baseIds = AgriculturalBase::where('type', BaseType::Town)->pluck('id')->toArray();
$q->whereIn('base_id', $baseIds);
}
$q->where('time_year', '>=', $nowYear - 3);