Dashboard sipadu mbip
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

StoreCompoundEPBT.php 8.2KB

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