diff --git a/src/main/webapp/jsp/bigScreen.jsp b/src/main/webapp/jsp/bigScreen.jsp index dbac5c89..f3b346b3 100644 --- a/src/main/webapp/jsp/bigScreen.jsp +++ b/src/main/webapp/jsp/bigScreen.jsp @@ -664,6 +664,14 @@ val3: 0, // 泥处理指标3 }, + // 泥处理点位编码配置 + nclMPointKeys: { + val1: "D_NiCL", // 泥处理指标1点位编码 + val2: "D_NiCL", // 泥处理指标2点位编码 + val3: "D_NiCL", // 泥处理指标3点位编码 + chart: "D_NiCL", // 泥处理图表点位编码 + }, + // 药耗数据 (yaohao) yaohao: { D_PACDSYH: 0, @@ -880,44 +888,6 @@ }); } - // 从接口获取数据并更新页面(示例方法,供后期调用) - function fetchDataFromApi(apiUrl) { - $.ajax({ - url: apiUrl, - type: "GET", - dataType: "json", - success: function (response) { - // 假设接口返回的数据格式如下: - // { - // slqs: { todayTotal: xxx, yesterdayTotal: xxx, monthTotal: xxx }, - // ncl: { val1: xxx, val2: xxx, val3: xxx }, - // yaohao: { val1: xxx, val2: xxx, val3: xxx }, - // qualityTable: [...], - // sevenDaysChart: { xAxis: [...], data: [...] }, - // nclChart: { xAxis: [...], data: [...] }, - // qualityChart: { xAxis: [...], data: [...] } - // } - if (response) { - if (response.slqs) pageData.slqs = response.slqs; - if (response.ncl) pageData.ncl = response.ncl; - if (response.yaohao) pageData.yaohao = response.yaohao; - if (response.qualityTable) - pageData.qualityTable = response.qualityTable; - if (response.sevenDaysChart) - pageData.sevenDaysChart = response.sevenDaysChart; - if (response.nclChart) pageData.nclChart = response.nclChart; - if (response.qualityChart) - pageData.qualityChart = response.qualityChart; - - refreshPage(); - } - }, - error: function (xhr, status, error) { - console.error("获取数据失败:", error); - }, - }); - } - // 刷新页面所有数据 function refreshPage() { updateSlqs(); @@ -929,6 +899,14 @@ initQualityChart(); } + // 格式化日期为 YYYY-MM-DD 格式 + function formatDate(date) { + var year = date.getFullYear(); + var month = (date.getMonth() + 1).toString().padStart(2, "0"); + var day = date.getDate().toString().padStart(2, "0"); + return year + "-" + month + "-" + day; + } + // 进入全屏函数 function enterFullscreen() { var elem = document.documentElement; @@ -1077,51 +1055,46 @@ }); } - // 获取点位信息数据 - // mpcode: 点位编码 - // sdt: 开始时间 (可选,默认7天前) - // edt: 结束时间 (可选,默认当前时间) - // 返回: Promise对象 - function fetchPointData(mpcode, sdt, edt) { - // 默认时间范围:近7天 - if (!edt) { - var now = new Date(); - edt = formatDate(now); - } - if (!sdt) { - var sevenDaysAgo = new Date(); - sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7); - sdt = formatDate(sevenDaysAgo); - } - - return new Promise(function(resolve, reject) { - $.ajax({ - url: '<%=request.getContextPath()%>/data/getDetailData.do', - type: 'GET', - data: { - mpcode: mpcode, - sdt: sdt, - edt: edt - }, - dataType: 'json', - success: function(response) { - console.log('点位数据[' + mpcode + ']:', response); - resolve(response); - }, - error: function(xhr, status, error) { - console.error('获取点位数据失败:', mpcode, error); - reject(error); - } - }); - }); - } + // 获取泥处理数据(每日汇总) + function fetchNclData() { + var mPointKey = pageData.nclMPointKeys.chart; + var now = new Date(); + var endTime = formatDate(now) + " 23:59:59"; + var startTime = formatDate(new Date(now.getTime() - 10 * 24 * 60 * 60 * 1000)) + " 00:00:00"; // 最近10天 - // 格式化日期为 YYYY-MM-DD 格式 - function formatDate(date) { - var year = date.getFullYear(); - var month = (date.getMonth() + 1).toString().padStart(2, "0"); - var day = date.getDate().toString().padStart(2, "0"); - return year + "-" + month + "-" + day; + $.ajax({ + url: "<%=request.getContextPath()%>/mpoint/data/getDailyAggregation.do", + type: "GET", + data: { + mPointKey: mPointKey, + startTime: startTime, + endTime: endTime + }, + dataType: "json", + success: function (response) { + console.log("泥处理数据:", response); + if (response && response.success && response.dailyData) { + var xAxis = []; + var data = []; + response.dailyData.forEach(function (item) { + // 日期格式: "2026-03-07" -> "03-07" + var dateStr = item.dateStr || ""; + if (dateStr.length >= 10) { + xAxis.push(dateStr.substring(5)); // 取 "MM-DD" 部分 + } else { + xAxis.push(dateStr); + } + data.push(parseFloat(item.totalValue) || 0); + }); + pageData.nclChart.xAxis = xAxis; + pageData.nclChart.data = data; + initNclChart(); // 重新渲染图表 + } + }, + error: function (xhr, status, error) { + console.error("获取泥处理数据失败:", error); + } + }); } $(function () { @@ -1145,6 +1118,9 @@ // 获取质量指标表格数据 fetchQualityTableData(); + // 获取泥处理数据 + fetchNclData(); + // 批量获取点位数据并更新显示 var pointList = getAllPointIds(); pointList.forEach(function (mpcode) { @@ -1156,6 +1132,7 @@ console.log('定时刷新数据...'); fetchSlqsData(); fetchQualityTableData(); + fetchNclData(); // 批量刷新点位数据 pointList.forEach(function (mpcode) { getValue('0533JS', mpcode, mpcode, `${mpcode}_name`, '<%=request.getContextPath()%>');