partial update fix sync data pbg

This commit is contained in:
arifal
2025-08-07 22:04:40 +07:00
parent dd1cd72450
commit 3902a486f7
11 changed files with 114 additions and 9 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace App\Console\Commands;
use App\Models\PbgTask;
use App\Models\PbgTaskAttachment;
use App\Models\PbgTaskDetail;
use App\Models\PbgTaskRetributions;
use DB;
use Illuminate\Console\Command;
class TruncatePBGTable extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:truncate-pbg-table';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
PbgTask::truncate();
PbgTaskAttachment::truncate();
PbgTaskRetributions::truncate();
PbgTaskDetail::truncate();
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
}

View File

@@ -33,11 +33,24 @@ class RequestAssignmentController extends Controller
switch ($filter) {
case 'non-business':
$query->whereRaw("LOWER(function_type) != ?", ['sebagai tempat usaha'])->orWhereNull('function_type');
$query->where(function ($q) {
$q->where(function ($q2) {
$q2->whereRaw("LOWER(function_type) != ?", ['sebagai tempat usaha'])
->orWhereNull('function_type');
})
->whereDoesntHave('googleSheet', function ($sub) {
$sub->whereRaw("LOWER(status_verifikasi) = ?", ['selesai verifikasi']);
});
});
break;
case 'business':
$query->whereRaw("LOWER(function_type) = ?", ['sebagai tempat usaha']);
$query->where(function ($q) {
$q->whereRaw("LOWER(function_type) = ?", ['sebagai tempat usaha'])
->whereDoesntHave('googleSheet', function ($sub) {
$sub->whereRaw("LOWER(status_verifikasi) = ?", ['selesai verifikasi']);
});
});
break;
case 'verified':

View File

@@ -50,8 +50,8 @@ class ScrapingDataJob implements ShouldQueue
]);
// Run the scraping services
$service_google_sheet->run_service();
$service_pbg_task->run_service();
// $service_google_sheet->run_service();
// $service_pbg_task->run_service();
try{
$service_tab_pbg_task->run_service();
}catch(\Exception $e){

View File

@@ -43,7 +43,7 @@ class PbgTask extends Model
}
public function googleSheet(){
return $this->hasOne(PbgTaskGoogleSheet::class, 'no_registrasi', 'registration_number');
return $this->hasOne(PbgTaskGoogleSheet::class, 'formatted_registration_number', 'registration_number');
}
public function taskAssignments()

View File

@@ -106,7 +106,7 @@ class ServicePbgTask
};
do {
$url = "{$this->simbg_host}/api/pbg/v1/list/?page={$currentPage}&size={$this->fetch_per_page}&sort=ASC";
$url = "{$this->simbg_host}/api/pbg/v1/list/?page={$currentPage}&size={$this->fetch_per_page}&sort=ASC&date&search&status&slf_status&type&sort_by=created_at&application_type=1&start_date&end_date";
$fetch_data = $fetchData($url);
if (!$fetch_data) {
@@ -123,6 +123,8 @@ class ServicePbgTask
$data = $response['data'];
$totalPage = isset($response['total_page']) ? (int) $response['total_page'] : 1;
Log::info("Total data scraping {$totalPage}");
$saved_data = [];
foreach ($data as $item) {
$saved_data[] = [

View File

@@ -55,7 +55,7 @@ class ServiceTabPbgTask
try{
$this->current_uuid = $pbg_task->uuid;
$this->scraping_task_details($pbg_task->uuid);
$this->scraping_task_assignments($pbg_task->uuid);
// $this->scraping_task_assignments($pbg_task->uuid);
$this->scraping_task_retributions($pbg_task->uuid);
$this->scraping_task_integrations($pbg_task->uuid);
}catch(\Exception $e){
@@ -98,6 +98,8 @@ class ServiceTabPbgTask
$data = $responseData['data'];
Log::info("Executed uid : {$uuid}");
// Use the static method from PbgTaskDetail model to create/update
PbgTaskDetail::createFromApiResponse($data, $uuid);