更新xx并部署

This commit is contained in:
Mac mini git server 2026-04-23 22:46:15 +08:00
parent be8de4c00a
commit 96d6b8e8af
4 changed files with 17 additions and 52 deletions

Binary file not shown.

View File

@ -4,13 +4,12 @@
* - **仅 HTTP**:与 MQTT 无关;看板在 `VITE_LASER_BOX_URL` 已配置时应只展示本模块 `devices`。
* - **近 7 日**:日统计与柱图对齐「今天往前 7 天(含今天)」,见 `getLast7DaysStatContext`。
* - **机台状态**:`CutSystemState.NcState` 以机台状态接口为准;`SysState` 驱动卡片状态,`AlarmCount` 仅展示、不标报警态。
* - **主页报警列**:`alarm/v2` 仅查「当前时刻往前 1 小时」,结果存 `_laser.alarmsLastHour`。
* - **报警展示**:不再调用 `alarm/v2`,主页报警列直接取机台状态接口返回的 `NcState.AlarmMsg`。
*/
import { reactive } from 'vue'
import {
fetchMachineList,
fetchCutSystemState,
fetchAlarms,
fetchSummary,
fetchDailyLength,
fetchDailyPierce,
@ -19,7 +18,7 @@ import {
fetchDailyRunTime,
isLaserBoxHttpLog
} from './laserBoxClient.js'
import { getLast7DaysStatContext, getLastHourAlarmQueryRange } from '../utils/weekLabels.js'
import { getLast7DaysStatContext } from '../utils/weekLabels.js'
export const laserBoxRuntime = reactive({
devices: [],
@ -96,11 +95,9 @@ function indexDailyRows(rows, keyStatDate = 'statDate') {
async function fetchOneMachine(baseUrl, ip, appName) {
const win = getLast7DaysStatContext()
const alarmRange = getLastHourAlarmQueryRange()
const [
cutRes,
alarmRes,
summaryRes,
lenRes,
pierceRes,
@ -109,7 +106,6 @@ async function fetchOneMachine(baseUrl, ip, appName) {
runRes
] = await Promise.allSettled([
fetchCutSystemState(baseUrl, ip, appName),
fetchAlarms(baseUrl, ip, appName, alarmRange.startDate, alarmRange.endDate),
fetchSummary(baseUrl, ip, appName, win.summaryStart, win.summaryEnd),
fetchDailyLength(baseUrl, ip, appName, win.startYmd, win.endYmd),
fetchDailyPierce(baseUrl, ip, appName, win.startYmd, win.endYmd),
@ -119,7 +115,6 @@ async function fetchOneMachine(baseUrl, ip, appName) {
])
const cut = cutRes.status === 'fulfilled' ? cutRes.value : null
const alarmsRaw = alarmRes.status === 'fulfilled' ? alarmRes.value : []
const summary = summaryRes.status === 'fulfilled' ? summaryRes.value : null
const lenRows = lenRes.status === 'fulfilled' ? lenRes.value : []
@ -144,8 +139,6 @@ async function fetchOneMachine(baseUrl, ip, appName) {
const cutTimeHours = laserTimeDaily.map((s) => Math.round((s / 3600) * 10) / 10)
/** 近 1 小时,供主页报警列展示(与机台状态里的 AlarmCount 无关) */
const alarmList = Array.isArray(alarmsRaw) ? alarmsRaw : []
const { labels } = win
const cutSystemState = buildCutSystemState(cut || {})
@ -183,7 +176,7 @@ async function fetchOneMachine(baseUrl, ip, appName) {
gasTimeDaily,
runTimeDaily
},
_laser: { ip, appName, alarmsLastHour: alarmList }
_laser: { ip, appName }
}
}

View File

@ -36,17 +36,7 @@ export function formatYmdHms(d) {
return `${formatYmd(d)} ${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`
}
/**
* 魔盒 `alarm/v2` 查询区间:当前时刻往前 1 小时 → 当前时刻(主页报警列仅展示该窗口内数据)。
*/
export function getLastHourAlarmQueryRange(now = new Date()) {
const end = new Date(now)
const start = new Date(end.getTime() - 2 * 60 * 1000)
return {
startDate: formatYmdHms(start),
endDate: formatYmdHms(end)
}
}
// 说明:历史上用于魔盒 `alarm/v2` 的时间窗口查询;当前 A 类主页报警改为直接取 `NcState.AlarmMsg`。
/**
* 本周一~周日与魔盒 statistic/daily 的 statDate(整数 yyyymmdd)对齐。

View File

@ -133,23 +133,11 @@ const weeklyProduceTotal = computed(() => {
return totals
})
/** 魔盒报警行上的发生时间(不同版本字段名不一,尽量兼容) */
function laserAlarmOccurAt(a) {
const raw =
a?.AlarmTime ??
a?.alarmTime ??
a?.CreateTime ??
a?.createTime ??
a?.OccurTime ??
a?.occurTime ??
a?.Time ??
a?.time
if (raw == null || raw === '') return null
const d = new Date(raw)
return Number.isNaN(d.getTime()) ? null : d
}
// 报警汇总:B/C 仍为「设备处于报警态」一条;A 类(魔盒)为近 1 小时 alarm/v2 多条,不按 AlarmCount 标设备报警态
/**
* 报警汇总:
* - B/C:仍为「设备处于报警态」一条摘要
* - A 类:不再调用 alarm/v2,直接展示机台状态接口的 NcState.AlarmMsg(有内容则展示一条)
*/
const alarms = computed(() => {
const rows = []
const now = new Date()
@ -162,7 +150,6 @@ const alarms = computed(() => {
const a = d.machineData.alarm
const msg = a?.length ? a[0] : 'CNC系统报警'
rows.push({
at: now.getTime(),
time: now.toLocaleTimeString('zh-CN', { hour12: false }),
device: `CNC-${d.name}`,
message: msg
@ -171,22 +158,17 @@ const alarms = computed(() => {
laserListForUi.value.forEach((d) => {
if (!d.online || d.type !== 'laser') return
const list = d._laser?.alarmsLastHour
if (!Array.isArray(list) || !list.length) return
list.forEach((a) => {
const at = laserAlarmOccurAt(a) || now
const msg = a?.AlarmDesc || a?.alarmDesc || a?.message || a?.msg || ''
rows.push({
at: at.getTime(),
time: at.toLocaleTimeString('zh-CN', { hour12: false }),
device: d.name,
message: msg || '报警'
})
const nc = d.machineData?.CutSystemState?.NcState
const msg = String(nc?.AlarmMsg || '').trim()
if (!msg) return
rows.push({
time: now.toLocaleTimeString('zh-CN', { hour12: false }),
device: d.name,
message: msg
})
})
rows.sort((x, y) => y.at - x.at)
return rows.map(({ at: _t, ...rest }) => rest)
return rows
})
function goDetail(id) {