处理冲突
parent
9b10527985
commit
767e42ec5a
|
|
@ -18,10 +18,12 @@ class AgriculturalBaseController extends AdminController
|
|||
*/
|
||||
protected function grid()
|
||||
{
|
||||
return Grid::make(new AgriculturalBase(), function (Grid $grid) {
|
||||
$builder = AgriculturalBase::with('parent');
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
$grid->model()->where('type', BaseType::Base);
|
||||
// $grid->column('id')->sortable();
|
||||
$grid->column('name');
|
||||
$grid->column('parent.name', '所属镇街')->label();
|
||||
$grid->column('person');
|
||||
$grid->column('address');
|
||||
$grid->column('address_lat');
|
||||
|
|
@ -55,6 +57,7 @@ class AgriculturalBaseController extends AdminController
|
|||
$model = $form->model();
|
||||
|
||||
$form->display('id');
|
||||
$form->select('parent_id', '所属镇街')->options(AgriculturalBase::town()->get()->pluck('name', 'id'))->required();
|
||||
$form->text('name');
|
||||
$form->text('person');
|
||||
$form->number('areas');
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class CropController extends AdminController
|
|||
protected function grid()
|
||||
{
|
||||
return Grid::make(Crop::with(['category', 'parent']), function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->id();
|
||||
$grid->column('category.name', '行业');
|
||||
$grid->column('parent.name', '上级');
|
||||
// $grid->column('crop_type');
|
||||
|
|
@ -33,12 +33,20 @@ class CropController extends AdminController
|
|||
$grid->column('created_at')->sortable();
|
||||
// $grid->column('updated_at')
|
||||
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
|
||||
$grid->showCreateButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.crops.create'));
|
||||
$grid->showQuickEditButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.crops.edit'));
|
||||
$grid->showDeleteButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.crops.destroy'));
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->like('name')->width(3);
|
||||
$filter->equal('category_id')->select(Keywords::where('type_key', 'crops-category')->get()->pluck('name', 'id'))->width(3);
|
||||
$filter->equal('crop_type')->select([
|
||||
1=> '基地',
|
||||
2=> '镇街'
|
||||
])->width(3);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class CropYieldController extends AdminController
|
|||
$grid->showDeleteButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.crop_yields.destroy'));
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('base_id')->select(AgriculturalBase::all()->pluck('name', 'name'))->width(3);
|
||||
$filter->equal('base_id')->select(AgriculturalBase::all()->pluck('name', 'id'))->width(3);
|
||||
$filter->equal('crop_id')->select(Crop::where('is_end', 1)->pluck('name', 'id'))->width(3);
|
||||
});
|
||||
});
|
||||
|
|
@ -124,15 +124,19 @@ class CropYieldController extends AdminController
|
|||
|
||||
return $v;
|
||||
});
|
||||
$form->currency('output')->symbol('元')->default(0)->required()->saving(function ($v) {
|
||||
$form->currency('output')->symbol('元')->default(0)->saving(function ($v) {
|
||||
if ($v === null) {
|
||||
$v = 0;
|
||||
}
|
||||
|
||||
return $v;
|
||||
});
|
||||
// $form->text('created_by');
|
||||
// $form->text('updated_by');
|
||||
|
||||
$form->hidden('category_id');
|
||||
$form->saving(function($form){
|
||||
$crop = Crop::findOrFail($form->crop_id);
|
||||
$form->category_id = $crop->category_id;
|
||||
});
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use Dcat\Admin\Form;
|
||||
use Dcat\Admin\Grid;
|
||||
use Dcat\Admin\Show;
|
||||
use Dcat\Admin\Admin;
|
||||
use App\Models\Device;
|
||||
use Dcat\Admin\Http\Controllers\AdminController;
|
||||
|
||||
class DeviceController extends AdminController
|
||||
{
|
||||
/**
|
||||
* Make a grid builder.
|
||||
*
|
||||
* @return Grid
|
||||
*/
|
||||
protected function grid()
|
||||
{
|
||||
$builder = Device::with('base');
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
$grid->column('id')->sortable();
|
||||
$grid->column('base.name');
|
||||
$grid->column('sn');
|
||||
$grid->column('name');
|
||||
$grid->column('model');
|
||||
$grid->column('monitoring_point');
|
||||
$grid->column('type');
|
||||
$grid->column('status');
|
||||
// $grid->column('extends');
|
||||
// $grid->column('created_by');
|
||||
// $grid->column('updated_by');
|
||||
$grid->column('created_at')->sortable();
|
||||
|
||||
$grid->model()->orderBy('created_at', 'desc');
|
||||
|
||||
$grid->showCreateButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.devices.create'));
|
||||
$grid->showQuickEditButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.devices.edit'));
|
||||
$grid->showDeleteButton(! config('admin.permission.enable') || Admin::user()->can('dcat.admin.devices.destroy'));
|
||||
|
||||
$grid->filter(function (Grid\Filter $filter) {
|
||||
$filter->equal('id');
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a show builder.
|
||||
*
|
||||
* @param mixed $id
|
||||
*
|
||||
* @return Show
|
||||
*/
|
||||
protected function detail($id)
|
||||
{
|
||||
return Show::make($id, new Device(), function (Show $show) {
|
||||
$show->field('id');
|
||||
$show->field('agricultural_base_id');
|
||||
$show->field('sn');
|
||||
$show->field('name');
|
||||
$show->field('model');
|
||||
$show->field('monitoring_point');
|
||||
$show->field('type');
|
||||
$show->field('status');
|
||||
$show->field('extends');
|
||||
$show->field('created_by');
|
||||
$show->field('updated_by');
|
||||
$show->field('created_at');
|
||||
$show->field('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form()
|
||||
{
|
||||
return Form::make(new Device(), function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('agricultural_base_id');
|
||||
$form->text('sn');
|
||||
$form->text('name');
|
||||
$form->text('model');
|
||||
$form->text('monitoring_point');
|
||||
$form->text('type');
|
||||
$form->radio('status')->options([
|
||||
|
||||
]);
|
||||
// $form->text('extends');
|
||||
// $form->text('created_by');
|
||||
// $form->text('updated_by');
|
||||
|
||||
$form->display('created_at');
|
||||
$form->display('updated_at');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -21,4 +21,6 @@ Route::group([
|
|||
$router->get('api/crops/{id}', 'CropController@info')->name('api.crops.info');
|
||||
|
||||
$router->resource('crop-yields', 'CropYieldController')->names('crop_yields');
|
||||
|
||||
$router->resource('devices', 'DeviceController')->names('devices');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ class AgriculturalBaseController extends Controller
|
|||
|
||||
public function show(AgriculturalBase $agriculturalBasic)
|
||||
{
|
||||
$agriculturalBasic->load('crops');
|
||||
|
||||
$agriculturalBasic->load(['crops', 'devices']);
|
||||
return $this->json(AgriculturalBaseResource::make($agriculturalBasic));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class AgriculturalBaseResource extends JsonResource
|
|||
'workforce' => $this->workforce ?? 0, //人数
|
||||
'cultivated' => $this->cultivated ?? 0, //种养殖面积
|
||||
'crops' => CropResource::collection($this->whenLoaded('crops')),
|
||||
'devices' => DeviceResource::collection($this->whenLoaded('devices')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ class AgriculturalBase extends Model
|
|||
'parent_id', 'cultivated',
|
||||
];
|
||||
|
||||
public function parent(){
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function scopeBase($q)
|
||||
{
|
||||
return $q->where('type', BaseType::Base);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class CropYield extends Model
|
|||
];
|
||||
|
||||
protected $fillable = [
|
||||
'base_id', 'crop_id', 'time_year', 'yield', 'cultivated', 'output', 'user_id',
|
||||
'base_id', 'crop_id', 'time_year', 'yield', 'cultivated', 'output',
|
||||
'created_by', 'updated_by',
|
||||
'quarter', 'extends',
|
||||
'category_id',
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\DeviceStatus;
|
||||
use App\Enums\DeviceType;
|
||||
use App\Enums\DeviceStatus;
|
||||
use EloquentFilter\Filterable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Device extends Model
|
||||
{
|
||||
use HasFactory, Filterable;
|
||||
use HasFactory, Filterable, HasDateTimeFormatter;
|
||||
|
||||
protected $attributes = [
|
||||
'status' => DeviceStatus::Offline,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Throwable;
|
||||
use App\Models\Crop;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\AgriculturalBase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CropSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
$cropsArr = [
|
||||
//城镇农作物
|
||||
['name' => '粮食作物', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '谷物', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '稻谷', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '小麦', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '玉米', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '高粱', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '其他谷物', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
]],
|
||||
['name' => '豆类', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '折粮薯类', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children' => [
|
||||
['name' => '洋芋', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨']
|
||||
]],
|
||||
]],
|
||||
['name' => '经济作物', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '油料', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '棉花', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '生麻', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '糖料', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '甘蔗', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '甜菜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨']
|
||||
]],
|
||||
['name' => '中草药材', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '蔬菜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '芹菜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '油菜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '菠菜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '西红柿', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '生姜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '辣椒', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '其他蔬菜', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
]],
|
||||
['name' => '瓜果类', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '花卉苗木', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '食用菌', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
]],
|
||||
['name' => '茶叶水果', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '茶叶', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '园林水果', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '食用坚果', 'category_id' => 2, 'crop_type' => 2, 'unit' => '吨'],
|
||||
]],
|
||||
['name' => '竹木', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '木材', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '竹材', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
]],
|
||||
['name' => '林产品', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' => '天然橡胶', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '天然生漆', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '油茶籽', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '油橄榄', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '油用牡丹籽', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '松香', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '紫胶(原胶)', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '竹笋干', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '核桃', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '其它林产品', 'category_id' => 5, 'crop_type' => 2, 'unit' => '吨'],
|
||||
]],
|
||||
['name' => '猪', 'category_id' => 4, 'crop_type' => 2, 'unit' => '头', 'extends'=> [
|
||||
['name' =>'当年出栏', 'unit' =>'头'],
|
||||
['name' =>'期末存栏', 'unit' =>'头'],
|
||||
['name' =>'肉产量', 'unit' =>'吨'],
|
||||
]],
|
||||
['name' => '牛', 'category_id' => 4, 'crop_type' => 2, 'unit' => '头', 'extends'=> [
|
||||
['name' =>'当年出栏', 'unit' =>'头'],
|
||||
['name' =>'期末存栏', 'unit' =>'头'],
|
||||
['name' =>'肉产量', 'unit' =>'吨'],
|
||||
]],
|
||||
['name' => '羊', 'category_id' => 4, 'crop_type' => 2, 'unit' => '头', 'extends'=> [
|
||||
['name' =>'当年出栏', 'unit' =>'头'],
|
||||
['name' =>'期末存栏', 'unit' =>'头'],
|
||||
['name' =>'肉产量', 'unit' =>'吨'],
|
||||
]],
|
||||
['name' => '活家禽', 'category_id' => 4, 'crop_type' => 2, 'unit' => '头', 'extends'=> [
|
||||
['name' =>'当年出栏', 'unit' =>'头'],
|
||||
['name' =>'期末存栏', 'unit' =>'头'],
|
||||
['name' =>'肉产量', 'unit' =>'吨'],
|
||||
]],
|
||||
['name' => '家兔', 'category_id' => 4, 'crop_type' => 2, 'unit' => '头', 'extends'=> [
|
||||
['name' =>'当年出栏', 'unit' =>'头'],
|
||||
['name' =>'期末存栏', 'unit' =>'头'],
|
||||
['name' =>'肉产量', 'unit' =>'吨'],
|
||||
]],
|
||||
['name'=>'附加产品', 'category_id' => 4, 'crop_type' => 2, 'unit' => '吨', 'children' => [
|
||||
['name' =>'奶类', 'category_id' => 4, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' =>'生牛奶', 'category_id' => 4, 'crop_type' => 2, 'unit' => '吨']
|
||||
]],
|
||||
['name' =>'羊毛', 'category_id'=> 4, 'crop_type' => 2, 'unit' => '吨', 'children'=> [
|
||||
['name' =>'山羊毛', 'category_id' => 4, 'crop_type' => 2, 'unit' => '吨', 'extends'=> [
|
||||
['name' =>'山羊粗毛', 'unit' =>'吨'],
|
||||
['name' =>'山羊绒', 'unit' =>'吨']
|
||||
]],
|
||||
['name' =>'绵羊毛', 'category_id' => 4, 'crop_type' => 2, 'unit' => '吨', 'extends'=> [
|
||||
['name' =>'细羊毛', 'unit' =>'吨'],
|
||||
['name' =>'半细羊毛', 'unit' =>'吨']
|
||||
]]
|
||||
]],
|
||||
['name' => '禽蛋', 'category_id'=> 4, 'crop_type' => 2, 'unit' => '吨','children'=> [
|
||||
['name'=>'鸡蛋', 'category_id'=>4, 'crop_type' => 2, 'unit' => '吨']
|
||||
]],
|
||||
['name' => '天然蜂蜜', 'category_id'=> 4, 'crop_type' => 2, 'unit' => '吨'],
|
||||
['name' => '蚕茧', 'category_id'=> 4, 'crop_type' => 2, 'unit' => '吨']
|
||||
]],
|
||||
['name'=>'鱼类', 'category_id' => 3, 'crop_type' => 2, 'unit' => '吨', 'extends'=> [
|
||||
['name' =>'淡水捕捞', 'unit' =>'吨'],
|
||||
['name' =>'淡水养殖', 'unit' =>'吨']
|
||||
]],
|
||||
['name'=>'虾蟹类', 'category_id' => 3, 'crop_type' => 2, 'unit' => '吨', 'extends'=> [
|
||||
['name' =>'淡水捕捞', 'unit' =>'吨'],
|
||||
['name' =>'淡水养殖', 'unit' =>'吨']
|
||||
]],
|
||||
['name'=>'贝类', 'category_id' => 3, 'crop_type' => 2, 'unit' => '吨', 'extends'=> [
|
||||
['name' =>'淡水捕捞', 'unit' =>'吨'],
|
||||
['name' =>'淡水养殖', 'unit' =>'吨']
|
||||
]],
|
||||
['name'=>'其他类', 'category_id' => 3, 'crop_type' => 2, 'unit' => '吨', 'extends'=> [
|
||||
['name' =>'淡水捕捞', 'unit' =>'吨'],
|
||||
['name' =>'淡水养殖', 'unit' =>'吨']
|
||||
]],
|
||||
|
||||
//基地农作物
|
||||
['name'=>'不知火','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
|
||||
['name'=>'耙耙柑','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
|
||||
['name'=>'爱媛','category_id' => 2, 'crop_type' => 1, 'unit' => '吨'],
|
||||
];
|
||||
DB::table('crops')->truncate();
|
||||
try {
|
||||
DB::begintransaction();
|
||||
$this->createCrops($cropsArr);
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
}
|
||||
}
|
||||
|
||||
public function createCrops(array $crops, ?Crop $parentCrop = null)
|
||||
{
|
||||
foreach ($crops as $item) {
|
||||
$crop = Crop::create([
|
||||
'name' => $item['name'],
|
||||
'category_id' => $item['category_id'],
|
||||
'crop_type' => $item['crop_type'],
|
||||
'parent_id' => $parentCrop ? ($parentCrop?->id ?? 0) :0,
|
||||
'path' => $parentCrop ? (($parentCrop?->path ?? '').$parentCrop->id.'-'):'',
|
||||
'unit' => $item['unit'],
|
||||
'extends' => isset($item['extends']) ? json_encode($item['extends']) : null,
|
||||
'is_end' => isset($item['children']) ? 0 : 1,
|
||||
]);
|
||||
|
||||
$children = $item['children'] ?? [];
|
||||
|
||||
if($children){
|
||||
$this->createCrops($children, $crop);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Crop;
|
||||
use App\Models\CropYield;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\AgriculturalBase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CropYieldSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$crops = Crop::where('is_end', 1)->where('crop_type', 1)->get();
|
||||
|
||||
$insertData = [];
|
||||
foreach ($crops as $crop) {
|
||||
$base = AgriculturalBase::where('type', 1)->inRandomOrder()->first();
|
||||
for($i = 2019; $i < 2023; $i++){
|
||||
for($j = 1; $j< 5; $j++) {
|
||||
$insertData[] = [
|
||||
'base_id' => $base->id,
|
||||
'crop_id' => $crop->id,
|
||||
'category_id' => $crop->category_id,
|
||||
'time_year' => $i,
|
||||
'quarter' => $j,
|
||||
'yield' => rand(10000, 99999),
|
||||
'cultivated'=> rand(100, 999),
|
||||
'output'=> rand(100000, 999999),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($insertData) > 1){
|
||||
DB::table('crop_yields')->truncate();
|
||||
CropYield::insert($insertData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -511,6 +511,7 @@ namespace Dcat\Admin {
|
|||
|
||||
/**
|
||||
* @method \App\Admin\Form\Amap amap(...$params)
|
||||
* @method \App\Admin\Form\CropExtends cropExtends(...$params)
|
||||
*/
|
||||
class Form
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
return [
|
||||
'labels' => [
|
||||
'Device' => 'Device',
|
||||
'device' => 'Device',
|
||||
],
|
||||
'fields' => [
|
||||
'agricultural_base_id' => '基地',
|
||||
'sn' => '序列号',
|
||||
'name' => '名称',
|
||||
'model' => '型号',
|
||||
'monitoring_point' => '监控点',
|
||||
'type' => '设备类型',
|
||||
'status' => '状态',
|
||||
'extends' => '扩展信息',
|
||||
'created_by' => '创建人',
|
||||
'updated_by' => '修改人',
|
||||
],
|
||||
'options' => [
|
||||
],
|
||||
];
|
||||
Loading…
Reference in New Issue