[ // 心跳间隔时间(秒) 'PULSE' => 120, // 骑行定位包间隔(秒) 'FREQ' => 10, // 骑行时静止多少分钟报锁车(分) 'VIBFILTERREMINDT' => 30, // 配置服务器地址 'SERVER' => 'relay.weilaibike.com:8282', // 蓝牙秘钥 // 'DFTBLEENCKEY' => 'TBIT_WA205-7HBLE', // // 蓝牙功能开关 'BLEKG' => 1, //车的最高速度 'MAXECUSPEED' => 3 ], 'xiaobanma' => [ // 心跳间隔时间(秒) 'PULSE' => 120, // 骑行定位包间隔(秒) 'FREQ' => 15, // 骑行时静止多少分钟报锁车(分) 'VIBFILTERREMINDT' => 30, // 配置服务器地址 'SERVER' => 'relay.xbm.weilaibike.com:8383', // 蓝牙秘钥 // 'DFTBLEENCKEY' => 'TBIT_WA205-7HBLE', // 蓝牙功能开关 'BLEKG' => 1, //车的最高速度 'MAXECUSPEED' => 7 ], 'demo' => [ // 心跳间隔时间(秒) 'PULSE' => 120, // 骑行定位包间隔(秒) 'FREQ' => 10, // 骑行时静止多少分钟报锁车(分) 'VIBFILTERREMINDT' => 30, // 配置服务器地址 'SERVER' => 'relay.demo.weilaibike.com:8282', // 蓝牙秘钥 // 'DFTBLEENCKEY' => 'TBIT_WA205-7HBLE', // 蓝牙功能开关 // 'BLEKG' => 1, //车的最高速度 'MAXECUSPEED' => 7 ] ]; /** * Execute the console command. * * @return mixed */ public function handle() { $bike_no = $this->option('bike_no'); $box_no = $this->option('box_no'); $area_id = $this->option('area'); $min = $this->option('min'); $max = $this->option('max'); $bike = Bike::query(); if ($area_id) { $bike->where('put_area_id', $area_id); } if ($bike_no) { $bike->where('bike_no', $bike_no); } if ($box_no) { $bike->where('box_no', $box_no); } if ($min) { $bike->where('bike_no', '>=', $min); } if ($max) { $bike->where('bike_no', '<=', $max); } $bikes = $bike->select(['bike_no', 'box_no', 'id', 'blu_key', 'put_area_id'])->get(); if ($bikes->isEmpty()) { $this->line('没有找到要调整的车'); return true; } $config_name = $this->choice('请选择配置文件?(weilaibike「闪现GO」和xiaobanma「小班马」)', ['no', 'weilaibike', 'xiaobanma', 'demo'], 'no'); if ($config_name === 'no') { return false; } $MAXECUSPEED = $this->choice('请选择速度配置值?(1~7 值越大越快(70%~100%))', [7, 6, 5, 4, 3, 2, 1], 7); $num = count($bikes); $setting = []; foreach (self::config[$config_name] as $key => $item) { if ($key === 'MAXECUSPEED') { $item = $MAXECUSPEED; } $setting[] = "{$key}={$item}"; } $this->line("配置文件为:" . implode(';', $setting)); $results = []; if ($this->confirm("您确定要修改{$num}辆车?")) { foreach ($bikes as $bike) { if (in_array('DFTBLEENCKEY', array_keys(self::config[$config_name]))) { // 处理蓝牙模块 } if ($bike['box_no']) { $result = BikeControl::setBoxSetting($bike['box_no'], $setting); $results[] = [ 'bike_no' => $bike['bike_no'], 'box_no' => $bike['box_no'], 'status' => $result ]; } else { $results[] = [ 'bike_no' => $bike['bike_no'], 'box_no' => $bike['box_no'], 'status' => '没有绑定' ]; } } $this->line('设置完成,结果见下表:'); $this->table(array_keys($results[0]), $results); $this->line('------over------'); return true; } $this->line('关闭修改'); } }