partial update fix sync data pbg
This commit is contained in:
11
.config/psysh/psysh_history
Normal file
11
.config/psysh/psysh_history
Normal 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
|
||||
40
app/Console/Commands/TruncatePBGTable.php
Normal file
40
app/Console/Commands/TruncatePBGTable.php
Normal 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;');
|
||||
}
|
||||
}
|
||||
@@ -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':
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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[] = [
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -25,7 +25,7 @@ class GlobalSettingSeeder extends Seeder
|
||||
],
|
||||
[
|
||||
"key" => "SIMBG_PASSWORD",
|
||||
"value" => "Simbg123",
|
||||
"value" => "LogitechG29",
|
||||
"type" => "string",
|
||||
"description" => "Password SIMBG",
|
||||
"created_at" => Carbon::now()->format("Y-m-d H:i:s"),
|
||||
|
||||
@@ -32,7 +32,7 @@ class MenuSeeder extends Seeder
|
||||
"sort_order" => 2,
|
||||
"children" => [
|
||||
[
|
||||
"name" => "Dashboard Pimpinan SIMBG",
|
||||
"name" => "Dashboard Pimpinan (PBG)",
|
||||
"url" => "dashboard.home",
|
||||
"icon" => null,
|
||||
"sort_order" => 1,
|
||||
|
||||
Reference in New Issue
Block a user