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