Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90ebd7c545 | |||
| 1b1aed2858 | |||
| 114c7fbcc9 | |||
| 751a4f9283 | |||
| 56b9f227a0 | |||
| e4b089b695 | |||
| 0da23d7f12 | |||
| bbbe40afb3 |
@@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\Pegawai;
|
||||||
|
|
||||||
|
use App\Models\Verifikator\Dosen;
|
||||||
|
use App\Models\Verifikator\Tendik;
|
||||||
|
use App\Services\SiskaService;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class UpdateNoHpPimpinanCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'pegawai:update-no-hp-pimpinan';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Update nomor HP dosen dan tendik dari SISKA API (api/v2/user/pimpinan)';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(SiskaService $siskaService)
|
||||||
|
{
|
||||||
|
$this->info('Mengambil data pimpinan dari SISKA...');
|
||||||
|
|
||||||
|
$pimpinan = $siskaService->daftarPimpinan();
|
||||||
|
|
||||||
|
if ($pimpinan === null) {
|
||||||
|
$this->error('Gagal mengambil data dari SISKA');
|
||||||
|
|
||||||
|
return Command::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Total data pimpinan: '.count($pimpinan));
|
||||||
|
|
||||||
|
// NIP bisa muncul berkali-kali dengan no_hp berbeda, ambil yang terakhir
|
||||||
|
$noHpByNip = [];
|
||||||
|
foreach ($pimpinan as $item) {
|
||||||
|
$nip = $item['nip'] ?? null;
|
||||||
|
$noHp = $item['no_hp'] ?? null;
|
||||||
|
|
||||||
|
if (! $nip || ! $noHp) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$noHpByNip[$nip] = $noHp;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Total NIP unik: '.count($noHpByNip));
|
||||||
|
$this->newLine();
|
||||||
|
|
||||||
|
$updatedDosen = 0;
|
||||||
|
$updatedTendik = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$nipList = array_keys($noHpByNip);
|
||||||
|
|
||||||
|
$dosens = Dosen::whereIn('nip', $nipList)->get(['id', 'nip', 'no_hp']);
|
||||||
|
foreach ($dosens as $dosen) {
|
||||||
|
$noHp = $noHpByNip[$dosen->nip];
|
||||||
|
if ($dosen->no_hp !== $noHp) {
|
||||||
|
$dosen->update(['no_hp' => $noHp]);
|
||||||
|
$updatedDosen++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tendiks = Tendik::whereIn('nip', $nipList)->get(['id', 'nip', 'no_hp']);
|
||||||
|
foreach ($tendiks as $tendik) {
|
||||||
|
$noHp = $noHpByNip[$tendik->nip];
|
||||||
|
if ($tendik->no_hp !== $noHp) {
|
||||||
|
$tendik->update(['no_hp' => $noHp]);
|
||||||
|
$updatedTendik++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->error('Terjadi error: '.$e->getMessage());
|
||||||
|
Log::error('Error saat update no_hp pimpinan', [
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return Command::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Dosen diupdate: {$updatedDosen}");
|
||||||
|
$this->info("Tendik diupdate: {$updatedTendik}");
|
||||||
|
$this->info('Selesai.');
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,11 +44,11 @@ class KeseluruhanExport implements FromArray, ShouldAutoSize, WithColumnFormatti
|
|||||||
return ['C'];
|
return ['C'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(int $tahun, ?string $jenisPegawai, mixed $unit)
|
public function __construct(int $tahun, ?string $jenisPegawai, mixed $unit, bool $includePppk2025 = false, bool $includeP1Zero = false)
|
||||||
{
|
{
|
||||||
$controller = app(KeseluruhanController::class);
|
$controller = app(KeseluruhanController::class);
|
||||||
|
|
||||||
$this->rows = $controller->getRekapRows($tahun, $jenisPegawai, $unit);
|
$this->rows = $controller->getRekapRows($tahun, $jenisPegawai, $unit, $includePppk2025, $includeP1Zero);
|
||||||
$this->bulanTerakhir = $controller->getBulanTerakhir($tahun);
|
$this->bulanTerakhir = $controller->getBulanTerakhir($tahun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,10 @@ class KeseluruhanController extends Controller
|
|||||||
$tahun = (int) ($request->tahun ?: now()->year);
|
$tahun = (int) ($request->tahun ?: now()->year);
|
||||||
$jenisPegawai = $request->jenis_pegawai ?: null;
|
$jenisPegawai = $request->jenis_pegawai ?: null;
|
||||||
$unit = $request->unit;
|
$unit = $request->unit;
|
||||||
|
$includePppk2025 = $request->boolean('include_pppk_2025');
|
||||||
|
$includeP1Zero = $request->boolean('include_p1_zero');
|
||||||
|
|
||||||
$rows = collect($this->getRekapRows($tahun, $jenisPegawai, $unit));
|
$rows = collect($this->getRekapRows($tahun, $jenisPegawai, $unit, $includePppk2025, $includeP1Zero));
|
||||||
|
|
||||||
return DataTables::of($rows)
|
return DataTables::of($rows)
|
||||||
->editColumn('jenis_pegawai', fn ($row) => $row['jenis_pegawai'] === 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] === 'tendik' ? 'Tendik' : '-'))
|
->editColumn('jenis_pegawai', fn ($row) => $row['jenis_pegawai'] === 'dosen' ? 'Dosen' : ($row['jenis_pegawai'] === 'tendik' ? 'Tendik' : '-'))
|
||||||
@@ -69,6 +71,8 @@ class KeseluruhanController extends Controller
|
|||||||
$tahun = (int) ($request->tahun ?: now()->year);
|
$tahun = (int) ($request->tahun ?: now()->year);
|
||||||
$jenisPegawai = $request->jenis_pegawai ?: null;
|
$jenisPegawai = $request->jenis_pegawai ?: null;
|
||||||
$unit = $request->unit;
|
$unit = $request->unit;
|
||||||
|
$includePppk2025 = $request->boolean('include_pppk_2025');
|
||||||
|
$includeP1Zero = $request->boolean('include_p1_zero');
|
||||||
|
|
||||||
$unitName = '_Semua_Unit_Kerja';
|
$unitName = '_Semua_Unit_Kerja';
|
||||||
if ($unit !== null && $unit !== '') {
|
if ($unit !== null && $unit !== '') {
|
||||||
@@ -80,7 +84,7 @@ class KeseluruhanController extends Controller
|
|||||||
|
|
||||||
$filename = "Remunerasi_Keseluruhan_{$tahun}{$unitName}.xlsx";
|
$filename = "Remunerasi_Keseluruhan_{$tahun}{$unitName}.xlsx";
|
||||||
|
|
||||||
return Excel::download(new KeseluruhanExport($tahun, $jenisPegawai, $unit), $filename);
|
return Excel::download(new KeseluruhanExport($tahun, $jenisPegawai, $unit, $includePppk2025, $includeP1Zero), $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +92,7 @@ class KeseluruhanController extends Controller
|
|||||||
* tahun terpilih. Dipakai bersama oleh data() (DataTables) dan KeseluruhanExport supaya kedua
|
* tahun terpilih. Dipakai bersama oleh data() (DataTables) dan KeseluruhanExport supaya kedua
|
||||||
* sisi (tampilan web & export Excel) selalu konsisten.
|
* sisi (tampilan web & export Excel) selalu konsisten.
|
||||||
*/
|
*/
|
||||||
public function getRekapRows(int $tahun, ?string $jenisPegawai, mixed $unit): array
|
public function getRekapRows(int $tahun, ?string $jenisPegawai, mixed $unit, bool $includePppk2025 = false, bool $includeP1Zero = false): array
|
||||||
{
|
{
|
||||||
$rows = $this->buildRekap($tahun, $jenisPegawai);
|
$rows = $this->buildRekap($tahun, $jenisPegawai);
|
||||||
|
|
||||||
@@ -103,12 +107,20 @@ class KeseluruhanController extends Controller
|
|||||||
})->values();
|
})->values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $includePppk2025) {
|
||||||
|
$rows = $rows->filter(fn ($row) => ! str_contains($row['nip'] ?? '', '202521'))->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $includeP1Zero) {
|
||||||
|
$rows = $rows->filter(fn ($row) => ($row['jumlah_p1'] ?? 0) > 0)->values();
|
||||||
|
}
|
||||||
|
|
||||||
return $rows->sortBy('nama', SORT_NATURAL | SORT_FLAG_CASE)->values()->all();
|
return $rows->sortBy('nama', SORT_NATURAL | SORT_FLAG_CASE)->values()->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildRekap(int $tahun, ?string $jenisPegawai): Collection
|
private function buildRekap(int $tahun, ?string $jenisPegawai): Collection
|
||||||
{
|
{
|
||||||
$cacheKey = 'remunerasi_keseluruhan_v2_'.$tahun.'_'.($jenisPegawai ?: 'semua');
|
$cacheKey = 'remunerasi_keseluruhan_v4_'.$tahun.'_'.($jenisPegawai ?: 'semua');
|
||||||
|
|
||||||
return collect(Cache::remember($cacheKey, now()->addHours(6), fn () => $this->computeRekap($tahun, $jenisPegawai)));
|
return collect(Cache::remember($cacheKey, now()->addHours(6), fn () => $this->computeRekap($tahun, $jenisPegawai)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -685,6 +685,21 @@ class SiskaService
|
|||||||
return $sks;
|
return $sks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function daftarPimpinan(): ?array
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = $this->client->get('api/v2/user/pimpinan');
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
Log::error('SISKA: '.$th->getMessage());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($response->getBody()->getContents(), true);
|
||||||
|
|
||||||
|
return $data['data'] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
public function status(string $status)
|
public function status(string $status)
|
||||||
{
|
{
|
||||||
$result = [
|
$result = [
|
||||||
|
|||||||
@@ -77,6 +77,16 @@
|
|||||||
<option value="dosen">Dosen</option>
|
<option value="dosen">Dosen</option>
|
||||||
<option value="tendik">Tendik</option>
|
<option value="tendik">Tendik</option>
|
||||||
</select>
|
</select>
|
||||||
|
<div class="d-flex align-items-center gap-3 mt-1">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="include_pppk_2025">
|
||||||
|
<label class="form-check-label" for="include_pppk_2025">PPPK 2025</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" id="include_p1_zero">
|
||||||
|
<label class="form-check-label" for="include_p1_zero">P1 = 0</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
@@ -164,6 +174,8 @@
|
|||||||
d.jenis_pegawai = $('#filter-jenis-pegawai').val();
|
d.jenis_pegawai = $('#filter-jenis-pegawai').val();
|
||||||
d.unit = $('#filter-unit').val();
|
d.unit = $('#filter-unit').val();
|
||||||
d.tahun = $('#filter-tahun').val();
|
d.tahun = $('#filter-tahun').val();
|
||||||
|
d.include_pppk_2025 = $('#include_pppk_2025').is(':checked') ? 1 : 0;
|
||||||
|
d.include_p1_zero = $('#include_p1_zero').is(':checked') ? 1 : 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
@@ -209,7 +221,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#filter-jenis-pegawai, #filter-unit, #filter-tahun').on('change', function() {
|
$('#filter-jenis-pegawai, #filter-unit, #filter-tahun, #include_pppk_2025, #include_p1_zero').on('change', function() {
|
||||||
table.draw();
|
table.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -233,10 +245,14 @@
|
|||||||
var jenisPegawai = $('#filter-jenis-pegawai').val();
|
var jenisPegawai = $('#filter-jenis-pegawai').val();
|
||||||
var unit = $('#filter-unit').val();
|
var unit = $('#filter-unit').val();
|
||||||
var tahun = $('#filter-tahun').val();
|
var tahun = $('#filter-tahun').val();
|
||||||
|
var includePppk2025 = $('#include_pppk_2025').is(':checked') ? 1 : 0;
|
||||||
|
var includeP1Zero = $('#include_p1_zero').is(':checked') ? 1 : 0;
|
||||||
|
|
||||||
if (jenisPegawai) { params.push('jenis_pegawai=' + jenisPegawai); }
|
if (jenisPegawai) { params.push('jenis_pegawai=' + jenisPegawai); }
|
||||||
if (unit) { params.push('unit=' + unit); }
|
if (unit) { params.push('unit=' + unit); }
|
||||||
if (tahun) { params.push('tahun=' + tahun); }
|
if (tahun) { params.push('tahun=' + tahun); }
|
||||||
|
params.push('include_pppk_2025=' + includePppk2025);
|
||||||
|
params.push('include_p1_zero=' + includeP1Zero);
|
||||||
|
|
||||||
var url = "{{ route('remunerasi.keseluruhan.export') }}";
|
var url = "{{ route('remunerasi.keseluruhan.export') }}";
|
||||||
if (params.length > 0) {
|
if (params.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user