This commit is contained in:
威勝 張 2024-02-14 21:43:14 +08:00
commit f8e4ce69c4
4 changed files with 69 additions and 530 deletions

View File

@ -242,10 +242,10 @@
var myLineChart = new Chart(ctx1, {
type: 'line',
data: {
labels: date.reverse(),
labels: date,
datasets: [{
label: '車流量',
data: values.reverse(),
data: values,
backgroundColor: 'rgba(75, 192, 192, 0.2)', // 設定背景色
borderColor: 'rgba(75, 192, 192, 1)', // 設定邊框色
pointHitRadius: 10,
@ -334,10 +334,10 @@
var myBarChart = new Chart(ctx, {
type: 'bar',
data: {
labels: date.reverse(),
labels: date,
datasets: [{
label: '違規數量',
data: values.reverse(),
data: values,
backgroundColor: 'rgba(255, 0, 0, 0.5)', // 設定半透明的紅色背景
borderColor: 'rgba(255, 0, 0, 1)', // 設定不透明的紅色邊框
borderWidth: 1
@ -366,21 +366,23 @@
var token_ckeck //= document.getElementById("token_ckeck_id").value
var position //職位
function get_violation_data_1() {
day = 30
violation_car_list = []
//console.log("start")
//token_check = document.getElementById("token_check_id").value
//console.log(token_check)
$.ajax({
type: "GET",
url: "http://localhost:5174/api/Parking_spaces_violation_total_table",
url: "http://140.125.20.183:7700/api/Parking_spaces_violation_total_table",
data: {},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
get_violation_data_2(Model)
//get_violation_data_2(Model)
console.log(Model)
set_violation_data_1(Model)
}
});
@ -393,150 +395,31 @@
////console.log(name)
$.ajax({
type: "GET",
url: "http://localhost:5174/api/Violation_car_table/violation_location_name-" + name,
url: "http://140.125.20.183:7700/api/Violation_car_table/violation_location_name-" + name,
data: {},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
set_violation_data_1(Model)
}
});
}
}
set_violation_data_3()
}
</script>
<!--設置違規資料-->
<script>
var date_list = []
var violation_car_list = []
function set_violation_data_1(Model) {
// 獲取當前日期
var today = new Date();
// 提取年、月、日
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var todayDate = year + '-' + month + '-' + day;
var date_list = []
var violation_car_list = []
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].create_data_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
if (daysDifference > 29) {
console.log(date_list)
break
}
if (D != date) {
D = date
var D_1 = new Date(D);
var D_1 = new Date(Model[i]['date']);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var hasValue = date_list.includes(MD);
if (hasValue == false) {
date_list.push(MD)
violation_car_list.push(Model[i]['occurrences'])
}
}
}
}
//console.log(date_list)
set_violation_data_2(Model)
}
function set_violation_data_2(Model) {
if (date_list.length > 0 && violation_car_list.length <= 0) {
for (var i = 0; i < date_list.length; i++) {
violation_car_list.push(0)
}
}
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
var todayDate = year + '-' + month + '-' + day;
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].create_data_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
////console.log(daysDifference)
if (daysDifference > date_list.length) {
break
}
var D_1 = new Date(date);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var index = date_list.indexOf(MD);
////console.log(index)
violation_car_list[index] = violation_car_list[index] + 1
}
}
}
function set_violation_data_3() {
// 等待 2000 毫秒2 秒)
setTimeout(function () {
set_violation_table(date_list, violation_car_list)
}, 200);
}
</script>
@ -546,21 +429,18 @@
<!--獲取進入雲科資料-->
<script>
function get_in_yuntech_data_1() {
day = 30
in_car_list = []
//console.log(token_check)
$.ajax({
type: "GET",
url: "http://localhost:5174/api/Yuntech_in_car_table",
url: "http://140.125.20.183:7700/api/Yuntech_in_car_table",
data: {},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
//console.log(Model)
setTimeout(function () {
set_in_yuntech_data_1(Model)
}, 200);
}
@ -572,61 +452,16 @@
<script>
var in_car_list = []
function set_in_yuntech_data_1(Model) {
if (date_list.length > 0 && in_car_list.length <= 0) {
for (var i = 0; i < date_list.length; i++) {
in_car_list.push(0)
}
}
console.log(in_car_list)
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
var todayDate = year + '-' + month + '-' + day;
var date_list = []
var in_car_list = []
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].in_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
////console.log(daysDifference)
if (daysDifference > date_list.length) {
break
}
var D_1 = new Date(date);
var D_1 = new Date(Model[i]['date']);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var index = date_list.indexOf(MD);
////console.log(index)
in_car_list[index] = in_car_list[index] + 1
date_list.push(MD)
in_car_list.push(Model[i]['occurrences'])
}
set_in_yuntech_data_3()
}
}
function set_in_yuntech_data_3() {
set_in_yuntech_table(date_list, in_car_list)
}

