create new thing
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
namespace App\Http\Controllers\V3\Dashboard\Harim;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\V3\Dashboard\Harim\PanjareVahed\GetAccessRouteRequest;
|
use App\Http\Requests\V3\Dashboard\Harim\PanjareVahed\GetAccessRoadRequest;
|
||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
use App\Models\Harim;
|
use App\Models\Harim;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -21,7 +21,7 @@ class PanjareVahedController extends Controller
|
|||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
public function getAccessRoute(GetAccessRouteRequest $request,Harim $harim)
|
public function getAccessRoad(GetAccessRoadRequest $request, Harim $harim)
|
||||||
{
|
{
|
||||||
Harim::update([
|
Harim::update([
|
||||||
'panjarevahed_id' => $request->panjarevahed_id,
|
'panjarevahed_id' => $request->panjarevahed_id,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace App\Http\Requests\V3\Dashboard\Harim\PanjareVahed;
|
|||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class GetAccessRouteRequest extends FormRequest
|
class GetAccessRoadRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
@@ -37,32 +37,49 @@ class OperatorService
|
|||||||
public function countryActivity(int $info_id): array
|
public function countryActivity(int $info_id): array
|
||||||
{
|
{
|
||||||
return DB::select("
|
return DB::select("
|
||||||
WITH province_data AS (
|
WITH base AS (
|
||||||
|
SELECT
|
||||||
|
p.id AS province_id,
|
||||||
|
a.id AS axis_type_id,
|
||||||
|
COALESCE(SUM(t.step = 1), 0) AS s1,
|
||||||
|
COALESCE(SUM(t.step = 2), 0) AS s2,
|
||||||
|
COALESCE(SUM(t.step = 3), 0) AS s3
|
||||||
|
FROM provinces p
|
||||||
|
JOIN axis_types a
|
||||||
|
LEFT JOIN safety_and_privacy t
|
||||||
|
ON t.province_id = p.id
|
||||||
|
AND t.axis_type_id = a.id
|
||||||
|
AND t.info_id = :infoId
|
||||||
|
GROUP BY p.id, a.id
|
||||||
|
)
|
||||||
SELECT
|
SELECT
|
||||||
p.id AS province_id,
|
province_id,
|
||||||
a.id AS axis_type_id,
|
axis_type_id,
|
||||||
SUM(CASE WHEN t.step = 1 THEN 1 ELSE 0 END) AS s1,
|
s1,
|
||||||
SUM(CASE WHEN t.step = 2 THEN 1 ELSE 0 END) AS c2,
|
s2,
|
||||||
SUM(CASE WHEN t.step = 3 THEN 1 ELSE 0 END) AS c3
|
s3,
|
||||||
FROM provinces p
|
COALESCE(
|
||||||
CROSS JOIN axis_types a
|
SUM(s1 + s2 + s3)
|
||||||
LEFT JOIN safety_and_privacy t
|
OVER (PARTITION BY province_id), 0
|
||||||
ON p.id = t.province_id
|
) AS total_sum
|
||||||
AND a.id = t.axis_type_id
|
FROM base
|
||||||
AND t.info_id = :infoId
|
|
||||||
GROUP BY p.id, a.id
|
|
||||||
)
|
|
||||||
SELECT * FROM province_data
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
-1 AS province_id,
|
-1 AS province_id,
|
||||||
axis_type_id,
|
axis_type_id,
|
||||||
SUM(s1) AS s1,
|
COALESCE(SUM(s1), 0) AS s1,
|
||||||
SUM(c2) AS c2,
|
COALESCE(SUM(s2), 0) AS s2,
|
||||||
SUM(c3) AS c3
|
COALESCE(SUM(s3), 0) AS s3,
|
||||||
FROM province_data
|
COALESCE(
|
||||||
|
SUM(SUM(s1 + s2 + s3)) OVER (), 0
|
||||||
|
) AS total_sum
|
||||||
|
FROM base
|
||||||
GROUP BY axis_type_id
|
GROUP BY axis_type_id
|
||||||
|
|
||||||
ORDER BY province_id, axis_type_id
|
ORDER BY province_id, axis_type_id
|
||||||
|
|
||||||
", [
|
", [
|
||||||
'infoId' => $info_id,
|
'infoId' => $info_id,
|
||||||
]);
|
]);
|
||||||
@@ -71,33 +88,49 @@ class OperatorService
|
|||||||
public function provinceActivity(int $info_id, int $province_id): array
|
public function provinceActivity(int $info_id, int $province_id): array
|
||||||
{
|
{
|
||||||
return DB::select("
|
return DB::select("
|
||||||
WITH edareh_data AS (
|
WITH edareh_data AS (
|
||||||
SELECT
|
SELECT
|
||||||
e.id AS edareh_id,
|
e.id AS edareh_id,
|
||||||
a.id AS axis_type_id,
|
a.id AS axis_type_id,
|
||||||
SUM(CASE WHEN t.step = 1 THEN 1 ELSE 0 END) AS c1,
|
COALESCE(SUM(t.step = 1), 0) AS s1,
|
||||||
SUM(CASE WHEN t.step = 2 THEN 1 ELSE 0 END) AS c2,
|
COALESCE(SUM(t.step = 2), 0) AS s2,
|
||||||
SUM(CASE WHEN t.step = 3 THEN 1 ELSE 0 END) AS c3
|
COALESCE(SUM(t.step = 3), 0) AS s3
|
||||||
FROM edarate_shahri e
|
FROM edarate_shahri e
|
||||||
CROSS JOIN axis_types a
|
JOIN axis_types a ON 1
|
||||||
LEFT JOIN safety_and_privacy t
|
LEFT JOIN safety_and_privacy t
|
||||||
ON e.id = t.edare_shahri_id
|
ON e.id = t.edare_shahri_id
|
||||||
AND a.id = t.axis_type_id
|
AND t.axis_type_id = a.id
|
||||||
AND t.info_id = :infoId
|
AND t.info_id = :infoId
|
||||||
WHERE e.province_id = :provinceId
|
WHERE e.province_id = :provinceId
|
||||||
GROUP BY e.id, a.id
|
GROUP BY e.id, a.id
|
||||||
)
|
)
|
||||||
SELECT * FROM edareh_data
|
SELECT
|
||||||
UNION ALL
|
edareh_id,
|
||||||
SELECT
|
axis_type_id,
|
||||||
-1 AS edareh_id,
|
s1,
|
||||||
axis_type_id,
|
s2,
|
||||||
SUM(s1) AS s1,
|
s3,
|
||||||
SUM(c2) AS c2,
|
COALESCE(
|
||||||
SUM(c3) AS c3
|
SUM(s1 + s2 + s3)
|
||||||
FROM edareh_data
|
OVER (PARTITION BY edareh_id), 0
|
||||||
GROUP BY axis_type_id
|
) AS total_sum
|
||||||
ORDER BY edareh_id, axis_type_id
|
FROM edareh_data
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
-1 AS edareh_id,
|
||||||
|
axis_type_id,
|
||||||
|
COALESCE(SUM(s1), 0) AS s1,
|
||||||
|
COALESCE(SUM(s2), 0) AS s2,
|
||||||
|
COALESCE(SUM(s3), 0) AS s3,
|
||||||
|
COALESCE(
|
||||||
|
SUM(SUM(s1 + s2 + s3)) OVER (), 0
|
||||||
|
) AS total_sum
|
||||||
|
FROM edareh_data
|
||||||
|
GROUP BY axis_type_id
|
||||||
|
|
||||||
|
ORDER BY edareh_id , axis_type_id
|
||||||
", [
|
", [
|
||||||
'provinceId' => $province_id,
|
'provinceId' => $province_id,
|
||||||
'infoId' => $info_id,
|
'infoId' => $info_id,
|
||||||
|
|||||||
@@ -565,7 +565,7 @@ Route::prefix('harim')
|
|||||||
->name('panjarevahed.')
|
->name('panjarevahed.')
|
||||||
->controller(PanjarevahedController::class)
|
->controller(PanjarevahedController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::post('/get_access_route','getAccessRoute')->name('getAccessRoute');
|
Route::post('/get_access_road','getAccessRoad')->name('getAccessRoad');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user