From 06a57d35e09237f6ee639075f7fdd9f2bd366197 Mon Sep 17 00:00:00 2001 From: pecintaseni Date: Wed, 4 Sep 2024 12:54:56 +0700 Subject: [PATCH] identifikasi lapangan per bulan --- app/Controllers/Kewilayahan/Kytp.php | 37 +++++++- .../Sebaran/IdentifikasiLapangan.php | 86 +++++++++++++++++-- app/Views/kewilayahan/dist/kpdl.js | 20 +++-- .../kytp/componentProgresifitas/ChartKPDL.js | 35 ++++---- app/Views/kewilayahan/kytp/readme.txt | 5 ++ 5 files changed, 146 insertions(+), 37 deletions(-) diff --git a/app/Controllers/Kewilayahan/Kytp.php b/app/Controllers/Kewilayahan/Kytp.php index 4004f375..625d9b53 100644 --- a/app/Controllers/Kewilayahan/Kytp.php +++ b/app/Controllers/Kewilayahan/Kytp.php @@ -136,15 +136,44 @@ class Kytp extends Controller public function identifikasiLapangan() { - $sebaran = new IdentifikasiLapangan; - $bulan = $this->request->getGet('bulan') ?? 'semua'; - $dataReturn['akum'] = $sebaran->dataAgg($this->request, $bulan); - $dataReturn['kpdl'] = $sebaran->dataKpdl($this->request, $bulan); + $sebaran = new IdentifikasiLapangan; + $bulan = $this->request->getPost('bulan') ?? 'semua'; + $dataReturn['kpdl'] = $sebaran->dataKpdl($this->request, $bulan); + $dataReturn['categories'] = ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"]; + if ($bulan == 'semua') { + $dataReturn['categories'] = ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"]; + } else { + $dataReturn['categories'] = $sebaran->generateSeries($bulan); + } + + $arr_data_akum_dikenali = array(); + $nilai_akum = 0; + foreach ($dataReturn['kpdl'] as $data) { + $nilai_akum += $data; + array_push($arr_data_akum_dikenali, $nilai_akum); + } + $c_arr = count($arr_data_akum_dikenali) - 1; + $arr_data_akum_dikenali_temp = $arr_data_akum_dikenali; + for ($i = $c_arr; $i > 0; $i--) { + if ($arr_data_akum_dikenali[$i] == $arr_data_akum_dikenali[$i - 1]) { + $arr_data_akum_dikenali_temp[$i] = 0; + } else { + break; + } + } + $dataReturn['akum'] = $arr_data_akum_dikenali_temp; return $this->respond($dataReturn, 200); } + public function getBulan() + { + $bulan = ['semua', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; + return $this->respond($bulan, 200); + + } + private function get_poi_agg() { ini_set('max_input_vars', 3000); diff --git a/app/Controllers/Kewilayahan/Sebaran/IdentifikasiLapangan.php b/app/Controllers/Kewilayahan/Sebaran/IdentifikasiLapangan.php index e1cc2f0f..990cbd88 100644 --- a/app/Controllers/Kewilayahan/Sebaran/IdentifikasiLapangan.php +++ b/app/Controllers/Kewilayahan/Sebaran/IdentifikasiLapangan.php @@ -2,6 +2,7 @@ namespace App\Controllers\Kewilayahan\Sebaran; use App\Libraries\KpdlLibrary; +use CodeIgniter\Database\RawSql; class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp @@ -12,7 +13,8 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp $adm4_pcode = $request->getPost('adm4_pcode') ?? []; $id_poly_zona = $request->getPost('id_poly_zona') ?? []; - $db = \Config\Database::connect(); + $db = \Config\Database::connect(); + $KpdlLibrary = new KpdlLibrary; if ($bulan == 'semua') { $npwp = $db->table('KPDL_MV_JML_KPDL_AGG A') @@ -36,10 +38,36 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp ->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left') ->orderBy('BULAN'); - $KpdlLibrary = new KpdlLibrary; - return $KpdlLibrary->single_array($data->get()->getResult(), 'JML'); + } else { + $tgl_format = date('Y') . '-' . $bulan . '-' . '01'; + $generateTgl = $db->newQuery(new RawSql("SELECT trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1) AS TGL + FROM + dual + CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1)")); + + $data = $db->table('KPDL_MV_LOKASI_SUBJEK B') + ->select("TO_CHAR(CREATION_DATE,'DD') as TGL, COUNT(1) JML") + ->where("to_char(CREATION_DATE,'YYYY') = ", date('Y')) + ->where("to_char(CREATION_DATE,'MM') = ", $bulan) + ->groupBy("TO_CHAR(CREATION_DATE,'DD')"); + + if ($opsiWilZona == 'wilayah') { + $data = $data->whereIn('ADM4_PCODE', $adm4_pcode); + } + + if ($opsiWilZona == 'zona') { + $data = $data->whereIn('ID_POLY_ZONA', $id_poly_zona); + } + $data = $data->getCompiledSelect(); + + $dataRet = $db->newQuery() + ->select("A.TGL, B.JML") + ->from($generateTgl, "A") + ->join("(" . $data . ") B", "A.TGL = B.TGL", 'left') + ->orderBy("TGL"); + return $KpdlLibrary->single_array($dataRet->get()->getResult(), 'JML'); } } @@ -49,7 +77,8 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp $adm4_pcode = $request->getPost('adm4_pcode') ?? []; $id_poly_zona = $request->getPost('id_poly_zona') ?? []; - $db = \Config\Database::connect(); + $db = \Config\Database::connect(); + $KpdlLibrary = new KpdlLibrary; if ($bulan == 'semua') { $npwp = $db->table('KPDL_MV_JML_KPDL A') @@ -73,10 +102,55 @@ class IdentifikasiLapangan extends \App\Controllers\Kewilayahan\Kytp ->join("(" . $npwp . ") C", 'A.KODE = C.BULAN', 'left') ->orderBy('BULAN'); - $KpdlLibrary = new KpdlLibrary; - return $KpdlLibrary->single_array($data->get()->getResult(), 'JML'); + } else { + $tgl_format = date('Y') . '-' . $bulan . '-' . '01'; + $generateTgl = "SELECT TO_CHAR(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1,'DD') AS TGL + FROM + dual + CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1)"; + + $data = $db->table('KPDL_MV_LOKASI_SUBJEK B') + ->select("TO_CHAR(CREATION_DATE,'DD') as TGL, COUNT(1) JML") + ->where("to_char(CREATION_DATE,'YYYY') = ", date('Y')) + ->where("to_char(CREATION_DATE,'MM') = " . $bulan) + ->groupBy("TO_CHAR(CREATION_DATE,'DD')"); + + if ($opsiWilZona == 'wilayah') { + $data = $data->whereIn('ADM4_PCODE', $adm4_pcode); + } + + if ($opsiWilZona == 'zona') { + $data = $data->whereIn('ID_POLY_ZONA', $id_poly_zona); + } + $data = $data->getCompiledSelect(); + + $dataRet = $db->newQuery() + ->select("A.TGL, B.JML") + ->from("(" . $generateTgl . ") A") + ->join("(" . $data . ") B", "A.TGL = B.TGL", 'left') + ->orderBy("TGL"); + + return $KpdlLibrary->single_array($dataRet->get()->getResult(), 'JML'); } } + + protected function generateSeries($bulan) + { + $db = \Config\Database::connect(); + $tgl_format = date('Y') . '-' . $bulan . '-' . '01'; + $generateTgl = $db->query("SELECT TO_CHAR(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD')) - level + 1,'DD') AS TGL + FROM + dual + CONNECT BY LEVEL <= (trunc(LAST_DAY(to_date('" . $tgl_format . "','YYYY-MM-DD'))) - to_date('" . $tgl_format . "','YYYY-MM-DD') + 1) ORDER BY TGL"); + + $data = $generateTgl->getResult(); + $data_arr = []; + foreach ($data as $row) { + array_push($data_arr, $row->TGL); + } + return $data_arr; + } + } diff --git a/app/Views/kewilayahan/dist/kpdl.js b/app/Views/kewilayahan/dist/kpdl.js index 350df88b..d5b4530f 100644 --- a/app/Views/kewilayahan/dist/kpdl.js +++ b/app/Views/kewilayahan/dist/kpdl.js @@ -62797,6 +62797,7 @@ const ChartKpdl = ({ categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] }); const [selectedBulan, setSelectedBulan] = (0,react.useState)("semua"); + const [bulan, setBulan] = (0,react.useState)([]); (0,react.useEffect)(() => { jquery_default().get({ url: base_url + "kewilayahan/kytp/identifikasiLapangan", @@ -62811,6 +62812,16 @@ const ChartKpdl = ({ } }); }, [dataSend, selectedBulan]); + (0,react.useEffect)(() => { + jquery_default().get({ + url: base_url + "kewilayahan/kytp/getBulan", + dataType: "json", + type: "GET", + success: data => { + setBulan(data); + } + }); + }, []); const optionsChart1 = () => { return { chart: { @@ -62899,6 +62910,7 @@ const ChartKpdl = ({ const refBulanOnClick = e => { const kodeBulan = e.target.dataset.value; console.log(kodeBulan); + setSelectedBulan(kodeBulan); }; return /*#__PURE__*/react.createElement(react.Fragment, null, /*#__PURE__*/react.createElement(es_Row, null, /*#__PURE__*/react.createElement(es_Col, { md: "12" @@ -62906,13 +62918,7 @@ const ChartKpdl = ({ className: "d-flex justify-content-start " }, /*#__PURE__*/react.createElement("span", { className: "mr-2" - }, "Bulan :"), /*#__PURE__*/react.createElement(badge_esm_Badge, { - value: "semua", - id: "semua", - severity: "warning", - className: "ref_bulan_a cursor-pointer mr-10", - onClick: e => refBulanOnClick(e) - }), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((val, idx) => { + }, "Bulan :"), bulan.map((val, idx) => { return /*#__PURE__*/react.createElement(badge_esm_Badge, { id: idx, "data-value": val, diff --git a/app/Views/kewilayahan/kytp/componentProgresifitas/ChartKPDL.js b/app/Views/kewilayahan/kytp/componentProgresifitas/ChartKPDL.js index 2e48cdd5..d63ad690 100644 --- a/app/Views/kewilayahan/kytp/componentProgresifitas/ChartKPDL.js +++ b/app/Views/kewilayahan/kytp/componentProgresifitas/ChartKPDL.js @@ -156,26 +156,21 @@ const ChartKpdl = ({ dataSend }) => { <> -
-
- Bulan : - {bulan.map((val, idx) => { - return ( - refBulanOnClick(e)} - > - ) - })} -
-
- Bulan terpilih : - {selectedBulan} -
+
+ Bulan : + refBulanOnClick(e)}> + {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((val, idx) => { + return ( + refBulanOnClick(e)} + > + ) + })}
diff --git a/app/Views/kewilayahan/kytp/readme.txt b/app/Views/kewilayahan/kytp/readme.txt index 65ecc262..500a640c 100644 --- a/app/Views/kewilayahan/kytp/readme.txt +++ b/app/Views/kewilayahan/kytp/readme.txt @@ -13,3 +13,8 @@ jalankan perintah : npx webpack untuk dev : npx webpack --watch config ada webapack.config.js + + +dalam membentuk table yang harus diperhatikan adalah tabel zona pengawasan (KPDL_ZP_NAS_DIFF) : + - pastikan tidak ada polygon yang saling crossing / intersect karena dapat menyebabkan data KPDL terduplikasi atas beberapa zona pengawasan!!!!! + - untuk itu atas polygon yang intersect harus dinormalisasi terlebih dahulu.!!!!