request = $request_; $this->kpd = $kpd_; $this->enf_nama = $enf_nama_; $this->no_badan = $no_badan_; $this->kesalahan= $kesalahan_; } /** * Execute the job. * * @return void */ public function handle() { // $faulty = Faulty::with('DeedLaw', 'Department')->where('_id', $this->seksyen_kesalahan)->first(); $compound = Compound::with('Department','DeedLaw','Faulty')->where('kpd',$this->kpd)->first(); // $compound = Compound::with('Department','DeedLaw','Faulty')->where('kpd', 'KP43932')->first(); $now = Carbon::now()->toDateTimeString(); $coordinate = []; if (!empty($compound->latlong)) { $coordinate = explode(",",$compound->latlong); } //get ePBT MBIP faulty lists $client = new \GuzzleHttp\Client(); $epbt_faulty_ = $client->request('GET', 'http://218.208.81.239:81/appsepbtkompaun_ws/getinfokompaun/infokompaun?infokompaun[]=352405067769401&infokompaun[]=ekpn_kesalahan'); $epbt_faulty = json_decode($epbt_faulty_->getBody()->getContents()); if(!empty($epbt_faulty)){ $k = []; $kod_kompaun = '-'; $jenis_kompaun = 'kt'; $no_akaun = '-'; $nama_pesalah = '-'; $no_kereta = '-'; $jenis_kereta = '-'; $no_petak = '-'; $no_cukai_jalan = '-'; $warna_kenderaan = '-'; //search if epbt kesalahan match db kesalahan $faulty = $compound->Faulty->nama; $epbt_faulty = array_pluck($epbt_faulty, "kesalahan"); $epbt_faulty = array_where($epbt_faulty, function($key, $value) use ($faulty){ if($key == $faulty){ return true; } return false; }); if($epbt_faulty){ // info($epbt_faulty); $roads = CodeMukim::where('MKM_MNAMA', $compound['nama_kawasan'])->first(); if($compound->jenis == 'Parkir') { $kod_kompaun = 'KPD'; $jenis_kompaun = 'K'; $no_akaun = $compound->no_plate; $nama_pesalah = $compound->no_plate; $no_kereta = $compound->no_plate; $jenis_kereta = $compound->model_kenderaan; $no_petak = $compound->no_parking; $no_cukai_jalan = $compound->no_cukai_jalan; $warna_kenderaan= $compound->warna_kenderaan; } elseif($compound->jenis == 'Pelbagai_KT'){ $kod_kompaun = 'kt'; $jenis_kompaun = 'P'; $no_akaun = $compound->no_akaun_lesen; $nama_pesalah = $compound->nama; } else if($compound->jenis == 'Pelbagai_JPB'){ $kod_kompaun = 'jpb'; $jenis_kompaun = 'P'; $no_akaun = $compound->no_akaun_lesen; $nama_pesalah = $compound->nama; } elseif ($compound->jenis == 'Pelbagai_LESEN'){ $kod_kompaun = 'KT1'; $jenis_kompaun = 'P'; $no_akaun = $compound->no_akaun_lesen; $nama_pesalah = $compound->nama; } array_push($k, strtoupper($this->kpd), //no kompaun $kod_kompaun, //strtoupper($kod_kompaun), //kodKompaun $compound->Deedlaw->akkod, //kod akta strtoupper($compound->Faulty->nama), //keterangan kesalahan $compound->created_at->toDateString(), //tarikh $compound->created_at->toTimeString(), //masa 14, //tempoh $compound->nama_jalan .' , '. $compound->nama_taman,//namajalan, namataman $roads->JLN_MKKOD, //kodbandar $jenis_kompaun, //jenis strtoupper($no_akaun), //no akaun (no plat) $compound->jumlah_asal_kompaun, //jumlah kompaun strtoupper($this->no_badan), //no badan '-', //no pembantu penguatkuasa strtoupper($this->enf_nama), //nama enforcer $now, //time created epbt $compound->Faulty->itkod, //kod kesalahan strtoupper($nama_pesalah), //nama pesalah $compound->nama_jalan, //nama jalan - alamat pesalah $compound->nama_taman, //nama taman - alamat pesalah '81300', //postcode $compound->nama_kawasan, //bandar 'JOHOR', //negeri 'B', //notis 'NULL', //notisamaran $coordinate[0], //latitud $coordinate[1], //longitud '-', //device $no_cukai_jalan, //no cukai jalan $no_kereta, //no plat 'NULL', //no kupon $jenis_kereta, //jenis kenderaan $warna_kenderaan, //warna kenderaan $no_petak, //no petak parking $no_petak //kod petak ); $urlQueryString = ''; for ($i=0; $i < count($k); $i++){ if($i == 0) { $urlQueryString = $urlQueryString . '?'; } else { $urlQueryString = $urlQueryString . '&'; } $urlQueryString = $urlQueryString . 'KompaunDetails[]=' . $k[$i]; } try { $client = new \GuzzleHttp\Client(); //121.120.88.133:8077 ip testing $result = $client->request('GET', 'http://218.208.81.239:81/appsepbtkompaun_ws/registerkompaun/registerkompaunDetails' . $urlQueryString); $response = json_decode($result->getBody()); if ($response->status) { info("Berjaya simpan rekod kompaun ke epbt!"); } else{ info("Tidak berjaya simpan rekod kompaun ke epbt!"); } } catch (Throwable $e) { report($e); info($e); // return true; } } else{ info("Kesalahan tiada di dalam epbt"); } } else{ info("Gagal untuk mendapatkan senarai kesalahan ePBT MBIP!"); } } }