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,11 @@
PbgTask::truncate();
exit
(new App\Jobs\ScrapingDataJob())->handle();
(new App\Jobs\ScrapingDataJob())->handle();
(new App\Jobs\ScrapingDataJob())->handle();
exit
(new App\Jobs\ScrapingDataJob())->handle();
exit
(new App\Jobs\ScrapingDataJob())->handle();
(new App\Jobs\ScrapingDataJob())->handle();
exit

1
.lesshst Normal file
View File

@@ -0,0 +1 @@
.less-history-file:

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) { switch ($filter) {
case 'non-business': 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; break;
case 'business': 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; break;
case 'verified': case 'verified':

View File

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

View File

@@ -43,7 +43,7 @@ class PbgTask extends Model
} }
public function googleSheet(){ 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() public function taskAssignments()

View File

@@ -106,7 +106,7 @@ class ServicePbgTask
}; };
do { 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); $fetch_data = $fetchData($url);
if (!$fetch_data) { if (!$fetch_data) {
@@ -123,6 +123,8 @@ class ServicePbgTask
$data = $response['data']; $data = $response['data'];
$totalPage = isset($response['total_page']) ? (int) $response['total_page'] : 1; $totalPage = isset($response['total_page']) ? (int) $response['total_page'] : 1;
Log::info("Total data scraping {$totalPage}");
$saved_data = []; $saved_data = [];
foreach ($data as $item) { foreach ($data as $item) {
$saved_data[] = [ $saved_data[] = [

View File

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

View File

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('pbg_task_details', function (Blueprint $table) {
$table->string("nik")->nullable()->change();
$table->string("type_card")->nullable()->change();
$table->string("basement")->nullable()->change();
$table->decimal('latitude', 15, 8)->nullable()->change();
$table->decimal('longitude', 15, 8)->nullable()->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('pbg_task_details', function (Blueprint $table) {
$table->string("nik")->nullable()->change();
$table->string("type_card")->nullable()->change();
$table->string("basement")->nullable()->change();
$table->decimal('latitude', 15, 8)->nullable()->change();
$table->decimal('longitude', 15, 8)->nullable()->change();
});
}
};

View File

@@ -25,7 +25,7 @@ class GlobalSettingSeeder extends Seeder
], ],
[ [
"key" => "SIMBG_PASSWORD", "key" => "SIMBG_PASSWORD",
"value" => "Simbg123", "value" => "LogitechG29",
"type" => "string", "type" => "string",
"description" => "Password SIMBG", "description" => "Password SIMBG",
"created_at" => Carbon::now()->format("Y-m-d H:i:s"), "created_at" => Carbon::now()->format("Y-m-d H:i:s"),

View File

@@ -32,7 +32,7 @@ class MenuSeeder extends Seeder
"sort_order" => 2, "sort_order" => 2,
"children" => [ "children" => [
[ [
"name" => "Dashboard Pimpinan SIMBG", "name" => "Dashboard Pimpinan (PBG)",
"url" => "dashboard.home", "url" => "dashboard.home",
"icon" => null, "icon" => null,
"sort_order" => 1, "sort_order" => 1,