接口调整

This commit is contained in:
sjl
2025-08-11 15:59:29 +08:00
parent c85eac3888
commit 77d2176812
8 changed files with 153 additions and 321 deletions

View File

@@ -4,8 +4,8 @@
<el-table :data="mockTableData" height="357px" :header-cell-style="{ textAlign: 'center' } "
:cell-style="{ textAlign: 'center' }">
<el-table-column label="A相" >
<el-table-column prop="stdA" :label="'标准值'"/>
<el-table-column prop="dataA" :label="'被检值'"/>
<el-table-column prop="stdA" :label="'被检值'"/>
<el-table-column prop="dataA" :label="'标准值'"/>
<el-table-column prop="isDataA" label="检测结果">
<template #default="scope">
<el-tooltip effect="dark" placement="bottom">
@@ -18,8 +18,8 @@
</el-table-column>
</el-table-column>
<el-table-column label="B相" >
<el-table-column prop="stdB" :label="'标准值'"/>
<el-table-column prop="dataB" :label="'被检值'"/>
<el-table-column prop="stdB" :label="'被检值'"/>
<el-table-column prop="dataB" :label="'标准值'"/>
<el-table-column prop="isDataB" label="检测结果">
<template #default="scope">
<el-tooltip effect="dark" placement="bottom">
@@ -32,8 +32,8 @@
</el-table-column>
</el-table-column>
<el-table-column label="C相" >
<el-table-column prop="stdC" :label="'标准值'"/>
<el-table-column prop="dataC" :label="'被检值'"/>
<el-table-column prop="stdC" :label="'被检值'"/>
<el-table-column prop="dataC" :label="'标准值'"/>
<el-table-column prop="isDataC" label="检测结果">
<template #default="scope">
<el-tooltip effect="dark" placement="bottom">

View File

