partial update add env for setting api url from env, partial update detail pbg, add tata ruang for dashboard pimpinan, fix service sync simbg add unique for prasarana table
This commit is contained in:
@@ -12,30 +12,34 @@ class DashboardController extends Controller
|
||||
use GlobalApiResponse;
|
||||
|
||||
public function businnessDocument(Request $request){
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join ke pbg_task_retributions
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->orWhereNull('ptgs.status_verifikasi');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(pt.function_type)) = ?', [strtolower(trim('Sebagai Tempat Usaha'))]);
|
||||
})
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
$query = once(function () {
|
||||
return DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid')
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) != ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->orWhereNull('ptgs.status_verifikasi');
|
||||
})
|
||||
->where(function ($query) {
|
||||
$query->whereRaw('LOWER(TRIM(pt.function_type)) = ?', [strtolower(trim('Sebagai Tempat Usaha'))]);
|
||||
})
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution')
|
||||
->first();
|
||||
});
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
$result = [
|
||||
|
||||
return $this->resSuccess([
|
||||
"count" => $taskCount,
|
||||
"total" => $taskTotal
|
||||
];
|
||||
return $this->resSuccess($result);
|
||||
]);
|
||||
}
|
||||
public function nonBusinnessDocument(Request $request){
|
||||
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
$query = once( function () {
|
||||
return DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join ke pbg_task_retributions
|
||||
->where(function ($query) {
|
||||
@@ -49,53 +53,55 @@ class DashboardController extends Controller
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
});
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
$result = [
|
||||
return $this->resSuccess([
|
||||
"count" => $taskCount,
|
||||
"total" => $taskTotal
|
||||
];
|
||||
return $this->resSuccess($result);
|
||||
]);
|
||||
}
|
||||
public function allTaskDocuments(){
|
||||
$query = DB::table('pbg_task')
|
||||
$query = once( function () {
|
||||
return DB::table('pbg_task')
|
||||
->leftJoin('pbg_task_retributions', 'pbg_task.uuid', '=', 'pbg_task_retributions.pbg_task_uid')
|
||||
->select(
|
||||
DB::raw('COUNT(DISTINCT pbg_task.id) as task_count'),
|
||||
DB::raw('SUM(pbg_task_retributions.nilai_retribusi_bangunan) as total_retribution')
|
||||
)
|
||||
->first();
|
||||
});
|
||||
$taskCount = $query->task_count;
|
||||
$taskTotal = $query->total_retribution;
|
||||
$result = [
|
||||
return $this->resSuccess([
|
||||
"count" => $taskCount,
|
||||
"total" => $taskTotal
|
||||
];
|
||||
return $this->resSuccess($result);
|
||||
]);
|
||||
}
|
||||
|
||||
public function verificationDocuments(){
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Menambahkan join ke pbg_task_retributions
|
||||
->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) = ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution')
|
||||
->first();
|
||||
$query = once( function (){
|
||||
return DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Menambahkan join ke pbg_task_retributions
|
||||
->whereRaw('LOWER(TRIM(ptgs.status_verifikasi)) = ?', [strtolower(trim('Selesai Verifikasi'))])
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution')
|
||||
->first();
|
||||
});
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution;
|
||||
|
||||
$result = [
|
||||
return $this->resSuccess([
|
||||
"count"=> $taskCount,
|
||||
"total"=> $taskTotal
|
||||
];
|
||||
|
||||
return $this->resSuccess($result);
|
||||
]);
|
||||
}
|
||||
|
||||
public function nonVerificationDocuments(){
|
||||
$query = DB::table('pbg_task AS pt')
|
||||
$query = once(function () {
|
||||
return DB::table('pbg_task AS pt')
|
||||
->leftJoin('pbg_task_google_sheet AS ptgs', 'pt.registration_number', '=', 'ptgs.no_registrasi')
|
||||
->leftJoin('pbg_task_retributions AS ptr', 'pt.uuid', '=', 'ptr.pbg_task_uid') // Join tabel pbg_task_retributions
|
||||
->where(function ($query) {
|
||||
@@ -105,16 +111,15 @@ class DashboardController extends Controller
|
||||
->selectRaw('COUNT(pt.id) AS total_data,
|
||||
SUM(ptr.nilai_retribusi_bangunan) AS total_retribution') // Menambahkan SUM dari pbg_task_retributions
|
||||
->first();
|
||||
});
|
||||
|
||||
$taskCount = $query->total_data;
|
||||
$taskTotal = $query->total_retribution ?? 0;
|
||||
|
||||
$result = [
|
||||
return $this->resSuccess([
|
||||
"count"=> $taskCount,
|
||||
"total"=> $taskTotal
|
||||
];
|
||||
|
||||
return $this->resSuccess($result);
|
||||
]);
|
||||
}
|
||||
|
||||
public function pbgTaskDocuments(Request $request){
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\PbgTaskMultiStepRequest;
|
||||
use App\Http\Resources\PbgTaskResource;
|
||||
use App\Models\PbgTask;
|
||||
use App\Models\PbgTaskGoogleSheet;
|
||||
use App\Services\GoogleSheetService;
|
||||
@@ -68,7 +69,19 @@ class PbgTaskController extends Controller
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
try{
|
||||
$pbg_task = PbgTask::with(['pbg_task_retributions','pbg_task_index_integrations'])->findOrFail($id);
|
||||
return response()->json([
|
||||
"success"=> true,
|
||||
"message"=> "Data ditemukan",
|
||||
"data"=> $pbg_task
|
||||
]);
|
||||
}catch(\Exception $e){
|
||||
return response()->json([
|
||||
"success"=> false,
|
||||
"message"=> $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\RequestAssignment;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PbgTask;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PbgTaskController extends Controller
|
||||
@@ -36,7 +37,8 @@ class PbgTaskController extends Controller
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
return view("pbg_task.show");
|
||||
$data = PbgTask::with(['pbg_task_retributions','pbg_task_index_integrations'])->findOrFail($id);
|
||||
return view("pbg_task.show", compact("data"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,32 +8,38 @@ use Illuminate\Http\Request;
|
||||
use Exception;
|
||||
class SyncronizeController extends Controller
|
||||
{
|
||||
protected $service_simbg;
|
||||
public function __construct(ServiceSIMBG $service_simbg){
|
||||
$this->service_simbg = $service_simbg;
|
||||
}
|
||||
public function index(Request $request){
|
||||
return view('settings.syncronize.index');
|
||||
}
|
||||
|
||||
public function syncPbgTask(){
|
||||
$res = (new ServiceSIMBG())->syncTaskList();
|
||||
$res = $this->service_simbg->syncTaskList();
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function syncronizeTask(Request $request){
|
||||
$res = (new ServiceSIMBG())->syncTaskList();
|
||||
$res = $this->service_simbg->syncTaskList();
|
||||
return redirect()->back()->with('success', 'Processing completed successfully');
|
||||
}
|
||||
|
||||
public function getUserToken(){
|
||||
$res = (new ServiceSIMBG())->getToken();
|
||||
$res = $this->service_simbg->getToken();
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function syncIndexIntegration($uuid){
|
||||
$res = (new ServiceSIMBG())->syncIndexIntegration($uuid);
|
||||
public function syncIndexIntegration(Request $request, $uuid){
|
||||
$token = $request->get('token');
|
||||
$res = $this->service_simbg->syncIndexIntegration($uuid, $token);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function syncTaskDetailSubmit($uuid){
|
||||
$res = (new ServiceSIMBG())->syncTaskDetailSubmit($uuid);
|
||||
public function syncTaskDetailSubmit(Request $request, $uuid){
|
||||
$token = $request->get('token');
|
||||
$res = $this->service_simbg->syncTaskDetailSubmit($uuid, $token);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,11 @@ class PbgTask extends Model
|
||||
'task_created_at'
|
||||
];
|
||||
|
||||
public function retributions(){
|
||||
public function pbg_task_retributions(){
|
||||
return $this->hasOne(PbgTaskRetributions::class, 'pbg_task_uid', 'uuid');
|
||||
}
|
||||
|
||||
public function pbg_task_index_integrations(){
|
||||
return $this->hasOne(PbgTaskIndexIntegrations::class, 'pbg_task_uid', 'uuid');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,8 @@ class PbgTaskIndexIntegrations extends Model
|
||||
'indeks_terintegrasi',
|
||||
'total',
|
||||
];
|
||||
|
||||
public function pbg_task(){
|
||||
return $this->belongsTo(PbgTask::class, 'pbg_task_uid', 'uuid');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class PbgTaskRetributions extends Model
|
||||
'pbg_task_uid'
|
||||
];
|
||||
|
||||
public function task(){
|
||||
public function pbg_task(){
|
||||
return $this->belongsTo(PbgTask::class, 'pbg_task_uid', 'uuid');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,26 +21,27 @@ class ServiceSIMBG
|
||||
private $password;
|
||||
private $simbg_host;
|
||||
private $fetch_per_page;
|
||||
private $service_client;
|
||||
/**
|
||||
* Create a new class instance.
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(ServiceClient $service_client)
|
||||
{
|
||||
$this->email = trim((string) GlobalSetting::where('key','SIMBG_EMAIL')->first()->value);
|
||||
$this->password = trim((string) GlobalSetting::where('key','SIMBG_PASSWORD')->first()->value);
|
||||
$this->simbg_host = trim((string)GlobalSetting::where('key','SIMBG_HOST')->first()->value);
|
||||
$this->fetch_per_page = trim((string)GlobalSetting::where('key','FETCH_PER_PAGE')->first()->value);
|
||||
$this->service_client = new ServiceClient($this->simbg_host);
|
||||
}
|
||||
|
||||
public function getToken(){
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$url = "/api/user/v1/auth/login/";
|
||||
$body = [
|
||||
'email' => $this->email,
|
||||
'password' => $this->password,
|
||||
];
|
||||
|
||||
$res = $clientHelper->post($url, $body);
|
||||
$res = $this->service_client->post($url, $body);
|
||||
if(!$res->original['success']){
|
||||
Log::error("Token not retrieved ", ['response' => $res]);
|
||||
return null;
|
||||
@@ -50,14 +51,13 @@ class ServiceSIMBG
|
||||
|
||||
public function syncIndexIntegration($uuid, $token)
|
||||
{
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$url = "/api/pbg/v1/detail/" . $uuid . "/retribution/indeks-terintegrasi/";
|
||||
|
||||
$headers = [
|
||||
'Authorization' => "Bearer " . $token,
|
||||
];
|
||||
|
||||
$res = $clientHelper->get($url, $headers);
|
||||
$res = $this->service_client->get($url, $headers);
|
||||
|
||||
Log::info("response index integration", ['res' => $res]);
|
||||
|
||||
@@ -98,7 +98,6 @@ class ServiceSIMBG
|
||||
|
||||
public function syncTaskList()
|
||||
{
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
$initResToken = $this->getToken();
|
||||
|
||||
$importDatasource = ImportDatasource::create([
|
||||
@@ -117,7 +116,7 @@ class ServiceSIMBG
|
||||
$headers = ['Authorization' => "Bearer " . $apiToken];
|
||||
|
||||
$url = "/api/pbg/v1/list/?page=1&size={$this->fetch_per_page}&sort=ASC";
|
||||
$initialResponse = $clientHelper->get($url, $headers);
|
||||
$initialResponse = $this->service_client->get($url, $headers);
|
||||
|
||||
$totalPage = $initialResponse->original['data']['total_page'] ?? 0;
|
||||
if ($totalPage == 0) {
|
||||
@@ -130,7 +129,7 @@ class ServiceSIMBG
|
||||
|
||||
$savedCount = $failedCount = 0;
|
||||
|
||||
for ($currentPage = 50; $currentPage <= $totalPage; $currentPage++) {
|
||||
for ($currentPage = 1; $currentPage <= $totalPage; $currentPage++) {
|
||||
$pageUrl = "/api/pbg/v1/list/?page={$currentPage}&size={$this->fetch_per_page}&sort=ASC";
|
||||
$getToken = $this->getToken();
|
||||
Log::info("response index integration", ['currentPage' => $currentPage]);
|
||||
@@ -143,7 +142,7 @@ class ServiceSIMBG
|
||||
}
|
||||
$token = $getToken->original['data']['token']['access'];
|
||||
$headers = ['Authorization' => "Bearer " . $token];
|
||||
$response = $clientHelper->get($pageUrl, $headers);
|
||||
$response = $this->service_client->get($pageUrl, $headers);
|
||||
$tasks = $response->original['data']['data'] ?? [];
|
||||
|
||||
if (empty($tasks)) {
|
||||
@@ -221,14 +220,12 @@ class ServiceSIMBG
|
||||
|
||||
public function syncTaskDetailSubmit($uuid, $token)
|
||||
{
|
||||
$clientHelper = new ServiceClient($this->simbg_host);
|
||||
|
||||
$url = "/api/pbg/v1/detail/" . $uuid . "/retribution/submit/";
|
||||
$headers = [
|
||||
'Authorization' => "Bearer " . $token,
|
||||
];
|
||||
|
||||
$res = $clientHelper->get($url, $headers);
|
||||
$res = $this->service_client->get($url, $headers);
|
||||
|
||||
Log::info("response task detail submit", ['res' => $res]);
|
||||
|
||||
@@ -290,7 +287,7 @@ class ServiceSIMBG
|
||||
], $prasaranaData);
|
||||
|
||||
// Use bulk insert or upsert for faster database operation
|
||||
PbgTaskPrasarana::upsert($insertData, ['pbg_task_uid', 'prasarana_id']);
|
||||
PbgTaskPrasarana::upsert($insertData, ['prasarana_id']);
|
||||
}
|
||||
|
||||
Log::info("retribution and prasarana successfully", ['uuid' => $uuid]);
|
||||
|
||||
Reference in New Issue
Block a user