提交 27204661 authored 作者: liujiaxing's avatar liujiaxing

精确到秒级

上级 39a0c761
...@@ -165,43 +165,134 @@ const deviceStatusMap = ref([ ...@@ -165,43 +165,134 @@ const deviceStatusMap = ref([
]) ])
import useAppStore from '@/store/module/app'
// 监听 errorDeviceList 的变化 const useAppStoreInstance = useAppStore();
watch(() => props.errorDeviceList, (newVal) => { watch(() => useAppStoreInstance.globalTimeLineEndSelectTime, (val) => {
console.log(props.errorDeviceList, '故障详情'); // console.log(val, '时间变化----------------', faultData.value);
//故障情况判定--每一个信关站的故障设备判定
if (newVal.length === 0) { // console.log('当前时间', props.errorDeviceList);
if (props.errorDeviceList.length === 0) {
devices.value = [] devices.value = []
return return
} }
if (newVal && typeof newVal === 'object' && !Array.isArray(newVal)) { if (props.errorDeviceList && typeof props.errorDeviceList === 'object' && !Array.isArray(props.errorDeviceList)) {
// 如果是对象且包含 groundNetworkElementResponses 数组 // 如果是对象且包含 groundNetworkElementResponses 数组
if (newVal.groundNetworkElementResponses && Array.isArray(newVal.groundNetworkElementResponses)) { if (props.errorDeviceList.groundNetworkElementResponses && Array.isArray(props.errorDeviceList.groundNetworkElementResponses)) {
devices.value = newVal.groundNetworkElementResponses.map(item => ({ devices.value = props.errorDeviceList.groundNetworkElementResponses.map(item => ({
name: item.elementName || '未知设备', name: item.elementName || '未知设备',
status: item.status === '正常' ? 'normal' : 'error', status: item.status === '正常' ? 'normal' : 'error',
expanded: false, expanded: false,
errorDetails: item.stAlarmInfoResponse || null errorDetails: item.stAlarmInfoResponse || null
})) }))
} }
} else if (Array.isArray(newVal)) { } else if (Array.isArray(props.errorDeviceList)) {
// 如果是数组,直接映射 // 如果是数组,直接映射
devices.value = newVal.map(item => ({ devices.value = []
name: item.elementName || '未知设备', props.errorDeviceList.forEach(item => {
status: item.statue === '正常' ? 'normal' : 'error', let status = true
expanded: false, item.stAlarmInfoResponseArr.forEach(it => {
errorDetails: item.stAlarmInfoResponse?.locationInfo || null if (it.status == "故障") {
})) if (compareTime(val, it.startTime) && compareTime(it.endTime, val)) {
} else if (newVal && typeof newVal === 'object') { status = false
devices.value.push({
name: item.elementName || '未知设备',
status: 'error',
expanded: true,
errorDetails: it.locationInfo || null
})
}
}
})
if (status) {
devices.value.push({
name: item.elementName || '未知设备',
status: item.statue === '正常' ? 'normal' : 'error',
expanded: false,
errorDetails: item.stAlarmInfoResponseArr[0]?.locationInfo || null
})
}
})
// devices.value = props.errorDeviceList.map(item => ({
// name: item.elementName || '未知设备',
// status: item.statue === '正常' ? 'normal' : 'error',
// expanded: false,
// errorDetails: item.stAlarmInfoResponse?.locationInfo || null
// }))
// console.log(devices.value, '设备列表');
} else if (props.errorDeviceList && typeof props.errorDeviceList === 'object') {
// 如果是普通对象,尝试直接使用 // 如果是普通对象,尝试直接使用
devices.value = [{ devices.value = [{
name: newVal.elementName || '未知设备', name: props.errorDeviceList.elementName || '未知设备',
status: newVal.statue === '正常' ? 'normal' : 'error', status: props.errorDeviceList.statue === '正常' ? 'normal' : 'error',
expanded: false, expanded: false,
errorDetails: newVal.stAlarmInfoResponse?.locationInfo || null errorDetails: props.errorDeviceList.stAlarmInfoResponse?.locationInfo || null
}] }]
} }
}, { immediate: true })
})
// 对比时间
const compareTime = (time1, time2) => {
// console.log('cao每隔开始compareTime----------1', time1, time2);
// 将时间字符串转换为 Date 对象
const date1 = new Date(time1);
if (time2 === null || time2 === "" || time2 === undefined) {
time2 = new Date(
new Date(selectedStartTime.value).getTime() + 60 * 1000
).toISOString();
// //console.log('每隔开始compareTime----------', time1, time2);
}
const date2 = new Date(time2);
// 检查时间是否有效
if (isNaN(date1.getTime()) || isNaN(date2.getTime())) {
throw new Error("无效的时间格式");
}
// 比较时间戳
if (date1 >= date2) {
return true;
} else {
return false;
}
};
// 监听 errorDeviceList 的变化
// watch(() => props.errorDeviceList, (newVal) => {
// console.log(props.errorDeviceList, '故障详情');
// if (newVal.length === 0) {
// devices.value = []
// return
// }
// if (newVal && typeof newVal === 'object' && !Array.isArray(newVal)) {
// // 如果是对象且包含 groundNetworkElementResponses 数组
// if (newVal.groundNetworkElementResponses && Array.isArray(newVal.groundNetworkElementResponses)) {
// devices.value = newVal.groundNetworkElementResponses.map(item => ({
// name: item.elementName || '未知设备',
// status: item.status === '正常' ? 'normal' : 'error',
// expanded: false,
// errorDetails: item.stAlarmInfoResponse || null
// }))
// }
// } else if (Array.isArray(newVal)) {
// // 如果是数组,直接映射
// devices.value = newVal.map(item => ({
// name: item.elementName || '未知设备',
// status: item.statue === '正常' ? 'normal' : 'error',
// expanded: false,
// errorDetails: item.stAlarmInfoResponse?.locationInfo || null
// }))
// } else if (newVal && typeof newVal === 'object') {
// // 如果是普通对象,尝试直接使用
// devices.value = [{
// name: newVal.elementName || '未知设备',
// status: newVal.statue === '正常' ? 'normal' : 'error',
// expanded: false,
// errorDetails: newVal.stAlarmInfoResponse?.locationInfo || null
// }]
// }
// }, { immediate: true })
watch(() => props.baseDeviceList, (newVal) => { watch(() => props.baseDeviceList, (newVal) => {
deviceStatusMap.value = [] deviceStatusMap.value = []
......
...@@ -443,7 +443,7 @@ function searchEquipmentList() { ...@@ -443,7 +443,7 @@ function searchEquipmentList() {
) )
filteredData.map(item => { filteredData.map(item => {
item.allData.arr.map(it => { item.allData.arr.map(it => {
console.log(useAppStoreInstance.globalTimeLineEndSelectTime, it.startTime, it.endTime, '故障时间',isTimeInRange(useAppStoreInstance.globalTimeLineEndSelectTime, it.startTime, it.endTime)); // console.log(useAppStoreInstance.globalTimeLineEndSelectTime, it.startTime, it.endTime, '故障时间',isTimeInRange(useAppStoreInstance.globalTimeLineEndSelectTime, it.startTime, it.endTime));
//判断故障时间是否包含当前时间 //判断故障时间是否包含当前时间
if (isTimeInRange(useAppStoreInstance.globalTimeLineEndSelectTime, it.startTime, it.endTime)) { if (isTimeInRange(useAppStoreInstance.globalTimeLineEndSelectTime, it.startTime, it.endTime)) {
...@@ -452,7 +452,7 @@ function searchEquipmentList() { ...@@ -452,7 +452,7 @@ function searchEquipmentList() {
item.monitor = it.controlBaseStationNum item.monitor = it.controlBaseStationNum
item.baseband = it.baseStationNum item.baseband = it.baseStationNum
// console.log(item.ku, item.qv, item.monitor, item.baseband, '故障数量',it); // console.log(item.ku, item.qv, item.monitor, item.baseband, '故障数量',it);
} }
}) })
}) })
...@@ -904,9 +904,9 @@ watch(() => useAppStoreInstance.globalLeftWssCONTINE, val => { ...@@ -904,9 +904,9 @@ watch(() => useAppStoreInstance.globalLeftWssCONTINE, val => {
if (JSONdata.type === 'realtime') {//实时模式 if (JSONdata.type === 'realtime') {//实时模式
//卫星轨迹数据,实时模式下的wss数据结构和历史模式不太一样,历史模式是CurrData数组里套satelliteBasicInfoResponse对象,实时模式是CurrData数组里直接就是satelliteBasicInfoResponse对象 //卫星轨迹数据,实时模式下的wss数据结构和历史模式不太一样,历史模式是CurrData数组里套satelliteBasicInfoResponse对象,实时模式是CurrData数组里直接就是satelliteBasicInfoResponse对象
const satelliteList = [] const satelliteList = []
JSONdata.CurrData?.forEach(items => { JSONdata.CurrData?.forEach(items => {
let temp = items.satelliteBasicInfoResponse||{} let temp = items.satelliteBasicInfoResponse || {}
temp.siteName = items.siteName temp.siteName = items.siteName
satelliteList.push(temp) satelliteList.push(temp)
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论