chore(screen): 同步更新大屏挂载脚本并与后端API规范对齐
这个提交包含在:
@@ -89,49 +89,69 @@ function loadGranaryData() {
|
||||
|
||||
// 尝试连接后台接口同步最新配置
|
||||
if (typeof fetch !== 'undefined') {
|
||||
fetch('/api/index/granaryList?site=xishui', { cache: 'no-cache', signal: AbortSignal.timeout(2000) })
|
||||
.then(res => res.ok ? res.json() : null)
|
||||
.then(json => {
|
||||
if (json && json.data && Array.isArray(json.data.list) && json.data.list.length > 0) {
|
||||
STATE.list = normalizeGranaryList(json);
|
||||
if (json.data.coords) {
|
||||
STATE.customCoords = json.data.coords;
|
||||
const urls = [
|
||||
'/api/index/granaryList?site=xishui',
|
||||
'https://grain.gynhc.com/api/index/granaryList?site=xishui',
|
||||
'/api/granary/list?site=xishui'
|
||||
];
|
||||
(async () => {
|
||||
for (const u of urls) {
|
||||
try {
|
||||
const res = await fetch(u, { cache: 'no-cache', signal: AbortSignal.timeout(2000) });
|
||||
if (!res.ok) continue;
|
||||
const json = await res.json();
|
||||
if (json && json.data && Array.isArray(json.data.list) && json.data.list.length > 0) {
|
||||
STATE.list = normalizeGranaryList(json);
|
||||
if (json.data.coords) {
|
||||
STATE.customCoords = json.data.coords;
|
||||
}
|
||||
renderKPIs();
|
||||
renderHotspots();
|
||||
renderMiniGrid();
|
||||
renderDepotAlerts();
|
||||
return;
|
||||
}
|
||||
renderKPIs();
|
||||
renderHotspots();
|
||||
renderMiniGrid();
|
||||
renderDepotAlerts();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
} catch (e) {}
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
// 3.1 加载习水子库微气候环境工况
|
||||
function loadEnvData() {
|
||||
if (typeof fetch !== 'undefined') {
|
||||
fetch('/api/granary/env?site=xishui', { cache: 'no-cache', signal: AbortSignal.timeout(2000) })
|
||||
.then(res => res.ok ? res.json() : null)
|
||||
.then(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 urls = [
|
||||
'/api/index/env?site=xishui',
|
||||
'https://grain.gynhc.com/api/index/env?site=xishui',
|
||||
'/api/granary/env?site=xishui'
|
||||
];
|
||||
(async () => {
|
||||
for (const u of urls) {
|
||||
try {
|
||||
const res = await fetch(u, { 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}%`;
|
||||
}
|
||||
renderDepotAlerts();
|
||||
return;
|
||||
}
|
||||
renderDepotAlerts();
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
} catch (e) {}
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户