dev
parent
dd893d40c9
commit
b4996e9686
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Enums\BaseType;
|
||||
use App\Enums\DeviceType;
|
||||
use App\Helpers\Paginator;
|
||||
use App\Enums\DeviceStatus;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\AgriculturalBase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
|
@ -106,7 +107,7 @@ class AgriculturalBaseController extends Controller
|
|||
public function deviceBase(Request $request){
|
||||
$deviceType = $request->input('device_type', DeviceType::Monitor);
|
||||
$list = AgriculturalBase::filter($request->all())->whereHas('devices', function($q) use ($deviceType){
|
||||
return $q->where('type', $deviceType);
|
||||
return $q->where('type', $deviceType)->where('status', DeviceStatus::Online);
|
||||
})->get();
|
||||
|
||||
return $this->json(AgriculturalBaseResource::collection($list));
|
||||
|
|
|
|||
|
|
@ -26,4 +26,8 @@ class CropFilter extends ModelFilter
|
|||
|
||||
return $q;
|
||||
}
|
||||
|
||||
public function cropType($cropType){
|
||||
return $this->where('crop_type', $cropType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,6 @@ class AgriculturalBase extends Model
|
|||
}
|
||||
|
||||
public function devices(){
|
||||
return $this->hasMany(Device::class, 'base_id');
|
||||
return $this->hasMany(Device::class, 'agricultural_base_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,6 @@ class Crop extends Model
|
|||
'path', 'is_end',
|
||||
'sort',
|
||||
'extends',
|
||||
'crop_type'
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->unsignedBigInteger('category_id')->comment('行业ID');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->comment('父级ID');
|
||||
$table->unsignedTinyInteger('crop_type')->default(1)->comment('1基地农作物,2镇街农作物');
|
||||
$table->string('name')->comment('名称');
|
||||
$table->string('path')->nullable()->comment('路径');
|
||||
$table->unsignedTinyInteger('is_end')->default(0)->comment('是否结点');
|
||||
|
|
|
|||
|
|
@ -19,19 +19,19 @@ class AgriculturalBaseSeeder extends Seeder
|
|||
{
|
||||
//
|
||||
$bases = [
|
||||
['name' => '古湖街道', 'type' => 2, 'description' => '', 'areas' => '100', 'workforce'=> '200'],
|
||||
['name' => '金鹅街道', 'type' => 2, 'description' => '', 'areas' => '101', 'workforce'=> '201'],
|
||||
['name' => '响石镇', 'type' => 2, 'description' => '', 'areas' => '102', 'workforce'=> '202'],
|
||||
['name' => '圣灯镇', 'type' => 2, 'description' => '', 'areas' => '103', 'workforce'=> '203'],
|
||||
['name' => '黄家镇', 'type' => 2, 'description' => '', 'areas' => '104', 'workforce'=> '204'],
|
||||
['name' => '双凤镇', 'type' => 2, 'description' => '', 'areas' => '105', 'workforce'=> '205'],
|
||||
['name' => '龙市镇', 'type' => 2, 'description' => '', 'areas' => '106', 'workforce'=> '206'],
|
||||
['name' => '界市镇', 'type' => 2, 'description' => '', 'areas' => '107', 'workforce'=> '207'],
|
||||
['name' => '石碾镇', 'type' => 2, 'description' => '', 'areas' => '108', 'workforce'=> '208'],
|
||||
['name' => '石燕桥镇', 'type' => 2, 'description' => '', 'areas' => '109', 'workforce'=> '209'],
|
||||
['name' => '胡家镇', 'type' => 2, 'description' => '', 'areas' => '110', 'workforce'=> '210'],
|
||||
['name' => '云顶镇', 'type' => 2, 'description' => '', 'areas' => '111', 'workforce'=> '211'],
|
||||
['name' => '普润镇', 'type' => 2, 'description' => '', 'areas' => '112', 'workforce'=> '212'],
|
||||
['name' => '古湖街道', 'type' => 2, 'description' => '', 'areas' => '38674', 'workforce'=> '86860'],
|
||||
['name' => '金鹅街道', 'type' => 2, 'description' => '', 'areas' => '39532', 'workforce'=> '201'],
|
||||
['name' => '响石镇', 'type' => 2, 'description' => '', 'areas' => '56630', 'workforce'=> '47690'],
|
||||
['name' => '圣灯镇', 'type' => 2, 'description' => '', 'areas' => '21448', 'workforce'=> '23895'],
|
||||
['name' => '黄家镇', 'type' => 2, 'description' => '', 'areas' => '93373', 'workforce'=> '204'],
|
||||
['name' => '双凤镇', 'type' => 2, 'description' => '', 'areas' => '76150', 'workforce'=> '69042'],
|
||||
['name' => '龙市镇', 'type' => 2, 'description' => '', 'areas' => '86558', 'workforce'=> '206'],
|
||||
['name' => '界市镇', 'type' => 2, 'description' => '', 'areas' => '69345', 'workforce'=> '207'],
|
||||
['name' => '石碾镇', 'type' => 2, 'description' => '', 'areas' => '66164', 'workforce'=> '208'],
|
||||
['name' => '石燕桥镇', 'type' => 2, 'description' => '', 'areas' => '58382', 'workforce'=> '209'],
|
||||
['name' => '胡家镇', 'type' => 2, 'description' => '', 'areas' => '55742', 'workforce'=> '69332'],
|
||||
['name' => '云顶镇', 'type' => 2, 'description' => '', 'areas' => '46676', 'workforce'=> '40749'],
|
||||
['name' => '普润镇', 'type' => 2, 'description' => '', 'areas' => '58370', 'workforce'=> '212'],
|
||||
];
|
||||
DB::table('agricultural_bases')->truncate();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue