1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Console\Commands;
- use App\Http\Controllers\Api\FeederDataGenerator;
- use App\Model\ForDeviceData;
- use App\Model\SystemL;
- use App\Service\FeederDataGeneratorService;
- use Illuminate\Console\Command;
- class InsertDeviceData extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'command:insert_device_data';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Command description';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- echo '生成设备数据--------start---------------';
- $dispatch = ForDeviceData::where("del_time",0)
- ->select('id','finished_num','start_time as upd_time','device_id')
- ->get()->toArray();
- if(! empty($dispatch)){
- $first_id = SystemL::max('id');
- list($status, $msg) = (new FeederDataGeneratorService())->generateData($dispatch);
- if($status){
- $end_id = SystemL::max('id');
- ForDeviceData::whereIn('id',array_column($dispatch,'id'))
- ->update(['del_time' => time(), 'systeml_id_str' => $first_id . '|' . $end_id]);
- }else{
- echo $msg . "\n";
- }
- }else{
- echo "暂无\n";
- }
- echo '生成设备数据--------end---------------';
- }
- }
|