Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StoreCompoundEPBT.php 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <?php
  2. namespace App\Jobs;
  3. use Carbon\Carbon;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Queue\SerializesModels;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. use Illuminate\Http\Request;
  10. use App\SiteSetting;
  11. use App\Model\Staff;
  12. use App\Model\StaffDetail;
  13. use App\Model\Module\Department;
  14. use App\Model\Module\DeedLaw;
  15. use App\Model\Module\Faulty;
  16. use App\Model\Module\Compound;
  17. use App\Model\Module\ConfidentialFile;
  18. use App\Model\Module\History;
  19. use App\Model\Module\SubHistory;
  20. use App\Model\Module\Memo;
  21. use App\Model\Module\Attachment;
  22. use App\Model\Module\CodeMukim;
  23. use App\Jobs\UpdateCompoundPrice;
  24. class StoreCompoundEPBT implements ShouldQueue
  25. {
  26. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  27. protected $request, $kpd, $no_badan, $enf_nama, $kesalahan;
  28. /**
  29. * Create a new job instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct(array $request_, $kpd_, $enf_nama_, $no_badan_, $kesalahan_)
  34. {
  35. $this->request = $request_;
  36. $this->kpd = $kpd_;
  37. $this->enf_nama = $enf_nama_;
  38. $this->no_badan = $no_badan_;
  39. $this->kesalahan= $kesalahan_;
  40. }
  41. /**
  42. * Execute the job.
  43. *
  44. * @return void
  45. */
  46. public function handle()
  47. {
  48. // $faulty = Faulty::with('DeedLaw', 'Department')->where('_id', $this->seksyen_kesalahan)->first();
  49. $compound = Compound::with('Department','DeedLaw','Faulty')->where('kpd',$this->kpd)->first();
  50. // $compound = Compound::with('Department','DeedLaw','Faulty')->where('kpd', 'KP43932')->first();
  51. $now = Carbon::now()->toDateTimeString();
  52. $coordinate = [];
  53. if (!empty($compound->latlong)) {
  54. $coordinate = explode(",",$compound->latlong);
  55. }
  56. //get ePBT MBIP faulty lists
  57. $client = new \GuzzleHttp\Client();
  58. $epbt_faulty_ = $client->request('GET', 'http://218.208.81.239:81/appsepbtkompaun_ws/getinfokompaun/infokompaun?infokompaun[]=352405067769401&infokompaun[]=ekpn_kesalahan');
  59. $epbt_faulty = json_decode($epbt_faulty_->getBody()->getContents());
  60. if(!empty($epbt_faulty)){
  61. $k = [];
  62. $kod_kompaun = '-';
  63. $jenis_kompaun = 'kt';
  64. $no_akaun = '-';
  65. $nama_pesalah = '-';
  66. $no_kereta = '-';
  67. $jenis_kereta = '-';
  68. $no_petak = '-';
  69. $no_cukai_jalan = '-';
  70. $warna_kenderaan = '-';
  71. //search if epbt kesalahan match db kesalahan
  72. $faulty = $compound->Faulty->nama;
  73. $epbt_faulty = array_pluck($epbt_faulty, "kesalahan");
  74. $epbt_faulty = array_where($epbt_faulty, function($key, $value) use ($faulty){
  75. if($key == $faulty){
  76. return true;
  77. }
  78. return false;
  79. });
  80. if($epbt_faulty){
  81. // info($epbt_faulty);
  82. $roads = CodeMukim::where('MKM_MNAMA', $compound['nama_kawasan'])->first();
  83. if($compound->jenis == 'Parkir')
  84. {
  85. $kod_kompaun = 'KPD';
  86. $jenis_kompaun = 'K';
  87. $no_akaun = $compound->no_plate;
  88. $nama_pesalah = $compound->no_plate;
  89. $no_kereta = $compound->no_plate;
  90. $jenis_kereta = $compound->model_kenderaan;
  91. $no_petak = $compound->no_parking;
  92. $no_cukai_jalan = $compound->no_cukai_jalan;
  93. $warna_kenderaan= $compound->warna_kenderaan;
  94. }
  95. elseif($compound->jenis == 'Pelbagai_KT'){
  96. $kod_kompaun = 'kt';
  97. $jenis_kompaun = 'P';
  98. $no_akaun = $compound->no_akaun_lesen;
  99. $nama_pesalah = $compound->nama;
  100. }
  101. else if($compound->jenis == 'Pelbagai_JPB'){
  102. $kod_kompaun = 'jpb';
  103. $jenis_kompaun = 'P';
  104. $no_akaun = $compound->no_akaun_lesen;
  105. $nama_pesalah = $compound->nama;
  106. }
  107. elseif ($compound->jenis == 'Pelbagai_LESEN'){
  108. $kod_kompaun = 'KT1';
  109. $jenis_kompaun = 'P';
  110. $no_akaun = $compound->no_akaun_lesen;
  111. $nama_pesalah = $compound->nama;
  112. }
  113. array_push($k,
  114. strtoupper($this->kpd), //no kompaun
  115. $kod_kompaun, //strtoupper($kod_kompaun), //kodKompaun
  116. $compound->Deedlaw->akkod, //kod akta
  117. strtoupper($compound->Faulty->nama), //keterangan kesalahan
  118. $compound->created_at->toDateString(), //tarikh
  119. $compound->created_at->toTimeString(), //masa
  120. 14, //tempoh
  121. $compound->nama_jalan .' , '. $compound->nama_taman,//namajalan, namataman
  122. $roads->JLN_MKKOD, //kodbandar
  123. $jenis_kompaun, //jenis
  124. strtoupper($no_akaun), //no akaun (no plat)
  125. $compound->jumlah_asal_kompaun, //jumlah kompaun
  126. strtoupper($this->no_badan), //no badan
  127. '-', //no pembantu penguatkuasa
  128. strtoupper($this->enf_nama), //nama enforcer
  129. $now, //time created epbt
  130. $compound->Faulty->itkod, //kod kesalahan
  131. strtoupper($nama_pesalah), //nama pesalah
  132. $compound->nama_jalan, //nama jalan - alamat pesalah
  133. $compound->nama_taman, //nama taman - alamat pesalah
  134. '81300', //postcode
  135. $compound->nama_kawasan, //bandar
  136. 'JOHOR', //negeri
  137. 'B', //notis
  138. 'NULL', //notisamaran
  139. $coordinate[0], //latitud
  140. $coordinate[1], //longitud
  141. '-', //device
  142. $no_cukai_jalan, //no cukai jalan
  143. $no_kereta, //no plat
  144. 'NULL', //no kupon
  145. $jenis_kereta, //jenis kenderaan
  146. $warna_kenderaan, //warna kenderaan
  147. $no_petak, //no petak parking
  148. $no_petak //kod petak
  149. );
  150. $urlQueryString = '';
  151. for ($i=0; $i < count($k); $i++){
  152. if($i == 0)
  153. {
  154. $urlQueryString = $urlQueryString . '?';
  155. }
  156. else
  157. {
  158. $urlQueryString = $urlQueryString . '&';
  159. }
  160. $urlQueryString = $urlQueryString . 'KompaunDetails[]=' . $k[$i];
  161. }
  162. try {
  163. $client = new \GuzzleHttp\Client();
  164. //121.120.88.133:8077 ip testing
  165. $result = $client->request('GET', 'http://218.208.81.239:81/appsepbtkompaun_ws/registerkompaun/registerkompaunDetails' . $urlQueryString);
  166. $response = json_decode($result->getBody());
  167. if ($response->status) {
  168. info("Berjaya simpan rekod kompaun ke epbt!");
  169. }
  170. else{
  171. info("Tidak berjaya simpan rekod kompaun ke epbt!");
  172. }
  173. } catch (Throwable $e) {
  174. report($e);
  175. info($e);
  176. // return true;
  177. }
  178. }
  179. else{
  180. info("Kesalahan tiada di dalam epbt");
  181. }
  182. }
  183. else{
  184. info("Gagal untuk mendapatkan senarai kesalahan ePBT MBIP!");
  185. }
  186. }
  187. }