|
@@ -15,10 +15,7 @@ class CarIllegalDownController extends BaseController
|
|
|
|
|
|
|
|
|
$mineCode = isset($request->mine_code) ? $request->mine_code : null; // 矿分类
|
|
|
- $stateDate = isset($request->date) ? $request->date : date("Y-m-d"); // 统计日期
|
|
|
-
|
|
|
- $listStartTime = isset($request->date) ? $request->date.' 00:00:00' : date("Y-m-d 00:00:00"); // 开始时间
|
|
|
- $listEndTime = isset($request->date) ? $request->date.' 23:59:59' : date("Y-m-d 23:59:59"); // 结束时间
|
|
|
+ $statisDate = isset($request->date) ? $request->date : date("Y-m-d"); // 统计日期
|
|
|
|
|
|
$page = isset($request->page) ? $request->page : 0; // 分页
|
|
|
$perPage = isset($request->perPage) ? $request->perPage : 20; // 每页显示几条
|
|
@@ -26,7 +23,7 @@ class CarIllegalDownController extends BaseController
|
|
|
// 超速违章统计
|
|
|
for($i = 1; $i < 7; $i++) {
|
|
|
|
|
|
- // 今日
|
|
|
+ // 今日(每4小时统计)
|
|
|
$date = date("Y-m-d");
|
|
|
$stime = sprintf("%02d",($i * 4 - 4)).":00:00";
|
|
|
$etime = ($i * 4) == 24 ? "23:59:59":sprintf("%02d",($i * 4)).":00:00";
|
|
@@ -34,12 +31,13 @@ class CarIllegalDownController extends BaseController
|
|
|
$startTime = $date.' '.$stime;
|
|
|
$endTime = $date.' '.$etime;
|
|
|
|
|
|
+ // 返回统计数据
|
|
|
$res = $this->getCarIllegalByTimeSpan($startTime, $endTime, $mineCode);
|
|
|
|
|
|
$categories1[]= substr($etime, 0, -3);
|
|
|
$data1[] = $res[0]->con;
|
|
|
|
|
|
- // 昨日
|
|
|
+ // 昨日(每4小时统计)
|
|
|
$yesterday = date("Y-m-d", strtotime("-1 day"));
|
|
|
$yStartTime = $yesterday.' '.$stime;
|
|
|
$yEndTime = $yesterday.' '.$etime;
|
|
@@ -65,10 +63,10 @@ class CarIllegalDownController extends BaseController
|
|
|
// 一周内超速趋势
|
|
|
for($i = 1; $i <= 7; $i++) {
|
|
|
|
|
|
- $stateDate = date("Y-m-d", strtotime("-".(7-$i)." day"));
|
|
|
+ $statisDate = date("Y-m-d", strtotime("-".(7-$i)." day"));
|
|
|
|
|
|
- $res = $this->getCarIllegalCount($stateDate, $mineCode);
|
|
|
- $categories3[]= substr($stateDate, -5);
|
|
|
+ $res = $this->getCarIllegalCount($statisDate, $mineCode);
|
|
|
+ $categories3[]= substr($statisDate, -5);
|
|
|
$data3['data'][] = $res[0]->con ?? 0;
|
|
|
}
|
|
|
$data3['name']="数量";
|
|
@@ -78,8 +76,8 @@ class CarIllegalDownController extends BaseController
|
|
|
];
|
|
|
|
|
|
// 违章数据列表
|
|
|
- $dataList = $this->getCarIllegalList($stateDate, $mineCode, $page, $perPage);
|
|
|
- $dataTotal = $this->getCarIllegalCount($stateDate, $mineCode);
|
|
|
+ $dataList = $this->getCarIllegalList($statisDate, $mineCode, $page, $perPage);
|
|
|
+ $dataTotal = $this->getCarIllegalCount($statisDate, $mineCode);
|
|
|
$data = [
|
|
|
"total"=>reset($dataTotal[0]),
|
|
|
"speeding_con"=>$res1,
|
|
@@ -90,27 +88,45 @@ class CarIllegalDownController extends BaseController
|
|
|
}
|
|
|
|
|
|
// 今日超速统计
|
|
|
- public function getCarIllegalCount($stateDate, $mineCode='zaoquan') {
|
|
|
+ public function getCarIllegalCount($statisDate, $mineCode='zaoquan') {
|
|
|
|
|
|
- $sqlStr = "select count(car_num) con from `down_car_speed_warn` where statis_date = '".date("Y-m-d", strtotime($stateDate))."'";
|
|
|
+ $sqlStr = /** @lang text */
|
|
|
+ "select count(t.car_num) con from (
|
|
|
+ select car_num from down_car_speed_warn where statis_date = '".date("Y-m-d", strtotime($statisDate))."'
|
|
|
+ union all
|
|
|
+ select car_num from down_car_run_red_light_warn where statis_date = '".date("Y-m-d", strtotime($statisDate))."'
|
|
|
+ ) t";
|
|
|
|
|
|
return $this->executeSql($sqlStr, 2, $mineCode);
|
|
|
|
|
|
}
|
|
|
|
|
|
- // 超速详细列表
|
|
|
+ // 详细列表
|
|
|
public function getCarIllegalList($startTime, $mineCode='zaoquan', $page=0, $perPage = 15) {
|
|
|
|
|
|
-
|
|
|
if ($startTime == null) return null;
|
|
|
-
|
|
|
- $sqlStr = 'SELECT b.numberplate, b.car_type, b.department, a.warn_start_time, a.warn_stop_time, a.act_val, a.warn_val ';
|
|
|
- $sqlStr .= 'FROM down_car_speed_warn a ';
|
|
|
- $sqlStr .= 'join down_car_base_info b on a.car_num = b.car_num ';
|
|
|
- $sqlStr .= 'where a.statis_date = "'.$startTime.'"';
|
|
|
- $sqlStr .= "order by a.warn_start_time desc ";
|
|
|
-
|
|
|
- $conn = 'etl_'.$mineCode;
|
|
|
+ $sqlStr = /** @lang text */
|
|
|
+
|
|
|
+ "select * from (
|
|
|
+ select '闯红灯' illegal_type,
|
|
|
+ b.numberplate,
|
|
|
+ a.warn_start_time,
|
|
|
+ department,
|
|
|
+ c.light_name illegal_info
|
|
|
+ from down_car_run_red_light_warn a
|
|
|
+ join down_car_base_info b on a.car_num = b.car_num
|
|
|
+ join down_light_info c on a.light_num = c.light_num
|
|
|
+ where statis_date = '".date("Y-m-d", strtotime($startTime))."'
|
|
|
+ union all
|
|
|
+ select '超速' illegal_type,
|
|
|
+ b.numberplate,
|
|
|
+ a.warn_start_time,
|
|
|
+ b.department,
|
|
|
+ concat(a.act_val, ' km/h')
|
|
|
+ from down_car_speed_warn a
|
|
|
+ join down_car_base_info b on a.car_num = b.car_num
|
|
|
+ where statis_date = '".date("Y-m-d", strtotime($startTime))."'
|
|
|
+ ) t order by warn_start_time desc";
|
|
|
|
|
|
$dbResult = $this->executeSql($sqlStr, 4, $mineCode);
|
|
|
|
|
@@ -118,9 +134,10 @@ class CarIllegalDownController extends BaseController
|
|
|
$val = $dbResult[$i];
|
|
|
$data[] = [
|
|
|
'car_number' => $val->numberplate,
|
|
|
- 'speed' => $val->act_val.'km/h',
|
|
|
+ 'type' => $val->illegal_type,
|
|
|
+ 'speed' => $val->department,
|
|
|
'time' => $val->warn_start_time,
|
|
|
- 'place' => $val->department
|
|
|
+ 'place' => $val->illegal_info
|
|
|
];
|
|
|
}
|
|
|
return $data ?? null;
|
|
@@ -133,10 +150,11 @@ class CarIllegalDownController extends BaseController
|
|
|
|
|
|
$sqlStr = /** @lang text */
|
|
|
"select count(case when warn_start_time >= '{$startTime}'
|
|
|
- and warn_start_time < '{$endTime}' then car_num end) con
|
|
|
- from down_car_speed_warn where statis_date = '".date("Y-m-d", strtotime($startTime))."'";
|
|
|
-
|
|
|
- // return $sqlStr;
|
|
|
+ and warn_start_time < '{$endTime}' then car_num end)con from (
|
|
|
+ select car_num, warn_start_time from down_car_speed_warn where statis_date = '2023-11-08'
|
|
|
+ union all
|
|
|
+ select car_num, warn_start_time from down_car_run_red_light_warn where statis_date = '2023-11-08'
|
|
|
+ ) t";
|
|
|
|
|
|
return $this->executeSql($sqlStr, 4, $mineCode);
|
|
|
|