Merge remote-tracking branch 'origin/hainan' into hainan
# Conflicts: # frontend/src/views/machine/freqConverter/components/freqConverterDipChart.vue
This commit is contained in:
@@ -17,11 +17,11 @@
|
||||
导出数据
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!props.autoDrawCurve"
|
||||
type="primary"
|
||||
plain
|
||||
class="draw-curve-button"
|
||||
@click="drawCharacteristicCurve"
|
||||
v-if="!props.autoDrawCurve"
|
||||
type="primary"
|
||||
plain
|
||||
class="draw-curve-button"
|
||||
@click="drawCharacteristicCurve"
|
||||
>
|
||||
绘制特性曲线
|
||||
</el-button>
|
||||
@@ -30,15 +30,15 @@
|
||||
</template>
|
||||
|
||||
<div class="chart-wrapper">
|
||||
<MyEchart ref="chartRef" :options="chartOptions" />
|
||||
<MyEchart ref="chartRef" :options="chartOptions"/>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Document, Download } from '@element-plus/icons-vue'
|
||||
import {computed, nextTick, ref, watch} from 'vue'
|
||||
import {ElMessage} from 'element-plus'
|
||||
import {Document, Download} from '@element-plus/icons-vue'
|
||||
import * as XLSX from 'xlsx'
|
||||
import MyEchart from '@/components/echarts/line/index.vue'
|
||||
|
||||
@@ -125,23 +125,29 @@ const sortedChartPoints = computed(() => {
|
||||
|
||||
const sortedCharacteristicCurveData = computed(() => {
|
||||
return [...characteristicCurveData.value].sort((a, b) => {
|
||||
if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) {
|
||||
return a.timeMs - b.timeMs
|
||||
// 保留1位小数
|
||||
let aResidualVoltage = Math.floor(a.residualVoltage * 10) / 10
|
||||
let bResidualVoltage = Math.floor(b.residualVoltage * 10) / 10
|
||||
if (aResidualVoltage != bResidualVoltage) {
|
||||
return a.residualVoltage - b.residualVoltage;
|
||||
} else {
|
||||
let aDuration = a.duration * 1000 - a.duration * 1000 % 10
|
||||
let bDuration = b.duration * 1000 - b.duration * 1000 % 10
|
||||
if (aDuration != bDuration) {
|
||||
return a.duration - b.duration
|
||||
} else if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) {
|
||||
return a.timeMs - b.timeMs
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
if (a.timeMs !== null && b.timeMs === null) {
|
||||
return -1
|
||||
}
|
||||
|
||||
if (a.timeMs === null && b.timeMs !== null) {
|
||||
return 1
|
||||
}
|
||||
|
||||
if (a.duration !== b.duration) {
|
||||
return a.duration - b.duration
|
||||
}
|
||||
|
||||
return a.residualVoltage - b.residualVoltage
|
||||
// if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) {
|
||||
// return a.timeMs - b.timeMs
|
||||
// } else {
|
||||
// return 0
|
||||
// }
|
||||
//
|
||||
// return a.residualVoltage - b.residualVoltage
|
||||
})
|
||||
})
|
||||
|
||||
@@ -161,18 +167,18 @@ const characteristicCurvePointSeriesData = computed(() => {
|
||||
|
||||
const passPointSeriesData = computed(() => {
|
||||
return sortedChartPoints.value
|
||||
.filter(item => item.status === 'pass')
|
||||
.map(item => ({
|
||||
value: [item.duration, item.residualVoltage, getStatusText(item.status)]
|
||||
}))
|
||||
.filter(item => item.status === 'pass')
|
||||
.map(item => ({
|
||||
value: [item.duration, item.residualVoltage, getStatusText(item.status)]
|
||||
}))
|
||||
})
|
||||
|
||||
const failPointSeriesData = computed(() => {
|
||||
return sortedChartPoints.value
|
||||
.filter(item => item.status === 'fail')
|
||||
.map(item => ({
|
||||
value: [item.duration, item.residualVoltage, getStatusText(item.status)]
|
||||
}))
|
||||
.filter(item => item.status === 'fail')
|
||||
.map(item => ({
|
||||
value: [item.duration, item.residualVoltage, getStatusText(item.status)]
|
||||
}))
|
||||
})
|
||||
|
||||
const hasChartData = computed(() => {
|
||||
@@ -225,7 +231,7 @@ const parsePointTime = (value: unknown) => {
|
||||
|
||||
const normalizedValue = value.trim()
|
||||
const match = normalizedValue.match(
|
||||
/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})\.(\d{3})$/
|
||||
/^(\d{4})-(\d{2})-(\d{2})\s+(\d{2}):(\d{2}):(\d{2})\.(\d{3})$/
|
||||
)
|
||||
|
||||
if (!match) {
|
||||
@@ -237,23 +243,23 @@ const parsePointTime = (value: unknown) => {
|
||||
|
||||
const [, year, month, day, hour, minute, second, millisecond] = match
|
||||
const parsedDate = new Date(
|
||||
Number(year),
|
||||
Number(month) - 1,
|
||||
Number(day),
|
||||
Number(hour),
|
||||
Number(minute),
|
||||
Number(second),
|
||||
Number(millisecond)
|
||||
Number(year),
|
||||
Number(month) - 1,
|
||||
Number(day),
|
||||
Number(hour),
|
||||
Number(minute),
|
||||
Number(second),
|
||||
Number(millisecond)
|
||||
)
|
||||
|
||||
if (
|
||||
parsedDate.getFullYear() !== Number(year) ||
|
||||
parsedDate.getMonth() !== Number(month) - 1 ||
|
||||
parsedDate.getDate() !== Number(day) ||
|
||||
parsedDate.getHours() !== Number(hour) ||
|
||||
parsedDate.getMinutes() !== Number(minute) ||
|
||||
parsedDate.getSeconds() !== Number(second) ||
|
||||
parsedDate.getMilliseconds() !== Number(millisecond)
|
||||
parsedDate.getFullYear() !== Number(year) ||
|
||||
parsedDate.getMonth() !== Number(month) - 1 ||
|
||||
parsedDate.getDate() !== Number(day) ||
|
||||
parsedDate.getHours() !== Number(hour) ||
|
||||
parsedDate.getMinutes() !== Number(minute) ||
|
||||
parsedDate.getSeconds() !== Number(second) ||
|
||||
parsedDate.getMilliseconds() !== Number(millisecond)
|
||||
) {
|
||||
return {
|
||||
time: normalizedValue,
|
||||
@@ -282,9 +288,9 @@ const normalizeTolerantValue = (value: unknown) => {
|
||||
|
||||
const normalizeDuration = (source: Record<string, any>) => {
|
||||
return toNumber(
|
||||
source.durationMs !== undefined && source.durationMs !== null
|
||||
? Number(source.durationMs) / 1000
|
||||
: source.duration ?? source.x ?? source.dipDuration ?? source.retainTime ?? source.durationValue
|
||||
source.durationMs !== undefined && source.durationMs !== null
|
||||
? Number(source.durationMs) / 1000
|
||||
: source.duration ?? source.x ?? source.dipDuration ?? source.retainTime ?? source.durationValue
|
||||
)
|
||||
}
|
||||
|
||||
@@ -296,12 +302,12 @@ const normalizeStatus = (value: unknown): ChartPointStatus => {
|
||||
const rawValue = `${value ?? ''}`.trim().toLowerCase()
|
||||
|
||||
if (
|
||||
value === 0 ||
|
||||
rawValue === '0' ||
|
||||
rawValue === 'false' ||
|
||||
rawValue === 'fail' ||
|
||||
rawValue === 'failed' ||
|
||||
rawValue.includes('不耐受')
|
||||
value === 0 ||
|
||||
rawValue === '0' ||
|
||||
rawValue === 'false' ||
|
||||
rawValue === 'fail' ||
|
||||
rawValue === 'failed' ||
|
||||
rawValue.includes('不耐受')
|
||||
) {
|
||||
return 'fail'
|
||||
}
|
||||
@@ -312,7 +318,7 @@ const normalizeStatus = (value: unknown): ChartPointStatus => {
|
||||
const normalizeTolerantPoint = (source: Record<string, any>): NormalizedTolerantPoint | null => {
|
||||
const duration = normalizeDuration(source)
|
||||
const residualVoltage = normalizeResidualVoltageValue(source)
|
||||
const { time, timeMs } = parsePointTime(source.time)
|
||||
const {time, timeMs} = parsePointTime(source.time)
|
||||
|
||||
if (duration === null || residualVoltage === null) {
|
||||
return null
|
||||
@@ -323,7 +329,7 @@ const normalizeTolerantPoint = (source: Record<string, any>): NormalizedTolerant
|
||||
}
|
||||
|
||||
const tolerant = normalizeTolerantValue(
|
||||
source.tolerant ??
|
||||
source.tolerant ??
|
||||
source.endure ??
|
||||
source.isEndure ??
|
||||
source.tolerable ??
|
||||
@@ -341,21 +347,21 @@ const normalizeTolerantPoint = (source: Record<string, any>): NormalizedTolerant
|
||||
time,
|
||||
timeMs,
|
||||
status:
|
||||
tolerant === 0
|
||||
? 'fail'
|
||||
: tolerant === 1
|
||||
? 'pass'
|
||||
: normalizeStatus(
|
||||
source.tolerant ??
|
||||
source.endure ??
|
||||
source.isEndure ??
|
||||
source.tolerable ??
|
||||
source.isTolerable ??
|
||||
source.status ??
|
||||
source.pointStatus ??
|
||||
source.result ??
|
||||
source.state
|
||||
)
|
||||
tolerant === 0
|
||||
? 'fail'
|
||||
: tolerant === 1
|
||||
? 'pass'
|
||||
: normalizeStatus(
|
||||
source.tolerant ??
|
||||
source.endure ??
|
||||
source.isEndure ??
|
||||
source.tolerable ??
|
||||
source.isTolerable ??
|
||||
source.status ??
|
||||
source.pointStatus ??
|
||||
source.result ??
|
||||
source.state
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,10 +432,10 @@ const mergeCharacteristicCurvePoints = (points: CharacteristicCurvePoint[]) => {
|
||||
}
|
||||
|
||||
const existingPointMap = new Map(
|
||||
characteristicCurveData.value.map(item => [
|
||||
item.time ? `${item.time}|${item.duration}|${item.residualVoltage}` : `${item.duration}|${item.residualVoltage}`,
|
||||
item
|
||||
] as const)
|
||||
characteristicCurveData.value.map(item => [
|
||||
item.time ? `${item.time}|${item.duration}|${item.residualVoltage}` : `${item.duration}|${item.residualVoltage}`,
|
||||
item
|
||||
] as const)
|
||||
)
|
||||
|
||||
points.forEach(item => {
|
||||
@@ -529,29 +535,29 @@ const exportChartData = () => {
|
||||
|
||||
if (sortedChartPoints.value.length) {
|
||||
const pointSheet = XLSX.utils.json_to_sheet(
|
||||
sortedChartPoints.value.map((item, index) => ({
|
||||
序号: index + 1,
|
||||
持续时间_s: item.duration,
|
||||
残余电压_pct: item.residualVoltage,
|
||||
状态: getStatusText(item.status)
|
||||
}))
|
||||
sortedChartPoints.value.map((item, index) => ({
|
||||
序号: index + 1,
|
||||
持续时间_s: item.duration,
|
||||
残余电压_pct: item.residualVoltage,
|
||||
状态: getStatusText(item.status)
|
||||
}))
|
||||
)
|
||||
XLSX.utils.book_append_sheet(workbook, pointSheet, '耐受点')
|
||||
}
|
||||
|
||||
if (sortedCharacteristicCurveData.value.length) {
|
||||
const curveSheet = XLSX.utils.json_to_sheet(
|
||||
sortedCharacteristicCurveData.value.map((item, index) => ({
|
||||
序号: index + 1,
|
||||
持续时间_s: item.duration,
|
||||
残余电压_pct: item.residualVoltage,
|
||||
时间: item.time ?? ''
|
||||
}))
|
||||
sortedCharacteristicCurveData.value.map((item, index) => ({
|
||||
序号: index + 1,
|
||||
持续时间_s: item.duration,
|
||||
残余电压_pct: item.residualVoltage,
|
||||
时间: item.time ?? ''
|
||||
}))
|
||||
)
|
||||
XLSX.utils.book_append_sheet(workbook, curveSheet, '特性点')
|
||||
}
|
||||
|
||||
const workbookBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' })
|
||||
const workbookBuffer = XLSX.write(workbook, {bookType: 'xlsx', type: 'array'})
|
||||
const blob = new Blob([workbookBuffer], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
})
|
||||
@@ -714,44 +720,44 @@ watch(
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.webMsgSend,
|
||||
newValue => {
|
||||
if (!newValue) {
|
||||
return
|
||||
}
|
||||
() => props.webMsgSend,
|
||||
newValue => {
|
||||
if (!newValue) {
|
||||
return
|
||||
}
|
||||
|
||||
const nextPoints = extractPoints(newValue)
|
||||
if (nextPoints.length) {
|
||||
const existingPointMap = new Map(
|
||||
chartPoints.value.map(item => [`${item.duration}|${item.residualVoltage}`, item] as const)
|
||||
)
|
||||
const nextPoints = extractPoints(newValue)
|
||||
if (nextPoints.length) {
|
||||
const existingPointMap = new Map(
|
||||
chartPoints.value.map(item => [`${item.duration}|${item.residualVoltage}`, item] as const)
|
||||
)
|
||||
|
||||
nextPoints.forEach(item => {
|
||||
const key = `${item.duration}|${item.residualVoltage}`
|
||||
existingPointMap.set(key, item)
|
||||
})
|
||||
nextPoints.forEach(item => {
|
||||
const key = `${item.duration}|${item.residualVoltage}`
|
||||
existingPointMap.set(key, item)
|
||||
})
|
||||
|
||||
chartPoints.value = Array.from(existingPointMap.values())
|
||||
}
|
||||
chartPoints.value = Array.from(existingPointMap.values())
|
||||
}
|
||||
|
||||
mergeCharacteristicCurvePoints(extractCharacteristicCurvePoints(newValue))
|
||||
updateCharacteristicCurveVisibility()
|
||||
},
|
||||
{ deep: true }
|
||||
mergeCharacteristicCurvePoints(extractCharacteristicCurvePoints(newValue))
|
||||
updateCharacteristicCurveVisibility()
|
||||
},
|
||||
{deep: true}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.resultData,
|
||||
newValue => {
|
||||
if (!newValue) {
|
||||
return
|
||||
}
|
||||
() => props.resultData,
|
||||
newValue => {
|
||||
if (!newValue) {
|
||||
return
|
||||
}
|
||||
|
||||
chartPoints.value = extractPoints(newValue)
|
||||
characteristicCurveData.value = extractCharacteristicCurvePoints(newValue)
|
||||
updateCharacteristicCurveVisibility()
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
chartPoints.value = extractPoints(newValue)
|
||||
characteristicCurveData.value = extractCharacteristicCurvePoints(newValue)
|
||||
updateCharacteristicCurveVisibility()
|
||||
},
|
||||
{deep: true, immediate: true}
|
||||
)
|
||||
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user