修改正式检测推送逻辑
This commit is contained in:
@@ -114,7 +114,10 @@
|
||||
</el-drawer>
|
||||
</div>
|
||||
|
||||
<CompareDataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef" />
|
||||
<CompareDataCheckSingleChannelSingleTestPopup
|
||||
ref="dataCheckSingleChannelSingleTestPopupRef"
|
||||
:append-to-body="true"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="tsx" setup name="test">
|
||||
@@ -297,69 +300,131 @@ let count = 0
|
||||
watch(
|
||||
webMsgSend,
|
||||
function (newValue, oldValue) {
|
||||
if (testStatus.value == 'test_init') {
|
||||
// 正式检测
|
||||
} else {
|
||||
// 预监测 正式检测
|
||||
if (newValue.requestId == 'formal_real') {
|
||||
switch (newValue.code) {
|
||||
case 25001:
|
||||
let result: CheckData.ScriptChnItem[] = []
|
||||
scriptData.forEach(item => {
|
||||
// 处理当前节点的数据
|
||||
let temp: CheckData.ScriptChnItem = {
|
||||
scriptType: item.id,
|
||||
scriptName: item.scriptName,
|
||||
devices: []
|
||||
}
|
||||
let message = JSON.parse(newValue.data)
|
||||
for (let i = 0; i < message?.length; i++) {
|
||||
temp.devices.push({
|
||||
deviceId: message[i].deviceId,
|
||||
deviceName: message[i].deviceName,
|
||||
chnResult: message[i].chnResult
|
||||
})
|
||||
}
|
||||
result.push(temp)
|
||||
})
|
||||
Object.assign(checkResult, result)
|
||||
testLogList.push({
|
||||
type: 'info',
|
||||
log: `${new Date().toLocaleString()}:` + '检测完成!'
|
||||
})
|
||||
if(testLogList[0].log === '正在检测,请稍等...'){
|
||||
testLogList.shift()
|
||||
}
|
||||
stopTimeCount()
|
||||
break
|
||||
case 25003:
|
||||
|
||||
testLogList.push({
|
||||
type: 'error',
|
||||
log: `${new Date().toLocaleString()}:` + '检测失败!'
|
||||
})
|
||||
if(testLogList[0].log === '正在检测,请稍等...'){
|
||||
testLogList.shift()
|
||||
}
|
||||
stopTimeCount()
|
||||
break
|
||||
default:
|
||||
if (newValue.code != 10201) {
|
||||
testLogList.push({
|
||||
type: newValue.code == 10200 ? 'info' : 'error',
|
||||
log: `${new Date().toLocaleString()}:` + newValue.data
|
||||
})
|
||||
|
||||
updatePercentage()
|
||||
}
|
||||
console.log('🚀 ~ newValue:', newValue)
|
||||
|
||||
if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') {
|
||||
if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') {
|
||||
testLogList.shift()
|
||||
setLogList('info', '初始化开始!')
|
||||
}
|
||||
let str =
|
||||
newValue.requestId == 'yjc_sbtxjy'
|
||||
? '设备通讯校验'
|
||||
: newValue.requestId == 'yjc_mxyzxjy'
|
||||
? '模型一致性检验'
|
||||
: newValue.requestId == 'yjc_align'
|
||||
? '实时数据对齐检验'
|
||||
: newValue.requestId == 'YJC_xujy'
|
||||
? '相序校验'
|
||||
: ''
|
||||
// 预检测处理
|
||||
switch (newValue.code) {
|
||||
case 25001:
|
||||
// 成功
|
||||
if (newValue.data != undefined) return
|
||||
setLogList('info', str + '成功!')
|
||||
if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化成功!')
|
||||
break
|
||||
case 25003:
|
||||
// 失败
|
||||
if (newValue.data != undefined) return
|
||||
setLogList('error', str + '失败!')
|
||||
if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化失败!')
|
||||
break
|
||||
}
|
||||
}
|
||||
// 预监测 正式检测
|
||||
else if (newValue.requestId == 'formal_real') {
|
||||
if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') {
|
||||
testLogList.shift()
|
||||
}
|
||||
switch (newValue.code) {
|
||||
case 25001:
|
||||
let result: CheckData.ScriptChnItem[] = []
|
||||
scriptData.forEach(item => {
|
||||
// 处理当前节点的数据
|
||||
let temp: CheckData.ScriptChnItem = {
|
||||
scriptType: item.id,
|
||||
scriptName: item.scriptName,
|
||||
devices: []
|
||||
}
|
||||
let message = JSON.parse(newValue.data)
|
||||
for (let i = 0; i < message?.length; i++) {
|
||||
temp.devices.push({
|
||||
deviceId: message[i].deviceId,
|
||||
deviceName: message[i].deviceName,
|
||||
chnResult: message[i].chnResult
|
||||
})
|
||||
}
|
||||
result.push(temp)
|
||||
})
|
||||
Object.assign(checkResult, result)
|
||||
setLogList('info', '检测完成!')
|
||||
stopTimeCount()
|
||||
break
|
||||
case 25003:
|
||||
setLogList('error', '检测失败!')
|
||||
|
||||
stopTimeCount()
|
||||
break
|
||||
default:
|
||||
if (newValue.code != 10201) {
|
||||
setLogList(newValue.code == 10200 ? 'info' : 'error', newValue.data)
|
||||
|
||||
updatePercentage()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
switch (newValue.requestId) {
|
||||
case 'connect':
|
||||
switch (newValue.operateCode) {
|
||||
case 'Contrast_Dev':
|
||||
setLogList('error', '设备服务端连接失败!')
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'unknown_operate':
|
||||
break
|
||||
case 'error_flow_end':
|
||||
ElMessageBox.alert(`当前流程存在异常结束!`, '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
setLogList('error', '当前流程存在异常结束!')
|
||||
break
|
||||
case 'socket_timeout':
|
||||
ElMessageBox.alert(`设备连接异常,请检查设备连接情况!`, '检测失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
setLogList('error', '设备连接异常,请检查设备连接情况!')
|
||||
break
|
||||
case 'server_error':
|
||||
ElMessageBox.alert('服务端主动关闭连接!', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
setLogList('error', '服务端主动关闭连接!')
|
||||
break
|
||||
case 'device_error':
|
||||
ElMessageBox.alert('设备主动关闭连接!', '初始化失败', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'error'
|
||||
})
|
||||
setLogList('error', '设备主动关闭连接!')
|
||||
break
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
const setLogList = (state: 'error' | 'info' | 'warning', text: string) => {
|
||||
testLogList.push({
|
||||
type: state,
|
||||
log: `${new Date().toLocaleString()}:` + text
|
||||
})
|
||||
}
|
||||
|
||||
// 更新进度条
|
||||
const updatePercentage = async () => {
|
||||
@@ -428,11 +493,7 @@ const secondToTime = (second: number) => {
|
||||
return h + ':' + m + ':' + s
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
await initScriptData()
|
||||
initDeviceList()
|
||||
initCheckResult()
|
||||
})
|
||||
onBeforeMount(async () => {})
|
||||
|
||||
const showTestLog = () => {
|
||||
drawer.value = true
|
||||
@@ -658,9 +719,17 @@ const handlePause = () => {
|
||||
log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`
|
||||
})
|
||||
}
|
||||
const initializeParameters = () => {
|
||||
const initializeParameters = async () => {
|
||||
await initScriptData()
|
||||
initDeviceList()
|
||||
initCheckResult()
|
||||
|
||||
percentage.value = 0
|
||||
testLogList.splice(0, testLogList.length, { type: 'info', log: '正在检测,请稍等...' })
|
||||
|
||||
testLogList.splice(0, testLogList.length, {
|
||||
type: 'info',
|
||||
log: checkStore.selectTestItems.preTest ? '正在检测,请稍等...' : '暂无数据,等待检测开始'
|
||||
})
|
||||
}
|
||||
|
||||
const pauseSuccessCallback = () => {
|
||||
@@ -685,8 +754,8 @@ const handleResumeTest = () => {
|
||||
}
|
||||
//
|
||||
onMounted(() => {
|
||||
console.log(123123);
|
||||
|
||||
console.log(123123)
|
||||
|
||||
initializeParameters()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user