接口调整
This commit is contained in:
@@ -144,7 +144,6 @@ const testLogList = reactive<CheckData.LogItem[]>([{type: 'info', log: '暂无
|
||||
const testStatus = toRef(props, 'testStatus')
|
||||
const webMsgSend = toRef(props, 'webMsgSend')
|
||||
|
||||
// const resultDialogVisible = ref(false)
|
||||
const scrollContainerRef = ref();
|
||||
const dataCheckSingleChannelSingleTestPopupRef = ref<InstanceType<typeof CompareDataCheckSingleChannelSingleTestPopup>>()
|
||||
|
||||
@@ -566,16 +565,7 @@ watch(webMsgSend, function (newValue, oldValue) {
|
||||
}, {deep: true})
|
||||
|
||||
const handleStartItem = (code: string, desc: string | undefined) => {
|
||||
if (desc === undefined) {
|
||||
activeIndex = getActiveIndex(code)
|
||||
updateCheckResultView(code, true)
|
||||
updateLog(true)
|
||||
} else {
|
||||
// if (desc.length > 150) {
|
||||
// desc = desc.substring(0, 150) + '...'
|
||||
// }
|
||||
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:${desc}准确度检测:开始`})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const handleEndItem = (code: string, desc: string | undefined, devices: CheckData.DeviceCheckResult[] = []) => {
|
||||
@@ -650,18 +640,15 @@ const showTestLog = () => {
|
||||
|
||||
// 初始化检测脚本数据
|
||||
const initScriptData = async () => {
|
||||
|
||||
let response: any = await getBigTestItem({reCheckType: checkStore.reCheckType, planId: checkStore.plan.id, devIds: checkStore.devices.map(item => item.deviceId)})
|
||||
|
||||
let temp = response.data.map((item: any) => {
|
||||
let temp = checkStore.compareTestItem.map(item => {
|
||||
return {
|
||||
...item,
|
||||
scriptName: item.scriptName
|
||||
id: item.id,
|
||||
code: '',
|
||||
scriptName: item.name
|
||||
}
|
||||
})
|
||||
|
||||
scriptData.push(...temp)
|
||||
checkTotal = scriptData.length
|
||||
scriptData.push(...temp)
|
||||
checkTotal = scriptData.length
|
||||
}
|
||||
// 初始化设备列表
|
||||
const initDeviceList = () => {
|
||||
@@ -716,96 +703,12 @@ const scrollToBottom = () => {
|
||||
}
|
||||
};
|
||||
|
||||
function getRandomInt(max: number): number {
|
||||
return Math.floor(Math.random() * max)
|
||||
}
|
||||
|
||||
|
||||
function getTimeDifference(timeDifference: number): string {
|
||||
// 将时间差转换为天、小时、分钟、秒
|
||||
const millisecondsPerDay = 1000 * 60 * 60 * 24;
|
||||
const millisecondsPerHour = 1000 * 60 * 60;
|
||||
const millisecondsPerMinute = 1000 * 60;
|
||||
const millisecondsPerSecond = 1000;
|
||||
|
||||
const days = Math.floor(timeDifference / millisecondsPerDay);
|
||||
const hours = Math.floor((timeDifference % millisecondsPerDay) / millisecondsPerHour);
|
||||
const minutes = Math.floor((timeDifference % millisecondsPerHour) / millisecondsPerMinute);
|
||||
const seconds = Math.floor((timeDifference % millisecondsPerMinute) / millisecondsPerSecond);
|
||||
if (days > 0) {
|
||||
return `: ${days} 天, ${hours} 小时, ${minutes} 分钟, ${seconds} 秒`
|
||||
} else if (hours > 0) {
|
||||
return `: ${hours} 小时, ${minutes} 分钟, ${seconds} 秒`
|
||||
} else {
|
||||
return `: ${minutes} 分钟, ${seconds} 秒`
|
||||
}
|
||||
}
|
||||
|
||||
watch(testLogList, () => {
|
||||
scrollToBottom();
|
||||
}, {deep: true})
|
||||
|
||||
// 更新日志
|
||||
const updateLog = (isStart: boolean) => {
|
||||
const currentTime = ref(new Date().toLocaleString());
|
||||
let timeDifferenceItem = 0
|
||||
|
||||
if (activeIndex === 1 && isStart) {
|
||||
// timeDifference.value = 0;
|
||||
//testLogList.length = 0; // 清空数组
|
||||
}
|
||||
// debugger
|
||||
if (activeIndex <= checkTotal) {
|
||||
if (isStart) {
|
||||
startData.value = new Date();
|
||||
testLogList.push({
|
||||
type: 'info',
|
||||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测:开始`,
|
||||
})
|
||||
} else {
|
||||
endData.value = new Date();
|
||||
timeDifferenceItem = endData.value.getTime() - startData.value.getTime();
|
||||
timeDifference.value += timeDifferenceItem
|
||||
|
||||
let errorItem = getErrorCheckItem(scriptData[activeIndex - 1].id)
|
||||
switch (errorItem?.type) {
|
||||
case CheckData.ChnCheckResultEnum.SUCCESS:
|
||||
testLogList.push({
|
||||
type: 'info',
|
||||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测结束:符合,用时` + getTimeDifference(timeDifferenceItem),
|
||||
})
|
||||
break
|
||||
case CheckData.ChnCheckResultEnum.FAIL:
|
||||
testLogList.push({
|
||||
type: 'error',
|
||||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测结束:不符合,用时` + getTimeDifference(timeDifferenceItem),
|
||||
})
|
||||
break
|
||||
case CheckData.ChnCheckResultEnum.TIMEOUT:
|
||||
testLogList.push({
|
||||
type: 'warning',
|
||||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测结束:连接超时,用时` + getTimeDifference(timeDifferenceItem),
|
||||
})
|
||||
break
|
||||
case CheckData.ChnCheckResultEnum.ERRORDATA:
|
||||
testLogList.push({
|
||||
type: 'warning',
|
||||
log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测结束:数据异常,用时` + getTimeDifference(timeDifferenceItem),
|
||||
})
|
||||
break
|
||||
}
|
||||
|
||||
timeView.value = secondToTime(timeDifference.value / 1000)
|
||||
if (activeIndex === checkTotal) {
|
||||
testLogList.push({
|
||||
type: 'info',
|
||||
log: currentTime.value + ' :检测结束,总用时' + getTimeDifference(timeDifference.value),
|
||||
})
|
||||
stopTimeCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckResult[]) => {
|
||||
let type = 1
|
||||
@@ -840,15 +743,7 @@ const setErrorCheckItem = (scriptType: string, devices: CheckData.DeviceCheckRes
|
||||
errorCheckItem.push({scriptType, type: type})
|
||||
}
|
||||
|
||||
//判断该检测项(例如 频率准确度检测)是否全部合格(所有设备所有通道所有子检测项目全部合格为合格,否则为不合格)
|
||||
function getErrorCheckItem(scriptType: string) {
|
||||
let results = errorCheckItem.filter((item) => item.scriptType === scriptType)
|
||||
if (results.length > 0) {
|
||||
return results[0]
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: CheckData.DeviceCheckResult[] = []) => {
|
||||
let scriptType = scriptData.filter(item => item.code === scriptCode)[0]?.id
|
||||
@@ -891,38 +786,6 @@ const getLoadingResult = (scriptType: string) => {
|
||||
return tempScriptChnItem
|
||||
}
|
||||
|
||||
// 模拟检测 todo 可移除
|
||||
const getCheckResult = (scriptType: string) => {
|
||||
// debugger
|
||||
let devices = []
|
||||
|
||||
devices = deviceList.map(item => {
|
||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||
for (let i = 0; i < item.chnNum; i++) {
|
||||
tempChnResult.push(CheckData.ChnCheckResultEnum.SUCCESS)
|
||||
}
|
||||
let randomNum = getRandomInt(item.chnNum * 2)
|
||||
if (randomNum < item.chnNum && activeIndex >= 4 && activeIndex <= 8) {
|
||||
tempChnResult[randomNum] = CheckData.ChnCheckResultEnum.FAIL
|
||||
errorCheckItem.push({scriptType, type: CheckData.ChnCheckResultEnum.FAIL})
|
||||
}
|
||||
// }
|
||||
|
||||
return {
|
||||
deviceId: item.deviceId,
|
||||
deviceName: item.deviceName,
|
||||
chnResult: tempChnResult,
|
||||
}
|
||||
})
|
||||
// }
|
||||
|
||||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||||
scriptType,
|
||||
devices,
|
||||
}
|
||||
|
||||
return tempScriptChnItem
|
||||
}
|
||||
|
||||
const getResult = (devices: CheckData.DeviceCheckResult[] = []) => {
|
||||
let type = 1
|
||||
@@ -975,68 +838,12 @@ const handleClick = (item: any, chnNum: number, scriptType: string) => {
|
||||
// }
|
||||
// if (flag === -1 || flag === 1) {
|
||||
// checkStore.setShowDetailType(2)
|
||||
console.log('handleTest',item.deviceId,chnNum,scriptType)
|
||||
dataCheckSingleChannelSingleTestPopupRef.value?.open(item.deviceId, chnNum + '', scriptType);
|
||||
//}
|
||||
};
|
||||
|
||||
// todo 可移除
|
||||
const startTimer = () => {
|
||||
console.log('开始检测第' + activeIndex + '项')
|
||||
switch (activeIndex) {
|
||||
case 0:
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'yjc_ytxjy',
|
||||
operateCode: "INIT_GATHER",
|
||||
code: 10200
|
||||
})
|
||||
}, 2000)
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'yjc_sbtxjy',
|
||||
operateCode: "INIT_GATHER$01",
|
||||
code: 25001
|
||||
})
|
||||
}, 4000);
|
||||
setTimeout(() => {
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'yjc_xyjy',
|
||||
operateCode: "INIT_GATHER$03",
|
||||
code: 25001
|
||||
})
|
||||
}, 6000)
|
||||
break;
|
||||
case 1:
|
||||
todoItem('V')
|
||||
break;
|
||||
case 2:
|
||||
todoItem('I')
|
||||
break;
|
||||
case 3:
|
||||
todoItem('IMBV')
|
||||
break;
|
||||
case 4:
|
||||
todoItem('FREQ')
|
||||
break;
|
||||
case 5:
|
||||
todoItem('HV')
|
||||
break;
|
||||
case 6:
|
||||
todoItem('HI')
|
||||
break;
|
||||
case 7:
|
||||
todoItem('HSV')
|
||||
break;
|
||||
case 8:
|
||||
todoItem('HSI')
|
||||
break;
|
||||
case 9:
|
||||
emit('update:webMsgSend', {
|
||||
requestId: 'Quit'
|
||||
})
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const handlePause = () => {
|
||||
//emit('sendPause')
|
||||
testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:当前测试小项正在执行中,将在该小项执行结束后暂停...`})
|
||||
@@ -1145,69 +952,10 @@ const handleResumeTest = () => {
|
||||
console.log('开始继续检测')
|
||||
};
|
||||
|
||||
// 获取当前执行的大测试项序号
|
||||
const getActiveIndex = (code: string): number => {
|
||||
for (let i = 0; i < scriptData.length; i++) {
|
||||
if (scriptData[i].code === code) {
|
||||
return i + 1
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// 获取当前执行的大测试项序 的 下一个大测试项序号
|
||||
const getNextActiveIndex = (code: string = ''): number => {
|
||||
if (code === '') {
|
||||
return -1
|
||||
}
|
||||
for (let i = 0; i < scriptData.length; i++) {
|
||||
if (scriptData[i].code === code) {
|
||||
return i + 2
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
const startTimeCount = () => {
|
||||
if (!timer) {
|
||||
timer = setInterval(() => {
|
||||
timeCount.value = timeCount.value + 1
|
||||
timeView.value = secondToTime(timeCount.value)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
const stopTimeCount = () => {
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}
|
||||
|
||||
const resumeTimeCount = () => {
|
||||
timer = setInterval(() => {
|
||||
timeCount.value = timeCount.value + 1
|
||||
timeView.value = secondToTime(timeCount.value)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
|
||||
const secondToTime = (second: number) => {
|
||||
//将秒数转换成时分秒
|
||||
let h: string | number = Math.floor(second / 3600)
|
||||
let m: string | number = Math.floor((second - h * 3600) / 60)
|
||||
let s: string | number = Math.floor(second % 60);
|
||||
|
||||
h = h < 10 ? '0' + h : h;
|
||||
m = m < 10 ? '0' + m : m;
|
||||
s = s < 10 ? '0' + s : s;
|
||||
return h + ':' + m + ':' + s;
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
if (timer) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
handlePause
|
||||
|
||||
Reference in New Issue
Block a user