dev
vine_liutk 2023-11-18 17:13:18 +08:00
parent ef1eb76159
commit cb1fc1e0d9
1 changed files with 25 additions and 23 deletions

View File

@ -160,29 +160,31 @@ class CropYieldController extends Controller
]; ];
if ($crop?->is_end) { if ($crop?->is_end) {
$staticCropIds[] = $crop->id; $staticCropIds[] = $crop->id;
if ($crop->extends) {
$i = 0; //注释掉扩展字段统计情况
if(is_array($crop->extends)){ // if ($crop->extends) {
$extends = $crop->extends; // $i = 0;
}else{ // if(is_array($crop->extends)){
$extends = json_decode($crop->extends, true); // $extends = $crop->extends;
} // }else{
foreach ($extends as $item) { // $extends = json_decode($crop->extends, true);
$i++; // }
$_key = 'extend_'.$i; // foreach ($extends as $item) {
$staticsData[$_key] = [ // $i++;
'name' => $item['name'], // $_key = 'extend_'.$i;
'unit' => $item['unit'], // $staticsData[$_key] = [
'list' => [ // 'name' => $item['name'],
'第1季度' => null, // 'unit' => $item['unit'],
'第2季度' => null, // 'list' => [
'第3季度' => null, // '第1季度' => null,
'第4季度' => null, // '第2季度' => null,
], // '第3季度' => null,
]; // '第4季度' => null,
$extendsQ .= ", sum((extends->> '".$item['name']."')::NUMERIC) as extend_".$i.'_total '; // ],
} // ];
} // $extendsQ .= ", sum((extends->> '".$item['name']."')::NUMERIC) as extend_".$i.'_total ';
// }
// }
} else { } else {
$cropQ = Crop::query(); $cropQ = Crop::query();
if ($crop) { if ($crop) {