} $inputs = $request->all(); if (env('ADMIN_PASSWORD', 'admin') !== $inputs['password']) { return Util::errorResponse('incorrect password'); } $start2 = json_decode($inputs['data'], true); if (Util::exists('api_start2.json')) { $data = Util::load('api_start2.json'); if (Util::compareJson($data, $start2)) { return Util::errorResponse('duplicate start2 data'); } } Util::dump('api_start2.json', $start2); $datetime = new DateTime(); $today = $datetime->format('YmdH'); Util::dump("start2/{$today}.json", $start2); Queue::push(function ($job) { Artisan::call('parse:start2'); $job->delete(); }); return Util::successResponse(); }); $app->get('/start2', function () { try { $data = Util::read('api_start2.json'); return response($data)->header('Content-Type', 'application/json'); } catch (FileNotFoundException $e) { return Util::errorResponse('api_start2.json not found in server'); } }); $app->get('/start2/archives', function () {
private function handleTyku() { $results = []; $rows = DB::select('select mapId,mapAreaId,cellId,count(*) as count from tyku group by mapId,mapAreaId,cellId order by mapId,mapAreaId,cellId'); foreach ($rows as $r) { $maxTyku = DB::select("select max(maxTyku) as max,count(*) as count from tyku where (seiku=0 or seiku=3 or seiku=4) and mapId=:mapId and mapAreaId=:mapAreaId and cellId=:cellId", ['mapId' => $r->mapId, 'mapAreaId' => $r->mapAreaId, 'cellId' => $r->cellId]); $minTyku = DB::select("select min(maxTyku) as min,count(*) as count from tyku where (seiku=1 or seiku=2) and mapId=:mapId and mapAreaId=:mapAreaId and cellId=:cellId", ['mapId' => $r->mapId, 'mapAreaId' => $r->mapAreaId, 'cellId' => $r->cellId]); if ($maxTyku[0]->count == 0 && $minTyku[0]->count == 0) { $tyku = -1; } else { if ($maxTyku[0]->count == 0) { $tyku = $minTyku[0]->min; } else { if ($minTyku[0]->count == 0) { $tyku = $maxTyku[0]->max + 1; } else { if ($maxTyku[0]->max + 1 > $minTyku[0]->min) { $tyku = $maxTyku[0]->max + 1; } else { $tyku = $minTyku[0]->min; } } } } array_push($results, ['mapId' => $r->mapId, 'mapAreaId' => $r->mapAreaId, 'cellId' => $r->cellId, 'tyku' => $tyku, 'count' => $r->count]); } Util::dump('report/tyku.json', $results); }