Selaa lähdekoodia

模型1:移除连续曲线开关,PKS 点位默认可选(默认7号机组一缸);分图 PKS 测点 y 轴自适应

18922397810 2 viikkoa sitten
vanhempi
commit
6da2cbe35e
2 muutettua tiedostoa jossa 18 lisäystä ja 54 poistoa
  1. 8 16
      frontend/src/App.vue
  2. 10 38
      frontend/src/components/WaveChart.vue

+ 8 - 16
frontend/src/App.vue

@@ -11,6 +11,7 @@ import WaveChart from './components/WaveChart.vue'
 import { STOPPED_COLOR, statusGradientColor } from './statusColor'
 import { DEVICE_POINT_TO_TYPE, DEVICE_POINTS, PRIMARY_DEVICE_POINT, type Annotation, type AnnotationLabel, type Cycle, type DevicePoint, type Fault, type MeasurementType, type PeriodDetail, type QueryOption, type SitePoint, type TimePoint, type QueryOptionsResponse, type WaveWindowFile, type WaveWindowResponse } from './types'
 
+const DEFAULT_DEVICE_PART = '7号机组一缸'
 const queryMeta = ref<QueryOptionsResponse | null>(null)
 const selectedDevicePart = ref('')
 const selectedDevicePoints = ref<DevicePoint[]>([PRIMARY_DEVICE_POINT])
@@ -18,14 +19,13 @@ const fileListPoint = ref<DevicePoint | string>(PRIMARY_DEVICE_POINT)
 const minTime = ref('')
 const maxTime = ref('')
 const selectedTimeRangePoint = ref<DevicePoint | ''>('')
-const windowSize = ref(4)
+const windowSize = ref(50)
 const maxPoints = ref(200000)
 const noSampling = ref(false)
 const includeStopped = ref(false)
 const abnormalOnly = ref(false)
 const noCycleOnly = ref(false)
 const minStatus = ref<number | null>(null)
-const firstCycleOnly = ref(false)
 const sitePointOptions = ref<SitePoint[]>([])
 const selectedSitePoints = ref<string[]>([])
 const pksTimeBounds = ref<{ min: string | null; max: string | null } | null>(null)
@@ -66,7 +66,7 @@ const unitNumber = computed(() => {
   const match = /^([789])号机组/.exec(selectedDevicePart.value)
   return match ? match[1] : null
 })