View File

@ -179,10 +179,10 @@
var myBarChart = new Chart(ctx, {
type: 'bar',
data: {
labels: date.reverse(),
labels: date,
datasets: [{
label: '違規數量',
data: values.reverse(),
data: values,
backgroundColor: 'rgba(255, 0, 0, 0.5)', // 設定半透明的紅色背景
borderColor: 'rgba(255, 0, 0, 1)', // 設定不透明的紅色邊框
borderWidth: 1
@ -316,6 +316,7 @@
var token_ckeck //= document.getElementById("token_ckeck_id").value
var position //職位
function get_violation_data_1() {
day = 30
violation_car_list = []
//console.log("start")
//token_check = document.getElementById("token_check_id").value
@ -329,164 +330,34 @@
'Authorization': token
},
success: function (Model) {
get_violation_data_2(Model)
}
});
}
function get_violation_data_2(Model) {
if (Model.length > 0) {
for (var i = 0; i < Model.length; i++) {
var name = Model[i].parking_spaces_violation_name
////console.log(name)
$.ajax({
type: "GET",
url: "http://localhost:5174/api/Violation_car_table/violation_location_name-" + name,
data: {},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
//get_violation_data_2(Model)
console.log(Model)
set_violation_data_1(Model)
}
});
}
}
}
set_violation_data_3()
}
</script>
<!--設置違規資料-->
<script>
var date_list = []
var violation_car_list = []
function set_violation_data_1(Model) {
// 獲取當前日期
var today = new Date();
// 提取年、月、日
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var todayDate = year + '-' + month + '-' + day;
var date_list = []
var violation_car_list = []
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].create_data_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
if (daysDifference > 29) {
console.log(date_list)
break
}
if (D != date) {
D = date
var D_1 = new Date(D);
var D_1 = new Date(Model[i]['date']);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var hasValue = date_list.includes(MD);
if (hasValue == false) {
date_list.push(MD)
violation_car_list.push(Model[i]['occurrences'])
}
}
}
}
//console.log(date_list)
set_violation_data_2(Model)
}
function set_violation_data_2(Model) {
if (date_list.length > 0 && violation_car_list.length <= 0) {
for (var i = 0; i < date_list.length; i++) {
violation_car_list.push(0)
}
}
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
var todayDate = year + '-' + month + '-' + day;
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].create_data_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
////console.log(daysDifference)
if (daysDifference > date_list.length) {
break
}
var D_1 = new Date(date);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var index = date_list.indexOf(MD);
////console.log(index)
violation_car_list[index] = violation_car_list[index] + 1
}
}
}
function set_violation_data_3() {
// 等待 2000 毫秒2 秒)
setTimeout(function () {
set_violation_table(date_list, violation_car_list)
}, 200);
}
</script>
@ -495,6 +366,7 @@
<!--檢查token-->
<script>
var token

View File

