Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 998dc0f887 | |||
| cd3d717c33 | |||
| 2b93b6e906 | |||
| f8e534603e |
@@ -13,6 +13,7 @@ use App\Models\Verifikator\PengajuanPresensi;
|
|||||||
use App\Models\Verifikator\Tendik;
|
use App\Models\Verifikator\Tendik;
|
||||||
use App\Models\Verifikator\View\Pegawai;
|
use App\Models\Verifikator\View\Pegawai;
|
||||||
use App\Services\DawaiService;
|
use App\Services\DawaiService;
|
||||||
|
use App\Services\SenjaService;
|
||||||
use App\Services\GoogleDriveService;
|
use App\Services\GoogleDriveService;
|
||||||
use App\Services\VerifikasiAbsenLinkService;
|
use App\Services\VerifikasiAbsenLinkService;
|
||||||
use App\Services\VerifikatorWebhookService;
|
use App\Services\VerifikatorWebhookService;
|
||||||
@@ -23,7 +24,6 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
@@ -758,20 +758,6 @@ class PengajuanAbsenController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->notifikasiTertunda[] = fn () => (new VerifikatorWebhookService)->kirimIzin($pengajuan, VerifikatorWebhookService::STATUS_APPROVED);
|
$this->notifikasiTertunda[] = fn () => (new VerifikatorWebhookService)->kirimIzin($pengajuan, VerifikatorWebhookService::STATUS_APPROVED);
|
||||||
$this->notifikasiTertunda[] = function () use ($pengajuan, $pegawai, $kategori) {
|
|
||||||
try {
|
|
||||||
Http::timeout(5)->asMultipart()->post('http://172.16.50.94:8084/webhook/presensi', [
|
|
||||||
['name' => 'nip', 'contents' => $pengajuan->nip],
|
|
||||||
...array_map(fn ($hari) => ['name' => 'tanggal[]', 'contents' => $hari], $this->daftarHari($pengajuan->tanggal_mulai, $pengajuan->tanggal_selesai ?: $pengajuan->tanggal_mulai)),
|
|
||||||
['name' => 'kategori', 'contents' => (string) $kategori],
|
|
||||||
['name' => 'username', 'contents' => $pegawai->nip],
|
|
||||||
['name' => 'name', 'contents' => $pegawai->nama],
|
|
||||||
]);
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
Log::error("Webhook Presensi error (auto approve): $pengajuan->nip - ".$e->getMessage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -965,6 +951,12 @@ class PengajuanAbsenController extends Controller
|
|||||||
|
|
||||||
Log::info("Hapus Pengajuan Tugas / Dinas: ID $id - NIP $pengajuan->nip - DAWAI ID $pengajuan->dawai_id");
|
Log::info("Hapus Pengajuan Tugas / Dinas: ID $id - NIP $pengajuan->nip - DAWAI ID $pengajuan->dawai_id");
|
||||||
|
|
||||||
|
$mulai = Carbon::parse($pengajuan->tanggal_mulai)->format('Y-m-d');
|
||||||
|
$selesai = Carbon::parse($pengajuan->tanggal_selesai ?: $pengajuan->tanggal_mulai)->format('Y-m-d');
|
||||||
|
if (! (new SenjaService)->resetJamKerja($pengajuan->nip, $mulai, $selesai)) {
|
||||||
|
Log::warning("Hapus Tugas / Dinas: reset jam kerja di SENJA gagal: ID $id - NIP $pengajuan->nip");
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
|
|||||||
@@ -257,6 +257,8 @@ class DawaiService
|
|||||||
$dawaiId = is_array($result['data'] ?? null) ? ($result['data']['id'] ?? null) : ($result['data'] ?? null);
|
$dawaiId = is_array($result['data'] ?? null) ? ($result['data']['id'] ?? null) : ($result['data'] ?? null);
|
||||||
if ($pengajuan && $dawaiId) {
|
if ($pengajuan && $dawaiId) {
|
||||||
$pengajuan->update(['dawai_id' => $dawaiId]);
|
$pengajuan->update(['dawai_id' => $dawaiId]);
|
||||||
|
} elseif ($pengajuan) {
|
||||||
|
Log::warning("DAWAI siskaPengajuanPresensi: respons tanpa id, dawai_id tidak disimpan (pengajuan #{$pengajuan->id}): ".json_encode($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class SenjaService
|
||||||
|
{
|
||||||
|
private const URL = 'http://172.16.40.168:9123';
|
||||||
|
|
||||||
|
private const PIN = 'UntanUltra-2026';
|
||||||
|
|
||||||
|
public const JAM_MASUK_DEFAULT = '07:30:00';
|
||||||
|
|
||||||
|
public const JAM_PULANG_DEFAULT = '16:30:00';
|
||||||
|
|
||||||
|
public function simpanIndex(string $nip, string $tanggalMulai, string $tanggalSelesai, string $jenisAbsen, string $jam): bool
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$response = Http::timeout(15)->asMultipart()->post(self::URL.'/api/simpan-index2026', [
|
||||||
|
['name' => 'start_date', 'contents' => $tanggalMulai],
|
||||||
|
['name' => 'end_date', 'contents' => $tanggalSelesai],
|
||||||
|
['name' => 'jenis_absen', 'contents' => $jenisAbsen],
|
||||||
|
['name' => 'jam', 'contents' => $jam],
|
||||||
|
['name' => 'nip', 'contents' => $nip],
|
||||||
|
['name' => 'pin', 'contents' => self::PIN],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
Log::error("SENJA simpan-index2026 gagal ($nip $tanggalMulai s/d $tanggalSelesai $jenisAbsen $jam): HTTP {$response->status()} ".$response->body());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
Log::error('SENJA simpan-index2026: '.$th->getMessage());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetJamKerja(string $nip, string $tanggalMulai, ?string $tanggalSelesai = null): bool
|
||||||
|
{
|
||||||
|
$tanggalSelesai = $tanggalSelesai ?: $tanggalMulai;
|
||||||
|
|
||||||
|
$masuk = $this->simpanIndex($nip, $tanggalMulai, $tanggalSelesai, 'masuk', self::JAM_MASUK_DEFAULT);
|
||||||
|
$pulang = $this->simpanIndex($nip, $tanggalMulai, $tanggalSelesai, 'pulang', self::JAM_PULANG_DEFAULT);
|
||||||
|
|
||||||
|
return $masuk && $pulang;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user