| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?phpnamespace App\Console\Commands;use App\Http\Controllers\Api\FeederDataGenerator;use App\Model\ForDeviceData;use App\Model\SystemL;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 FeederDataGenerator)->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---------------';    }}
 |