Compare commits
3 Commits
feature/Ne
...
feature/do
| Author | SHA1 | Date | |
|---|---|---|---|
| d833f4dc0d | |||
| 5f19a26f67 | |||
| dff218541c |
72
Dockerfile
72
Dockerfile
@@ -1,58 +1,32 @@
|
||||
FROM alpine:3.18
|
||||
FROM dunglas/frankenphp:1.11.1-php8.2
|
||||
|
||||
RUN apk update && apk add --no-cache\
|
||||
bash \
|
||||
wget \
|
||||
curl \
|
||||
nano \
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends default-mysql-client \
|
||||
unzip \
|
||||
libzip-dev \
|
||||
libxml2 \
|
||||
libxml2-dev \
|
||||
git \
|
||||
zlib-dev \
|
||||
libpng-dev \
|
||||
php81 \
|
||||
php81-common \
|
||||
php81-fpm \
|
||||
php81-pdo \
|
||||
php81-opcache \
|
||||
php81-soap \
|
||||
php81-zip \
|
||||
php81-phar \
|
||||
php81-iconv \
|
||||
php81-cli \
|
||||
php81-curl \
|
||||
php81-openssl \
|
||||
php81-mbstring \
|
||||
php81-tokenizer \
|
||||
php81-fileinfo \
|
||||
php81-json \
|
||||
php81-xml \
|
||||
php81-xmlwriter \
|
||||
php81-xmlreader \
|
||||
php81-simplexml \
|
||||
php81-dom \
|
||||
php81-pdo_mysql \
|
||||
php81-pdo_pgsql \
|
||||
php81-pdo_sqlite \
|
||||
php81-tokenizer \
|
||||
php81-pecl-redis \
|
||||
php81-gd
|
||||
zip \
|
||||
&& install-php-extensions pdo_mysql \
|
||||
&& install-php-extensions zip \
|
||||
&& install-php-extensions gd \
|
||||
&& install-php-extensions pcntl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
WORKDIR /var/www/rms
|
||||
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
# Copy Laravel application
|
||||
COPY . .
|
||||
|
||||
ARG MOUNT_PATH
|
||||
# Give permissions to storage and bootstrap/cache
|
||||
RUN chmod -R 777 storage bootstrap/cache
|
||||
|
||||
COPY . /var/www/app
|
||||
|
||||
WORKDIR /var/www/app
|
||||
# Install Composer
|
||||
COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Optional: Run migrations/seeds if you want
|
||||
# CMD php artisan migrate && php artisan db:seed && frankenphp run --config /etc/frankenphp/config.prod.yaml
|
||||
CMD composer install;\
|
||||
php artisan key:generate;\
|
||||
# php artisan migrate ;\
|
||||
# php artisan db:seed;\
|
||||
# php artisan storege:link;\
|
||||
php artisan serve --host=0.0.0.0
|
||||
php artisan migrate;\
|
||||
php artisan db:seed;\
|
||||
cd public;\
|
||||
frankenphp php-server
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
|
||||
|
||||
use App\Exports\V3\Mission\Report\Tradod\CountryReport;
|
||||
use App\Exports\V3\Mission\Report\Tradod\ProvinceReport;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use App\Services\Cartables\Mission\Report\ReportTradodService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class MachineMissionController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function Activity(Request $request, ReportTradodService $reportMissionService): JsonResponse
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' => $reportMissionService->countryActivity($request),
|
||||
'provinces' => Province::all(['id', 'name_fa']),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
*/
|
||||
|
||||
public function countryExcelActivity(Request $request, ReportTradodService $reportMissionService): BinaryFileResponse
|
||||
{
|
||||
$data = $reportMissionService->countryActivity($request);
|
||||
$name = 'گزارش کل تردد '.verta()->now()->format('Y-m-d H-i').'.xlsx';
|
||||
|
||||
return Excel::download(new CountryReport($data), $name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,14 +2,10 @@
|
||||
|
||||
namespace App\Listeners\V3\Dashboard\Harim;
|
||||
|
||||
use App\Enums\HarimStates;
|
||||
use App\Events\V3\Dashboard\Harim\RejectRequestEvent;
|
||||
use App\Services\PanjarehVahed\SendAccessRoadStatusService;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
|
||||
class RejectRequestListener implements ShouldQueue
|
||||
{
|
||||
@@ -19,28 +15,20 @@ class RejectRequestListener implements ShouldQueue
|
||||
* @var string|null
|
||||
*/
|
||||
public ?string $queue = 'harim';
|
||||
public int $tries = 2;
|
||||
public function backoff(): array
|
||||
{
|
||||
return [10, 30];
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
|
||||
private SendAccessRoadStatusService $sendAccessRoadStatusService
|
||||
){}
|
||||
public function __construct(){}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(RejectRequestEvent $event): void
|
||||
public function handle(RejectRequestEvent $event, SendAccessRoadStatusService $sendAccessRoadStatusService): void
|
||||
{
|
||||
|
||||
$arrayData = json_decode($event->harim->data, true);
|
||||
|
||||
$this->sendAccessRoadStatusService->makeInputParameters([
|
||||
$sendAccessRoadStatusService->makeInputParameters([
|
||||
'data' => [
|
||||
'actionId' => 470,
|
||||
'actionId' => $arrayData['actionId'],
|
||||
'ruleId' => $arrayData['ruleId'],
|
||||
'activityId' => $arrayData['activityId'],
|
||||
'requestId' => $arrayData['requestId'],
|
||||
@@ -53,119 +41,6 @@ class RejectRequestListener implements ShouldQueue
|
||||
'token' => $arrayData['token'],
|
||||
]);
|
||||
|
||||
$this->sendAccessRoadStatusService->run();
|
||||
}
|
||||
|
||||
public function failed(RejectRequestEvent $event, Throwable $e): void
|
||||
{
|
||||
$harim = $event->harim->fresh();
|
||||
|
||||
DB::transaction(function () use ($harim, $e) {
|
||||
if ((int)$harim->state_id === HarimStates::EMKAN_PAZIR_NEMEBASHAD->value) {
|
||||
$harim->update([
|
||||
'state_id' => HarimStates::BARESI_TAVASOT_MODIR_KOL->value, // همون 4
|
||||
'state_name' => HarimStates::BARESI_TAVASOT_MODIR_KOL->label(),
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
$sendAccessRoadStatusService->run();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//namespace App\Listeners\V3\Dashboard\Harim;
|
||||
//
|
||||
//use App\Enums\HarimStates;
|
||||
//use App\Events\V3\Dashboard\Harim\RejectRequestEvent;
|
||||
//use App\Services\PanjarehVahed\SendAccessRoadStatusService;
|
||||
//use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
//use Illuminate\Support\Facades\DB;
|
||||
//use Illuminate\Support\Facades\Log;
|
||||
//
|
||||
//class RejectRequestListener implements ShouldQueue
|
||||
//{
|
||||
// public ?string $queue = 'harim';
|
||||
//
|
||||
// public function __construct(
|
||||
// private readonly SendAccessRoadStatusService $sendAccessRoadStatusService
|
||||
// )
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public function handle(RejectRequestEvent $event): void
|
||||
// {
|
||||
// $harim = $event->harim;
|
||||
//
|
||||
// $raw = $harim->data;
|
||||
//
|
||||
// // ✅ اگر data خالی/Null یا غیر string بود => 500 نده، فقط revert و خارج شو
|
||||
// if (!is_string($raw) || trim($raw) === '') {
|
||||
// $this->revertHarim($harim->id, 'harim.data is empty or not string');
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// $arrayData = json_decode($raw, true);
|
||||
//
|
||||
// // ✅ اگر json خراب بود => 500 نده، فقط revert و خارج شو
|
||||
// if (!is_array($arrayData) || json_last_error() !== JSON_ERROR_NONE) {
|
||||
// $this->revertHarim($harim->id, 'Invalid harim.data JSON: ' . json_last_error_msg());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// $payload = [
|
||||
// 'data' => [
|
||||
// 'actionId' => $arrayData['actionId'] ?? 470,
|
||||
// 'ruleId' => $arrayData['ruleId'] ?? null,
|
||||
// 'activityId' => $arrayData['activityId'] ?? null,
|
||||
// 'requestId' => $arrayData['requestId'] ?? null,
|
||||
// 'taskId' => $arrayData['taskId'] ?? null,
|
||||
// 'code' => $harim->id,
|
||||
// 'resultStatus' => 3,
|
||||
// 'Description' => $harim->last_description,
|
||||
// ],
|
||||
// 'token' => $arrayData['token'] ?? null,
|
||||
// ];
|
||||
//
|
||||
// // ✅ اگر فیلد حیاتی نبود => revert و خارج شو
|
||||
// if (empty($payload['token']) || empty($payload['data']['requestId'])) {
|
||||
// $this->revertHarim($harim->id, 'Missing token/requestId for external service');
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // ✅ اگر سرویس بیرونی fail شد => 500 نده، revert کن و خارج شو
|
||||
// try {
|
||||
// $this->sendAccessRoadStatusService->makeInputParameters($payload);
|
||||
// $this->sendAccessRoadStatusService->run();
|
||||
//
|
||||
// Log::info('RejectRequest external call succeeded', ['harim_id' => $harim->id]);
|
||||
//
|
||||
// } catch (\Throwable $e) {
|
||||
// $this->revertHarim($harim->id, 'External call failed: ' . $e->getMessage());
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private function revertHarim(int $harimId): void
|
||||
// {
|
||||
// DB::transaction(function () use ($harimId) {
|
||||
// $harim = \App\Models\Harim::query()->lockForUpdate()->find($harimId);
|
||||
//
|
||||
// if (!$harim) {
|
||||
// Log::error('Revert failed: harim not found', ['harim_id' => $harimId]);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if ((int)$harim->state_id === HarimStates::EMKAN_PAZIR_NEMEBASHAD->value) {
|
||||
// $harim->update([
|
||||
// 'state_id' => HarimStates::BARESI_TAVASOT_MODIR_KOL->value,
|
||||
// 'state_name' => HarimStates::BARESI_TAVASOT_MODIR_KOL->label(),
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// Log::warning('RejectRequest reverted harim state (sync mode)', [
|
||||
// 'harim_id' => $harimId,
|
||||
// ]);
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables\Mission\Report;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\MissionViolation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MachinMissionService
|
||||
{
|
||||
public function Activity(Request $request): array
|
||||
{
|
||||
$provinceId = $request->province_id ?? auth()->user()->province_id;
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
cm.machine_code,
|
||||
cm.car_name,
|
||||
COALESCE(c.name_fa, '---') AS city_name,
|
||||
COUNT(m.id) AS missions_count,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations
|
||||
|
||||
FROM cmms_machines cm
|
||||
|
||||
LEFT JOIN missions m
|
||||
ON m.machine_code = cm.machine_code
|
||||
AND m.created_at >= :from
|
||||
AND m.created_at <= :to
|
||||
|
||||
LEFT JOIN cities c
|
||||
ON c.id = cm.city_id
|
||||
|
||||
WHERE (:car_group IS NULL OR cm.car_group = :car_group)
|
||||
AND (:province_id IS NULL OR cm.province_id = :province_id)
|
||||
|
||||
GROUP BY
|
||||
cm.machine_code,
|
||||
cm.car_name,
|
||||
c.name_fa
|
||||
|
||||
ORDER BY
|
||||
missions_count DESC,
|
||||
durations DESC,
|
||||
cm.machine_code;
|
||||
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'province_id' => $provinceId,
|
||||
'from' => $from,
|
||||
'to' => $to,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class SendAccessRoadStatusService
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('harim_web_services.Reject.url');
|
||||
$this->channelName = 'send_access_road';
|
||||
$this->channelName = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@ class SendPaymentInfoService
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('harim_web_services.Reject.url');
|
||||
$this->channelName = 'send_payment_info';
|
||||
$this->channelName = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -152,15 +152,5 @@ return [
|
||||
'path' => storage_path('logs/cmms/daily_moving_machine_service.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
'send_access_road' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/harim/send_access_road_service.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
'send_payment_info' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/harim/send_payment_info_service.log'),
|
||||
'level' => 'info',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
33
docker-compose.yml
Normal file
33
docker-compose.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:10.11.8
|
||||
container_name: rms-mariadb
|
||||
ports:
|
||||
- "3307:3306"
|
||||
environment:
|
||||
MARIADB_DATABASE: ${DB_DATABASE}
|
||||
MARIADB_USER: ${DB_USERNAME}
|
||||
MARIADB_PASSWORD: ${DB_PASSWORD}
|
||||
MARIADB_ROOT_PASSWORD: ${DB_PASSWORD}
|
||||
volumes:
|
||||
- /var/www/rmsdb:/var/lib/mysql
|
||||
networks:
|
||||
- rms
|
||||
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: rms
|
||||
ports:
|
||||
- "8003:80"
|
||||
volumes:
|
||||
- ./:/var/www/rms
|
||||
depends_on:
|
||||
- mariadb
|
||||
networks:
|
||||
- rms
|
||||
|
||||
networks:
|
||||
rms:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user