/** * Execute the console command. * * @return mixed */ public function fire(Almaty $almaty, Astana $astana) { $city = $this->option('city'); if ($city == 1) { $this->city = $almaty; } else { $this->city = $astana; } if ($this->city->obman_gps == "0") { return false; } $results = DB::connection($this->city->db)->table('cars')->join('crews', 'crews.car', '=', 'cars.id')->join('crews_inline as ci', 'crews.id', '=', 'ci.id')->join('wialon_cars as wi', 'cars.gn', '=', 'wi.gn')->where('ci.status', '=', 'waiting')->select('crews.driver', 'cars.gn', 'crews.id', 'ci.status', 'wi.pos_x AS wi_lon', 'wi.pos_y AS wi_lat', 'ci.lat AS tm_lat', 'ci.lon AS tm_lon')->get(); if (!empty($results)) { foreach ($results as $v) { if (isset($v->tm_lat) && isset($v->tm_lon) && isset($v->wi_lat) && isset($v->wi_lon)) { $diff = Helpers::distance($v->tm_lat, $v->tm_lon, $v->wi_lat, $v->wi_lon) / 1000; $diff = round($diff, 1); if ($diff >= 4.5) { if (isset($v->driver)) { $tm_address = Helpers::get_address_by_coords($v->tm_lat, $v->tm_lon); $wialon_address = Helpers::get_address_by_coords($v->wi_lat, $v->wi_lon); $this->call('drivers:operations', ['driver' => $v->driver, 'op' => 0, 'summ' => $this->city->obman_gps_price, 'reason' => 'Обман GPS', 'time' => time(), 'comment' => "ТМ Адрес: {$tm_address}, Wialon Адрес: {$wialon_address} Разница: {$diff} км", '--city' => $city]); } } } } } }
/** * Execute the console command. * * @return mixed */ public function fire(Almaty $almaty, Astana $astana) { $city = $this->option('city'); if ($city == 1) { $this->city = $almaty; } else { $this->city = $astana; } if ($this->city->overshift == "0") { return false; } $start = microtime(true); $slise_size = 150; $crews = file_get_contents('http://api.komandir.kz/ovsh/main2.php'); $crews = json_decode($crews, true); $wialon = new Wialon($this->city); $report_from_wialon = []; for ($i = 0; $i < count($crews); $i += $slise_size) { $tmp = array_slice($crews, $i, $i + $slise_size, true); $tmp = $wialon->get_test_report($tmp); $tmp = json_decode($tmp); $report_from_wialon = array_merge($tmp, $report_from_wialon); } $results = []; foreach ($report_from_wialon as $v) { if (isset($v->reportResult->stats)) { $cnt = str_replace(' km', '', $v->reportResult->stats[0][1]); if ($cnt > 2) { $gn = substr($v->reportResult->stats[1][1], 0, 5); array_push($results, ['gn' => $gn, 'cnt' => $cnt]); } } } $results = Helpers::merge_two_arrays($results, $crews, 'gn'); foreach ($results as $v) { if (isset($v['cnt'])) { $driver = DB::connection($this->city->db)->table('crews_info')->where('crew_id', '=', $v['id'])->get(['driver_id']); $sum = $v['cnt'] * $this->city->overshift_price; if (!empty($driver)) { foreach ($driver as $val) { $this->call('drivers:operations', ['driver' => $val->driver_id, 'op' => 0, 'summ' => $sum, 'reason' => 'Перепробег вне смены', 'time' => time(), '--city' => $city]); DB::connection($this->city->db)->table('overshift')->insert(['time' => time(), 'crews_id' => $v['id'], 'km' => $v['cnt'], 'begin' => $v['begin_time'], 'end' => $v['end_time']]); DB::connection($this->city->db)->table('overshift_called')->insert(['crew_id' => $v['id'], 'time' => time()]); } } } } $end_time = microtime(true); $this->info($end_time - $start); }
public function obmanGPS() { $results = DB::connection($this->city->db)->table('cars')->join('crews', 'crews.car', '=', 'cars.id')->join('crews_inline as ci', 'crews.id', '=', 'ci.crew_id')->join('wialon_cars as wi', 'cars.gn', '=', 'wi.gn')->where('ci.status', '=', 'waiting')->select('crews.driver', 'cars.gn', 'crews.id', 'ci.status', 'wi.pos_x AS wi_lon', 'wi.pos_y AS wi_lat', 'ci.lat AS tm_lat', 'ci.lon AS tm_lon')->get(); foreach ($results as $v) { if (isset($v->tm_lat) && isset($v->tm_lon) && isset($v->wi_lat) && isset($v->wi_lon)) { $diff = Helpers::distance($v->tm_lat, $v->tm_lon, $v->wi_lat, $v->wi_lon) / 1000; if ($diff > 4.5) { $id = $v->driver; $this->MoneyOperations($id, 0, 1, 'TEST', 'TEST OBMAN GPS'); } } } }