调整产值

dev
vine_liutk 2022-11-07 14:32:36 +08:00
parent df7b480517
commit e6f39637ca
1 changed files with 9 additions and 8 deletions

View File

@ -17,26 +17,27 @@ class CropYieldSeeder extends Seeder
*/
public function run()
{
$crops = Crop::where('is_end', 1)->where('crop_type', 1)->get();
$type = 2;
$insertData = [];
foreach ($crops as $crop) {
$base = AgriculturalBase::where('type', 1)->inRandomOrder()->first();
for($i = 2019; $i < 2023; $i++){
for($j = 1; $j< 5; $j++) {
$bases = AgriculturalBase::where('type', $type)->get();
foreach ($bases as $base){
for ($i = 2019; $i < 2023; $i++) {
$crop = Crop::where('is_end', 1)->where('crop_type', $type)->inRandomOrder()->first();
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),
'yield' => rand(1000, 9999),
'cultivated'=> rand(100, 999),
'output'=> rand(100000, 999999),
'output'=> rand(10000, 99999),
];
}
}
}
if(count($insertData) > 1){
DB::table('crop_yields')->truncate();
CropYield::insert($insertData);