-const isPksMode = computed(() => firstCycleOnly.value && !!unitNumber.value)
+const isPksMode = computed(() => !!unitNumber.value)
 const isPksOnly = computed(() => isPksMode.value && !selectedDevicePoints.value.length && selectedSitePoints.value.length > 0)
 const canQueryTimePoints = computed(() => Boolean(selectedDevicePart.value) && (selectedDevicePoints.value.length > 0 || (isPksMode.value && selectedSitePoints.value.length > 0)))
 const pointModel = computed({
@@ -278,7 +278,9 @@ async function loadOptions() {
   try {
     const result = await fetchQueryOptions()
     queryMeta.value = result
-    selectedDevicePart.value = result.deviceParts[0] ?? ''
+    selectedDevicePart.value = result.deviceParts.includes(DEFAULT_DEVICE_PART)
+      ? DEFAULT_DEVICE_PART
+      : result.deviceParts[0] ?? ''
     selectedTimeRangePoint.value = ''
     syncTimeBounds(true)
     initialized.value = true
@@ -390,7 +392,7 @@ async function loadWaveWindowNow() {
       points,
       maxPoints: maxPoints.value,
       noSampling: noSampling.value,
-      firstCycleOnly: firstCycleOnly.value,
+      firstCycleOnly: true,
       sitePoints: isPksMode.value ? selectedSitePoints.value : [],
     })
     if (requestId === waveRequestId) {
@@ -746,13 +748,7 @@ watch(noCycleOnly, () => {
 watch(minStatus, () => {
   if (initialized.value) scheduleTimePoints()
 })
-watch(firstCycleOnly, () => {
-  if (!initialized.value) return
-  windowSize.value = firstCycleOnly.value ? 50 : 4
-  markChartDirty()
-  void loadWaveWindowNow()
-})
-watch([firstCycleOnly, unitNumber], async () => {
+watch(unitNumber, async () => {
   if (!initialized.value) return
   if (isPksMode.value) {
     await loadSitePoints()
@@ -1047,10 +1043,6 @@ onBeforeUnmount(() => {
                   :title="isPksOnly ? '仅 PKS 点位组合下不可用' : (noCycleOnly ? '勾选无周期时忽略质心距离' : undefined)"
                 />
               </label>
-              <label class="field field-first-cycle">
-                <span class="field-label">首个周期</span>
-                <el-checkbox v-model="firstCycleOnly" class="query-checkbox" size="large" :disabled="queryLoading">连续曲线</el-checkbox>
-              </label>
             </div>
             <label class="field window-field">
               <span class="field-label">时间窗口 <em>{{ isPksOnly ? '时间点数量' : '文件数量' }}</em></span>

+ 10 - 38
frontend/src/components/WaveChart.vue

@@ -51,16 +51,15 @@ type RowMeta = { name: string; kind: RowKind; siteSeq: number }
 const SITE_AGG_NAME = '全场点位(归一化)'
 const SITE_AGG_PREFIX = '全场点位·'
 
-// PKS 全场点位按物理分类规范 y 轴:同分类所有子图用同一刻度步长(step),
-// 每个子图范围由各自数据自适应起点/终点;波动过小时用 minSpan 保证最小显示幅度。
-type SiteScaleRule = { unit: string; step: number; minSpan: number }
+// PKS 全场点位分图 y 轴按各自数据自适应,给小幅波动留出显示空间,仅保留分类单位标注。
+type SiteScaleRule = { unit: string }
 const SITE_SCALE_RULES: Record<string, SiteScaleRule> = {
-  温度: { unit: '℃', step: 5, minSpan: 10 },
-  压力: { unit: 'MPa', step: 1, minSpan: 2 },
-  振动: { unit: 'mm/s', step: 0.5, minSpan: 2 },
-  电流: { unit: 'A', step: 10, minSpan: 20 },
-  频率: { unit: 'Hz', step: 5, minSpan: 10 },
-  阀位: { unit: '%', step: 5, minSpan: 10 },
+  温度: { unit: '℃' },
+  压力: { unit: 'MPa' },
+  振动: { unit: 'mm/s' },
+  电流: { unit: 'A' },
+  频率: { unit: 'Hz' },
+  阀位: { unit: '%' },
 }
 
 function siteScaleRuleFor(description: string | undefined): SiteScaleRule | null {
@@ -75,26 +74,6 @@ function siteScaleRuleFor(description: string | undefined): SiteScaleRule | null
   return null
 }
 
-function siteAxisRange(rule: SiteScaleRule, values: number[]): { min: number; max: number; interval: number } | null {
-  const finite = values.filter(Number.isFinite)
-  if (!finite.length) return null
-  let min = Math.min(...finite)
-  let max = Math.max(...finite)
-  if (!(max > min)) {
-    min -= rule.minSpan / 2
-    max += rule.minSpan / 2
-  }
-  if (max - min < rule.minSpan) {
-    const center = (max + min) / 2
-    min = center - rule.minSpan / 2
-    max = center + rule.minSpan / 2
-  }
-  min = Math.floor(min / rule.step) * rule.step
-  max = Math.ceil(max / rule.step) * rule.step
-  if (!(max > min)) max = min + rule.step
-  return { min, max, interval: rule.step }
-}
-
 const SPLIT_ROW_HEIGHT = 120
 const SPLIT_ROW_GAP = 14
 const CHART_TOP_INSET = 32
@@ -390,18 +369,11 @@ function buildOption(zoomMode: 'initial' | 'keep' = 'initial') {
     const isDisplacement = isDevicePoint
       ? data.series.find((series) => series.devicePoint === rowName)?.measurementType === '位移'
       : false
-    let siteRule: SiteScaleRule | null = null
     let siteRange: { min: number; max: number; interval: number } | null = null
     let axisName = rowName
     if (meta?.kind === 'site') {
       const rule = siteScaleRuleFor(props.siteDescriptions?.[rowName])
-      if (rule) {
-        siteRule = rule
-        axisName = `${rowName} ${rule.unit}`
-        const siteValues = data.siteSeries?.series.find((series) => series.itemName === rowName)?.data
-          .map((item) => item.value[1]) ?? []
-        siteRange = siteAxisRange(rule, siteValues)
-      }
+      if (rule) axisName = `${rowName} ${rule.unit}`
     } else if (meta?.kind === 'siteAgg') {
       siteRange = { min: 0, max: 1, interval: 0.2 }
     }
@@ -419,7 +391,7 @@ function buildOption(zoomMode: 'initial' | 'keep' = 'initial') {
         formatter: meta?.kind === 'siteAgg' ? (value: number) => Number(value).toFixed(1) : undefined,
       },
       splitLine: { show: true, lineStyle: { color: '#e7edf0', width: 1 } },
-      scale: meta?.kind === 'site' ? !siteRule : isDisplacement,
+      scale: meta?.kind === 'site' ? true : isDisplacement,
       min: siteRange?.min ?? fixed?.min,
       max: siteRange?.max ?? fixed?.max,
       interval: siteRange?.interval ?? fixed?.interval,