123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Console\Commands;
- use App\Models\Bike;
- use App\Models\Statistic;
- use App\Models\WorkOrder;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- class updateStatisticBody extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'update:statistic_body';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '更新统计表';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- //
- $sta = Statistic::query()->where('slug',Statistic::SLUG_PROFIT_STATIC)->whereIn('area_id',[9999,9])
- ->where('date','>',Carbon::today()->subDays(30))->get();
- $bikes = Bike::query()->where('put_area_id',9)->where('put_status',Bike::PUT_STATUS_YES)->count();
- $bar = $this->output->createProgressBar(count($sta));
- $bar->start();
- foreach ($sta as $v){
- $body = json_decode($v->body,true);
- $body['put_bikes'] = $bikes;
- $v->body = json_encode($body);
- $v->save();
- $bar->advance();
- }
- $bar->finish();
- }
- public function getWorkOrder($offset,$limit){
- $workOrder = WorkOrder::query()
- ->offset($offset)
- ->limit($limit)
- ->get();
- foreach ($workOrder as $v){
- $v->warning_type = WorkOrder::$typeWarningMaps[$v->type];
- $v->save();
- }
- $this->line($offset);
- }
- }
|