更新xx并部署
This commit is contained in:
1 parent
be8de4c00a
commit
96d6b8e8af
4 files changed
+17
-52
No files matched your search
Binary file not shown.
@@ -4,13 +4,12 @@
|
|||||||
* - **仅 HTTP**:与 MQTT 无关;看板在 `VITE_LASER_BOX_URL` 已配置时应只展示本模块 `devices`。
|
* - **仅 HTTP**:与 MQTT 无关;看板在 `VITE_LASER_BOX_URL` 已配置时应只展示本模块 `devices`。
|
||||||
* - **近 7 日**:日统计与柱图对齐「今天往前 7 天(含今天)」,见 `getLast7DaysStatContext`。
|
* - **近 7 日**:日统计与柱图对齐「今天往前 7 天(含今天)」,见 `getLast7DaysStatContext`。
|
||||||
* - **机台状态**:`CutSystemState.NcState` 以机台状态接口为准;`SysState` 驱动卡片状态,`AlarmCount` 仅展示、不标报警态。
|
* - **机台状态**:`CutSystemState.NcState` 以机台状态接口为准;`SysState` 驱动卡片状态,`AlarmCount` 仅展示、不标报警态。
|
||||||
* - **主页报警列**:`alarm/v2` 仅查「当前时刻往前 1 小时」,结果存 `_laser.alarmsLastHour`。
|
* - **报警展示**:不再调用 `alarm/v2`,主页报警列直接取机台状态接口返回的 `NcState.AlarmMsg`。
|
||||||
*/
|
*/
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import {
|
import {
|
||||||
fetchMachineList,
|
fetchMachineList,
|
||||||
fetchCutSystemState,
|
fetchCutSystemState,
|
||||||
fetchAlarms,
|
|
||||||
fetchSummary,
|
fetchSummary,
|
||||||
fetchDailyLength,
|
fetchDailyLength,
|
||||||
fetchDailyPierce,
|
fetchDailyPierce,
|
||||||
@@ -19,7 +18,7 @@ import {
|
|||||||
fetchDailyRunTime,
|
fetchDailyRunTime,
|
||||||
isLaserBoxHttpLog
|
isLaserBoxHttpLog
|
||||||
} from './laserBoxClient.js'
|
} from './laserBoxClient.js'
|
||||||
import { getLast7DaysStatContext, getLastHourAlarmQueryRange } from '../utils/weekLabels.js'
|
import { getLast7DaysStatContext } from '../utils/weekLabels.js'
|
||||||
|
|
||||||
export const laserBoxRuntime = reactive({
|
export const laserBoxRuntime = reactive({
|
||||||
devices: [],
|
devices: [],
|
||||||
@@ -96,11 +95,9 @@ function indexDailyRows(rows, keyStatDate = 'statDate') {
|
|||||||
|
|
||||||
async function fetchOneMachine(baseUrl, ip, appName) {
|
async function fetchOneMachine(baseUrl, ip, appName) {
|
||||||
const win = getLast7DaysStatContext()
|
const win = getLast7DaysStatContext()
|
||||||
const alarmRange = getLastHourAlarmQueryRange()
|
|
||||||
|
|
||||||
const [
|
const [
|
||||||
cutRes,
|
cutRes,
|
||||||
alarmRes,
|
|
||||||
summaryRes,
|
summaryRes,
|
||||||
lenRes,
|
lenRes,
|
||||||
pierceRes,
|
pierceRes,
|
||||||
@@ -109,7 +106,6 @@ async function fetchOneMachine(baseUrl, ip, appName) {
|
|||||||
runRes
|
runRes
|
||||||
] = await Promise.allSettled([
|
] = await Promise.allSettled([
|
||||||
fetchCutSystemState(baseUrl, ip, appName),
|
fetchCutSystemState(baseUrl, ip, appName),
|
||||||
fetchAlarms(baseUrl, ip, appName, alarmRange.startDate, alarmRange.endDate),
|
|
||||||
fetchSummary(baseUrl, ip, appName, win.summaryStart, win.summaryEnd),
|
fetchSummary(baseUrl, ip, appName, win.summaryStart, win.summaryEnd),
|
||||||
fetchDailyLength(baseUrl, ip, appName, win.startYmd, win.endYmd),
|
fetchDailyLength(baseUrl, ip, appName, win.startYmd, win.endYmd),
|
||||||
fetchDailyPierce(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 cut = cutRes.status === 'fulfilled' ? cutRes.value : null
|
||||||
const alarmsRaw = alarmRes.status === 'fulfilled' ? alarmRes.value : []
|
|
||||||
const summary = summaryRes.status === 'fulfilled' ? summaryRes.value : null
|
const summary = summaryRes.status === 'fulfilled' ? summaryRes.value : null
|
||||||
|
|
||||||
const lenRows = lenRes.status === 'fulfilled' ? lenRes.value : []
|
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)
|
const cutTimeHours = laserTimeDaily.map((s) => Math.round((s / 3600) * 10) / 10)
|
||||||
|
|
||||||
/** 近 1 小时,供主页报警列展示(与机台状态里的 AlarmCount 无关) */
|
|
||||||
const alarmList = Array.isArray(alarmsRaw) ? alarmsRaw : []
|
|
||||||
const { labels } = win
|
const { labels } = win
|
||||||
const cutSystemState = buildCutSystemState(cut || {})
|
const cutSystemState = buildCutSystemState(cut || {})
|
||||||
|
|
||||||
@@ -183,7 +176,7 @@ async function fetchOneMachine(baseUrl, ip, appName) {
|
|||||||
gasTimeDaily,
|
gasTimeDaily,
|
||||||
runTimeDaily
|
runTimeDaily
|
||||||
},
|
},
|
||||||
_laser: { ip, appName, alarmsLastHour: alarmList }
|
_laser: { ip, appName }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-11
@@ -36,17 +36,7 @@ export function formatYmdHms(d) {
|
|||||||
return `${formatYmd(d)} ${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`
|
return `${formatYmd(d)} ${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// 说明:历史上用于魔盒 `alarm/v2` 的时间窗口查询;当前 A 类主页报警改为直接取 `NcState.AlarmMsg`。
|
||||||
* 魔盒 `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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本周一~周日与魔盒 statistic/daily 的 statDate(整数 yyyymmdd)对齐。
|
* 本周一~周日与魔盒 statistic/daily 的 statDate(整数 yyyymmdd)对齐。
|
||||||
|
|||||||
+13
-31
@@ -133,23 +133,11 @@ const weeklyProduceTotal = computed(() => {
|
|||||||
return totals
|
return totals
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 魔盒报警行上的发生时间(不同版本字段名不一,尽量兼容) */
|
/**
|
||||||
function laserAlarmOccurAt(a) {
|
* 报警汇总:
|
||||||
const raw =
|
* - B/C:仍为「设备处于报警态」一条摘要
|
||||||
a?.AlarmTime ??
|
* - A 类:不再调用 alarm/v2,直接展示机台状态接口的 NcState.AlarmMsg(有内容则展示一条)
|
||||||
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 标设备报警态
|
|
||||||
const alarms = computed(() => {
|
const alarms = computed(() => {
|
||||||
const rows = []
|
const rows = []
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
@@ -162,7 +150,6 @@ const alarms = computed(() => {
|
|||||||
const a = d.machineData.alarm
|
const a = d.machineData.alarm
|
||||||
const msg = a?.length ? a[0] : 'CNC系统报警'
|
const msg = a?.length ? a[0] : 'CNC系统报警'
|
||||||
rows.push({
|
rows.push({
|
||||||
at: now.getTime(),
|
|
||||||
time: now.toLocaleTimeString('zh-CN', { hour12: false }),
|
time: now.toLocaleTimeString('zh-CN', { hour12: false }),
|
||||||
device: `CNC-${d.name}`,
|
device: `CNC-${d.name}`,
|
||||||
message: msg
|
message: msg
|
||||||
@@ -171,22 +158,17 @@ const alarms = computed(() => {
|
|||||||
|
|
||||||
laserListForUi.value.forEach((d) => {
|
laserListForUi.value.forEach((d) => {
|
||||||
if (!d.online || d.type !== 'laser') return
|
if (!d.online || d.type !== 'laser') return
|
||||||
const list = d._laser?.alarmsLastHour
|
const nc = d.machineData?.CutSystemState?.NcState
|
||||||
if (!Array.isArray(list) || !list.length) return
|
const msg = String(nc?.AlarmMsg || '').trim()
|
||||||
list.forEach((a) => {
|
if (!msg) return
|
||||||
const at = laserAlarmOccurAt(a) || now
|
rows.push({
|
||||||
const msg = a?.AlarmDesc || a?.alarmDesc || a?.message || a?.msg || ''
|
time: now.toLocaleTimeString('zh-CN', { hour12: false }),
|
||||||
rows.push({
|
device: d.name,
|
||||||
at: at.getTime(),
|
message: msg
|
||||||
time: at.toLocaleTimeString('zh-CN', { hour12: false }),
|
|
||||||
device: d.name,
|
|
||||||
message: msg || '报警'
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
rows.sort((x, y) => y.at - x.at)
|
return rows
|
||||||
return rows.map(({ at: _t, ...rest }) => rest)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function goDetail(id) {
|
function goDetail(id) {
|
||||||
|
|||||||
Reference in new issue
Block a user