chore(screen): 同步更新大屏挂载脚本并与后端API规范对齐
这个提交包含在:
@@ -136,27 +136,35 @@ async function fetchGranaryData() {
|
||||
|
||||
// 3.1 加载微气候环境工况
|
||||
async function fetchEnvData() {
|
||||
try {
|
||||
const res = await fetch('/api/granary/env?site=center', { cache: 'no-cache' });
|
||||
if (!res.ok) return;
|
||||
const json = await res.json();
|
||||
if (json && json.code === 0 && json.data) {
|
||||
const d = json.data;
|
||||
STATE.envData = d;
|
||||
const inpTmI = document.getElementById('input-forecast-tm-i');
|
||||
const inpTmO = document.getElementById('input-forecast-tm-o');
|
||||
const inpHmI = document.getElementById('input-forecast-hm-i');
|
||||
const inpHmO = document.getElementById('input-forecast-hm-o');
|
||||
if (inpTmI && d.tm_i !== undefined) inpTmI.value = d.tm_i;
|
||||
if (inpTmO && d.tm_o !== undefined) inpTmO.value = d.tm_o;
|
||||
if (inpHmI && d.hm_i !== undefined) inpHmI.value = d.hm_i;
|
||||
if (inpHmO && d.hm_o !== undefined) inpHmO.value = d.hm_o;
|
||||
const pill = document.getElementById('forecast-trend-env-pill');
|
||||
if (pill) {
|
||||
pill.textContent = `工况: 仓内 ${d.tm_i}℃ / ${d.hm_i}% | 仓外 ${d.tm_o}℃ / ${d.hm_o}%`;
|
||||
const endpoints = [
|
||||
'/api/index/env?site=center',
|
||||
'https://grain.gynhc.com/api/index/env?site=center',
|
||||
'/api/granary/env?site=center'
|
||||
];
|
||||
for (const url of endpoints) {
|
||||
try {
|
||||
const res = await fetch(url, { cache: 'no-cache', signal: AbortSignal.timeout(2000) });
|
||||
if (!res.ok) continue;
|
||||
const json = await res.json();
|
||||
if (json && (json.code === 1 || json.code === 0) && json.data) {
|
||||
const d = json.data;
|
||||
STATE.envData = d;
|
||||
const inpTmI = document.getElementById('input-forecast-tm-i');
|
||||
const inpTmO = document.getElementById('input-forecast-tm-o');
|
||||
const inpHmI = document.getElementById('input-forecast-hm-i');
|
||||
const inpHmO = document.getElementById('input-forecast-hm-o');
|
||||
if (inpTmI && d.tm_i !== undefined) inpTmI.value = d.tm_i;
|
||||
if (inpTmO && d.tm_o !== undefined) inpTmO.value = d.tm_o;
|
||||
if (inpHmI && d.hm_i !== undefined) inpHmI.value = d.hm_i;
|
||||
if (inpHmO && d.hm_o !== undefined) inpHmO.value = d.hm_o;
|
||||
const pill = document.getElementById('forecast-trend-env-pill');
|
||||
if (pill) {
|
||||
pill.textContent = `工况: 仓内 ${d.tm_i}℃ / ${d.hm_i}% | 仓外 ${d.tm_o}℃ / ${d.hm_o}%`;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
// 3.2 渲染全库储粮安全感知与预警走马灯
|
||||
|
||||
在新工单中引用
屏蔽一个用户