@@ -25,10 +25,26 @@
<el-option v-for="item in chnList" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
<el-form-item v-if="checkStore.showDetailType===1">
<el-button type="primary" :icon="Postcard" >报告生成</el-button>
</el-form-item>
<el-form-item v-if="checkStore.showDetailType===0">
<el-button type="primary" :icon="Histogram" >重新计算</el-button>
</el-form-item>
</el-form>
</div>
<div class="data-check-body">
<div class="content-right">
<div class="content-right-title">
<div style="width: 840px;">
<span class="content-right-title-text">当前检测项目</span>
<span style="color: var(--el-color-primary);">频率</span>
</div>
<el-form-item style="margin-left: 280px;margin-bottom:0px !important;width: 280px;" label='测试项'>
<el-cascader v-model="currentCheckItem" :options="options" clearable />
</el-form-item>
</div>
<div class="content-right-Tabs">
<el-tabs type="border-card" v-model="activeTab">
<el-tab-pane label="检测结果" name="resultTab">
@@ -52,6 +68,7 @@ import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
import {CheckData} from "@/api/check/interface";
import {useCheckStore} from "@/stores/modules/check";
import {Histogram, Postcard} from "@element-plus/icons-vue";
const {appendToBody} = withDefaults(defineProps<{
appendToBody: boolean
@@ -64,6 +81,9 @@ const visible = ref(false)
const treeRef = ref()
const searchValue = ref<string>('')
const pqErrorList = reactive<{ id: string; name: string; }[]>([])
const activeTab = ref('resultTab')
const currentCheckItem = ref<any>()
watch(searchValue, (val) => {
treeRef.value!.filter(val)
})
@@ -92,8 +112,38 @@ const rawTableData = reactive<CheckData.RawDataItem[]>([])
const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => {
visible.value = true;
// 设置默认选中第一个选项
if (options.length > 0) {
const firstOption = options[0];
currentCheckItem.value = [firstOption.value];
// 如果第一个选项有子选项,默认也选中第一个子选项
if (firstOption.children && firstOption.children.length > 0) {
currentCheckItem.value.push(firstOption.children[0].value);
}
}
}
const options = [
{
value: 'guide',
label: '谐波电压',
children: [
{
value: 'disciplines',
label: '2次',
},
{
value: 'disciplines',
label: '3次',
},
],
},
]
defineExpose({
open
@@ -158,7 +208,7 @@ defineExpose({
.content-right-title {
display: flex;
padding: 10px 0;
margin-top: 10px;
margin-top: 0px;
line-height: 1.5;
.content-right-title-text {

View File

@@ -42,7 +42,7 @@
<el-collapse-item name="3">
<template #title>
实时数据对齐验证
<el-icon class="title-icon" @click="openDialog"><InfoFilled/></el-icon>
<el-icon class="title-icon" @click="openDialog" v-if="isShowDialog"><InfoFilled/></el-icon>
</template>
<div class="div-log">
<p v-for="(item, index) in step3InitLog" :key="index"
@@ -84,6 +84,7 @@
import {ElMessage, ElMessageBox, StepProps} from "element-plus";
import {defineExpose, PropType, ref, toRef, watch} from 'vue';
import RealTimeData from './realTimeDataAlign.vue'
import { el } from "element-plus/es/locale";
const realTimeDataRef = ref()
@@ -118,7 +119,7 @@ const step4InitLog = ref([
const isShowDialog = ref(true)
const collapseActiveName = ref('1')
const activeIndex = ref(0)
const activeTotalNum = ref(5)
@@ -177,9 +178,7 @@ const ts = ref('');
watch(webMsgSend, function (newValue, oldValue) {
console.log('newValue.requestId', newValue.requestId)
console.log('testStatus.value', testStatus.value)
if (testStatus.value !== 'waiting') {
console.log('newValue.requestId', newValue.requestId)
switch (newValue.requestId) {
case 'yjc_sbtxjy':
switch (newValue.operateCode) {
@@ -202,8 +201,8 @@ watch(webMsgSend, function (newValue, oldValue) {
log: newValue.data + '设备连接异常!',
})
step1.value = 'error'
// ts.value = 'error'
// step6.value = 'error'
ts.value = 'error'
step5.value = 'error'
} else if (newValue.code == 10551) {
step1InitLog.value.push({
type: 'error',
@@ -211,16 +210,15 @@ watch(webMsgSend, function (newValue, oldValue) {
})
step1.value = 'error'
ts.value = 'error'
step6.value = 'error'
step5.value = 'error'
} else if (newValue.code == 10552) {
//ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
step1InitLog.value = [{
type: 'wait',
type: 'error',
log: '存在已经初始化步骤,执行自动关闭,请重新发起检测!',
}];
step1.value = 'error'
ts.value = 'error'
step6.value = 'error'
step5.value = 'error'
} else if (newValue.code == 25001) {
activeIndex.value = 1
step1.value = 'success'
@@ -229,79 +227,88 @@ watch(webMsgSend, function (newValue, oldValue) {
break;
}
break;
case 'YJC_mxyzxjy':
case 'yjc_mxyzxjy':
switch (newValue.operateCode){
case 'DATA_REQUEST$02':
if (newValue.code == 10200) {
if (newValue.code == 10200) { //单个监测点成功
step2InitLog.value.push({
type: 'info',
log: '模型一致性检验成功!',
})
}
if (newValue.code == 25001) {
}else if (newValue.code == 25002) { //单个监测点失败
step2InitLog.value.push({
type: 'error',
log: '模型一致性检验失败!',
})
}else if (newValue.code == 25001) { //最终成功
step2.value = 'success'
step3.value = 'process'
activeIndex.value = 2
}else if (newValue.code == 25004) {
step2.value = 'error'
}else if (newValue.code == 25003) { //最终失败
step2.value = 'error'
ts.value = 'error'
step5.value = 'error'
}
break;
}
break;
case 'YJC_sssjdqjy':
case 'yjc_align':
switch (newValue.operateCode){
case 'OPER_GATHER':
case 'DATA_REQUEST$02':
if (newValue.code == 10200) { //单个监测点成功
step3InitLog.value.push({
type: 'info',
log: '实时数据对齐检验成功!',
})
}else if (newValue.code == 25002) { //单个监测点失败
step3InitLog.value.push({
type: 'error',
log: '实时数据对齐检验失败!',
})
}else if (newValue.code == 25001) { //最终成功
step3.value = 'error'
step4.value = 'process'
activeIndex.value = 3
}else if (newValue.code == 25003) { //最终失败
step3.value = 'error'
ts.value = 'error'
step5.value = 'error'
}
break;
}
break;
case 'YJC_xujy':
switch (newValue.operateCode) {
case 'OPER_GATHER':
if (newValue.code == 10200) {
if (newValue.code == 10552) {
step4InitLog.value.push({
type: 'info',
log: '源参数下发成功,等待校验中.....',
type: 'error',
log: '存在已经初始化步骤,已经自动关闭,请重新发起检测',
})
} else if (newValue.code == 10201) {
step4.value = 'process'
step4InitLog.value = [{
type: 'wait',
log: '源参数下发中.....',
}];
} else if (newValue.code == 10552) {
ElMessage.error("存在已经初始化步骤,已经自动关闭,请重新发起检测!")
step4.value = 'error'
ts.value = 'error'
step5.value = 'error'
} else if (newValue.code == 10520) {
step5.value = 'error'
step4InitLog.value.push({
type: 'error',
log: '解析报文异常',
})
step4.value = 'error'
ts.value = 'error'
step5.value = 'error'
}
break;
case 'DATA_REQUEST$02':
if (newValue.code == 10200) {
let type = 'info'
if (newValue.data.includes('不合格')) {
type = 'error'
}
newValue.data.split('<br/>')
step4InitLog.value.push({
type: type,
type: 'info',
log: newValue.data,
})
} else if (newValue.code == 10201) {
step4.value = 'process'
step4InitLog.value = [{
type: 'wait',
log: '获取数据相序校验数据!',
}];
}else if(newValue.code == 25002){
step4InitLog.value.push({
type: 'error',
log: '相序校验失败!',
})
} else if (newValue.code == 25003) {
step4.value = 'error'
step4InitLog.value.push({
@@ -313,13 +320,9 @@ watch(webMsgSend, function (newValue, oldValue) {
} else if (newValue.code == 25001) {
step4.value = 'success'
step5.value = 'success'
step4InitLog.value.push({
type: 'wait',
log: '相序校验成功!',
})
ts.value = 'success'
activeIndex.value = 4
}
activeIndex.value = 4
break
}
break;

View File

@@ -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

View File

@@ -184,7 +184,8 @@ const handleSubmitFast = async () => {
loginName: loginName.value,
devIds: devIds.value,
standardDevIds: standardDevIds.value,
pairs:pairs.value
pairs:pairs.value,
testItemList:[checkStore.selectTestItems.preTest,false,checkStore.selectTestItems.test]
})
preTestStatus.value = 'start'

View File

@@ -736,6 +736,22 @@ const handleTest2 = () => {
if (matchedItem) {
dataSources.value = matchedItem.datasourceIds
}
// 获取选中计划的测试项配置
const compareTestItem = ref<CheckData.CompareTestItem[]>([])
const names = matchedItem.testItemNameStr ? matchedItem.testItemNameStr.split(',') : []
const ids = matchedItem.testItems || []
// 构造 compareTestItem 数组
compareTestItem.value = ids.map((id: string, index: number) => {
return {
id: id,
name: names[index] || ''
}
})
checkStore.clearCompareTestItem()
checkStore.setCompareTestItem(compareTestItem.value)
deviceConnectionPopupRef.value?.open(channelsSelection.value, pqStandardDevList.value,props.id)
}