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.

EditCompoundEPBT.php 8.0KB

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