Ver código fonte

rankingApp: A23 电气柜温度、图例用 legend_entries、表格固定表头/机组列、报告下载修复

- A23 电气柜温度变化渲染 + 柜温测点明细表;A22/A23 横向柱状图
- 图例统一使用 JSON legend_entries 的规范中文名(按 metric_key 匹配)
- 全页面表格表头不换行、横向滚动时固定机组列;说明列限宽
- 修复下载报告 projectId 被 mock 覆盖导致报告为空
- 移除页面上数据来源类提示文字,无数据统一显示「暂无数据」
- 台账/权限管理 tabs 改为按路由动态渲染
liujiejie 4 horas atrás
pai
commit
2971ae645a

+ 5 - 5
.env.gzly

@@ -11,7 +11,7 @@ VUE_APP_HOME_COM="../views/admin/cockpitManage/Index.vue"
 VUE_APP_THEM="tech-blue"
 VUE_APP_ISSHOWHD='default'
 VUE_APP_Helath='dev'
-VUE_APP_TITLE='机组健康评估与性能检测系统'
+VUE_APP_TITLE='机组性能检测系统'
 VUE_APP_PROJECT='dt'
 # 本地开发页面 IP/端口(改后需重启 npm run serve:dt)
 # 0.0.0.0:可用本机局域网 IP 访问;127.0.0.1:仅本机
@@ -37,13 +37,13 @@ VUE_APP_DEV_PORT=8080
 
 #内网
 
-VUE_APP_MAPVIEW=/tiles/{z}/{x}/{y}.png
+# VUE_APP_MAPVIEW=/tiles/{z}/{x}/{y}.png
 # 卫星底图:nginx 若 alias 到 map/tiles/s2/,保持此路径
-# VUE_APP_MAPVIEW=/tiles_map/{z}/{x}/{y}.jpg
+VUE_APP_MAPVIEW=/tiles_map/{z}/{x}/{y}.jpg
 # # 行政区划叠加:nginx 需单独 alias 到 map/tiles/admin/
-# VUE_APP_MAPVIEW_ADMIN=/tiles_map/admin/{z}/{x}/{y}.png
+VUE_APP_MAPVIEW_ADMIN=/tiles_map/admin/{z}/{x}/{y}.png
 # # 乡镇/街道/村注记:nginx 需单独 alias 到 map/tiles/places/
-# VUE_APP_MAPVIEW_PLACES=/tiles_map/places/{z}/{x}/{y}.png
+VUE_APP_MAPVIEW_PLACES=/tiles_map/places/{z}/{x}/{y}.png
 # 公司配置——————————————————————————————————————————————————————————————
 VUE_APP_MAP="http://192.168.50.235:8000"
 VUE_APP_APIPROXY='http://192.168.50.235:16200'

+ 1 - 1
public/runtime-config.js

