From 4c58f8f132adf830917b6b8f49f8c8de87aaf748 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期四, 08 一月 2026 18:40:51 +0800
Subject: [PATCH] 数量检测提交2-检测协议实现
---
fzzy-igdss-web/src/main/resources/static/security/quantity.js | 368 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 342 insertions(+), 26 deletions(-)
diff --git a/fzzy-igdss-web/src/main/resources/static/security/quantity.js b/fzzy-igdss-web/src/main/resources/static/security/quantity.js
index 856ddd3..3c8be27 100644
--- a/fzzy-igdss-web/src/main/resources/static/security/quantity.js
+++ b/fzzy-igdss-web/src/main/resources/static/security/quantity.js
@@ -1,6 +1,12 @@
var layer;
var form;
var curCamera;
+var firstQuantity;
+var hisChart = null; //鏇茬嚎鍥�
+var listRecord;
+var fileRecord;
+var names = ['12-01', '12-02', '12-03', '12-04', '12-05', '12-06', '12-07'];
+var data = [2560000, 2510000, 2540000, 2530000, 2490000, 2610000, 2570000];
layui.use(['layer'], function () {
form = layui.form;
@@ -8,7 +14,7 @@
// 璋冭壊鏉垮垏鎹簨浠�
document.querySelectorAll('.palette-item').forEach(item => {
- item.addEventListener('click', function() {
+ item.addEventListener('click', function () {
document.querySelectorAll('.palette-item').forEach(i => {
i.classList.remove('active');
});
@@ -21,18 +27,14 @@
//閫夋嫨鎽勫儚澶村悗瑙﹀彂鐨勪簨浠�
const cameraSelect = document.getElementById('select-camera');
- cameraSelect.addEventListener('change', function() {
- const selectedCamera = this.value;
- //console.log("--------------"+selectedCamera);
- video(selectedCamera);
+ cameraSelect.addEventListener('change', function () {
+ const selectId = this.value;
- // 鏇存柊娓╁害璧板娍鍥�
- // updateEchartsTemp(selectedCamera);
+ ajaxData(selectId);
});
-
- // 鍒濆鍖朎Charts娓╁害璧板娍鍥�
- initEchartsTemp();
+ // 鍒濆鍖栬蛋鍔垮浘
+ initEcharts(names, data);
});
@@ -40,39 +42,344 @@
* 瑙嗛鎾斁
* @param selectId
*/
-function video(selectId) {
+function ajaxData(selectId) {
+ curCamera = null;
//浠庡垪琛ㄤ腑鑾峰彇鎽勫儚澶翠俊鎭�
- curCamera = listCamera.find(camera => camera.id === selectId);
- if (!curCamera) { layer.msg('娌℃湁鑾峰彇鍒板綋鍓嶆憚鍍忓ご淇℃伅鈥︹��', {icon: 1, time: 1200});}
+ curCamera = listCamera.find(camera => camera.depotId === selectId);
+ if (!curCamera) {
+ layer.msg('娌℃湁鑾峰彇鍒板綋鍓嶆憚鍍忓ご淇℃伅鈥︹��', {icon: 1, time: 1200});
+ return;
+ }
+ //鑾峰彇瑙嗛
+ video();
+ //娓叉煋璧板娍鍥�
+ ajaxEcharts();
+
+ //娓叉煋璁板綍
+ ajaxListRecord();
+
+ //娓叉煋鎶撴媿鍥�
+ ajaxSnapImg();
}
/**
- * 鏇存柊娓╁害璧板娍鍥�
- * @param selectId
+ * 璇锋眰鍥捐〃淇℃伅
*/
-function updateEchartsTemp(selectId) {
+function ajaxSnapImg() {
+ if(!firstQuantity){
+ renderSnapImg();
+ return;
+ }
+ fileRecord = null;
var data = {
- cameraId: selectId
+ key: firstQuantity.batchId
};
$.ajax({
type: 'POST',
- url: "/security/infrared/chart-data",
+ url: "/security/quantity-files",
dataType: 'JSON',
contentType: "application/json;charset=UTF-8",
data: JSON.stringify(data),
success: function (result) {
- //layer.msg("淇℃伅鏇存柊瀹屾垚锛侊紒");
+ if (result.code != "SUCCESS") {
+ renderSnapImg();
+ } else {
+ fileRecord = result.data;
+ renderSnapImg();
+ }
},
error: function (result) {
- // layer.msg(result.msg);
+ renderSnapImg();
+ }
+ });
+}
+
+/**
+ * 娓叉煋鎶撳浘
+ * @returns {null}
+ */
+function renderSnapImg() {
+
+ if (!fileRecord) return null;
+
+ if (fileRecord.length === 0) return null;
+
+ var record = fileRecord[0];
+ if (record) {
+ $("#file-time1").text(record.createTime);
+ $("#file-img1").attr("src", record.filePath);
+ } else {
+ $("#file-time1").text("----");
+ $("#file-img1").attr("src", "/img/web/security/p-snap.jpg");
+ }
+
+ record = fileRecord[1];
+ if (record) {
+ $("#file-time2").text(record.createTime);
+ $("#file-img2").attr("src", record.filePath);
+ } else {
+ $("#file-time2").text("----");
+ $("#file-img2").attr("src", "/img/web/security/p-snap.jpg");
+ }
+
+ record = fileRecord[2];
+ if (record) {
+ $("#file-time3").text(record.createTime);
+ $("#file-img3").attr("src", record.filePath);
+ } else {
+ $("#file-time3").text("----");
+ $("#file-img3").attr("src", "/img/web/security/p-snap.jpg");
+ }
+
+ record = fileRecord[3];
+ if (record) {
+ $("#file-time4").text(record.createTime);
+ $("#file-img4").attr("src", record.filePath);
+ } else {
+ $("#file-time4").text("----");
+ $("#file-img4").attr("src", "/img/web/security/p-snap.jpg");
+ }
+}
+
+/**
+ * 璇锋眰鍥捐〃淇℃伅
+ */
+function ajaxEcharts() {
+ var data = {
+ depotId: curCamera.depotId
+ };
+ $.ajax({
+ type: 'POST',
+ url: "/security/quantity-chart",
+ dataType: 'JSON',
+ contentType: "application/json;charset=UTF-8",
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.code != "SUCCESS") {
+ renderEcharts(null);
+ } else {
+ renderEcharts(result.data);
+ }
+ },
+ error: function (result) {
+ renderEcharts(null);
+ }
+ });
+}
+
+/**
+ * 娓叉煋鍥捐〃
+ * @param chartData
+ */
+function renderEcharts(chartData) {
+ var chart = hisChart;
+ if (chartData && chartData.xaxis.length > 0 && chartData.seriesData.length > 0) {
+ chart.option.xAxis.data = chartData.xaxis;
+ chart.option.series[0].data = chartData.seriesData;
+ chart.chart.setOption(chart.option, true);
+ } else {
+ chart.option.xAxis.data = names;
+ chart.option.series[0].data = data;
+ chart.chart.setOption(chart.option, true);
+ }
+ hisChart = chart;
+}
+
+/**
+ * 璇锋眰璁板綍
+ */
+function ajaxListRecord() {
+ firstQuantity = null;
+ listRecord = null;
+ var data = {
+ depotId: curCamera.depotId
+ };
+ $.ajax({
+ type: 'POST',
+ url: "/security/quantity-list",
+ dataType: 'JSON',
+ contentType: "application/json;charset=UTF-8",
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.code != "SUCCESS") {
+ renderListRecord();
+ } else {
+ listRecord = result.data;
+ renderListRecord();
+ }
+ },
+ error: function (result) {
+ renderListRecord();
+ }
+ });
+}
+
+/**
+ * 娓叉煋璁板綍
+ * @returns {null}
+ */
+function renderListRecord() {
+
+ if (!listRecord) return null;
+
+ if (listRecord.length === 0) return null;
+
+ var record = listRecord[0];
+ if (record) {
+ firstQuantity = record;
+ $("#record_title1").text("妫�娴嬮噸閲忥細" + record.weight + " KG");
+ $("#record_time1").text(record.receiveDate);
+ $("#record_content1").text(record.remark);
+ } else {
+ $("#record_title1").text("妫�娴嬮噸閲忥細---- KG");
+ $("#record_time1").text("----");
+ $("#record_content1").text("妫�娴嬮噸閲忎负---- KG锛屽疄闄呴噸閲忎负---- KG锛岃宸皬浜�-%銆�");
+ }
+
+ record = listRecord[1];
+ if (record) {
+ $("#record_title2").text("妫�娴嬮噸閲忥細" + record.weight + " KG");
+ $("#record_time2").text(record.receiveDate);
+ $("#record_content2").text(record.remark);
+ } else {
+ $("#record_title2").text("妫�娴嬮噸閲忥細---- KG");
+ $("#record_time2").text("----");
+ $("#record_content2").text("妫�娴嬮噸閲忎负---- KG锛屽疄闄呴噸閲忎负---- KG锛岃宸皬浜�-%銆�");
+ }
+
+ record = listRecord[2];
+ if (record) {
+ $("#record_title3").text("妫�娴嬮噸閲忥細" + record.weight + " KG");
+ $("#record_time3").text(record.receiveDate);
+ $("#record_content3").text(record.remark);
+ } else {
+ $("#record_title3").text("妫�娴嬮噸閲忥細---- KG");
+ $("#record_time3").text("----");
+ $("#record_content3").text("妫�娴嬮噸閲忎负---- KG锛屽疄闄呴噸閲忎负---- KG锛岃宸皬浜�-%銆�");
+ }
+
+ record = listRecord[3];
+ if (record) {
+ $("#record_title4").text("妫�娴嬮噸閲忥細" + record.weight + " KG");
+ $("#record_time4").text(record.receiveDate);
+ $("#record_content4").text(record.remark);
+ } else {
+ $("#record_title4").text("妫�娴嬮噸閲忥細---- KG");
+ $("#record_time4").text("----");
+ $("#record_content4").text("妫�娴嬮噸閲忎负---- KG锛屽疄闄呴噸閲忎负---- KG锛岃宸皬浜�-%銆�");
+ }
+}
+
+/**
+ * 瑙嗛鎾斁
+ * @param
+ */
+function video() {
+
+ var data = {
+ id: curCamera.cameraSn,
+ playType: curCamera.playType
+ };
+ $.ajax({
+ type: 'POST',
+ url: "/security/get-media",
+ dataType: 'JSON',
+ contentType: "application/json;charset=UTF-8",
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.code != "SUCCESS") {
+ layer.msg(result.msg, {icon: 1, time: 1200});
+ } else {
+ toPlay(result.playUrl);
+ }
+ },
+ error: function (result) {
+ layer.msg("鏈幏鍙栧埌鎾斁淇℃伅锛侊紒", {icon: 1, time: 1200});
+ }
+ });
+
+}
+
+/**
+ * 鎾斁瑙嗛
+ * @param url
+ */
+function toPlay(url) {
+ var html = '';
+ if (url) {
+ html += '<iframe src="' + url + '" width="100%" height="100%" frameborder="0" allowfullscreen></iframe>';
+ } else {
+ html += '<img src="/img/web/security/p-snap.jpg">';
+ }
+ $("#divPlugin2").html(html);
+}
+
+/**
+ * 鍚姩寮�濮嬫娴�
+ */
+function checkStart() {
+ if (!curCamera) {
+ shoTips("璇峰厛閫夋嫨璁惧锛�");
+ return;
+ }
+ layer.msg("寮�濮嬫墽琛屸�︹��");
+ var data = {
+ 'depotId': curCamera.depotId
+ };
+ $.ajax({
+ type: "POST",
+ url: "/security/check-single",
+ dataType: "json",
+ contentType: "application/json;charset=UTF-8",
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.code == "ORDER_SUCCESS") {
+ shoTips("鍛戒护鍙戠敓鎴愬姛锛岃绛夊緟缁堢杩斿洖缁撴灉鈥︹��");
+ } else {
+ shoTips("鍛戒护鍙戦�佸け璐ワ細" + result.msg);
+ }
+ },
+ error: function () {
+ shoTips("妫�娴嬪嚭鐜板紓甯革紝鎵ц澶辫触锛�");
+ }
+ });
+}
+
+/**
+ * 鍋滄妫�娴�
+ */
+function checkStop() {
+ if (!curCamera) {
+ shoTips("璇峰厛閫夋嫨浠撳簱锛�");
+ return;
+ }
+ layer.msg("寮�濮嬫墽琛屸�︹��");
+ var data = {
+ 'depotId': curCamera.depotId
+ };
+ $.ajax({
+ type: "POST",
+ url: "/security/check-stop",
+ dataType: "json",
+ contentType: "application/json;charset=UTF-8",
+ data: JSON.stringify(data),
+ success: function (result) {
+ if (result.code == "ORDER_SUCCESS") {
+ shoTips("鍛戒护鍙戠敓鎴愬姛鈥︹��");
+ } else {
+ shoTips("鍛戒护鍙戦�佸け璐ワ細" + result.msg);
+ }
+ },
+ error: function () {
+ shoTips("妫�娴嬪嚭鐜板紓甯革紝鎵ц澶辫触锛�");
}
});
}
// 鍒濆鍖朎Charts娓╁害璧板娍鍥�
-function initEchartsTemp() {
+function initEcharts(names, data) {
// 鍒濆鍖朎Charts娓╁害璧板娍鍥�
var temperatureChartDom = document.getElementById('temperatureChart');
var temperatureChart = echarts.init(temperatureChartDom);
@@ -102,7 +409,7 @@
{
type: 'category',
boundaryGap: false,
- data: ['12-01', '12-02', '12-03', '12-04', '12-05', '12-06', '12-07']
+ data: names
}
],
yAxis: [
@@ -127,18 +434,27 @@
},
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- { offset: 0, color: 'rgba(15, 52, 96, 0.3)' },
- { offset: 1, color: 'rgba(15, 52, 96, 0.05)' }
+ {offset: 0, color: 'rgba(15, 52, 96, 0.3)'},
+ {offset: 1, color: 'rgba(15, 52, 96, 0.05)'}
])
},
- data: [2560000, 2510000, 2540000, 2530000, 2490000, 2610000, 2570000]
+ data: data
}
]
};
// 娓叉煋鍥捐〃
option && temperatureChart.setOption(option);
+ hisChart = {"chart": temperatureChart, "option": option};
+
// 绐楀彛澶у皬鍙樺寲鏃惰皟鏁村浘琛ㄥぇ灏�
- window.addEventListener('resize', function() {
+ window.addEventListener('resize', function () {
temperatureChart.resize();
});
+}
+
+function shoTips(msg) {
+ layer.msg(msg,
+ {time: 3000, shift: 5, offset: "rb"},
+ function () {
+ });
}
\ No newline at end of file
--
Gitblit v1.9.3