develop #7
@@ -69,7 +69,7 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
return view('v3.Reports.Mission.Report.CountryActivityReport', [
|
||||
return view('v3.Reports.Mission.Report.Tradod .CountryActivityReport', [
|
||||
'rows' => $exportRows,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
$exportRows[] = $row;
|
||||
}
|
||||
|
||||
return view('v3.Reports.Mission.Report.ProvinceActivityReport', [
|
||||
return view('v3.Reports.Mission.Report.Tradod .ProvinceActivityReport', [
|
||||
'rows' => $exportRows,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
'province_name' => $name,
|
||||
'total' => (int) ($r->total ?? 0),
|
||||
'egdam_shode' => (int) ($r->done ?? 0),
|
||||
'bedone_egdam' => (int) ($r->undon ?? 0),
|
||||
'bedone_egdam' => (int) ($r->undone ?? 0),
|
||||
'sabt_gps' => (int) ($r->gps ?? 0),
|
||||
'sabt_herasat' => (int) ($r->herasat ?? 0),
|
||||
'mil_gps' => (int) ($r->mil_gps ?? 0),
|
||||
@@ -94,7 +94,7 @@ class CountryReport implements FromView, ShouldAutoSize, WithDrawings, WithEvent
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('E1');
|
||||
$drawing2->setCoordinates('G1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
'city_name' => $name,
|
||||
'total' => (int) ($r->total ?? 0),
|
||||
'egdam_shode' => (int) ($r->done ?? 0),
|
||||
'bedone_egdam' => (int) ($r->undon ?? 0),
|
||||
'bedone_egdam' => (int) ($r->undone ?? 0),
|
||||
'sabt_gps' => (int) ($r->gps ?? 0),
|
||||
'sabt_herasat' => (int) ($r->herasat ?? 0),
|
||||
'mil_gps' => (int) ($r->mil_gps ?? 0),
|
||||
@@ -98,7 +98,7 @@ class ProvinceReport implements FromView, ShouldAutoSize, WithDrawings, WithEven
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('E1');
|
||||
$drawing2->setCoordinates('G1');
|
||||
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard\Mission\Report;
|
||||
|
||||
use App\Exports\V3\Mission\Report\Violation\CountryReport;
|
||||
use App\Exports\V3\Mission\Report\Violation\ProvinceReport;
|
||||
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;
|
||||
@@ -31,7 +31,13 @@ class ReportTradodController extends Controller
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' =>$reportMissionService->provinceActivity($request),
|
||||
'city' => City::query()->where('province_id', $request->province_id)->get(['id', 'name_fa']),
|
||||
'city' => City::query()
|
||||
->where('province_id', $request->province_id)
|
||||
->where(function ($query) {
|
||||
$query->where('type_id', 1)
|
||||
->orWhereIn('name_fa', ['اداره ماشينآلات', 'اداره نقلیه']);
|
||||
})
|
||||
->get(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,13 @@ class ReportViolationController extends Controller
|
||||
{
|
||||
return $this->successResponse([
|
||||
'activities' =>$reportService->provinceActivity($request),
|
||||
'city' => City::query()->where('province_id', $request->province_id)->get(['id', 'name_fa']),
|
||||
'city' => City::query()
|
||||
->where('province_id', $request->province_id)
|
||||
->where(function ($query) {
|
||||
$query->where('type_id', 1)
|
||||
->orWhereIn('name_fa', ['اداره ماشينآلات', 'اداره نقلیه']);
|
||||
})
|
||||
->get(['id', 'name_fa'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,76 +27,60 @@ class ReportTradodService
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل کشور' AS province_name,
|
||||
-1 AS province_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.khareg_mahdode) AS khareg_mahdode,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.durations) AS durations,
|
||||
SUM(t.far_h) AS far_h,
|
||||
SUM(t.far_d) AS far_d,
|
||||
SUM(t.un_far_h) AS un_far_h,
|
||||
SUM(t.un_far_d) AS un_far_d,
|
||||
SUM(t.item) AS item,
|
||||
SUM(t.patrol) AS patrol
|
||||
FROM (
|
||||
SELECT
|
||||
p.id AS province_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
|
||||
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
|
||||
FROM provinces p
|
||||
LEFT JOIN missions m
|
||||
ON m.province_id = p.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
GROUP BY p.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
p.name_fa AS province_name,
|
||||
p.id AS province_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
|
||||
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
|
||||
FROM provinces p
|
||||
LEFT JOIN missions m
|
||||
ON m.province_id = p.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
GROUP BY p.id, p.name_fa
|
||||
)q
|
||||
ORDER BY
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name;
|
||||
|
||||
";
|
||||
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل کشور' AS province_name,
|
||||
-1 AS province_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
|
||||
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
|
||||
FROM missions m
|
||||
WHERE m.created_at >= :from_m_1
|
||||
AND m.created_at <= :to_m_1
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
p.name_fa AS province_name,
|
||||
p.id AS province_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(CASE WHEN m.type = 1 THEN 1 ELSE 0 END), 0) AS far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 2 THEN 1 ELSE 0 END), 0) AS far_d,
|
||||
COALESCE(SUM(CASE WHEN m.type = 3 THEN 1 ELSE 0 END), 0) AS un_far_h,
|
||||
COALESCE(SUM(CASE WHEN m.type = 4 THEN 1 ELSE 0 END), 0) AS un_far_d,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 1 THEN 1 ELSE 0 END), 0) AS item,
|
||||
COALESCE(SUM(CASE WHEN m.category_id = 2 THEN 1 ELSE 0 END), 0) AS patrol
|
||||
FROM provinces p
|
||||
LEFT JOIN missions m
|
||||
ON m.province_id = p.id
|
||||
AND m.created_at >= :from_m_2
|
||||
AND m.created_at <= :to_m_2
|
||||
GROUP BY p.id, p.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name;
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
'from_m_1' => $from,
|
||||
'to_m_1' => $to,
|
||||
'from_m_2' => $from,
|
||||
'to_m_2' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -104,90 +88,68 @@ class ReportTradodService
|
||||
{
|
||||
$provinceId = $request->province_id ?? auth()->user()->province_id;
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل استان' AS city_name,
|
||||
-1 AS city_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.khareg_mahdode) AS khareg_mahdode,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.durations) AS durations,
|
||||
SUM(t.far_h) AS far_h,
|
||||
SUM(t.far_d) AS far_d,
|
||||
SUM(t.un_far_h) AS un_far_h,
|
||||
SUM(t.un_far_d) AS un_far_d,
|
||||
SUM(t.item) AS item,
|
||||
SUM(t.patrol) AS patrol
|
||||
FROM (
|
||||
SELECT
|
||||
c.id AS city_id,
|
||||
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(m.type = 1), 0) AS far_h,
|
||||
COALESCE(SUM(m.type = 2), 0) AS far_d,
|
||||
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
|
||||
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
|
||||
COALESCE(SUM(m.category_id = 1), 0) AS item,
|
||||
COALESCE(SUM(m.category_id = 2), 0) AS patrol
|
||||
FROM cities c
|
||||
LEFT JOIN missions m
|
||||
ON m.city_id = c.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.name_fa AS city_name,
|
||||
c.id AS city_id,
|
||||
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(m.type = 1), 0) AS far_h,
|
||||
COALESCE(SUM(m.type = 2), 0) AS far_d,
|
||||
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
|
||||
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
|
||||
COALESCE(SUM(m.category_id = 1), 0) AS item,
|
||||
COALESCE(SUM(m.category_id = 2), 0) AS patrol
|
||||
|
||||
FROM cities c
|
||||
LEFT JOIN missions m
|
||||
ON m.city_id = c.id
|
||||
AND m.created_at >= :from_m
|
||||
AND m.created_at <= :to_m
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
|
||||
q.city_name;
|
||||
|
||||
";
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل استان' AS city_name,
|
||||
-1 AS city_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(m.type = 1), 0) AS far_h,
|
||||
COALESCE(SUM(m.type = 2), 0) AS far_d,
|
||||
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
|
||||
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
|
||||
COALESCE(SUM(m.category_id = 1), 0) AS item,
|
||||
COALESCE(SUM(m.category_id = 2), 0) AS patrol
|
||||
FROM missions m
|
||||
WHERE m.created_at >= :from_m_1
|
||||
AND m.created_at <= :to_m_1
|
||||
AND m.province_id = :province_id_1
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.name_fa AS city_name,
|
||||
c.id AS city_id,
|
||||
COUNT(m.id) AS total,
|
||||
COALESCE(SUM(m.mission_duration != m.in_area_duration), 0) AS khareg_mahdode,
|
||||
COALESCE(SUM(m.in_area_duration), 0) AS gps,
|
||||
COALESCE(SUM(m.mission_duration), 0) AS durations,
|
||||
COALESCE(SUM(m.type = 1), 0) AS far_h,
|
||||
COALESCE(SUM(m.type = 2), 0) AS far_d,
|
||||
COALESCE(SUM(m.type = 3), 0) AS un_far_h,
|
||||
COALESCE(SUM(m.type = 4), 0) AS un_far_d,
|
||||
COALESCE(SUM(m.category_id = 1), 0) AS item,
|
||||
COALESCE(SUM(m.category_id = 2), 0) AS patrol
|
||||
FROM cities c
|
||||
LEFT JOIN missions m
|
||||
ON m.city_id = c.id
|
||||
AND m.created_at >= :from_m_2
|
||||
AND m.created_at <= :to_m_2
|
||||
WHERE c.province_id = :province_id_2
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
|
||||
q.city_name;
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'province_id' => $provinceId,
|
||||
'from_m' => $from,
|
||||
'to_m' => $to,
|
||||
'province_id_1' => $provinceId,
|
||||
'from_m_1' => $from,
|
||||
'to_m_1' => $to,
|
||||
'province_id_2' => $provinceId,
|
||||
'from_m_2' => $from,
|
||||
'to_m_2' => $to,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,67 +27,53 @@ class ReportViolationService
|
||||
public function countryActivity(Request $request): array
|
||||
{
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل کشور' AS province_name,
|
||||
-1 AS province_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.done) AS done,
|
||||
SUM(t.undone) AS undone,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.herasat) AS herasat,
|
||||
SUM(t.mil_gps) AS mil_gps
|
||||
FROM (
|
||||
SELECT
|
||||
p.id AS province_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
|
||||
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل کشور' AS province_name,
|
||||
-1 AS province_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
|
||||
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
|
||||
FROM mission_violations mv
|
||||
WHERE mv.created_at >= :from_mv_1
|
||||
AND mv.created_at <= :to_mv_1
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
p.name_fa AS province_name,
|
||||
p.id AS province_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
|
||||
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
|
||||
FROM provinces p
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.province_id = p.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
GROUP BY p.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
p.name_fa AS province_name,
|
||||
p.id AS province_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 1 THEN 1 ELSE 0 END), 0) as done,
|
||||
COALESCE(SUM(CASE WHEN mv.status = 0 THEN 1 ELSE 0 END), 0) as undone,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN 1 ELSE 0 END), 0) as gps,
|
||||
COALESCE(SUM(CASE WHEN gps = 0 THEN 1 ELSE 0 END), 0) as herasat,
|
||||
COALESCE(SUM(CASE WHEN gps = 1 THEN mileage ELSE 0 END),0) as mil_gps
|
||||
|
||||
FROM provinces p
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.province_id = p.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
GROUP BY p.id, p.name_fa
|
||||
)q
|
||||
AND mv.created_at >= :from_mv_2
|
||||
AND mv.created_at <= :to_mv_2
|
||||
GROUP BY p.id, p.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name;
|
||||
|
||||
";
|
||||
CASE WHEN province_id = -1 THEN 0 ELSE 1 END,
|
||||
province_name;
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
'from_mv_1' => $from,
|
||||
'to_mv_1' => $to,
|
||||
'from_mv_2' => $from,
|
||||
'to_mv_2' => $to,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -95,77 +81,62 @@ class ReportViolationService
|
||||
{
|
||||
$provinceId = $request->province_id ?? auth()->user()->province_id;
|
||||
$from = $request->from_date ?? today()->startOfDay();
|
||||
$to = Carbon::parse($request->to_date)->endOfDay() ?? today()->endOfDay();
|
||||
$to = $request->to_date ? Carbon::parse($request->to_date)->endOfDay() : today()->endOfDay();
|
||||
|
||||
$sql = "
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل استان' AS city_name,
|
||||
-1 AS city_id,
|
||||
SUM(t.total) AS total,
|
||||
SUM(t.done) AS done,
|
||||
SUM(t.undone) AS undone,
|
||||
SUM(t.gps) AS gps,
|
||||
SUM(t.herasat) AS herasat,
|
||||
SUM(t.mil_gps) AS mil_gps
|
||||
FROM (
|
||||
SELECT
|
||||
c.id AS city_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(mv.status = 1), 0) AS done,
|
||||
COALESCE(SUM(mv.status = 0), 0) AS undone,
|
||||
COALESCE(SUM(mv.gps = 1), 0) AS gps,
|
||||
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
|
||||
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
|
||||
FROM cities c
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.city_id = c.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id
|
||||
) t
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.name_fa AS city_name,
|
||||
c.id AS city_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(mv.status = 1), 0) AS done,
|
||||
COALESCE(SUM(mv.status = 0), 0) AS undone,
|
||||
COALESCE(SUM(mv.gps = 1), 0) AS gps,
|
||||
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
|
||||
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
|
||||
FROM cities c
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.city_id = c.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv
|
||||
AND mv.created_at <= :to_mv
|
||||
WHERE c.province_id = :province_id
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
|
||||
q.city_name;
|
||||
|
||||
SELECT*
|
||||
FROM(
|
||||
SELECT
|
||||
'کل استان' AS city_name,
|
||||
-1 AS city_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(mv.status = 1), 0) AS done,
|
||||
COALESCE(SUM(mv.status = 0), 0) AS undone,
|
||||
COALESCE(SUM(mv.gps = 1), 0) AS gps,
|
||||
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
|
||||
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
|
||||
FROM mission_violations mv
|
||||
WHERE mv.type = 1
|
||||
AND mv.created_at >= :from_mv_1
|
||||
AND mv.created_at <= :to_mv_1
|
||||
AND mv.province_id = :province_id_1
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.name_fa AS city_name,
|
||||
c.id AS city_id,
|
||||
COUNT(mv.id) AS total,
|
||||
COALESCE(SUM(mv.status = 1), 0) AS done,
|
||||
COALESCE(SUM(mv.status = 0), 0) AS undone,
|
||||
COALESCE(SUM(mv.gps = 1), 0) AS gps,
|
||||
COALESCE(SUM(mv.gps = 0), 0) AS herasat,
|
||||
COALESCE(SUM(CASE WHEN mv.gps = 1 THEN mv.mileage ELSE 0 END), 0) AS mil_gps
|
||||
FROM cities c
|
||||
LEFT JOIN mission_violations mv
|
||||
ON mv.city_id = c.id
|
||||
AND mv.type = 1
|
||||
AND mv.created_at >= :from_mv_2
|
||||
AND mv.created_at <= :to_mv_2
|
||||
WHERE c.province_id = :province_id_2
|
||||
AND (
|
||||
c.type_id = 1
|
||||
OR c.name_fa IN ('اداره ماشينآلات', 'اداره نقلیه')
|
||||
)
|
||||
GROUP BY c.id, c.name_fa
|
||||
) q
|
||||
ORDER BY
|
||||
CASE WHEN q.city_id = -1 THEN 0 ELSE 1 END,
|
||||
q.city_name;
|
||||
";
|
||||
|
||||
return DB::select($sql, [
|
||||
'province_id' => $provinceId,
|
||||
'from_mv' => $from,
|
||||
'to_mv' => $to,
|
||||
'province_id_1' => $provinceId,
|
||||
'from_mv_1' => $from,
|
||||
'to_mv_1' => $to,
|
||||
'province_id_2' => $provinceId,
|
||||
'from_mv_2' => $from,
|
||||
'to_mv_2' => $to,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title> گزارش کل کشور </title>
|
||||
<title>گزارش کل کشور </title>
|
||||
|
||||
<style>
|
||||
table,
|
||||
@@ -27,18 +27,18 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3"
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3"
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3"
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نخلف های صورت گرفته
|
||||
</th>
|
||||
@@ -79,7 +79,7 @@
|
||||
@foreach ($rows as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total_violations'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['egdam_shode'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedone_egdam'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_gps'] ?? '-' }}</td>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title> گزارش ادارات شهرستان </title>
|
||||
<title>گزارش ادارات شهرستان </title>
|
||||
|
||||
<style>
|
||||
table,
|
||||
@@ -27,18 +27,18 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3"
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3"
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3"
|
||||
<th colspan="7"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نخلف های صورت گرفته
|
||||
</th>
|
||||
@@ -79,7 +79,7 @@
|
||||
@foreach ($rows as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['city_name'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total_violations'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['total'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['egdam_shode'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['bedone_egdam'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['sabt_gps'] ?? '-' }}</td>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title> گزارش کل کشور </title>
|
||||
<title>گزارش کل کشور </title>
|
||||
|
||||
<style>
|
||||
table,
|
||||
@@ -27,20 +27,20 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نخلف های صورت گرفته
|
||||
گزارش ماموریت های انجام شده
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title> گزارش ادارات شهرستان </title>
|
||||
<title>گزارش ادارات شهرستان </title>
|
||||
|
||||
<style>
|
||||
table,
|
||||
@@ -27,20 +27,20 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="7"
|
||||
<th colspan="11"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش نخلف های صورت گرفته
|
||||
گزارش ماموریت های انجام شده
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -546,8 +546,8 @@ Route::prefix('missions')
|
||||
Route::get('/country_excel_activity', 'countryExcelActivity')->name('countryExcelActivity');
|
||||
Route::get('/province_excel_activity', 'provinceExcelActivity')->name('provinceExcelActivity');
|
||||
});
|
||||
Route::prefix('report_tradod')
|
||||
->name('reportsTradod.')
|
||||
Route::prefix('report_taradod')
|
||||
->name('reportsTaradod.')
|
||||
->controller(ReportTradodController::class)
|
||||
->group(function () {
|
||||
Route::get('/country_activity', 'countryActivity')->name('countryActivity')
|
||||
|
||||
Reference in New Issue
Block a user