预检测出错

This commit is contained in:
sjl
2025-10-16 09:36:43 +08:00
parent 321b6c5465
commit 7d6dc55a76
5 changed files with 133 additions and 91 deletions

View File

@@ -190,8 +190,8 @@ export default class SocketService {
* WebSocket连接配置
*/
private config: SocketConfig = {
url: 'ws://127.0.0.1:7777/hello',
// url: 'ws://192.168.1.124:7777/hello',
//url: 'ws://127.0.0.1:7777/hello',
url: 'ws://192.168.1.124:7777/hello',
heartbeatInterval: 9000, // 9秒心跳间隔
reconnectDelay: 5000, // 5秒重连延迟
maxReconnectAttempts: 5, // 最多重连5次

View File

@@ -24,7 +24,7 @@
</template>
<script lang="ts" setup>
import { h, ref, onMounted, PropType } from 'vue'
import { h, ref, onMounted, PropType, computed } from 'vue'
import { VueFlow, useVueFlow } from '@vue-flow/core'
import { dialogBig } from '@/utils/elementBind'
import { Platform, Flag } from '@element-plus/icons-vue'
@@ -57,6 +57,10 @@ const prop = defineProps({
deviceMonitor: {
type: Map as PropType<Map<string, any[]>>,
default: () => new Map()
},
dialogWidth: {
type: Number,
default: 0
}
})
// 计算对话框高度
@@ -336,6 +340,24 @@ const generateChannelMapping = () => {
channelMapping.value = mapping
}
// 计算基于 dialogWidth 的位置参数 - 确保最小距离
const deviceWidthVal = computed(() => {
return Math.max(0, 50)
})
const inputChannelXVal = computed(() => {
return Math.max(300, deviceWidthVal.value + 300)
})
const outputChannelXVal = computed(() => {
return Math.max(650, prop.dialogWidth - 470)
})
const standardWidthVal = computed(() => {
return Math.max(800, prop.dialogWidth - 350)
})
const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[], deviceMonitor: Map<string, any[]>) => {
const channelCounts: Record<string, number> = {}
device.forEach(device => {
@@ -366,11 +388,14 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
const deviceChannelGroups: { deviceId: string; centerY: number }[] = []
const standardChannelGroups: any[] = []
const deviceWidth = 50
const inputChannelX = 350
const outputChannelX = 1050
const standardWidth = 1170
// const deviceWidth = 50
// const inputChannelX = 350
// const outputChannelX = 1050
// const standardWidth = 1170
const deviceWidth = deviceWidthVal.value
const inputChannelX = inputChannelXVal.value
const outputChannelX = outputChannelXVal.value
const standardWidth = standardWidthVal.value
// 添加被检通道
// let currentYPosition = 50; // 初始Y位置
@@ -385,7 +410,6 @@ const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResP
let currentYPosition = (vueFlowElement.value - 60 * actualChannelsTotalLength) / 2; // 初始Y位置
const deviceSpacing = 30; // 设备间的垂直间距
console.log('currentYPosition', currentYPosition)
Object.entries(channelCounts).forEach(([deviceId, count]) => {
// 从deviceMonitor中获取实际通道信息
let actualChannels = []; // 存储实际的通道号

View File

@@ -267,10 +267,10 @@ watch(webMsgSend, function (newValue, oldValue) {
step2.value = 'process'
}
if(newValue.code == 10550){
step1InitLog.value = [{
step1InitLog.value.push({
type: 'error',
log: '设备通讯校验时,设备连接异常!',
}];
});
step1.value = 'error'
ts.value = 'error'
step5.value = 'error'
@@ -278,10 +278,10 @@ watch(webMsgSend, function (newValue, oldValue) {
break;
case 'record_wave_step1':
if(newValue.code == 10550){
step1InitLog.value = [{
step1InitLog.value.push({
type: 'error',
log: '录波校验时,设备连接异常!',
}];
});
step1.value = 'error'
ts.value = 'error'
step5.value = 'error'
@@ -312,10 +312,10 @@ watch(webMsgSend, function (newValue, oldValue) {
}];
}
if(newValue.code == 10550){
step2InitLog.value = [{
step2InitLog.value.push({
type: 'error',
log: '模型一致性校验时,设备连接异常!',
}];
});
step2.value = 'error'
ts.value = 'error'
step5.value = 'error'
@@ -352,10 +352,10 @@ watch(webMsgSend, function (newValue, oldValue) {
}];
}
if(newValue.code == 10550){
step3InitLog.value = [{
step3InitLog.value.push({
type: 'error',
log: '实时数据对齐时,设备连接异常!',
}];
});
step3.value = 'error'
ts.value = 'error'
step5.value = 'error'
@@ -394,14 +394,14 @@ watch(webMsgSend, function (newValue, oldValue) {
step4.value = 'process'
step4InitLog.value = [{
type: 'wait',
log: '正在进行相序性检.....',
log: '正在进行相序校验.....',
}];
}
if(newValue.code == 10550){
step4InitLog.value = [{
step4InitLog.value.push({
type: 'error',
log: '相序校验时,设备连接异常!',
}];
});
step4.value = 'error'
ts.value = 'error'
step5.value = 'error'
@@ -488,6 +488,16 @@ watch(webMsgSend, function (newValue, oldValue) {
step5.value = 'error'
}
break;
case 'formal_real':
if (newValue.code == 25003) {
ElMessageBox.alert('数据收集不完整!', '检测失败', {
confirmButtonText: '确定',
type: 'error',
})
ts.value = 'error'
step5.value = 'error'
}
break;
}
}
})

View File

@@ -474,10 +474,6 @@ watch(
}
break;
case 'yjc_sbtxjy' :
if(newValue.code == 10550){
setLogList('error', '设备通讯校验时,设备连接异常!')
stopTimeCount()
}
if (newValue.code == 10552) {
ElMessageBox.alert('重复的初始化操作!', '检测失败', {
confirmButtonText: '确定',
@@ -537,32 +533,28 @@ watch(
case 25001:
case 25006:
case 25005:
case 25007:// 添加闪变处理
case 25007:
{
let result: CheckData.ScriptChnItem[] = []
let message = JSON.parse(newValue.data)
// 先保存当前所有项目的状态
const previousStates = new Map()
checkResult.forEach(item => {
previousStates.set(item.scriptType, JSON.parse(JSON.stringify(item.devices)))
})
// 当收到 25005/25006 消息时录波项目开始loading
if (newValue.code == 25005 || newValue.code == 25006) {
// 设置录波项目为LOADING状态
const waveResultItem = checkResult.find(item => item.code === 'wave_data')
if (waveResultItem) {
waveResultItem.devices.forEach(device => {
device.chnResult.fill(CheckData.ChnCheckResultEnum.LOADING)
})
}
}
if (newValue.code == 25007) {
// 设置闪变项目为LOADING状态
const flickerResultItem = checkResult.find(item => item.code === 'F')
if (flickerResultItem) {
flickerResultItem.devices.forEach(device => {
device.chnResult.fill(CheckData.ChnCheckResultEnum.LOADING)
@@ -570,33 +562,31 @@ watch(
}
}
// 重建结果时保留其他正在进行的项目状态
let result: CheckData.ScriptChnItem[] = []
scriptData.forEach(item => {
// 处理当前节点的数据
const temp: CheckData.ScriptChnItem = {
scriptType: item.id,
scriptName: item.scriptName,
code: item.code,
devices: []
}
// 特殊处理录波项目 - 如果是25005消息且当前项目是录波项目则使用已设置的状态
// 如果是当前处理的项目类型,则使用新数据
if ((newValue.code == 25005 || newValue.code == 25006) && item.code === 'wave_data') {
const existingWaveItem = checkResult.find(checkItem => checkItem.scriptType === 'wave_data')
if (existingWaveItem) {
temp.devices = [...existingWaveItem.devices] // 保留已设置的devices
// 使用已设置的录波状态
const existingItem = checkResult.find(i => i.scriptType === item.id)
if (existingItem) {
temp.devices = [...existingItem.devices]
}
} // 特殊处理闪变项目 - 如果是25007消息且当前项目是闪变项目则使用已设置的状态
else if (newValue.code == 25007 && item.code === 'F') {
const existingFlickerItem = checkResult.find(checkItem => checkItem.scriptName === '闪变')
if (existingFlickerItem) {
temp.devices = [...existingFlickerItem.devices] // 保留已设置的devices
} else if (newValue.code == 25007 && item.code === 'F') {
// 使用已设置的闪变状态
const existingItem = checkResult.find(i => i.scriptType === item.id)
if (existingItem) {
temp.devices = [...existingItem.devices]
}
}
else {
// 找到message中所有scriptName与当前item.code匹配的项
} else {
// 对于其他项目,保留之前的状态
const matchedDevices = message
.filter((msg: any) => msg.scriptName === item.code)
.map((msg: any) => ({
@@ -605,32 +595,32 @@ watch(
chnResult: msg.chnResult
}))
// 添加匹配到的设备
if (matchedDevices.length > 0) {
temp.devices.push(...matchedDevices)
// 对于未匹配到的设备,也要添加占位符(特别是录波项目)
if (item.code === 'wave_data' || item.code === 'F') {
} else {
// 保留之前的状态
const previousState = previousStates.get(item.id)
if (previousState) {
temp.devices = previousState
} else {
// 如果之前没有状态,则初始化
deviceList.forEach(device => {
const isDeviceExist = matchedDevices.some((matchedDevice: any) => matchedDevice.deviceId === device.deviceId)
if (!isDeviceExist) {
// 对于录波项目或未匹配到的设备,添加默认状态
temp.devices.push({
deviceId: device.deviceId,
deviceName: device.deviceName,
chnResult: new Array(checkStore.chnNumList.length).fill(
item.code === 'wave_data' || item.code === 'F' ?
CheckData.ChnCheckResultEnum.UNKNOWN :
CheckData.ChnCheckResultEnum.UNKNOWN
)
})
}
})
}
}
}
result.push(temp)
})
Object.assign(checkResult, result)
if (newValue.code == 25001) {
setLogList('info', '检测完成!')
stopTimeCount()

View File

@@ -47,6 +47,7 @@
:pqStandardDevList="prop.pqStandardDevList"
:planIdKey="prop.planIdKey"
:deviceMonitor="deviceMonitor2"
:dialogWidth="computedDialogWidth"
/>
</keep-alive>
<keep-alive>
@@ -135,7 +136,7 @@
</template>
<script lang="tsx" setup name="testPopup">
import { nextTick, reactive, ref, watch } from 'vue'
import { nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Coin, Edit, Key, Refresh, Right, SuccessFilled, Switch, VideoPause, VideoPlay } from '@element-plus/icons-vue'
import ComparePreTest from './comparePreTest.vue'
@@ -167,6 +168,25 @@ const dialogTitle = ref('')
const showComponent = ref(true)
const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
const testRef: any = ref(null)
const windowWidth = ref(window.innerWidth)
const computedDialogWidth = ref(0)
// 监听窗口大小变化
const handleResize = () => {
windowWidth.value = window.innerWidth
// 计算对话框实际宽度 (90vw但不超过1550px不小于800px)
computedDialogWidth.value = Math.min(Math.max(window.innerWidth * 0.9, 800), 1550)
}
onMounted(() => {
window.addEventListener('resize', handleResize)
handleResize() // 初始化
})
onUnmounted(() => {
window.removeEventListener('resize', handleResize)
})
const prop = defineProps({
devIdList: {
@@ -414,13 +434,10 @@ const emit = defineEmits<{
}>()
watch(preTestStatus, function (newValue, oldValue) {
ActiveStatue.value = newValue
})
watch(TestStatus, function (newValue, oldValue) {
ActiveStatue.value = newValue
})
@@ -438,7 +455,7 @@ watch(stepsActiveIndex, function (newValue, oldValue) {
watch(ActiveStatue, function (newValue, oldValue) {
if (newValue === 'error') {
stepsActiveIndex.value = stepsTotalNum.value + 1
stepsActiveIndex.value += 0
nextStepText.value = '检测失败'
}
if (newValue === 'success' && stepsActiveIndex.value === stepsTotalNum.value - 1) {
@@ -446,15 +463,15 @@ watch(ActiveStatue, function (newValue, oldValue) {
nextStepText.value = '检测完成'
}
if (newValue === 'test_init_fail') {
stepsActiveIndex.value += 2
stepsActiveIndex.value += 0
nextStepText.value = '初始化失败'
}
if (newValue === 'connect_timeout') {
stepsActiveIndex.value += 2
stepsActiveIndex.value += 0
nextStepText.value = '连接超时'
}
if (newValue === 'pause_timeout') {
stepsActiveIndex.value += 2
stepsActiveIndex.value += 0
// nextStepText.value = '结束测试'
nextStepText.value = '暂停超时'
}
@@ -462,6 +479,7 @@ watch(ActiveStatue, function (newValue, oldValue) {
nextStep() // 实现自动点击,进入下一个测试内容
//handleSubmitFast()
}
})
const handleQuit = () => {