@ -91,6 +91,9 @@
type: "GET",
url: "http://localhost:5174/api/Yuntech_in_car_table",
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
headers: {
'Authorization': token
@ -208,6 +211,9 @@
type: "GET",
url: "http://localhost:5174/api/Yuntech_in_car_table/license_plate_number-" + license_plate_number,
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
headers: {
'Authorization': token
@ -234,6 +240,9 @@
type: "GET",
url: "http://localhost:5174/api/Yuntech_in_car_table/location_name_1_-" + name + "-start_time-" + start_date + "-end_time-" + end_date,
data: {},
headers: {
'Authorization': token
},
contentType: "application/json",
headers: {
'Authorization': token

View File

@ -63,10 +63,10 @@
var myLineChart = new Chart(ctx1, {
type: 'line',
data: {
labels: date.reverse(),
labels: date,
datasets: [{
label: '車流量',
data: values.reverse(),
data: values,
backgroundColor: 'rgba(75, 192, 192, 0.2)', // 設定背景色
borderColor: 'rgba(75, 192, 192, 1)', // 設定邊框色
pointHitRadius: 10,
@ -155,10 +155,10 @@
var myBarChart = new Chart(ctx, {
type: 'bar',
data: {
labels: date.reverse(),
labels: date,
datasets: [{
label: '違規數量',
data: values.reverse(),
data: values,
backgroundColor: 'rgba(255, 0, 0, 0.5)', // 設定半透明的紅色背景
borderColor: 'rgba(255, 0, 0, 1)', // 設定不透明的紅色邊框
borderWidth: 1
@ -198,6 +198,7 @@
var token_ckeck //= document.getElementById("token_ckeck_id").value
var position //職位
function get_violation_data_1() {
day = 30
violation_car_list = []
//console.log("start")
//token_check = document.getElementById("token_check_id").value
@ -211,164 +212,34 @@
'Authorization': token
},
success: function (Model) {
get_violation_data_2(Model)
}
});
}
function get_violation_data_2(Model) {
if (Model.length > 0) {
for (var i = 0; i < Model.length; i++) {
var name = Model[i].parking_spaces_violation_name
////console.log(name)
$.ajax({
type: "GET",
url: "http://localhost:5174/api/Violation_car_table/violation_location_name-" + name,
data: {},
contentType: "application/json",
headers: {
'Authorization': token
},
success: function (Model) {
//get_violation_data_2(Model)
console.log(Model)
set_violation_data_1(Model)
}
});
}
}
}
set_violation_data_3()
}
</script>
<!--設置違規資料-->
<script>
var date_list = []
var violation_car_list = []
function set_violation_data_1(Model) {
// 獲取當前日期
var today = new Date();
// 提取年、月、日
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var todayDate = year + '-' + month + '-' + day;
var date_list = []
var violation_car_list = []
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].create_data_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
if (daysDifference > 29) {
console.log(date_list)
break
}
if (D != date) {
D = date
var D_1 = new Date(D);
var D_1 = new Date(Model[i]['date']);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var hasValue = date_list.includes(MD);
if (hasValue == false) {
date_list.push(MD)
violation_car_list.push(Model[i]['occurrences'])
}
}
}
}
//console.log(date_list)
set_violation_data_2(Model)
}
function set_violation_data_2(Model) {
if (date_list.length > 0 && violation_car_list.length <= 0) {
for (var i = 0; i < date_list.length; i++) {
violation_car_list.push(0)
}
}
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
var todayDate = year + '-' + month + '-' + day;
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].create_data_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
////console.log(daysDifference)
if (daysDifference > date_list.length) {
break
}
var D_1 = new Date(date);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var index = date_list.indexOf(MD);
////console.log(index)
violation_car_list[index] = violation_car_list[index] + 1
}
}
}
function set_violation_data_3() {
// 等待 2000 毫秒2 秒)
setTimeout(function () {
set_violation_table(date_list, violation_car_list)
}, 200);
}
</script>
@ -378,8 +249,8 @@
<!--獲取進入雲科資料-->
<script>
function get_in_yuntech_data_1() {
day = 30
in_car_list = []
//console.log(token_check)
$.ajax({
type: "GET",
url: "http://localhost:5174/api/Yuntech_in_car_table",
@ -389,10 +260,7 @@
'Authorization': token
},
success: function (Model) {
//console.log(Model)
setTimeout(function () {
set_in_yuntech_data_1(Model)
}, 200);
}
@ -404,61 +272,16 @@
<script>
var in_car_list = []
function set_in_yuntech_data_1(Model) {
if (date_list.length > 0 && in_car_list.length <= 0) {
for (var i = 0; i < date_list.length; i++) {
in_car_list.push(0)
}
}
console.log(in_car_list)
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth() + 1; // 注意:月份是從 0 開始的,所以需要加 1
var day = today.getDate();
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
var todayDate = year + '-' + month + '-' + day;
var date_list = []
var in_car_list = []
if (Model.length > 0) {
var D = ""
for (var i = 0; i < Model.length; i++) {
// 假設你有一個包含日期時間的字符串
var dateTimeString = Model[i].in_time;
// 將字符串轉換為 Date 對象
var dateTime = new Date(dateTimeString);
// 提取日期部分
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1; // 月份是從 0 開始的,所以要加 1
var day = dateTime.getDate();
// 將月份和日期補零,以確保是兩位數
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
// 構建日期字符串格式YYYY-MM-DD
var date = year + '-' + month + '-' + day;
// 將字符串轉換為 Date 對象
var startDate = new Date(date);
var endDate = new Date(todayDate);
// 計算天數差
var timeDifference = endDate - startDate;
var daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));// 轉換為天數(毫秒 / 1000 / 60 / 60 / 24
////console.log(daysDifference)
if (daysDifference > date_list.length) {
break
}
var D_1 = new Date(date);
var D_1 = new Date(Model[i]['date']);
var MD = D_1.toLocaleDateString('en-US', { month: '2-digit', day: '2-digit' });
var index = date_list.indexOf(MD);
////console.log(index)
in_car_list[index] = in_car_list[index] + 1
date_list.push(MD)
in_car_list.push(Model[i]['occurrences'])
}
set_in_yuntech_data_3()
}
}
function set_in_yuntech_data_3() {
set_in_yuntech_table(date_list, in_car_list)
}