123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <?php
-
- namespace App\Jobs;
-
- use Carbon\Carbon;
-
- use Illuminate\Bus\Queueable;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Http\Request;
- use App\Jobs\Throwable;
- use App\SiteSetting;
- use App\Model\Staff;
- use App\Model\StaffDetail;
- use App\Model\Module\Department;
- use App\Model\Module\DeedLaw;
- use App\Model\Module\Faulty;
- use App\Model\Module\Compound;
- use App\Model\Module\ConfidentialFile;
- use App\Model\Module\History;
- use App\Model\Module\SubHistory;
- use App\Model\Module\Memo;
- use App\Model\Module\Attachment;
- use App\Model\Module\CodeMukim;
-
- use App\Jobs\UpdateCompoundPrice;
-
- class StoreCompoundEPBT implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
- protected $request, $kpd, $no_badan, $enf_nama, $kesalahan;
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(array $request_, $kpd_, $enf_nama_, $no_badan_, $kesalahan_)
- {
- $this->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 (\Exception $e) {
-
- report($e);
-
- info($e);
-
- // return true;
- }
-
- }
- else{
- info("Kesalahan tiada di dalam epbt");
- }
- }
- else{
-
- info("Gagal untuk mendapatkan senarai kesalahan ePBT MBIP!");
- }
- }
- }
|