Update: Vue 2 to Vue 3 with Typescript, node 14 to node 22, Jenkinsfile, Dockerfile, vapor.yml (Post PROD Deployment)

This commit is contained in:
Dillon Ngo
2026-05-28 11:30:50 +08:00
parent 9b0746246c
commit 56e4c07adb
2 changed files with 72 additions and 32 deletions
@@ -17,6 +17,7 @@ use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Jobs\ControllersLogic\SubmitJobLogic;
use Illuminate\Support\Facades\Log;
class MonthlyReportController
{
@@ -150,45 +151,84 @@ class MonthlyReportController
}
public function customerReport(Request $request): JsonResponse {
try {
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
$invitee = $connection->invitee;
$connection = CompanyConnection::where('invitee_reference', $request->route('marking'))->firstOrFail();
$id = $connection->invitee->id;
if (!$invitee) {
Log::warning('Customer report: invitee not found for marking', ['marking' => $request->route('marking')]);
return (new ApiResponseObject('Customer not found',
'The customer associated with this marking no longer exists.',
HttpStatus::OK_WITH_MESSAGE, ['data' => [
'activated_orders' => 0,
'total_cbm' => 0,
'packages' => 0,
]]))->handler();
}
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::parse('01-01-2018');
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now();
$id = $invitee->id;
$containers = Container::whereBetween('loading_date', [$from, $to])->orderBy('loading_date')->get();
$from = $request->route('from') ? Carbon::parse($request->route('from')) : Carbon::parse('01-01-2018');
$to = $request->route('to') ? Carbon::parse($request->route('to')) : Carbon::now();
$packingLists = $containers->flatMap(function ($container) {
return $container->packingLists;
});
// Only load containers that actually have packing lists belonging to this customer,
// instead of loading ALL containers and filtering in PHP (which causes memory exhaustion).
$containers = Container::whereBetween('loading_date', [$from, $to])
->whereHas('packingLists', function ($query) use ($id) {
$query->whereHas('packages', function ($pkgQuery) use ($id) {
$pkgQuery->whereHas('companyModule', function ($cmQuery) use ($id) {
$cmQuery->where('company_modules.id', $id);
});
});
})
->orderBy('loading_date')
->get();
$packages = $packingLists->map(function ($packingList) {
$replica = in_array(Auth()->user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]) ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
return $replica ? $replica : $packingList;
})->flatMap(function ($packingList) {
return $packingList->packages;
});
$packingLists = $containers->flatMap(function ($container) {
return $container->packingLists;
});
$packages = $packages->filter(function($package) use ($id) {
return $package->companyModule->id === $id;
});
$userType = Auth() && Auth()->user() ? Auth()->user()->type : RoleTypes::USER;
$exceptionUsers = in_array($userType, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]);
$orders = $packages->unique(function ($package) {
return $package->order;
});
$packages = $packingLists->map(function ($packingList) use ($exceptionUsers) {
$replica = $exceptionUsers ? $packingList : $packingList->packingLists()->where('type', PackingListType::SHIPPING_PACKING_LIST_REPLICA)->first();
return $replica ? $replica : $packingList;
})->flatMap(function ($packingList) {
return $packingList->packages;
});
$totalCbm = $packages->sum(function($package){
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
});
$packages = $packages->filter(function($package) use ($id) {
$companyModule = $package->companyModule;
return $companyModule && $companyModule->id === $id;
});
return (new ApiResponseObject('fetch monthly report Successful',
'',
HttpStatus::OK_WITH_MESSAGE, ['data' => [
'activated_orders' => count($orders),
'total_cbm' => $totalCbm,
'packages' => $packages->sum('quantity'),
]]))->handler();
$orders = $packages->unique(function ($package) {
return $package->order;
});
$totalCbm = $packages->sum(function($package){
return (( (float) $package->width / 100) * ( (float) $package->length / 100) * ( (float) $package->height / 100)) * $package->quantity;
});
return (new ApiResponseObject('fetch monthly report Successful',
'',
HttpStatus::OK_WITH_MESSAGE, ['data' => [
'activated_orders' => count($orders),
'total_cbm' => $totalCbm,
'packages' => $packages->sum('quantity'),
]]))->handler();
} catch (\Exception $e) {
Log::error('Customer report failed', [
'marking' => $request->route('marking'),
'from' => $request->route('from'),
'to' => $request->route('to'),
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
throw $e;
}
}
public function serviceReport(Request $request): JsonResponse {
@@ -29,7 +29,7 @@
</div>
<div class="col p-l-0">
<div class="btn btn-primary b-rad-none" @click="fetchReport()">
<i class="fa fa-refresh lh-40"></i>
<i class="fa fa-search lh-40"></i>
</div>
</div>
</div>
@@ -130,4 +130,4 @@ const fetchReport = () => {
}
});
};
</script>
</script>