This commit is contained in:
威勝 張 2024-02-05 12:08:31 +08:00
parent 852d37b5aa
commit d087812571
4 changed files with 272 additions and 2 deletions

View File

@ -81,6 +81,11 @@ namespace Parking_spaces.Controllers
return View();
}
public IActionResult Yuntech_in_car()
{
return View();
}
}
}

View File

@ -108,7 +108,7 @@
</div>
<!--演算法狀態-->
<div class="col-xl-4 col-lg-5">
<div class="col-xl-4 col-lg-4">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3">
@ -154,7 +154,7 @@
</div>
</div>
<!--字幕機狀態-->
<div class="col-xl-4 col-lg-5">
<div class="col-xl-4 col-lg-4">
<div class="card shadow mb-4">
<!-- Card Header - Dropdown -->
<div class="card-header py-3">
@ -234,6 +234,7 @@
// 取得 canvas 元素
var ctx = document.getElementById('in_car_Bar')
// 使用 Chart.js 繪製長條圖
var myBarChart = new Chart(ctx, {
type: 'bar',
@ -257,6 +258,9 @@
}
}
});
}
@ -274,6 +278,8 @@
// 取得 canvas 元素
var ctx = document.getElementById('violation_car_Bar')
// 使用 Chart.js 繪製長條圖
var myBarChart = new Chart(ctx, {
type: 'bar',

View File

@ -0,0 +1,258 @@

@{
ViewData["Title"] = "Yuntech_in_car";
Layout = "~/Views/Shared/_Layout_Engineering.cshtml";
}
<h1>進入車輛</h1>
<div class="size2">
<table class="table">
<thead>
<tr>
<th>
區域
</th>
<th>
車牌號碼
</th>
<!--<th>
進入圖片
</th>
<th>
違規圖片
</th>-->
<th>
時間
</th>
<th></th>
</tr>
</thead>
<tbody id="demo">
</tbody>
</table>
</div>
<!--車輛詳細-彈跳視窗-->
<div>
<dialog id="detail_car_data_view" style="width:100%;">
<table class="table">
<button class="btn btn-danger" style="float:right" onclick="detail_car_data_view.close();"> 關閉 </button>
<p></p>
<thead>
<tr>
<th>
區域
</th>
<th>
車牌號碼
</th>
<th>
進入圖片
</th>
<th>
時間
</th>
</tr>
</thead>
<tbody id="detail_car_data">
</tbody>
</table>
<button class="btn btn-outline-success" style="float:left" onclick="previous_detail_data()"> Previous</button>
<button class="btn btn-outline-success" style="float:right" onclick="next_detail_data()"> Next </button>
</dialog>
</div>
<!--獲取資料-->
<script>
var All_Model
var serial_number = 0
function get_data() {
var name = "大門口"
//console.log(name)
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location-" + name,
data: {},
contentType: "application/json",
success: function (Model) {
//console.log(Model)
All_Model = Model
set_data(Model)
}
});
}
</script>
<!--放置資料-->
<script>
function set_data(Model) {
table = "<tr>";
console.log(Model.length)
if (Model.length > 0) {
for (var i = 0; i < Model.length; i++) {
if (Model[i].location != null) {
table += "<td>" + Model[i].location + "</td>"
table += "<td>" + Model[i].license_plate_number + "</td>"
// 将字符串转换为 Date 对象
var timestampDt = new Date(Model[i].in_time);
// 转换为其他格式
var options = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' };
var formattedDate = timestampDt.toLocaleDateString('en-US', options);
table += "<td>" + formattedDate + "</td>"
table += "<td>" + '<button class="btn btn-outline-success" onclick="detail_data(' + "'" + Model[i].location + "','" + i + "','" + Model[i].in_time + "'" + ')">詳細</button>'
}
table += "</tr>"
table += "<tr>"
}
}
document.getElementById("demo").innerHTML = table
}
</script>
<!--下一筆資料-->
<script>
function next_detail_data() {
serial_number = Number(serial_number) + 1
if (serial_number >= All_Model.length) {
window.alert('無下一筆資料')
serial_number = All_Model.length - 1
return
}
//console.log(serial_number)
//console.log(All_Model[serial_number])
detail_data(All_Model[serial_number]['location'], serial_number, All_Model[serial_number]['in_time'])
}
</script>
<!--上一筆資料-->
<script>
function previous_detail_data() {
serial_number = Number(serial_number) - 1
if (serial_number < 0) {
window.alert('無上一筆資料')
serial_number = 0
return
}
// console.log(serial_number)
//console.log(All_Model[serial_number])
detail_data(All_Model[serial_number]['location'], serial_number, All_Model[serial_number]['in_time'])
}
</script>
<!--違規車輛詳細-->
<script>
function detail_data(location_name, car_serial_number, time) {
//console.log(location_name)
//console.log(All_Model[car_serial_number])
//console.log(time)
serial_number = car_serial_number
$.ajax({
type: "GET",
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table/location_name-" + location_name + "-time-" + time,
data: {},
contentType: "application/json",
success: function (Model) {
console.log(Model)
table = "<tr>";
table += "<td>" + Model.location + "</td>"
table += "<td>" + '<input type="text" id = "license_plate_number_text_id" value="' + Model.license_plate_number + '"/>' + "</td>"
//table += "<td>" + "</td>"
//table += "<td>" + "</td>"
table += "<td>" + "<img src=" + Model.car_img + ' style="width:80%"' + ">" + "</td>"
table += "<td id = 'create_data_time_id' >" + Model.in_time + "</td>"
document.getElementById("detail_car_data").innerHTML = table
}
});
detail_car_data_view.showModal();
}
</script>
<!--檢查token-->
<script>
function token_check() {
// 检查本地存储中是否存在JWT令牌
var token = localStorage.getItem('token_park_space');
console.log(token)
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/token_check',
headers: {
'Authorization': token
},
success: function (response) {
console.log(response)
token_check = "true"
from_token_import_id()
},
error: function (xhr) {
token_check = "false"
window.location.href = '/';
// 处理错误响应,例如跳转到未授权页面
//window.location.href = 'https://example.com/unauthorized_page';
}
});
}
function from_token_import_id() {
var token = localStorage.getItem('token_park_space');
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/token-' + token,
headers: {
'Authorization': token
},
success: function (response) {
console.log(response)
from_id_import_user_data(response)
}
});
}
function from_id_import_user_data(id) {
var token = localStorage.getItem('token_park_space');
$.ajax({
type: "GET",
url: 'http://140.125.20.183:7700/Users/user_id-' + id,
headers: {
'Authorization': token
},
success: function (model) {
model = model.result
position = model.lastname
console.log(position)
if (position == "engineer") {
get_data()
}
else {
window.location.href = '/';
}
}
});
}
</script>
<!--開機自啟-->
<script>
window.onload = token_check;
</script>

View File

@ -78,6 +78,7 @@
<a class="collapse-item" asp-controller="Engineering" asp-action="Engineering_CAM">查看WEBCAM</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Engineering_LED">字幕機顯示</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Engineering_Violation"> 違規區域</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Yuntech_in_car"> 進入車輛</a>
<a class="collapse-item" asp-controller="Engineering" asp-action="Map_RTSP"> 即時影像</a>
</div>
</div>