@@ -5,7 +5,7 @@
 (function () {
   window.__RUNTIME_CONFIG__ = {
     /** 浏览器标签与登录页大标题(修改此处即可) */
-    title: "机组健康评估与性能检测系统",
+    title: "机组性能检测系统",
     // title:'风电机组智能健康状态评估系统', //健康评估
     // title:'风电机组性能检测系统', //异常检测
     // title: "风电机组隐患识别及健康状态评估系统", //吉林项目名称

+ 34 - 9
src/views/ledger/index.vue

@@ -22,15 +22,22 @@
 <script>
 export default {
   name: "LedgerIndex",
-  data() {
-    return {
-      tabs: [
-        { name: "风场信息", path: "/home/Ledger/enterprise" },
-        { name: "风电项目信息", path: "/home/Ledger/windsite" },
-        { name: "机型信息", path: "/home/Ledger/milltype" },
-        { name: "风机信息", path: "/home/Ledger/draught" },
-      ],
-    };
+  computed: {
+    // 子菜单动态取自后端权限树(userInfo.permission),与路由当前所属节点对齐
+    tabs() {
+      const permission =
+        (this.$store.state.auth &&
+          this.$store.state.auth.userInfo &&
+          this.$store.state.auth.userInfo.permission) ||
+        [];
+      const node = findPermissionNode(permission, this.shellRootPath());
+      if (!node || !Array.isArray(node.children)) return [];
+      return node.children
+        .filter((child) => child.permissionType === 2 && child.permissionShow === 1)
+        .slice()
+        .sort((a, b) => (a.permissionSort || 0) - (b.permissionSort || 0))
+        .map((child) => ({ name: child.permissionName, path: child.permissionCode }));
+    },
   },
   methods: {
     isActive(path) {
@@ -40,8 +47,26 @@ export default {
       if (this.$route.path === path) return;
       this.$router.push(path).catch(() => {});
     },
+    // /home/system/userMag -> /home/system;/home/Ledger/enterprise -> /home/Ledger
+    shellRootPath() {
+      const segments = (this.$route.path || "").split("/").filter(Boolean);
+      return segments.length >= 2
+        ? `/${segments.slice(0, 2).join("/")}`
+        : this.$route.path || "";
+    },
   },
 };
+
+function findPermissionNode(nodes, code) {
+  if (!Array.isArray(nodes)) return null;
+  for (const node of nodes) {
+    if (!node) continue;
+    if (node.permissionCode === code) return node;
+    const found = findPermissionNode(node.children, code);
+    if (found) return found;
+  }
+  return null;
+}
 </script>
 
 <style lang="scss">

+ 10 - 8
src/views/rankingApp/FarmDiagView.vue

@@ -79,7 +79,7 @@
                       :checked="isUnitChecked(u.id)"
                       @change="toggleUnit(u.id, $event.target.checked)"
                     />
-                    <span>{{ u.no }}号</span>
+                    <span>{{ u.engineName || u.no }}号</span>
                     <em>{{ modelName(u.modelId) }}</em>
                   </label>
                 </div>
@@ -115,6 +115,7 @@
       :year="periodYear"
       :number="periodNumber"
       :project-id="projectId"
+      :project-name="currentProject ? currentProject.name : ''"
       :farm-id="farmId"
       :model-id="filterModelId"
     />
@@ -222,7 +223,7 @@
           <table class="heat">
             <tr>
               <th></th>
-              <th v-for="u in scopedUnits" :key="u.id">{{ u.no }}号</th>
+              <th v-for="u in scopedUnits" :key="u.id">{{ u.engineName || u.no }}号</th>
             </tr>
             <tr v-for="row in sensorRows" :key="row.name">
               <th>{{ row.name }}</th>
@@ -247,7 +248,7 @@
           <table class="heat diag-heat">
             <tr>
               <th></th>
-              <th v-for="u in scopedUnits" :key="u.id">{{ u.no }}号</th>
+              <th v-for="u in scopedUnits" :key="u.id">{{ u.engineName || u.no }}号</th>
             </tr>
             <tr v-for="row in heatDiag" :key="row.mod + row.det">
               <th>{{ row.name }}</th>
@@ -280,7 +281,7 @@
           @click="enterUnit(u.id, true)"
         >
           <img class="turbine-icon" :src="turbineIcon" alt="" />
-          <span class="turbine-name">{{ u.no }}号</span>
+          <span class="turbine-name">{{ u.engineName || u.no }}号</span>
         </button>
       </div>
     </section>
@@ -367,7 +368,7 @@
                     v-for="u in sortedUnits"
                     :key="u.id"
                     :value="u.id"
-                    :label="u.no + '号 · ' + modelName(u.modelId)"
+                    :label="(u.engineName || u.no) + '号 · ' + modelName(u.modelId)"
                   />
                 </el-select>
               </label>
@@ -379,7 +380,7 @@
               <b>{{ farmName(currentUnit.farmId) }}</b>
               <span>{{ projectName(currentUnit.projectId) }}</span>
               <span>{{ modelName(currentUnit.modelId) }}</span>
-              <span>风机 {{ currentUnit.no }}</span>
+              <span>风机 {{ currentUnit.engineName || currentUnit.no }}</span>
             </div>
             <V6FarmCharts
               mode="detail"
@@ -555,7 +556,7 @@ export default {
       if (!this.filterUnitIds.length) return "未选机组";
       const names = this.diagFilterPool
         .filter((u) => this.filterUnitIds.includes(u.id))
-        .map((u) => `${u.no}号`);
+        .map((u) => `${u.engineName || u.no}号`);
       if (!names.length) return "未选机组";
       return names.length <= 2
         ? names.join("、")
@@ -612,7 +613,7 @@ export default {
           return {
             unitId: u.id,
             mark: heatMark(status, true),
-            title: `${u.no} · ${name} · ${status || "无数据"}`,
+            title: `${u.engineName || u.no} · ${name} · ${status || "无数据"}`,
           };
         }),
       }));
@@ -638,6 +639,7 @@ export default {
       return this.scopedUnits.map((unit) => ({
         id: unit.id,
         no: unit.no,
+        engineName: unit.engineName,
         modelId: unit.modelId,
         modelName: this.modelName(unit.modelId) || unit.modelId,
         status: detectorStatus(unit, this.detector),

+ 26 - 11
src/views/rankingApp/UnitDetailView.vue

@@ -10,7 +10,7 @@
           <b>{{ farmName(currentUnit.farmId) }}</b>
           <span>{{ projectName(currentUnit.projectId) }}</span>
           <span>{{ modelName(currentUnit.modelId) }}</span>
-          <span>风机 {{ currentUnit.no }}</span>
+          <span>风机 {{ currentUnit.engineName || currentUnit.no }}</span>
         </div>
         <div class="spacer"></div>
         <div class="date-field">
@@ -59,13 +59,13 @@
             <el-option
               v-if="currentUnit && !matchedUnits.some((u) => u.id === unitId)"
               :value="unitId"
-              :label="currentUnit.no + '号(当前)'"
+              :label="(currentUnit.engineName || currentUnit.no) + '号(当前)'"
             />
             <el-option
               v-for="u in matchedUnits"
               :key="u.id"
               :value="u.id"
-              :label="u.no + '号'"
+              :label="(u.engineName || u.no) + '号'"
             />
           </el-select>
         </label>
@@ -134,18 +134,20 @@
             {{ detectorAlg || "—" }}
           </span>
         </div>
-        <DiagChartPanel
+        <V6FarmCharts
           mode="detail"
           :alg="detectorAlg"
-          :detector-name="currentDetector ? currentDetector[1] : ''"
-          :unit-label="currentUnit ? currentUnit.no + '号机' : ''"
-          :status="currentStatus"
+          :unit-id="currentUnit ? currentUnit.id : ''"
           :year="periodYear"
           :month="periodNumber"
-          :conclusion="chartConclusion"
+          :detail-temp="detectorAlg === 'A22' ? detailTemp : ''"
           :field-code="currentUnit ? currentUnit.projectId : ''"
           :machine-type-code="currentUnit ? currentUnit.modelId : ''"
-          :engine-code="currentUnit ? currentUnit.no : ''"
+          :engine-code="currentUnit ? currentUnit.id : ''"
+          :unit-summaries="unitSummaries"
+          :month-key="periodValue"
+          @open-unit="onOpenUnit"
+          @set-temp="detailTemp = $event"
         />
       </div>
     </section>
@@ -168,7 +170,7 @@ import {
 } from "./constants";
 import { isBadStatus } from "./utils/rankHelpers";
 import { fetchUnitDetailChart, fetchCockpitBoard } from "@/api/rankingApp";
-import DiagChartPanel from "./components/DiagChartPanel.vue";
+import V6FarmCharts from "./components/V6FarmCharts.vue";
 import turbineIcon from "@/assets/ranking/iconFJ2-fit.png";
 
 function firstDetector(module) {
@@ -178,7 +180,7 @@ function firstDetector(module) {
 
 export default {
   name: "RankingUnitDetailView",
-  components: { DiagChartPanel },
+  components: { V6FarmCharts },
   data() {
     return {
       turbineIcon,
@@ -199,6 +201,7 @@ export default {
       paintSeq: 0,
       monthStatusMap: {},
       chartConclusion: null,
+      detailTemp: "",
     };
   },
   computed: {
@@ -314,6 +317,15 @@ export default {
       if (monthSt && monthSt[alg]) return monthSt[alg];
       return (u.st && u.st[alg]) || "";
     },
+    unitSummaries() {
+      return (this.units || []).map((unit) => ({
+        id: unit.id,
+        no: unit.no,
+        engineName: unit.engineName,
+        modelId: unit.modelId,
+        modelName: this.modelName(unit.modelId) || unit.modelId,
+      }));
+    },
   },
   watch: {
     "$route.query": {
@@ -436,6 +448,9 @@ export default {
       q.number = this.periodNumber;
       this.$router.replace({ path: this.$route.path, query: q }).catch(() => {});
     },
+    onOpenUnit({ id }) {
+      if (id) this.onUnitPick(id);
+    },
     goBack() {
       const q = this.$route.query || {};
       if (this.backTo === "farm") {

+ 112 - 111
src/views/rankingApp/components/DiagChartPanel.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="diag-chart-panel">
     <section v-if="showConclusion" class="diag-conclusion">
-      <h3>{{ conclusionTitle }}</h3>
+      <h3>{{ mode === "overview" ? "项目结论" : "本机结论" }}</h3>
       <div class="diag-conclusion__row">
         <div class="diag-conclusion__cell">
           <label>检测结果</label>
@@ -15,52 +15,64 @@
           <label>周期</label>
           <b>{{ periodText }}</b>
         </div>
-        <div v-if="metricLabel" class="diag-conclusion__cell">
-          <label>{{ metricLabel }}</label>
-          <b>{{ metricText }}</b>
+        <div v-for="(m, i) in metricCells" :key="'m' + i" class="diag-conclusion__cell">
+          <label>{{ m.label || "指标" }}</label>
+          <b>{{ m.value }}</b>
+        </div>
+        <div v-for="(t, i) in thresholdCells" :key="'t' + i" class="diag-conclusion__cell">
+          <label>{{ t.label || "判断线" }}</label>
+          <b>{{ t.value }}</b>
         </div>
       </div>
       <p class="diag-conclusion__reason">{{ reasonText }}</p>
     </section>
 
-    <section
-      v-for="view in blockViews"
-      :key="view.block.key"
-      class="diag-chart-block"
-    >
+    <section v-for="view in chartViews" :key="view.chart.id" class="diag-chart-block">
       <div class="diag-chart-block__head">
-        <h3>{{ view.block.title }}</h3>
-        <span v-if="view.block.kind" class="rk-muted">{{
-          kindLabel(view.block.kind)
-        }}</span>
+        <h3>{{ view.chart.title }}</h3>
+        <span v-if="view.chart.plotted_turbine_count" class="rk-muted">
+          {{ view.chart.plotted_turbine_count }} 台
+        </span>
       </div>
       <div class="chart-stage">
-        <EChart
-          v-if="view.desc.type === 'chart'"
-          :option="view.desc.option"
-        />
-        <table v-else-if="view.desc.type === 'table'" class="rk-table">
+        <EChart v-if="view.desc.type === 'chart'" :option="view.desc.option" />
+        <div v-else class="chart-empty">
+          <div class="chart-empty-mark" aria-hidden="true">
+            <i class="el-icon-data-analysis"></i>
+          </div>
+          <p>暂无图表数据</p>
+        </div>
+      </div>
+      <p v-if="view.desc.notes && view.desc.notes.length" class="diag-chart-block--note rk-muted">
+        {{ view.desc.notes[0] }}
+      </p>
+    </section>
+
+    <section v-if="emptyReasons.length" class="diag-chart-block diag-chart-block--note">
+      <p v-for="(r, i) in emptyReasons" :key="i" class="rk-muted">{{ r }}</p>
+    </section>
+
+    <section v-for="(t, ti) in tableViews" :key="'tab' + ti" class="diag-chart-block">
+      <div class="diag-chart-block__head">
+        <h3>逐机判据与结果</h3>
+      </div>
+      <div class="chart-stage chart-stage--table">
+        <table class="rk-table">
           <thead>
             <tr>
-              <th v-for="c in view.desc.columns" :key="c.key">{{ c.label }}</th>
+              <th v-for="c in t.columns" :key="c.key">{{ c.label }}</th>
             </tr>
           </thead>
           <tbody>
-            <tr v-for="(r, ri) in view.desc.rows" :key="ri">
-              <td v-for="c in view.desc.columns" :key="c.key">{{ r[c.key] }}</td>
+            <tr v-for="(r, ri) in t.rows" :key="ri">
+              <td v-for="c in t.columns" :key="c.key">{{ fmtCell(r[c.key]) }}</td>
             </tr>
           </tbody>
         </table>
-        <div v-else class="chart-empty">
-          <div class="chart-empty-mark" aria-hidden="true">
-            <i class="el-icon-data-analysis"></i>
-          </div>
-          <p>暂无图表数据</p>
-        </div>
       </div>
     </section>
 
-    <section v-if="!blocks.length" class="chart-stage">
+    <section v-if="!chartViews.length && !showConclusion" class="chart-stage">
       <div class="chart-empty">
         <div class="chart-empty-mark" aria-hidden="true">
           <i class="el-icon-data-analysis"></i>
@@ -73,31 +85,16 @@
 </template>
 
 <script>
-import { getAlgChartSpec, getChartBlocks } from "../utils/diagChartSpec";
 import { isBadStatus } from "../utils/rankHelpers";
-import { buildChartDesc } from "../utils/chartOption";
-import { getMockChartBundle } from "../mock/chartData";
+import { renderContractChart } from "../utils/contractChart";
+import { splitScopeTitle } from "../utils/sourceFunctionView";
 import {
   fetchDiagnosisProjectFunction,
   fetchDiagnosisTurbineFunction,
 } from "@/api/rankingApp";
-import { adaptTurbine, adaptProject, periodMonth } from "../utils/diagnosisAdapter";
+import { periodMonth } from "../utils/diagnosisAdapter";
 import EChart from "./EChart.vue";
 
-const KIND_LABEL = {
-  freq: "折线图",
-  rose: "玫瑰图",
-  bar: "柱状图",
-  line: "时序图",
-  curve: "曲线",
-  scatter: "散点图",
-  box: "箱线图",
-  heat: "热力图",
-  table: "表格",
-  multi: "多通道",
-  empty: "占位",
-};
-
 export default {
   name: "DiagChartPanel",
   components: { EChart },
@@ -109,7 +106,6 @@ export default {
     status: { type: String, default: "" },
     year: { type: [Number, String], default: "" },
     month: { type: [Number, String], default: "" },
-    conclusion: { type: Object, default: null },
     fieldCode: { type: String, default: "" },
     machineTypeCode: { type: String, default: "" },
     engineCode: { type: String, default: "" },
@@ -118,79 +114,85 @@ export default {
     return { realBundle: null, paintSeq: 0 };
   },
   computed: {
-    spec() {
-      return getAlgChartSpec(this.alg);
-    },
-    blocks() {
-      if (!this.alg) return [];
-      return getChartBlocks(this.alg, this.mode);
-    },
-    mockBundle() {
-      const year = Number(this.year) || 2026;
-      const month = Number(this.month) || 8;
-      return getMockChartBundle(this.alg, year, month);
-    },
     bundle() {
-      return this.realBundle || this.mockBundle;
+      return this.realBundle || {};
     },
-    blockViews() {
-      const emptyReal = this.realBundle && !this.realBundle.found;
-      return this.blocks.map((block) => ({
-        block,
-        desc: emptyReal
-          ? { type: "empty" }
-          : buildChartDesc(
-              block.kind,
-              block,
-              this.bundle.viz,
-              this.bundle.algData,
-              this.bundle.metrics,
-            ),
-      }));
+    graph() {
+      return this.bundle.graph || {};
     },
     showConclusion() {
-      return !!(this.alg && this.spec.conclusion);
-    },
-    conclusionTitle() {
-      return this.mode === "overview" ? "项目结论" : "本机结论";
+      return !!this.conclusionText;
     },
-    conclusionSource() {
-      if (this.conclusion) return this.conclusion;
-      const b = this.bundle;
-      if (!b) return null;
-      const algData = b.algData || {};
-      const conclusion = b.conclusion || {};
-      if (conclusion.text) {
-        return Object.assign({}, algData, {
-          reason: algData.reason || conclusion.text,
-        });
-      }
-      return algData;
+    conclusionText() {
+      const c = this.bundle.conclusion;
+      return (c && c.text) || "";
     },
     statusText() {
-      const c = this.conclusionSource;
-      return (c && (c.status || c.result)) || this.status || "—";
+      const r = this.bundle.result || {};
+      const s = this.bundle.status || {};
+      return r.status || s.source_status || this.status || "—";
     },
     isBad() {
       return isBadStatus(this.statusText);
     },
-    metricLabel() {
-      const d = this.conclusionSource && this.conclusionSource.display;
-      return (d && d.metric_label) || "";
+    display() {
+      return (this.bundle.result && this.bundle.result.display) || {};
     },
-    metricText() {
-      const c = this.conclusionSource;
-      if (c && c.display && c.display.metric != null) return c.display.metric;
-      if (c && c.value != null) return String(c.value) + (c.unit || "");
-      return "—";
+    metricCells() {
+      const d = this.display;
+      if (Array.isArray(d.metrics) && d.metrics.length) {
+        return d.metrics.map((m) => ({
+          label: m.label,
+          value: m.formatted != null ? m.formatted : m.value != null ? String(m.value) + (m.unit || "") : "—",
+        }));
+      }
+      if (d.metric_label || d.metric != null) return [{ label: d.metric_label, value: d.metric }];
+      return [];
     },
-    reasonText() {
-      const c = this.conclusionSource;
-      if (c && c.reason) return c.reason;
-      if (this.realBundle && !this.realBundle.found) {
-        return "该功能当前无可用结果数据。";
+    thresholdCells() {
+      const d = this.display;
+      if (Array.isArray(d.thresholds) && d.thresholds.length) {
+        return d.thresholds.map((t) => ({
+          label: t.label,
+          value: t.formatted != null ? t.formatted : t.value != null ? String(t.value) + (t.unit || "") : "—",
+        }));
       }
-      return "接口联调前暂无结论说明;切换模块 / 检测项 / 年月后将请求对应图表数据。";
+      if (d.threshold_label || d.threshold != null) return [{ label: d.threshold_label, value: d.threshold }];
+      return [];
+    },
+    reasonText() {
+      const r = this.bundle.result || {};
+      return this.conclusionText || r.reason || "";
+    },
+    chartViews() {
+      const charts = this.graph.charts || [];
+      const datasets = this.graph.datasets || {};
+      return charts
+        .filter((c) => c.renderable && c.observation_count > 0)
+        .map((c) => {
+          const chart = Object.assign({}, c, { title: splitScopeTitle(c.title, c.scope) });
+          return { chart, desc: renderContractChart(chart, datasets) };
+        });
+    },
+    emptyReasons() {
+      const charts = this.graph.charts || [];
+      const hidden = this.graph.hidden_charts || [];
+      const reasons = [];
+      charts
+        .filter((c) => !(c.renderable && c.observation_count > 0))
+        .forEach((c) => {
+          if (c.empty_reason && !reasons.includes(c.empty_reason)) reasons.push(c.empty_reason);
+        });
+      hidden.forEach((h) => {
+        if (h && h.empty_reason && !reasons.includes(h.empty_reason)) reasons.push(h.empty_reason);
+      });
+      return reasons;
+    },
+    tableViews() {
+      return (this.bundle.tables || []).map((t) => ({
+        columns: (t.columns || []).map((c) => ({ key: c.key, label: c.label })),
+        rows: t.rows || [],
+      }));
     },
     periodText() {
       if (!this.year) return "—";
@@ -211,8 +213,9 @@ export default {
     this.load();
   },
   methods: {
-    kindLabel(kind) {
-      return KIND_LABEL[kind] || kind || "";
+    fmtCell(v) {
+      if (v == null) return "—";
+      return v;
     },
     async load() {
       const seq = ++this.paintSeq;
@@ -243,9 +246,7 @@ export default {
                 Object.assign({}, params, { engineCode: this.engineCode }),
               );
         if (seq !== this.paintSeq) return;
-        const data = (res && res.data) || {};
-        this.realBundle =
-          this.mode === "overview" ? adaptProject(data) : adaptTurbine(data);
+        this.realBundle = (res && res.data) || null;
       } catch (_e) {
         if (seq !== this.paintSeq) return;
         this.realBundle = null;

+ 2 - 0
src/views/rankingApp/components/ReportExportDialog.vue

@@ -162,6 +162,7 @@ export default {
     year: { type: Number, default: 2026 },
     number: { type: Number, default: 8 },
     projectId: { type: String, default: "" },
+    projectName: { type: String, default: "" },
     farmId: { type: String, default: "" },
     modelId: { type: String, default: "" },
     unitId: { type: String, default: "" },
@@ -306,6 +307,7 @@ export default {
         year: this.form.year,
         number: this.form.number,
         projectId: this.projectId,
+        projectName: this.projectName,
         farmId: this.farmId,
         modelId,
         unitId: this.unitId,

+ 215 - 52
src/views/rankingApp/components/V6FarmCharts.vue

@@ -20,10 +20,10 @@
                 </tr>
               </thead>
               <tbody>
-                <tr v-for="row in findingRows" :key="row.engine_code || row.engine_name">
+                <tr v-for="(row, idx) in findingRows" :key="(row.engine_code || row.engine_name || '') + '#' + (row.channel_code || row.channel_name || '') + '#' + idx">
                   <td>
                     <button type="button" class="unit-link" @click="openUnit(row)">
-                      {{ unitLabel(row.engine_code) }}
+                      {{ row.engine_name || unitLabel(row.engine_code) }}
                     </button>
                     <div class="finding-aspect">{{ row.aspect }}</div>
                     <small>{{ row.modelName }}</small>
@@ -106,7 +106,7 @@
                 </tbody>
               </table>
             </div>
-            <p class="source-note">每个测点按评分从低到高取前五名。Top1 是分数最低的风机,格子里是风机和算法返回的评分。</p>
+            <p class="source-note">每个测点按评分从低到高取前五名</p>
           </div>
           <div v-if="block.matrix" class="source-table-wrap">
             <table class="matrix-table">
@@ -132,10 +132,9 @@
               </tbody>
             </table>
           </div>
-          <p v-if="block.matrix" class="source-note">点击单元格进入该机组。矩阵由各风机结论 TXT 的温度测点汇总。</p>
           <div v-for="view in block.charts" :key="view.id" class="model-chart">
             <h4>{{ view.title }}</h4>
-            <div v-if="view.option" class="source-plot" :class="{ 'source-plot--rose': view.roseAside }">
+            <div v-if="view.option" class="source-plot" :class="{ 'source-plot--rose': view.roseAside }" :style="view.height ? { height: view.height + 'px' } : {}">
               <div class="source-plot__chart">
                 <EChart :option="view.option" />
               </div>
@@ -152,8 +151,7 @@
                 </p>
               </aside>
             </div>
-            <p v-else class="source-muted">{{ view.reason || "图 JSON 里没有可绘制的序列" }}</p>
-            <p v-if="view.note" class="source-note">{{ view.note }}</p>
+            <p v-else class="source-muted">{{ view.reason || "暂无数据" }}</p>
           </div>
           <p v-if="fileState !== 'loading' && !block.matrix && !block.charts.length" class="source-muted">{{ block.chartEmpty }}</p>
         </section>
@@ -191,6 +189,53 @@
             </div>
           </div>
         </section>
+        <section v-if="alg === 'A23' && cabTempChannels.length" class="source-card temp-picker">
+          <div class="temp-picker__head">
+            <h3>各测点柜温分析</h3>
+            <label>
+              柜温测点
+              <el-select :value="activeCabTemp" size="small" filterable @change="pickTemp">
+                <el-option
+                  v-for="item in cabTempChannels"
+                  :key="item.code"
+                  :value="item.code"
+                  :label="tempOptionLabel(item)"
+                />
+              </el-select>
+            </label>
+          </div>
+          <div class="source-table-wrap">
+            <table class="cab-temp-table">
+              <thead>
+                <tr>
+                  <th>柜体 / 测点</th>
+                  <th>检测结果</th>
+                  <th>本月与同型差多少(℃)</th>
+                  <th>偏离判断线(℃)</th>
+                  <th>可比天数</th>
+                  <th>说明</th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr v-for="row in cabTempRows" :key="row.code">
+                  <td class="cab-temp-table__point">
+                    <b>{{ row.cabinet }}</b>
+                    <span class="cab-temp-table__sub">{{ row.name }}</span>
+                  </td>
+                  <td>
+                    <span class="result-tag" :class="resultTagClass(matrixStatus({ status: row.status }))">
+                      {{ matrixStatus({ status: row.status }) || "—" }}
+                    </span>
+                  </td>
+                  <td>{{ formatTemp(row.deviation) }}</td>
+                  <td>{{ formatTemp(row.threshold) }}</td>
+                  <td>{{ row.comparableDays == null ? "—" : row.comparableDays }}</td>
+                  <td class="cab-temp-table__explain">{{ row.explanation || "—" }}</td>
+                </tr>
+              </tbody>
+            </table>
+          </div>
+        </section>
         <div
           v-for="group in detailChartGroups"
           :key="group.key"
@@ -198,7 +243,7 @@
         >
           <section v-for="view in group.views" :key="view.id" class="source-card">
             <h3>{{ view.title }}</h3>
-            <div v-if="view.option" class="source-plot" :class="{ 'source-plot--rose': view.roseAside }">
+            <div v-if="view.option" class="source-plot" :class="{ 'source-plot--rose': view.roseAside }" :style="view.height ? { height: view.height + 'px' } : {}">
               <div class="source-plot__chart">
                 <EChart :option="view.option" />
               </div>
@@ -215,8 +260,7 @@
                 </p>
               </aside>
             </div>
-            <p v-else class="source-muted">{{ view.reason || "图 JSON 里没有可绘制的序列" }}</p>
-            <p v-if="view.note" class="source-note">{{ view.note }}</p>
+            <p v-else class="source-muted">{{ view.reason || "暂无数据" }}</p>
           </section>
         </div>
         <section v-if="fileState !== 'loading' && !chartViews.length" class="source-card">
@@ -252,7 +296,7 @@
               </tr>
             </thead>
             <tbody>
-              <tr v-for="row in filteredRows" :key="row.engine_code">
+              <tr v-for="(row, idx) in filteredRows" :key="(row.engine_code || '') + '#' + idx">
                 <td v-for="col in tableColumns" :key="col.key">
                   <button
                     v-if="col.key === 'engine_code'"
@@ -298,7 +342,7 @@ import {
   fetchDiagnosisProjectFunction,
   fetchDiagnosisTurbineFunction,
 } from "@/api/rankingApp";
-import { channelSnapshot, chartViewsOf, conclusionCardOf, conclusionTextOf, filterDatasetsByChannel, findingPresentation, matrixOf, tableModelOf, temperatureChannelsOf, unitResultsOf } from "../utils/sourceFunctionView";
+import { a23ChannelSnapshot, a23ChannelsOf, a23MatrixOf, channelSnapshot, chartViewsOf, conclusionCardOf, conclusionTextOf, filterChartsByChannel, filterDatasetsByChannel, findingFromClue, findingPresentation, matrixOf, reviewCluesOf, tableModelOf, temperatureChannelsOf, unitResultsOf } from "../utils/sourceFunctionView";
 import { isBadStatus } from "../utils/rankHelpers";
 import EChart from "./EChart.vue";
 
@@ -345,7 +389,7 @@ async function readRemoteFile(url, asJson) {
 
 async function hydrateDiagnosisFiles(data) {
   if (!data || typeof data !== "object") return data;
-  if (data.graphUrl) {
+  if (data.graphUrl && !data.graphJson) {
     try {
       const graph = await readRemoteFile(data.graphUrl, true);
       if (graph && typeof graph === "object") {
@@ -360,7 +404,7 @@ async function hydrateDiagnosisFiles(data) {
       }
     }
   }
-  if (data.txtUrl) {
+  if (data.txtUrl && !data.conclusionTxt && !data.conclusion) {
     try {
       const raw = await readRemoteFile(data.txtUrl, false);
       if (typeof raw === "string" && raw.trim()) {
@@ -450,16 +494,32 @@ export default {
     findingRows() {
       const rows = [];
       (this.fileGroups || []).forEach((group) => {
+        const clues = reviewCluesOf(group.data);
+        if (clues.length) {
+          clues.forEach((clue) => {
+            const engineName = clue.engine_name || clue.engineName || "";
+            const engineCode = clue.engine_code || clue.engineCode || engineName;
+            const summary = this.summaryOf(engineCode) || this.summaryOf(engineName);
+            rows.push(Object.assign({}, clue, findingFromClue(clue), {
+              engine_code: engineCode,
+              engine_name: engineName,
+              modelName: (summary && (summary.modelName || summary.modelId)) || group.name || "",
+            }));
+          });
+          return;
+        }
         const units = {};
         ((group.data && group.data.metrics) || []).forEach((item) => {
           if (item && item.engineCode) units[item.engineCode] = item.unit || "";
         });
         unitResultsOf(group.data).forEach((row) => {
           if (!isBadStatus(row.status)) return;
-          const summary = this.summaryOf(row.engine_code);
+          const engineCode = row.engine_code || row.engine_name || "";
+          const summary = this.summaryOf(engineCode);
           rows.push(Object.assign({}, row, findingPresentation(Object.assign({}, row, {
-            unit: units[row.engine_code] || "",
+            unit: units[engineCode] || "",
           }), this.alg), {
+            engine_code: engineCode,
             modelName: (summary && (summary.modelName || summary.modelId)) || group.name || "",
           }));
         });
@@ -488,11 +548,51 @@ export default {
     activeTempThreshold() {
       return this.formatTemp(this.activeChannel.threshold);
     },
+    cabTempChannels() {
+      if (this.alg !== "A23" || this.mode !== "detail") return [];
+      return a23ChannelsOf(this.filePayload);
+    },
+    activeCabTemp() {
+      const codes = this.cabTempChannels.map((item) => item.code);
+      if (this.detailTemp && codes.includes(this.detailTemp)) return this.detailTemp;
+      if (this.pickedTemp && codes.includes(this.pickedTemp)) return this.pickedTemp;
+      return codes[0] || "";
+    },
+    activeCabChannel() {
+      return a23ChannelSnapshot(this.filePayload, this.activeCabTemp);
+    },
+    activeCabStatus() {
+      return this.matrixStatus({ status: this.activeCabChannel.status });
+    },
+    activeCabMean() {
+      return this.formatTemp(this.activeCabChannel.mean);
+    },
+    activeCabThreshold() {
+      return this.formatTemp(this.activeCabChannel.threshold);
+    },
+    cabTempRows() {
+      return this.cabTempChannels.map((item) => {
+        const ev = item.evidence || {};
+        return {
+          code: item.code,
+          cabinet: item.cabinet || "",
+          name: item.name || item.code,
+          status: item.status,
+          deviation: ev.mean,
+          threshold: ev.change_threshold,
+          comparableDays: ev.month_days != null ? ev.month_days : null,
+          explanation: item.explanation || "",
+        };
+      });
+    },
     chartViews() {
       if (this.fileState === "loading") return [];
-      const source = this.alg === "A22" && this.mode === "detail"
-        ? filterDatasetsByChannel(this.filePayload, this.activeTemp)
-        : this.powerDetailPayload();
+      let source = this.powerDetailPayload();
+      if (this.alg === "A22" && this.mode === "detail") {
+        source = filterDatasetsByChannel(this.filePayload, this.activeTemp);
+      } else if (this.alg === "A23" && this.mode === "detail") {
+        source = filterChartsByChannel(this.filePayload, this.activeCabTemp);
+      }
       return chartViewsOf(source).map((view) => this.labelSeries(this.withUnitTitle(view)));
     },
     detailChartGroups() {
@@ -547,18 +647,20 @@ export default {
       const allow = this.allowedEngines;
       return (this.fileGroups || []).map((group) => {
         const data = group.data || {};
-        const matrix = this.alg === "A22" ? this.filterMatrix(matrixOf(data, group.name), allow) : null;
+        let matrix = null;
+        if (this.alg === "A22") matrix = this.filterMatrix(matrixOf(data, group.name), allow);
+        else if (this.alg === "A23") matrix = a23MatrixOf(data, group.name);
         return {
           id: group.id,
           name: group.name || group.id,
           conclusion: conclusionTextOf(data),
-          conclusionEmpty: group.error || data.txtError || "该机型结论 TXT 里没有可显示的正文。",
+          conclusionEmpty: group.error || data.txtError || "暂无数据",
           charts: this.alg === "A22" ? [] : chartViewsOf(data).map((view) => this.labelSeries(view)),
-          ranking: matrix ? this.matrixRanking(matrix) : null,
+          ranking: this.alg === "A22" && matrix ? this.matrixRanking(matrix) : null,
           matrix,
           chartEmpty: this.alg === "A22"
-            ? "各风机结论 TXT 里没有温度测点残差,无法聚合成矩阵。"
-            : (group.error || data.graphError || "该机型没有可绘制的总图。"),
+            ? "暂无数据"
+            : (group.error || data.graphError || "暂无数据"),
         };
       });
     },
@@ -606,35 +708,15 @@ export default {
       });
     },
     conclusionEmpty() {
-      if (this.fileState === "error") return this.fileError || "结论 TXT 读取失败";
-      const data = this.filePayload || {};
-      if (data.txtError) return data.txtError;
-      if (!data.txtPath) {
-        return "算法表里没有本项目、本机型、本月、本检测项的结论 TXT 路径。";
-      }
-      return "已定位结论 TXT,但文件里没有可显示的结论文本。";
+      if (this.fileState === "error") return this.fileError || "读取失败";
+      return "暂无数据";
     },
     chartEmpty() {
-      if (this.fileState === "error") return this.fileError || "图 JSON 读取失败";
-      const data = this.filePayload || {};
-      if (data.graphError) return data.graphError;
-      if (!data.graphPath) {
-        return "算法表里没有本项目、本机型、本月、本检测项的总图 JSON 路径。";
-      }
-      const status = data.graphStatus || (data.graphJson && data.graphJson.graph_status);
-      if (/not_applicable/i.test(String(status || ""))) {
-        return "本功能按配置不设分图。上方保留本机数值与文字结论,项目总览供同机型对比图。";
-      }
-      if (status && status !== "ok" && status !== "ready") return `图状态:${status}`;
-      const datasets = (data.graphJson && data.graphJson.datasets) || (data.graph && data.graph.datasets);
-      const keys = datasets && typeof datasets === "object" ? Object.keys(datasets) : [];
-      if (keys.length) {
-        return `已读到图 JSON,数据集为 ${keys.join("、")},但没有识别出可绘制的坐标列。`;
-      }
-      return "已定位图 JSON,但其中没有可绘制的数据集。";
+      if (this.fileState === "error") return this.fileError || "读取失败";
+      return "暂无数据";
     },
     tableEmpty() {
-      return "同项目各机判据存在每台风机的结论 TXT 里。当前没有汇总到机组、检测结果、实际情况这些列。";
+      return "暂无数据";
     },
   },
   watch: {
@@ -967,8 +1049,11 @@ export default {
       return Object.assign({}, matrix, { rows: rows.length ? rows : matrix.rows });
     },
     unitLabel(engineCode) {
-      const hit = (this.unitSummaries || []).find((unit) => unit.id === engineCode || unit.no === engineCode);
-      return hit && hit.no ? hit.no : engineCode;
+      const key = String(engineCode == null ? "" : engineCode);
+      const hit = (this.unitSummaries || []).find((unit) =>
+        unit.id === key || unit.no === key || unit.engineName === key,
+      );
+      return hit ? (hit.engineName || hit.no || hit.id || key) : key;
     },
     matrixRanking(matrix) {
       const columns = [];
@@ -1185,6 +1270,7 @@ export default {
   position: sticky;
   top: 0;
   z-index: 2;
+  white-space: nowrap;
 }
 
 .finding-table th,
@@ -1447,7 +1533,7 @@ export default {
   color: #d7e9f6;
   font-weight: 600;
   background: #123044;
-  white-space: normal;
+  white-space: nowrap;
 }
 
 .matrix-table thead th:first-child,
@@ -1505,11 +1591,56 @@ export default {
   color: #7f93a8;
 }
 
+.cab-temp-table {
+  width: 100%;
+  border-collapse: separate;
+  border-spacing: 0;
+  font-size: 12px;
+  color: #d7f4ff;
+}
+
+.cab-temp-table th,
+.cab-temp-table td {
+  padding: 9px 12px;
+  border-right: 1px solid rgba(126, 196, 232, 0.16);
+  border-bottom: 1px solid rgba(126, 196, 232, 0.16);
+  text-align: left;
+  vertical-align: middle;
+  background: #0e2438;
+  line-height: 1.4;
+}
+
+.cab-temp-table tr > :first-child {
+  border-left: 1px solid rgba(126, 196, 232, 0.16);
+}
+
+.cab-temp-table thead th {
+  color: #d7e9f6;
+  font-weight: 600;
+  background: #123044;
+  white-space: nowrap;
+}
+
+.cab-temp-table td b {
+  color: #eef7ff;
+  font-weight: 650;
+}
+
+.cab-temp-table .cab-temp-table__sub {
+  margin-left: 8px;
+  color: #9eb6c8;
+}
+
+.cab-temp-table .cab-temp-table__explain {
+  color: #9eb6c8;
+}
+
 .source-muted,
 .source-note {
   margin: 0;
   color: #8eafcc;
   line-height: 1.6;
+  white-space: pre-line;
 }
 
 .source-note {
@@ -1629,6 +1760,7 @@ export default {
   top: 0;
   z-index: 2;
   background: #10243d;
+  white-space: nowrap;
 }
 
 .source-table th {
@@ -1636,6 +1768,13 @@ export default {
   font-weight: 600;
 }
 
+/* 说明列(最后一列)限制宽度,避免长文本把表撑太宽 */
+.source-table th:last-child,
+.source-table td:last-child {
+  max-width: 240px;
+  word-break: break-word;
+}
+
 .source-table tbody tr {
   cursor: pointer;
 }
@@ -1644,4 +1783,28 @@ export default {
   background: rgba(36, 140, 110, 0.28);
   box-shadow: inset 0 0 0 1px #3ddea0;
 }
+
+/* 全页面统一:表头不换行;横向滚动时首列(机组)固定 */
+.source-table th,
+.cab-temp-table th,
+.finding-table th {
+  white-space: nowrap;
+}
+
+.source-table th:first-child,
+.source-table td:first-child,
+.cab-temp-table th:first-child,
+.cab-temp-table td:first-child {
+  position: sticky;
+  left: 0;
+  z-index: 2;
+  background: #0e2438;
+  box-shadow: 6px 0 8px rgba(4, 12, 24, 0.45);
+  white-space: nowrap;
+}
+
+.source-table thead th:first-child,
+.cab-temp-table thead th:first-child {
+  z-index: 3;
+}
 </style>

+ 7 - 2
src/views/rankingApp/constants.js

@@ -45,6 +45,7 @@ export const DET_ALG = {
   pitchWind: 'A20',
   envTemp: 'A21',
   partTemp: 'A22',
+  cabTemp: 'A23',
   yawStatic: 'Y01',
   yawDyn: 'Y02'
 }
@@ -65,7 +66,7 @@ export const COCKPIT_MODULES = [
   ['windRes', '风资源分析', ['A01', 'A02', 'A03']],
   ['power', '功率曲线分析', ['A04', 'A05']],
   ['partTemp', '大部件温度性能分析', ['A22']],
-  ['temp', '温度传感器性能分析', ['A21']],
+  ['temp', '温度传感器性能分析', ['A21', 'A23']],
   ['rated', '额定功率和风速分析', ['A06', 'A07']],
   ['pitchChar', '变桨特性分析', ['A17']],
   ['pitchSync', '变桨协调分析', ['A18', 'A19', 'A20']],
@@ -146,7 +147,10 @@ export const DETECTORS = {
     ['pitchRpm', '变桨和发电机转速协调性分析'],
     ['pitchWind', '变桨和有功功率及风速分析']
   ],
-  tempSensor: [['envTemp', '环境温度传感器分析']],
+  tempSensor: [
+    ['envTemp', '环境温度传感器分析'],
+    ['cabTemp', '电气柜温度变化']
+  ],
   partTemp: [['partTemp', '大部件温度传感器分析']],
   yawAim: [
     ['yawStatic', '静态偏航对风偏差分析'],
@@ -177,6 +181,7 @@ export const HEAT_DIAG = [
   ['pitchSame', '变桨和发电机转速协调性分析', 'pitchSync', 'pitchRpm'],
   ['pitchCoord', '变桨和有功功率及风速分析', 'pitchSync', 'pitchWind'],
   ['envTemp', '环境温度传感器分析', 'tempSensor', 'envTemp'],
+  ['cabTemp', '电气柜温度变化', 'tempSensor', 'cabTemp'],
   ['partTemp', '大部件温度传感器分析', 'partTemp', 'partTemp'],
   ['yawErr', '静态偏航对风偏差分析', 'yawAim', 'yawStatic'],
   ['yaw', '动态偏航对风偏差分析', 'yawAim', 'yawDyn']

+ 347 - 0
src/views/rankingApp/utils/contractChart.js

@@ -0,0 +1,347 @@
+/**
+ * 按后端新版契约(graph.datasets + graph.charts)通用渲染 ECharts。
+ * 遵循《前端结论与空图对接 3.3》:只遍历 charts,renderable 且 observation_count>0 才画;
+ * 配色对齐 V19 浅色绘图区。
+ */
+
+const PLOT_BG = "#e8eef6";
+const INK = "#19392e";
+const GRID_LINE = "#c6d0c2";
+const GREEN = "#24734e";
+const BLUE = "#668db5";
+const GOLD = "#c18a45";
+const RED = "#c63c43";
+
+function v4Color(i, n) {
+  const stops = [[232, 244, 194], [112, 179, 187], [40, 52, 116]];
+  const k = Math.min(1, Math.max(0, n > 1 ? i / (n - 1) : 0.5)) * 2;
+  const j = Math.min(1, Math.floor(k));
+  const q = k - j;
+  return `rgb(${stops[j].map((c, x) => Math.round(c + (stops[j + 1][x] - c) * q)).join(",")})`;
+}
+
+function num(v) {
+  const n = Number(v);
+  return Number.isFinite(n) ? n : null;
+}
+function axisLabel() {
+  return { color: INK, fontSize: 11 };
+}
+function splitLine() {
+  return { lineStyle: { color: GRID_LINE, opacity: 0.8 } };
+}
+function axisLine() {
+  return { lineStyle: { color: GRID_LINE, opacity: 1 } };
+}
+function baseGrid() {
+  return { left: 56, right: 18, top: 30, bottom: 34, containLabel: false };
+}
+function opt(extra) {
+  return Object.assign({ backgroundColor: PLOT_BG }, extra);
+}
+
+function groupBy(rows, key) {
+  const m = new Map();
+  rows.forEach((r) => {
+    const k = r[key] == null ? "—" : String(r[key]);
+    if (!m.has(k)) m.set(k, []);
+    m.get(k).push(r);
+  });
+  return m;
+}
+function cmp(a, b) {
+  if (a == null && b == null) return 0;
+  if (a == null) return -1;
+  if (b == null) return 1;
+  const na = Number(a);
+  const nb = Number(b);
+  if (Number.isFinite(na) && Number.isFinite(nb)) return na - nb;
+  return String(a).localeCompare(String(b));
+}
+function isTimeish(v) {
+  const s = String(v == null ? "" : v);
+  return /^\d{4}(-\d{2}(-\d{2})?)?$/.test(s) || /^\d{4}Q[1-4]$/.test(s);
+}
+function toX(v) {
+  const s = String(v);
+  if (/^\d{4}Q[1-4]$/.test(s)) {
+    const q = Number(s[5]);
+    return `${s.slice(0, 4)}-${String((q - 1) * 3 + 1).padStart(2, "0")}-01`;
+  }
+  if (/^\d{4}-\d{2}$/.test(s)) return `${s}-01`;
+  return s;
+}
+function colLabel(cols, key) {
+  const c = cols[key];
+  return (c && c.label) || key;
+}
+
+const NAMED = {
+  y: "", y1: "", y2: "", y3: "", y4: "", y5: "",
+  raw: "原始", smoothed: "EWMA", upper_reference: "参考上限", lower_limit: "判断下限",
+  upper_limit: "正向门槛", negative_limit: "负向门槛",
+};
+
+function lineChart(chart, rows, cols) {
+  const enc = chart.encoding || {};
+  const xKey = enc.x;
+  const groups = chart.series_by ? groupBy(rows, chart.series_by) : new Map([["", rows]]);
+  const multi = groups.size > 1;
+  const yEntries = Object.keys(NAMED)
+    .map((k) => [k, enc[k]])
+    .filter(([, key]) => key);
+  const series = [];
+  let gi = 0;
+  groups.forEach((grows, gname) => {
+    const srows = grows.slice().sort((a, b) => cmp(a[xKey], b[xKey]));
+    const base = multi ? v4Color(gi, groups.size) : BLUE;
+    yEntries.forEach(([k, key], yi) => {
+      const nm = multi
+        ? gname + (yEntries.length > 1 ? "·" + (NAMED[k] || colLabel(cols, key)) : "")
+        : NAMED[k] || colLabel(cols, key);
+      series.push({
+        name: nm,
+        type: "line",
+        data: srows.map((r) => [toX(r[xKey]), num(r[key])]),
+        showSymbol: false,
+        smooth: true,
+        lineStyle: { color: yEntries.length > 1 ? v4Color(yi, yEntries.length) : base, width: 2 },
+        itemStyle: { color: yEntries.length > 1 ? v4Color(yi, yEntries.length) : base },
+        progressive: 500,
+        progressiveThreshold: 2000,
+        sampling: "lttb",
+      });
+    });
+    gi += 1;
+  });
+  const xt = rows.some((r) => isTimeish(r[xKey])) ? "time" : "value";
+  const showLegend = groups.size <= 8 && yEntries.length <= 4;
+  return opt({
+    grid: Object.assign(baseGrid(), { top: 42 }),
+    tooltip: { trigger: "axis" },
+    xAxis: { type: xt, axisLabel: axisLabel(), axisLine: axisLine() },
+    yAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine() },
+    legend: showLegend ? { textStyle: { color: INK, fontSize: 11 }, top: 0 } : undefined,
+    series,
+  });
+}
+
+function scatterChart(chart, rows) {
+  const enc = chart.encoding || {};
+  const data = rows
+    .map((r) => [num(r[enc.x]), num(r[enc.y])])
+    .filter((p) => p[0] != null && p[1] != null);
+  return opt({
+    grid: baseGrid(),
+    tooltip: { trigger: "item", formatter: (p) => `x ${p.value[0]}, y ${p.value[1]}` },
+    xAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine(), axisLine: axisLine() },
+    yAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine() },
+    series: [
+      {
+        name: chart.title,
+        type: "scatter",
+        data,
+        symbolSize: 4,
+        itemStyle: { color: BLUE, opacity: 0.5 },
+        large: true,
+        largeThreshold: 800,
+        progressive: 400,
+        progressiveThreshold: 3000,
+      },
+    ],
+  });
+}
+
+function scatterLineChart(chart, rows) {
+  const enc = chart.encoding || {};
+  const xKey = enc.x;
+  const yKey = enc.y;
+  const roleKey = "role";
+  const roles = enc.geometry_by_role || {};
+  const series = [];
+  Object.entries(roles).forEach(([role, geom]) => {
+    const rrows = rows.filter((r) => r[roleKey] === role).sort((a, b) => cmp(a[xKey], b[xKey]));
+    if (!rrows.length) return;
+    if (geom === "line") {
+      series.push({
+        name: role, type: "line", data: rrows.map((r) => [num(r[xKey]), num(r[yKey])]),
+        showSymbol: false, lineStyle: { color: RED, width: 2 }, itemStyle: { color: RED },
+      });
+    } else {
+      series.push({
+        name: role, type: "scatter", data: rrows.map((r) => [num(r[xKey]), num(r[yKey])]),
+        symbolSize: 4, itemStyle: { color: BLUE, opacity: 0.5 }, large: true, largeThreshold: 800,
+      });
+    }
+  });
+  return opt({
+    grid: baseGrid(),
+    tooltip: { trigger: "item" },
+    xAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine(), axisLine: axisLine() },
+    yAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine() },
+    series,
+  });
+}
+
+function errorBarChart(chart, rows) {
+  const enc = chart.encoding || {};
+  const xKey = enc.x;
+  const yKey = enc.y;
+  const cats = rows.map((r) => String(r[xKey]));
+  const vals = rows.map((r) => num(r[yKey]));
+  const low = enc.error_low ? rows.map((r) => num(r[enc.error_low])) : null;
+  const high = enc.error_high ? rows.map((r) => num(r[enc.error_high])) : null;
+  const series = [
+    {
+      name: chart.title, type: "bar",
+      data: vals.map((v) => ({ value: v, itemStyle: { color: GOLD, opacity: 0.9 } })),
+    },
+  ];
+  if (low) {
+    const err = vals.map((v, i) => [v - (low[i] == null ? v : low[i]), (high[i] == null ? v : high[i]) - v]);
+    series.push({
+      name: "95% 区间", type: "scatter",
+      data: vals.map((v, i) => ({ value: [i, v], symbolSize: 0 })),
+      errorY: { value: err }, errorYPlus: true, itemStyle: { color: "transparent" }, z: 3,
+    });
+  }
+  return opt({
+    grid: baseGrid(),
+    tooltip: { trigger: "axis" },
+    xAxis: {
+      type: "category", data: cats,
+      axisLabel: { ...axisLabel(), interval: 0, rotate: cats.length > 8 ? 30 : 0 },
+      axisLine: axisLine(),
+    },
+    yAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine() },
+    series,
+  });
+}
+
+function heatColor(v, maxAbs) {
+  if (v == null) return "#edf0ed";
+  const q = Math.min(1, Math.abs(v) / maxAbs);
+  if (v >= 0) return `rgb(${Math.round(245 - 66 * q)},${Math.round(245 - 155 * q)},${Math.round(245 - 148 * q)})`;
+  return `rgb(${Math.round(245 - 177 * q)},${Math.round(245 - 121 * q)},${Math.round(245 - 63 * q)})`;
+}
+
+function heatmapChart(chart, rows) {
+  const enc = chart.encoding || {};
+  const xKey = enc.x;
+  const yKey = enc.y;
+  const vKey = enc.value;
+  const xs = [...new Set(rows.map((r) => r[xKey]))].sort(cmp);
+  const ys = [...new Set(rows.map((r) => r[yKey]))].sort((a, b) => String(a).localeCompare(String(b)));
+  const xi = new Map(xs.map((v, i) => [v, i]));
+  const yi = new Map(ys.map((v, i) => [v, i]));
+  const vals = rows.map((r) => num(r[vKey])).filter((v) => v != null);
+  const maxAbs = Math.max(1, ...vals.map(Math.abs));
+  const data = rows.map((r) => {
+    const v = num(r[vKey]);
+    return { value: [xi.get(r[xKey]), yi.get(r[yKey]), v == null ? 0 : v], raw: v, itemStyle: { color: heatColor(v, maxAbs), borderColor: "#fff", borderWidth: 1 } };
+  });
+  return opt({
+    grid: { left: 96, right: 16, top: 34, bottom: 46 },
+    tooltip: { formatter: (p) => { const v = p.data && p.data.raw; return `${p.value[1]} ${p.value[0]}<br/>值 ${v == null ? "—" : Number(v).toFixed(1)}`; } },
+    xAxis: { type: "category", data: xs, splitArea: { show: true }, axisLabel: { color: INK, fontSize: 10 }, axisLine: axisLine() },
+    yAxis: { type: "category", data: ys, splitArea: { show: true }, axisLabel: { color: INK, fontSize: 10 }, axisLine: axisLine() },
+    series: [
+      {
+        name: chart.title, type: "heatmap", data,
+        label: { show: true, fontSize: 9, color: INK, formatter: (p) => { const v = p.data && p.data.raw; return v == null ? "—" : (v >= 0 ? "+" : "") + Number(v).toFixed(1); } },
+        emphasis: { itemStyle: { borderColor: INK, borderWidth: 1.5 } },
+      },
+    ],
+  });
+}
+
+function polarStack(chart, rows) {
+  const enc = chart.encoding || {};
+  const angleKey = enc.angle;
+  const radiusKey = enc.radius;
+  const stackKey = enc.stack;
+  const angles = [...new Set(rows.map((r) => r[angleKey]))].sort(cmp);
+  const stacks = stackKey ? [...new Set(rows.map((r) => r[stackKey]))].sort() : null;
+  const series = [];
+  if (stacks) {
+    stacks.forEach((s, i) => {
+      series.push({
+        name: s, type: "bar", coordinateSystem: "polar", stack: "t",
+        data: angles.map((a) => num((rows.find((r) => r[angleKey] === a && r[stackKey] === s) || {})[radiusKey]) || 0),
+        itemStyle: { color: v4Color(i, stacks.length), opacity: 0.85 },
+      });
+    });
+  } else {
+    series.push({
+      name: chart.title, type: "bar", coordinateSystem: "polar",
+      data: angles.map((a) => num((rows.find((r) => r[angleKey] === a) || {})[radiusKey]) || 0),
+      itemStyle: { color: BLUE, opacity: 0.85 },
+    });
+  }
+  return opt({
+    tooltip: { trigger: "item" },
+    angleAxis: { type: "category", data: angles, axisLine: { lineStyle: { color: GRID_LINE } }, axisLabel: axisLabel() },
+    radiusAxis: { axisLabel: axisLabel(), splitLine: splitLine() },
+    polar: {},
+    series,
+  });
+}
+
+function boxplotChart(chart, rows) {
+  const enc = chart.encoding || {};
+  const cats = rows.map((r) => r[enc.x]);
+  const data = rows.map((r) => [num(r[enc.p05]), num(r[enc.p25]), num(r[enc.p50]), num(r[enc.p75]), num(r[enc.p95])]);
+  return opt({
+    grid: baseGrid(),
+    tooltip: { trigger: "item" },
+    xAxis: { type: "category", data: cats, axisLabel: { ...axisLabel(), interval: Math.ceil(cats.length / 10) }, axisLine: axisLine() },
+    yAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine() },
+    series: [{ name: chart.title, type: "boxplot", data, itemStyle: { color: BLUE, borderColor: BLUE, opacity: 0.7 } }],
+  });
+}
+
+function histogramLine(chart, rows) {
+  const enc = chart.encoding || {};
+  const cats = rows.map((r) => r[enc.x]);
+  return opt({
+    grid: baseGrid(),
+    tooltip: { trigger: "axis" },
+    xAxis: { type: "category", data: cats, axisLabel: axisLabel(), axisLine: axisLine() },
+    yAxis: { type: "value", axisLabel: axisLabel(), splitLine: splitLine() },
+    series: [
+      { name: "密度", type: "bar", data: rows.map((r) => num(r[enc.bar])), itemStyle: { color: BLUE, opacity: 0.6 } },
+      { name: "正态拟合", type: "line", data: rows.map((r) => num(r[enc.line])), showSymbol: false, lineStyle: { color: RED, width: 2 } },
+    ],
+  });
+}
+
+/** chart + datasets → { type: 'chart', option, notes } 或 { type: 'empty', notes } */
+export function renderContractChart(chart, datasets) {
+  const ds = datasets && chart && datasets[chart.dataset_id];
+  const rows = (ds && ds.rows) || [];
+  const cols = ((ds && ds.columns) || []).reduce((m, c) => {
+    m[c.key] = c;
+    return m;
+  }, {});
+  if (!rows.length) return { type: "empty", notes: chart.notes };
+  switch (chart.kind) {
+    case "line": return { type: "chart", option: lineChart(chart, rows, cols), notes: chart.notes };
+    case "polar_stack": return { type: "chart", option: polarStack(chart, rows), notes: chart.notes };
+    case "scatter": return { type: "chart", option: scatterChart(chart, rows), notes: chart.notes };
+    case "scatter_line": return { type: "chart", option: scatterLineChart(chart, rows), notes: chart.notes };
+    case "scatter_errorbar": return { type: "chart", option: errorBarChart(chart, rows), notes: chart.notes };
+    case "heatmap": return { type: "chart", option: heatmapChart(chart, rows), notes: chart.notes };
+    case "quantile_whisker": return { type: "chart", option: boxplotChart(chart, rows), notes: chart.notes };
+    case "histogram_line": return { type: "chart", option: histogramLine(chart, rows), notes: chart.notes };
+    default: return { type: "empty", notes: chart.notes };
+  }
+}
+
+/** tables 里的表转前端表格描述 */
+export function renderContractTable(table) {
+  return {
+    type: "table",
+    columns: (table.columns || []).map((c) => ({ key: c.key, label: c.label })),
+    rows: table.rows || [],
+  };
+}

+ 1 - 1
src/views/rankingApp/utils/rankHelpers.js

@@ -158,7 +158,7 @@ export function buildRankRows({
       )
       .map((u) => ({
         id: u.id,
-        name: farmName(u.farmId).replace('风电场', '') + ' ' + u.no + '号',
+        name: farmName(u.farmId).replace('风电场', '') + ' ' + (u.engineName || u.no) + '号',
         parent: modelName(u.modelId),
         turbines: 1,
         watch: isUnitBad(u) ? 1 : 0,

+ 6 - 5
src/views/rankingApp/utils/reportExportLocal.js

@@ -55,13 +55,14 @@ export function buildReportQuery(ctx = {}) {
     number = allowed.includes(8) ? 8 : allowed[allowed.length - 1];
   }
   const projectId = ctx.projectId || (PROJECTS[0] && PROJECTS[0].id) || "";
-  const project = PROJECTS.find((p) => p.id === projectId) || PROJECTS[0] || {};
+  const mock = PROJECTS.find((p) => p.id === projectId) || {};
   return {
     year,
     number,
-    projectId: project.id || projectId,
-    projectName: project.name || projectName(projectId) || "风电项目",
-    farmId: ctx.farmId || project.farmId || "",
+    // 保留真实 projectId(field_code),不要用 mock 的 id 覆盖,否则后端取不到真实数据
+    projectId,
+    projectName: ctx.projectName || mock.name || projectName(projectId) || projectId || "风电项目",
+    farmId: ctx.farmId || mock.farmId || "",
     modelId: ctx.modelId || "",
     unitId: ctx.unitId || "",
     scope: ctx.scope || "project",
@@ -139,7 +140,7 @@ export function buildLocalReportMeta(query) {
     moduleStats,
     units: units.slice(0, 60).map((u) => ({
       id: u.id,
-      name: u.no || u.id,
+      name: u.engineName || u.no || u.id,
       farmName: farmName(u.farmId),
       modelName: modelName(u.modelId),
       count: u.count || 0,

+ 649 - 39
src/views/rankingApp/utils/sourceFunctionView.js

@@ -25,10 +25,10 @@ const Y_KEYS = [
   "cp",
   "lambda",
 ];
-const SERIES_KEYS = ["engine_code", "series_id", "aggregate_id", "name", "cohort_id"];
+const SERIES_KEYS = ["engine_name", "engine_code", "series_id", "aggregate_id", "name", "cohort_id"];
 
 const TABLE_COLUMNS = [
-  ["engine_code", "机组"],
+  ["engine_name", "机组"],
   ["machine_type_code", "机型"],
   ["status_label", "检测结果"],
   ["actual", "实际情况"],
@@ -37,7 +37,7 @@ const TABLE_COLUMNS = [
 ];
 
 const Y02_COLUMNS = [
-  ["engine_code", "机组"],
+  ["engine_name", "机组"],
   ["machine_type_code", "机型"],
   ["mean", "均值"],
   ["std", "标准差"],
@@ -154,6 +154,42 @@ function findingUnit(alg, unit) {
   return text;
 }
 
+/** 后端 project-function 聚合返回的异常线索(result.review_clues 扁平列表)。 */
+export function reviewCluesOf(data) {
+  const clues = data && data.reviewClues;
+  return Array.isArray(clues) ? clues : [];
+}
+
+/** 把算法侧 review_clue 映射到「异常线索与排查建议」表格字段。 */
+export function findingFromClue(clue) {
+  const occurrence = (clue && clue.occurrence) || {};
+  const whenText = occurrence.description
+    || (occurrence.month ? `${occurrence.month}月统计线索` : "");
+  const causes = Array.isArray(clue && clue.possible_causes) ? clue.possible_causes : [];
+  const checks = Array.isArray(clue && clue.first_checks) ? clue.first_checks : [];
+  const metricValue = clue == null ? null : clue.metric_value;
+  const threshold = clue == null ? null : clue.threshold;
+  const unit = (clue && clue.unit) || "";
+  const finding = (clue && clue.finding) || "有情况需要复查";
+  const metricLine = metricValue != null || threshold != null
+    ? `指标值${metricValue == null ? "—" : formatGuide(metricValue)}${unit};判断线${threshold == null ? "—" : formatGuide(threshold)}${unit}`
+    : "";
+  const reviewReason = (clue && clue.review_reason) || "";
+  const evidence = [metricLine, reviewReason, whenText ? `出现时间:${whenText}` : ""]
+    .filter(Boolean)
+    .join(";");
+  const confirmed = !!(clue && clue.confirmed_fault);
+  return {
+    aspect: finding,
+    evidence,
+    cause: causes.join(";"),
+    check: checks.join(";"),
+    timing: confirmed ? "已确认故障" : "立即核对",
+    when: confirmed ? "已确认设备故障,安排登机处理。" : "近期查看趋势和检修记录;仍有偏差,再安排登机。",
+    rank: confirmed ? 0 : 1,
+  };
+}
+
 export function conclusionCardOf(data, alg) {
   if (!data) return null;
   const status = data.status && typeof data.status === "object" ? data.status : {};
@@ -164,6 +200,7 @@ export function conclusionCardOf(data, alg) {
     status.source_status,
     result.status_label,
     result.source_status,
+    result.status,
   );
   if (alg === "A06" || alg === "A07" || alg === "A21") return ratedConclusionCard(data, alg, statusText, display);
   const slope = Number(result.annualized_slope_pct_per_year);
@@ -393,9 +430,307 @@ function filterDatasetChannel(dataset, channelCode) {
   return kept;
 }
 
+function isA23Graph(graph) {
+  if (!graph || typeof graph !== "object") return false;
+  if (graph.algorithm_id === "A23") return true;
+  const identity = graph.identity;
+  return !!(identity && (identity.function === "A23" || identity.function_code === "A23"));
+}
+
+/** A23 电气柜温度测点列表(来自 result.channels / tables)。 */
+export function a23ChannelsOf(data) {
+  const channels = [];
+  const push = (row) => {
+    if (!row || typeof row !== "object" || !row.code) return;
+    if (channels.some((item) => item.code === String(row.code))) return;
+    channels.push({
+      code: String(row.code),
+      name: row.name || row.code,
+      cabinet: row.cabinet || "",
+      status: row.status || row.label || "",
+      label: row.name || row.code,
+      explanation: row.label || "",
+      evidence: row.evidence || null,
+    });
+  };
+  const graph = data && (data.graphJson || data.graph);
+  if (graph) {
+    const result = graph.result || graph.algorithm_result;
+    if (result && Array.isArray(result.channels)) result.channels.forEach(push);
+    (graph.tables || []).forEach((table) => {
+      if (table && Array.isArray(table.rows)) table.rows.forEach(push);
+    });
+  }
+  const result = data && data.result;
+  if (result && Array.isArray(result.channels)) result.channels.forEach(push);
+  (data && data.tables ? data.tables : []).forEach((table) => {
+    if (table && Array.isArray(table.rows)) table.rows.forEach(push);
+  });
+  return channels;
+}
+
+/** A23 单个测点的结论快照(平均偏差 / 判断线 / 状态)。 */
+export function a23ChannelSnapshot(data, channelCode) {
+  const empty = { mean: null, threshold: null, status: "" };
+  if (!data || !channelCode) return empty;
+  const channel = a23ChannelsOf(data).find((item) => item.code === String(channelCode));
+  if (!channel) return empty;
+  const ev = channel.evidence || {};
+  const mean = ev.mean != null ? ev.mean : ev.prior_median;
+  return {
+    mean: Number.isFinite(Number(mean)) ? Number(mean) : null,
+    threshold: Number.isFinite(Number(ev.change_threshold)) ? Number(ev.change_threshold) : null,
+    status: channel.status || "",
+  };
+}
+
+/** 按测点过滤 A23 图表。 */
+export function filterChartsByChannel(data, channelCode) {
+  if (!data || !channelCode) return data;
+  const graph = data.graphJson || data.graph;
+  if (!graph || typeof graph !== "object" || !Array.isArray(graph.charts)) return data;
+  const nextGraph = Object.assign({}, graph, {
+    charts: graph.charts.filter((chart) => !chart || String(chart.channel || "") === String(channelCode)),
+  });
+  const copy = Object.assign({}, data);
+  if (data.graphJson) copy.graphJson = nextGraph;
+  if (data.graph) copy.graph = nextGraph;
+  return copy;
+}
+
+function a23BreakGaps(item, maxGapDays) {
+  const data = item && item.data;
+  if (!Array.isArray(data) || data.length < 2) return;
+  const out = [];
+  for (let i = 0; i < data.length; i += 1) {
+    out.push(data[i]);
+    if (i >= data.length - 1) continue;
+    const cur = new Date(data[i][0]);
+    const nxt = new Date(data[i + 1][0]);
+    if (Number.isNaN(cur.getTime()) || Number.isNaN(nxt.getTime())) continue;
+    if ((nxt - cur) / 86400000 <= (maxGapDays || 1.1)) continue;
+    const mid = new Date(cur.getTime() + 86400000);
+    const pad = (value) => String(value).padStart(2, "0");
+    out.push([`${mid.getFullYear()}-${pad(mid.getMonth() + 1)}-${pad(mid.getDate())}`, null]);
+  }
+  item.data = out;
+}
+
+function a23HighlightColor(name) {
+  if (name === "本月偏差") return "#ff8c42";
+  if (/P90|90百分位|90分位/.test(name)) return "#ffd166";
+  return null;
+}
+
+function a23ChartOption(chart) {
+  const rawSeries = Array.isArray(chart.series) ? chart.series : [];
+  const series = rawSeries.map((item, index) => {
+    const name = String(item.name || "");
+    const own = name === "本机";
+    const highlight = a23HighlightColor(name);
+    const color = item.color || highlight || (own ? "#3f79b3" : windColor(index, rawSeries.length));
+    const s = {
+      name: item.name || `序列${index + 1}`,
+      type: "line",
+      data: item.data || [],
+      showSymbol: chart.show_markers !== false,
+      symbol: "circle",
+      symbolSize: own ? 4 : highlight ? 3.5 : 3,
+      connectNulls: chart.connect_nulls !== false,
+      lineStyle: { width: own ? 2.4 : highlight ? 2.2 : 1.4, color },
+      itemStyle: { color },
+    };
+    if (chart.connect_nulls === false) a23BreakGaps(s, chart.max_gap_days);
+    return s;
+  });
+  if (!series.length) return null;
+  const yName = (chart.y_axis && chart.y_axis.unit) || "℃";
+  const xName = (chart.x_axis && chart.x_axis.label) || "日期";
+  return {
+    backgroundColor: "#0c1e36",
+    tooltip: {
+      trigger: "axis",
+      backgroundColor: "rgba(255,255,255,0.96)",
+      borderColor: "#dce5dd",
+      textStyle: { color: "#19392e", fontSize: 12 },
+    },
+    legend: {
+      type: "scroll",
+      bottom: 0,
+      left: "center",
+      textStyle: { color: "#8eabc0", fontSize: 11 },
+      pageIconColor: "#8eafcc",
+      pageTextStyle: { color: "#8eabc0" },
+    },
+    grid: { left: 56, right: 24, top: 36, bottom: 58 },
+    xAxis: {
+      type: "time",
+      name: xName,
+      nameLocation: "middle",
+      nameGap: 28,
+      nameTextStyle: { color: AXIS_TEXT, fontSize: 11 },
+      axisLabel: { color: AXIS_TEXT, fontSize: 11 },
+      axisLine: { lineStyle: { color: AXIS_LINE } },
+      splitLine: { lineStyle: { color: GRID_LINE } },
+    },
+    yAxis: {
+      type: "value",
+      name: yName,
+      scale: true,
+      axisLabel: { color: AXIS_TEXT, fontSize: 11 },
+      splitLine: { lineStyle: { color: GRID_LINE } },
+    },
+    series,
+  };
+}
+
+function a23BarView(chart) {
+  if (!chart || !Array.isArray(chart.data) || !chart.data.length) return null;
+  const categories = chart.data.map((item) => String(item[0]));
+  const values = chart.data.map((item) => (item[1] == null ? null : Number(item[1])));
+  const unit = chart.unit || "个";
+  const color = "#4c8fd6";
+  const barMaxWidth = 18;
+  // 横向柱状图:纵轴为机组(分类),横轴为需复核测点数(数值)。
+  // 按机组数动态定高让柱子更紧凑;数值+单位统一标注在右侧。
+  const height = Math.max(180, categories.length * 36 + 70);
+  return {
+    id: chart.id,
+    title: chart.title || "各机组需复核的柜温测点",
+    height,
+    option: {
+      backgroundColor: "#0c1e36",
+      tooltip: {
+        trigger: "axis",
+        axisPointer: { type: "shadow" },
+        backgroundColor: "rgba(255,255,255,0.96)",
+        borderColor: "#dce5dd",
+        textStyle: { color: "#19392e", fontSize: 12 },
+        valueFormatter: (value) => (value == null ? "" : `${value}${unit}`),
+      },
+      grid: { left: 8, right: 72, top: 24, bottom: 36, containLabel: true },
+      xAxis: {
+        type: "value",
+        min: 0,
+        minInterval: 1,
+        axisLabel: { color: AXIS_TEXT, fontSize: 11 },
+        axisLine: { lineStyle: { color: AXIS_LINE } },
+        splitLine: { lineStyle: { color: GRID_LINE } },
+      },
+      yAxis: {
+        type: "category",
+        data: categories,
+        inverse: true,
+        axisTick: { show: false },
+        axisLabel: { color: AXIS_TEXT, fontSize: 11 },
+        axisLine: { lineStyle: { color: AXIS_LINE } },
+        splitLine: { show: false },
+      },
+      series: [
+        {
+          name: chart.title || "需复核测点",
+          type: "bar",
+          data: values,
+          barMaxWidth,
+          itemStyle: { color, borderRadius: [0, 4, 4, 0] },
+          label: {
+            show: true,
+            position: "right",
+            color: "#d7e9f6",
+            fontSize: 12,
+            fontWeight: 600,
+            formatter: (p) => (p.value == null ? "" : `${p.value}${unit}`),
+          },
+        },
+      ],
+    },
+  };
+}
+
+function a23ChartViews(graph) {
+  const charts = Array.isArray(graph.charts) ? graph.charts : [];
+  return charts
+    .filter((chart) => chart && typeof chart === "object" && !/^matrix$/.test(String(chart.type || "")))
+    .map((chart) => {
+      if (Array.isArray(chart.series) && !/_peers?$/.test(String(chart.id || ""))) {
+        const option = a23ChartOption(chart);
+        if (!option) return null;
+        return { id: chart.id, title: chart.title || chart.id, option };
+      }
+      // 各机组需复核的柜温测点(type=bar)已按需求从页面移除,不再渲染
+      return null;
+    })
+    .filter(Boolean);
+}
+
+/** A23 总览柜温偏差矩阵(来自 cabinet_matrix 图表)。 */
+export function a23MatrixOf(data, modelName) {
+  const graph = data && (data.graphJson || data.graph);
+  const chart = (graph && Array.isArray(graph.charts) ? graph.charts : [])
+    .find((item) => item && item.type === "matrix");
+  if (!chart || !Array.isArray(chart.rows)) return null;
+  const columns = [];
+  const seen = new Set();
+  (chart.columns || []).forEach((code) => {
+    const key = String(code || "");
+    if (!key || seen.has(key)) return;
+    seen.add(key);
+    const cell = chart.rows.reduce(
+      (found, row) => found || (((row && row.cells) || []).find((c) => c && c.channel === code) || null),
+      null,
+    );
+    columns.push({ key, label: (cell && (cell.name || cell.channel)) || key });
+  });
+  const rows = (chart.rows || []).map((row) => {
+    const cells = {};
+    ((row && row.cells) || []).forEach((cell) => {
+      if (!cell) return;
+      cells[String(cell.channel || "")] = {
+        engineCode: row.tid,
+        channelCode: cell.channel,
+        channelName: cell.name || cell.channel,
+        value: cell.value,
+        status: cell.status || cell.label,
+      };
+    });
+    return { engineCode: row.tid, cells };
+  });
+  return { title: `总图 · ${modelName || ""} · 柜温偏差与结果`, columns, rows };
+}
+
+/** 图表的 legend_entries:group_values -> label 的显示名映射。 */
+function legendLabelMap(chart) {
+  const byGroup = {};
+  const byMetric = {};
+  const entries = chart && Array.isArray(chart.legend_entries) ? chart.legend_entries : [];
+  entries.forEach((entry) => {
+    if (!entry || !entry.label) return;
+    const gv = entry.group_values || [];
+    if (gv.length) byGroup[gv.map(String).join("|")] = entry.label;
+    if (gv.length === 1) byGroup[String(gv[0])] = entry.label;
+    if (entry.metric_key) byMetric[String(entry.metric_key)] = entry.label;
+  });
+  return { byGroup, byMetric };
+}
+
+/** 用 legend_entries 的更规范中文 label 替换系列名(优先按 metric_key,其次按 group_values)。 */
+function relabelSeries(option, labelMap) {
+  if (!option || !Array.isArray(option.series)) return option;
+  const byGroup = (labelMap && labelMap.byGroup) || {};
+  const byMetric = (labelMap && labelMap.byMetric) || {};
+  if (!Object.keys(byGroup).length && !Object.keys(byMetric).length) return option;
+  const series = option.series.map((item) => {
+    const name = String(item && item.name != null ? item.name : "");
+    const label = (item && item.metricKey && byMetric[item.metricKey]) || byGroup[name];
+    return label ? Object.assign({}, item, { name: label }) : item;
+  });
+  return Object.assign({}, option, { series });
+}
+
 export function chartViewsOf(data) {
   const graph = data && (data.graphJson || data.graph);
   if (!graph || typeof graph !== "object") return [];
+  if (isA23Graph(graph)) return a23ChartViews(graph);
   const wind = windFrequencyView(graph);
   if (wind) return [wind];
   const datasets = collectDatasets(graph);
@@ -406,18 +741,33 @@ export function chartViewsOf(data) {
       const datasetIds = chartDatasetIds(chart);
       const datasetId = datasetIds[0] || "";
       const dataset = datasetId ? datasets[datasetId] : null;
-      const title = chart.title || chart.name || DATASET_TITLES[datasetId] || `总图${index + 1}`;
+      const machineType = data && (data.machineTypeCode || (data.identity && data.identity.machine_type_code));
+      const title = splitScopeTitle(chart.title || chart.name || DATASET_TITLES[datasetId] || `总图${index + 1}`, chart.scope)
+        .replace(/\{machine_type_code\}/g, machineType || "")
+        .replace(/·\s*·/g, "·")
+        .replace(/\s{2,}/g, " ")
+        .trim();
       const extras = companionDatasets(datasetId, datasetIds, datasets);
       const view = dataset ? buildDatasetChart(datasetId || title, dataset, title, data, extras) : null;
       if (view) {
+        // 同一数据集可能被多张图引用(如 A21 的 ambient_summary),用 chart.id/name 保证 key 唯一
+        view.id = chart.id || chart.name || `${view.id}-${index}`;
+        const chartNotes = Array.isArray(chart.notes)
+          ? chart.notes.filter((item) => item != null && item !== "").join("\n")
+          : "";
+        if (chartNotes) {
+          view.note = view.note ? `${view.note}\n${chartNotes}` : chartNotes;
+        }
+        const labelMap = legendLabelMap(chart);
+        if (view.option && (Object.keys(labelMap.byGroup).length || Object.keys(labelMap.byMetric).length)) {
+          view.option = relabelSeries(view.option, labelMap);
+        }
         views.push(view);
         return;
       }
       const reason = chartStatusText(chart.reason || chart.message || chart.status || graph.graph_status);
       if (reason) {
-        views.push({ id: datasetId || `chart-${index}`, title, option: null, reason });
-      } else if (dataset && !companionOnly(datasetId)) {
-        views.push({ id: datasetId || `chart-${index}`, title, option: null, reason: "图 JSON 里没有可绘制的序列" });
+        views.push({ id: chart.id || chart.name || datasetId || `chart-${index}`, title, option: null, reason });
       }
     });
   }
@@ -459,7 +809,7 @@ function windFrequencyView(graph) {
       if (speed > 15) return;
       data.push([speed, ((Number(count) || 0) / total) * 100]);
     });
-    if (data.length) series.push({ name: item.engine_code || `机组${series.length + 1}`, data });
+    if (data.length) series.push({ name: item.engine_name || item.engine_code || `机组${series.length + 1}`, data });
   });
   if (!series.length) return null;
   return {
@@ -600,11 +950,17 @@ function companionOnly(datasetId) {
 function chartStatusText(status) {
   const text = String(status || "").trim();
   if (!text || /^(ok|ready|available|configured|partial)$/i.test(text)) return "";
-  if (/no_data|not_provided|empty/i.test(text)) return "图 JSON 里这份数据是空的";
-  if (/unavailable/i.test(text)) return "这份图当前不可用";
-  if (/not_configured/i.test(text)) return "未配置这张图";
-  if (/not_applicable/i.test(text)) return "本功能按配置不设分图。上方保留本机数值与文字结论,项目总览供同机型对比图。";
-  return text;
+  return "暂无数据";
+}
+
+/** 算法侧部分图表把总图/分图标题合并成 "总图2 / 分图 · xxx",按 scope 拆开。 */
+export function splitScopeTitle(title, scope) {
+  if (typeof title !== "string" || !title.includes("/")) return title;
+  const parts = title.split("/").map((item) => item.trim()).filter(Boolean);
+  if (parts.length < 2) return title;
+  if (scope === "turbine") return parts[parts.length - 1];
+  const suffix = parts[parts.length - 1].replace(/^分图\s*·\s*/, "");
+  return suffix ? `${parts[0]} · ${suffix}` : parts[0];
 }
 
 function chartDatasetId(chart) {
@@ -799,7 +1155,7 @@ function darkLineOption(series, extra) {
             color: AXIS_TEXT,
             fontSize: 11,
             margin: 10,
-            rotate: opt.categories && opt.categories.length > 10 ? 35 : 0,
+            interval: "auto",
           },
           axisLine: { lineStyle: { color: AXIS_LINE } },
           splitLine: { show: false },
@@ -940,9 +1296,19 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
     return found ? found.rows : [];
   };
   if (has("p05") && has("p50") && has("p95") && (has("date") || has("month"))) {
-    return boxed(id, title, rows, has("date") ? "date" : "month");
+    if (has("sample_count")) {
+      return boxed(id, title, rows, has("date") ? "date" : "month");
+    }
+    // 三叶桨距角极差时序:P50 + P95 折线(V19)
+    return linesOf(id, title, rows, has("date") ? "date" : "month", [
+      ["p50", "日中位数"],
+      ["p95", "日P95", true],
+    ], "日期", "极差 °", null, false);
   }
   if (has("own_median_deg") && has("project_median_deg") && has("wind_ms")) {
+    if (has("difference_deg") && uniqueValues(rows, engineColumn(rows)).length > 1) {
+      return pitchHeatmap(id, title, rows);
+    }
     return pitchLines(id, title, rows);
   }
   if (has("pitch_deg") && has("wind_ms") && has("power_kw")) {
@@ -1016,7 +1382,7 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
   if (has("load_pct") && has("observed_c")) return loadChart(id, title, rows);
   if (has("density_per_deg") && has("bin_center_deg")) return yawHist(id, title, rows, extraRows("yaw_distribution_guides"));
   if (has("ambient_mean_c") || has("difference_median_c")) return ambientBars(id, title, rows);
-  if (has("offset_deg")) return engineBars(id, title, rows, "offset_deg", "偏航角 °", [], yawBandGuides(rows), false);
+  if (has("offset_deg")) return yawStaticOverview(id, title, rows);
   if (has("mean_deg") && has("engine_code")) {
     return engineBars(id, title, rows, "mean_deg", "均值 °", [
       ["lower_sigma_deg", "μ-σ"],
@@ -1035,13 +1401,15 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
       ["negative_limit_ms", "负向门槛"],
     ], null, false);
   }
-  if (has("out_of_band_pct")) return engineBars(id, title, rows, "out_of_band_pct", "带外率 %", [["limit_pct", "门槛"]], null, false);
+  if (has("out_of_band_pct")) return engineScatter(id, title, rows, "out_of_band_pct", "带外率 %", [
+    { y: finiteOf(rows, "limit_pct", null), label: "门槛", color: "#d9504f" },
+  ], false);
   if (has("peer_difference_pct")) {
-    return engineBars(id, title, rows, "peer_difference_pct", "相对偏离 %", [], [
-      { y: finiteOf(rows, "zero_reference_pct", 0), label: "零偏离", color: "#9eb6a6" },
+    return engineScatter(id, title, rows, "peer_difference_pct", "相对偏离 %", [
+      { y: finiteOf(rows, "zero_reference_pct", 0), label: "零偏离", color: "#d9504f" },
     ], false);
   }
-  if (has("deviation_pct") && has("engine_code") && !has("month") && !has("period") && !has("date")) {
+  if (has("deviation_pct") && (has("engine_code") || has("engine_name")) && !has("month") && !has("period") && !has("date")) {
     return metricPoints(id, title, rows);
   }
   return null;
@@ -1050,14 +1418,14 @@ function schemaChart(id, rows, sourceKeys, title, extras) {
 function boxed(id, title, rows, xKey) {
   const sorted = rows.slice().sort((a, b) => String(a[xKey]).localeCompare(String(b[xKey])));
   const categories = [];
-  const data = [];
+  const boxData = [];
   sorted.forEach((row) => {
     const box = ["p05", "p25", "p50", "p75", "p95"].map((key) => Number(row[key]));
     if (box.some((value) => !Number.isFinite(value))) return;
     categories.push(row[xKey]);
-    data.push(box);
+    boxData.push(box);
   });
-  if (!data.length) return null;
+  if (!boxData.length) return null;
   return {
     id,
     title,
@@ -1075,7 +1443,15 @@ function boxed(id, title, rows, xKey) {
           ))).join("<br/>");
         },
       },
-      grid: { left: 64, right: 24, top: 28, bottom: 48 },
+      legend: {
+        bottom: 0,
+        left: 12,
+        itemWidth: 18,
+        itemHeight: 8,
+        textStyle: { color: "#8eabc0", fontSize: 11 },
+        data: ["箱体(P25–P75)与须(P05–P95)"],
+      },
+      grid: { left: 64, right: 24, top: 28, bottom: 58 },
       xAxis: {
         type: "category",
         data: categories,
@@ -1091,13 +1467,100 @@ function boxed(id, title, rows, xKey) {
         axisLabel: { color: AXIS_TEXT, fontSize: 11 },
         splitLine: { lineStyle: { color: GRID_LINE } },
       },
-      series: [{ type: "boxplot", data, itemStyle: { color: "#69a9c1", borderColor: "#d7e9f6" } }],
+      series: [
+        {
+          name: "箱体(P25–P75)与须(P05–P95)",
+          type: "boxplot",
+          data: boxData,
+          itemStyle: { color: "#69a9c1", borderColor: "#d7e9f6" },
+        },
+      ],
     },
   };
 }
 
+function pitchHeatmap(id, title, rows) {
+  const engCol = engineColumn(rows);
+  const binSet = [];
+  rows.forEach((row) => {
+    const w = Math.floor(Number(row.wind_ms));
+    if (!binSet.includes(w)) binSet.push(w);
+  });
+  binSet.sort((a, b) => a - b);
+  const yCats = uniqueValues(rows, engCol);
+  const rawMap = new Map();
+  const data = [];
+  yCats.forEach((name, ri) => {
+    binSet.forEach((w, ci) => {
+      const row = rows.find((r) => String(r[engCol]) === name && Math.floor(Number(r.wind_ms)) === w);
+      const v = row && Number.isFinite(Number(row.difference_deg)) ? Number(row.difference_deg) : null;
+      const key = `${ci},${ri}`;
+      rawMap.set(key, v);
+      if (v == null) {
+        data.push({ value: [ci, ri, 0], itemStyle: { color: "#16283a" } });
+      } else {
+        data.push([ci, ri, v]);
+      }
+    });
+  });
+  const fmt = (p) => {
+    const key = `${p.value[0]},${p.value[1]}`;
+    const v = rawMap.get(key);
+    return v == null ? "—" : (v >= 0 ? "+" : "") + Number(v).toFixed(1);
+  };
+  return {
+    id,
+    title,
+    height: Math.max(300, yCats.length * 26 + 90),
+    option: {
+      backgroundColor: "#0c1e36",
+      grid: { left: 96, right: 16, top: 46, bottom: 46 },
+      tooltip: {
+        backgroundColor: "rgba(255,255,255,0.96)",
+        borderColor: "#dce5dd",
+        textStyle: { color: "#19392e", fontSize: 12 },
+        formatter: (p) => {
+          const key = `${p.value[0]},${p.value[1]}`;
+          const v = rawMap.get(key);
+          return `${p.value[1]} ${binSet[p.value[0]]}–${binSet[p.value[0]] + 1}m/s<br/>差 ${v == null ? "—" : Number(v).toFixed(1)}°`;
+        },
+      },
+      xAxis: { type: "category", data: binSet.map((w) => `${w}–${w + 1}`), position: "top", splitArea: { show: true }, axisLabel: { color: "#9ebad0", fontSize: 10 } },
+      yAxis: { type: "category", data: yCats, inverse: true, splitArea: { show: true }, axisLabel: { color: "#9ebad0", fontSize: 10 } },
+      visualMap: {
+        min: -3.4,
+        max: 3.4,
+        calculable: false,
+        orient: "horizontal",
+        left: "center",
+        bottom: 0,
+        text: ["高于全项目中位", "低于全项目中位"],
+        textStyle: { color: "#9ebad0", fontSize: 11 },
+        inRange: { color: ["#2f6bd8", "#0c1e36", "#d9504f"] },
+      },
+      series: [
+        {
+          type: "heatmap",
+          data,
+          label: { show: true, fontSize: 9, color: "#eef7ff", formatter: fmt },
+          itemStyle: { borderColor: "#0c1e36", borderWidth: 1 },
+        },
+      ],
+    },
+    note: `风速段 m/s · 差值 ° 蓝:低于全项目中位;红:高于全项目中位;灰:该箱样本不足。颜色范围 ±3.4°,色彩仅表示方向和幅度,不是新增告警门。`,
+  };
+}
+
+function pitchHeatColor(v, maxAbs) {
+  if (v == null) return "#edf0ed";
+  const q = Math.min(1, Math.abs(v) / maxAbs);
+  if (v >= 0) return `rgb(${Math.round(245 - 66 * q)},${Math.round(245 - 155 * q)},${Math.round(245 - 148 * q)})`;
+  return `rgb(${Math.round(245 - 177 * q)},${Math.round(245 - 121 * q)},${Math.round(245 - 63 * q)})`;
+}
+
 function pitchLines(id, title, rows) {
-  const engines = uniqueValues(rows, "engine_code");
+  const engCol = engineColumn(rows);
+  const engines = uniqueValues(rows, engCol);
   if (engines.length <= 1) {
     return linesOf(id, title, rows, "wind_ms", [
       ["own_median_deg", "本机中位数"],
@@ -1105,7 +1568,7 @@ function pitchLines(id, title, rows) {
     ], "风速 m/s", "桨距角 °", null, false);
   }
   const series = engines.map((engine, index) => pairSeries(
-    rows.filter((row) => String(row.engine_code) === engine),
+    rows.filter((row) => String(row[engCol]) === engine),
     "wind_ms",
     "own_median_deg",
     engine,
@@ -1394,7 +1857,7 @@ function seriesEngine(row, label) {
   if (row.series_engine_code) return String(row.series_engine_code);
   const parts = String(label || "").split("|");
   if (parts.length > 1) return parts.slice(0, -1).join("|");
-  return String(row.engine_code || label || "");
+  return String(row.engine_name || row.engine_code || label || "");
 }
 
 function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
@@ -1403,7 +1866,7 @@ function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
   if (highlightOwn) {
     rows.forEach((row) => {
       if (String(row.role || row.series_role || "").toLowerCase() !== "own") return;
-      ownEngines.add(String(row.engine_code || row.series_engine_code || ""));
+      ownEngines.add(String(row.engine_name || row.engine_code || row.series_engine_code || ""));
     });
   }
   const groups = new Map();
@@ -1412,7 +1875,8 @@ function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
     const y = Number(row[yKey]);
     if (!Number.isFinite(x) || !Number.isFinite(y)) return;
     const role = String(row.role || row.series_role || "").toLowerCase();
-    const label = row.series_id || row.series_engine_code || row.engine_code || row.month || "序列";
+    if (!highlightOwn && role === "peer") return; // 总图不展示同型参考
+    const label = row.series_id || row.series_engine_code || row.engine_name || row.engine_code || row.month || "序列";
     let key = String(label);
     let name = String(label);
     let dash = false;
@@ -1431,7 +1895,7 @@ function roleChart(id, title, rows, xKey, yKey, xName, yName, guide) {
       name = String(row.month || label);
       type = "scatter";
     } else if (highlightOwn && role === "own") {
-      const engine = String(row.engine_code || row.series_engine_code || label);
+      const engine = String(row.engine_name || row.engine_code || row.series_engine_code || label);
       key = `own:${engine}`;
       name = engine;
       color = "#3f79b3";
@@ -1518,6 +1982,35 @@ function pairSeries(rows, xKey, yKey, name, index) {
   return { name, data, color: index == null ? "#9ccbbd" : windColor(index, 6) };
 }
 
+/** 数据不连贯(日期/月份有缺口)处插入 null,让折线断开、只保留散点 */
+function breakLineGaps(item) {
+  const data = item && item.data;
+  if (!Array.isArray(data) || data.length < 2) return;
+  const isMonth = String(data[0][0]).length === 7;
+  const sorted = data.slice().sort((a, b) => String(a[0]).localeCompare(String(b[0])));
+  const out = [];
+  for (let i = 0; i < sorted.length; i += 1) {
+    out.push(sorted[i]);
+    if (i < sorted.length - 1) {
+      const cur = new Date(isMonth ? `${sorted[i][0]}-01` : sorted[i][0]);
+      const nxt = new Date(isMonth ? `${sorted[i + 1][0]}-01` : sorted[i + 1][0]);
+      if (Number.isNaN(cur.getTime()) || Number.isNaN(nxt.getTime())) continue;
+      const step = isMonth
+        ? (nxt.getFullYear() - cur.getFullYear()) * 12 + (nxt.getMonth() - cur.getMonth())
+        : Math.round((nxt - cur) / 86400000);
+      if (step > 1) {
+        const gap = new Date(cur.getTime());
+        if (isMonth) gap.setMonth(gap.getMonth() + 1);
+        else gap.setDate(gap.getDate() + 1);
+        const y = gap.getFullYear();
+        const m = String(gap.getMonth() + 1).padStart(2, "0");
+        out.push([isMonth ? `${y}-${m}` : `${y}-${m}-${String(gap.getDate()).padStart(2, "0")}`, null]);
+      }
+    }
+  }
+  item.data = out;
+}
+
 function historyLines(id, title, rows, extras) {
   const bundles = [{ id, rows }].concat((extras || []).filter((item) => (
     item && item.rows && item.rows.some((row) => (
@@ -1551,6 +2044,7 @@ function historyLines(id, title, rows, extras) {
   const yName = valueFields.find(([key]) => bundles.some((bundle) => columnHasNumber(bundle.rows, key)));
   const residual = yName && yName[0] === "residual_c";
   const series = [];
+  const guides = [];
   bundles.forEach((bundle) => {
     const bundleName = bundle.id === id
       ? (bundles.length > 1 && id === "daily_difference" ? "日温差" : "")
@@ -1562,6 +2056,7 @@ function historyLines(id, title, rows, extras) {
         const groupName = residual && groups.length > 1 ? windowRoleLabel(group.name) : group.name;
         const item = pairSeries(group.rows, xKey, key, historyName(bundleName, residual ? groupName : group.name, valueLabel));
         if (!item) return;
+        item.metricKey = key;
         if (label === "EWMA") {
           item.dash = true;
           item.color = "#c29345";
@@ -1572,16 +2067,28 @@ function historyLines(id, title, rows, extras) {
       limitFields.forEach(([key, label]) => {
         const limitLabel = residual && key === "threshold_c" ? "偏热判断线" : label;
         const groupName = residual && groups.length > 1 ? windowRoleLabel(group.name) : group.name;
+        const constVal = constantLimit(group.rows, key);
+        if (constVal != null) {
+          guides.push({ y: constVal, label: `${limitLabel} ${formatGuide(constVal)}`, color: residual && key === "threshold_c" ? "#d08a3a" : "#e07070" });
+          return;
+        }
         const item = pairSeries(group.rows, xKey, key, historyName(bundleName, residual ? groupName : group.name, limitLabel));
         if (!item) return;
+        item.metricKey = key;
         item.dash = true;
         item.color = residual && key === "threshold_c" ? "#d08a3a" : "#e07070";
+        item.limit = true;
         series.push(item);
       });
     });
   });
   if (!series.length) return null;
-  const guides = [];
+  series.forEach((item) => {
+    if (item.limit) return;
+    item.showSymbol = true;
+    item.symbolSize = 4;
+    breakLineGaps(item);
+  });
   bundles.forEach((bundle) => {
     if (columnHasNumber(bundle.rows, "zero_c")) {
       guides.push({ y: finiteOf(bundle.rows, "zero_c", 0), label: residual ? "零偏差" : "零残差", color: "#9eb6a6" });
@@ -1615,7 +2122,6 @@ function ambientKind(bundleId) {
 }
 
 function isAmbientHistory(id, title, bundles) {
-  if (/历史变化与判定阈值/.test(`${id} ${title || ""}`)) return true;
   const kinds = bundles.map((bundle) => ambientKind(bundle.id));
   return kinds.includes("daily") && kinds.includes("daynight");
 }
@@ -1644,6 +2150,7 @@ function ambientHistoryChart(id, title, bundles, xKey) {
       line.width = 1.6;
       line.showSymbol = true;
       line.symbolSize = 4;
+      breakLineGaps(line);
       series.push(line);
     }
     [
@@ -1795,6 +2302,18 @@ function yawHist(id, title, rows, guides) {
   }
   const series = [bars, normal].filter(Boolean);
   if (!series.length) return null;
+  const degs = rows
+    .filter((row) => Number(row.density_per_deg) > 0)
+    .map((row) => Number(row.bin_center_deg));
+  let xMin = null;
+  let xMax = null;
+  if (degs.length) {
+    const lo = Math.min(...degs, 0);
+    const hi = Math.max(...degs, 0);
+    const pad = Math.max(2, (hi - lo) * 0.25);
+    xMin = lo - pad;
+    xMax = hi + pad;
+  }
   const guide = [];
   const row = (guides || [])[0] || {};
   [
@@ -1809,7 +2328,7 @@ function yawHist(id, title, rows, guides) {
   return {
     id,
     title,
-    option: darkLineOption(series, { xName: "偏航角 °", yName: "密度 1/°", guide }),
+    option: darkLineOption(series, { xName: "偏航角 °", yName: "密度 1/°", guide, xMin, xMax }),
     note,
   };
 }
@@ -1880,10 +2399,49 @@ function yawBandGuides(rows) {
   ];
 }
 
+/** 静态偏航误差总图:按 abs_offset_band 分档着色(<3° 绿 / 3-5° 黄 / ≥5° 红)。 */
+function yawStaticOverview(id, title, rows) {
+  const engCol = engineColumn(rows);
+  const names = uniqueValues(rows, engCol);
+  if (!names.length) return null;
+  const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
+  const bands = [
+    ["<3", "偏航角 < 3°", "#288c50"],
+    ["3-5", "3° ≤ 偏航角 < 5°", "#c8a014"],
+    [">=5", "偏航角 ≥ 5°", "#c83c3c"],
+  ];
+  const series = [];
+  bands.forEach(([band, label, color]) => {
+    const data = names.map((name) => {
+      const row = rowOf(name);
+      if (String(row && row.abs_offset_band || "") !== band) return null;
+      const v = Number(row && row.offset_deg);
+      return Number.isFinite(v) ? v : null;
+    });
+    if (data.some((value) => value != null)) {
+      series.push({ name: label, type: "bar", barMaxWidth: 18, color, data });
+    }
+  });
+  if (!series.length) return null;
+  return {
+    id,
+    title,
+    option: darkLineOption(series, {
+      category: true,
+      categories: names,
+      boundaryGap: true,
+      xName: "机组",
+      yName: "偏航角 °",
+      guide: yawBandGuides(rows),
+    }),
+  };
+}
+
 function metricPoints(id, title, rows) {
-  const names = uniqueValues(rows, "engine_code");
+  const engCol = engineColumn(rows);
+  const names = uniqueValues(rows, engCol);
   if (!names.length) return null;
-  const rowOf = (name) => rows.find((item) => String(item.engine_code) === name);
+  const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
   const pick = (row, keys) => {
     const key = keys.find((item) => row && Number.isFinite(Number(row[item])));
     return key ? Number(row[key]) : null;
@@ -1963,10 +2521,57 @@ function finiteOrNull(value) {
   return Number.isFinite(number) ? number : null;
 }
 
+function engineScatter(id, title, rows, yKey, yName, guide, yScale) {
+  const engCol = engineColumn(rows);
+  const names = uniqueValues(rows, engCol);
+  if (!names.length) return null;
+  const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
+  const values = names.map((name) => {
+    const row = rowOf(name);
+    return finiteOrNull(row && row[yKey]);
+  });
+  if (!values.some((value) => Number.isFinite(value))) return null;
+  const series = [{
+    name: yName,
+    type: "scatter",
+    symbol: "circle",
+    symbolSize: 8,
+    color: "#4c8fd6",
+    z: 4,
+    data: values,
+  }];
+  (guide || []).forEach((item) => {
+    if (!item || !Number.isFinite(Number(item.y))) return;
+    series.push({
+      name: item.label || "参考线",
+      type: "line",
+      color: item.color || "#d9504f",
+      width: 1.8,
+      z: 2,
+      dash: true,
+      showSymbol: false,
+      data: names.map(() => item.y),
+    });
+  });
+  return {
+    id,
+    title,
+    option: darkLineOption(series, {
+      category: true,
+      categories: names,
+      boundaryGap: true,
+      xName: "机组",
+      yName,
+      yScale: !!yScale,
+    }),
+  };
+}
+
 function engineBars(id, title, rows, yKey, yName, limits, guide, yScale) {
-  const names = uniqueValues(rows, "engine_code");
+  const engCol = engineColumn(rows);
+  const names = uniqueValues(rows, engCol);
   if (!names.length) return null;
-  const rowOf = (name) => rows.find((item) => String(item.engine_code) === name);
+  const rowOf = (name) => rows.find((item) => String(item[engCol]) === name);
   const values = names.map((name) => {
     const row = rowOf(name);
     return finiteOrNull(row && row[yKey]);
@@ -2028,6 +2633,11 @@ function uniqueValues(rows, key) {
   return names;
 }
 
+/** 机组分组列:优先 engine_name,缺省回退 engine_code */
+function engineColumn(rows) {
+  return uniqueValues(rows, "engine_name").length ? "engine_name" : "engine_code";
+}
+
 function dedupeRows(rows, xKey) {
   const seen = new Set();
   return rows.filter((row) => {
@@ -2039,7 +2649,7 @@ function dedupeRows(rows, xKey) {
 }
 
 function splitGroups(rows) {
-  const key = ["channel_code", "engine_code", "window_role", "period_role"].find((name) => uniqueValues(rows, name).length > 1);
+  const key = ["channel_code", "engine_name", "engine_code", "window_role"].find((name) => uniqueValues(rows, name).length > 1);
   if (!key) return [{ name: "", rows }];
   return uniqueValues(rows, key).map((name) => ({
     name,

+ 34 - 8
src/views/system/index.vue

@@ -29,14 +29,22 @@
 <script>
 export default {
   name: "SystemIndex",
-  data() {
-    return {
-      tabs: [
-        { name: "用户管理", path: "/home/system/userMag" },
-        { name: "角色管理", path: "/home/system/roleMag" },
-        { name: "菜单权限", path: "/home/system/menuMag" },
-      ],
-    };
+  computed: {
+    // 子菜单动态取自后端权限树(userInfo.permission),与路由当前所属节点对齐
+    tabs() {
+      const permission =
+        (this.$store.state.auth &&
+          this.$store.state.auth.userInfo &&
+          this.$store.state.auth.userInfo.permission) ||
+        [];
+      const node = findPermissionNode(permission, this.shellRootPath());
+      if (!node || !Array.isArray(node.children)) return [];
+      return node.children
+        .filter((child) => child.permissionType === 2 && child.permissionShow === 1)
+        .slice()
+        .sort((a, b) => (a.permissionSort || 0) - (b.permissionSort || 0))
+        .map((child) => ({ name: child.permissionName, path: child.permissionCode }));
+    },
   },
   methods: {
     isActive(path) {
@@ -46,8 +54,26 @@ export default {
       if (this.$route.path === path) return;
       this.$router.push(path).catch(() => {});
     },
+    // /home/system/userMag -> /home/system;/home/Ledger/enterprise -> /home/Ledger
+    shellRootPath() {
+      const segments = (this.$route.path || "").split("/").filter(Boolean);
+      return segments.length >= 2
+        ? `/${segments.slice(0, 2).join("/")}`
+        : this.$route.path || "";
+    },
   },
 };
+
+function findPermissionNode(nodes, code) {
+  if (!Array.isArray(nodes)) return null;
+  for (const node of nodes) {
+    if (!node) continue;
+    if (node.permissionCode === code) return node;
+    const found = findPermissionNode(node.children, code);
+    if (found) return found;
+  }
+  return null;
+}
 </script>
 <style lang="scss">
 /* 权限管理:对齐 ranking 深色壳,仅 .system-shell 内生效 */