rui.jiang 2 weeks ago
parent
commit
1b9d7e7d88

BIN
src/assets/logoZN.png


+ 10 - 0
src/views/health/components/malfunction/temperature.vue

@@ -91,6 +91,8 @@
           :lineType="item.lineType"
           :lineColor="item.lineColor"
           :chartData="item.data"
+           :fieldCode="fieldCode"
+        :windTurbineNumber="windTurbineNumber"
         />
       </div>
     </div>
@@ -126,6 +128,14 @@ export default {
       type: Number,
       default: 0,
     },
+    fieldCode: {
+      type: String,
+      default: "",
+    },
+    windTurbineNumber: {
+      type: String,
+      default: "",
+    },
   },
   data() {
     return {

+ 81 - 1
src/views/health/components/malfunction/zhexian.vue

@@ -1,5 +1,16 @@
 <template>
-  <div ref="chartRef" style="width: 100%; height: 100%"></div>
+  <div>
+    <div ref="chartRef" style="width: 100%; height: 320px"></div>
+    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
+      <el-table :data="tableData" style="width: 100%">
+        <el-table-column prop="date" label="日期" width="180">
+        </el-table-column>
+        <el-table-column prop="name" label="姓名" width="180">
+        </el-table-column>
+        <el-table-column prop="address" label="地址"> </el-table-column>
+      </el-table>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
@@ -27,10 +38,43 @@ export default {
         values: [],
       }),
     },
+    fieldCode: {
+      // 新增 fieldCode 属性
+      type: String,
+      default: "",
+    },
+    windTurbineNumber: {
+      // 新增 windTurbineNumber 属性
+      type: String,
+      default: "",
+    },
   },
   data() {
     return {
       myChart: null,
+      dialogVisible: false,
+      tableData: [
+        {
+          date: "2016-05-02",
+          name: "王小虎",
+          address: "上海市普陀区金沙江路 1518 弄",
+        },
+        {
+          date: "2016-05-04",
+          name: "王小虎",
+          address: "上海市普陀区金沙江路 1517 弄",
+        },
+        {
+          date: "2016-05-01",
+          name: "王小虎",
+          address: "上海市普陀区金沙江路 1519 弄",
+        },
+        {
+          date: "2016-05-03",
+          name: "王小虎",
+          address: "上海市普陀区金沙江路 1516 弄",
+        },
+      ],
     };
   },
   watch: {
@@ -53,7 +97,43 @@ export default {
     initChart() {
       this.myChart = echarts.init(this.$refs.chartRef);
       this.updateChart();
+
+      this.myChart.getZr().on("click", (params) => {
+        const pointInPixel = [params.offsetX, params.offsetY];
+        const pointInGrid = this.myChart.convertFromPixel(
+          { xAxisIndex: 0, yAxisIndex: 0 },
+          pointInPixel
+        );
+        const clickedTime = pointInGrid[0];
+
+        if (!this.chartData.timestamps.length) return;
+
+        // 找最接近点击时间的索引
+        let minDiff = Infinity;
+        let closestIndex = -1;
+        for (let i = 0; i < this.chartData.timestamps.length; i++) {
+          const time = new Date(this.chartData.timestamps[i]).getTime();
+          const diff = Math.abs(time - clickedTime);
+          if (diff < minDiff) {
+            minDiff = diff;
+            closestIndex = i;
+          }
+        }
+
+        if (closestIndex !== -1) {
+          const value = this.chartData.values[closestIndex];
+          const time = this.chartData.timestamps[closestIndex];
+          if (value === 1) {
+            console.log("点击对应的values值:", value);
+            console.log("对应的timestamps:", time);
+            console.log("fieldCode:", this.fieldCode);
+            console.log("windTurbineNumber:", this.windTurbineNumber);
+            // this.dialogVisible = !this.dialogVisible
+          }
+        }
+      });
     },
+
     updateChart() {
       if (!this.myChart || !this.chartData.timestamps.length) return;
 

+ 151 - 78
src/views/health/malfunction copy.vue → src/views/health/malfunction copy 2.vue

@@ -91,11 +91,12 @@
           start-placeholder="开始日期"
           end-placeholder="结束日期"
         />
+        <!-- :picker-options="datePickerOptions" -->
       </p>
       <el-button
         type="primary"
         size="small"
-        @click="conditions(1)"
+        @click="onSearchClick"
         class="search-btn"
         >查询</el-button
       >
@@ -105,6 +106,7 @@
     <div class="main-body">
       <keep-alive>
         <component
+          ref="activeComponent"
           :is="activeTab"
           :codedata="tabData[activeTab].codedata"
           v-bind="
@@ -114,6 +116,8 @@
           "
           :totalCount="tabData[activeTab].totalCount"
           :totalPage="tabData[activeTab].totalPage"
+          :fieldCode="tabConditions[activeTab].companyCode"
+          :windTurbineNumber="tabConditions[activeTab].unitvalue"
           @updatePage="handlePageChange"
         />
       </keep-alive>
@@ -150,8 +154,8 @@ export default {
   },
   data() {
     return {
-      activeTab: "Temperature",
-      activeName: "Temperature",
+      activeTab: "Bearing",
+      activeName: "Bearing",
       menuItems: [
         {
           name: "轴承诊断",
@@ -205,6 +209,24 @@ export default {
           echartsdata: {},
         },
       },
+      datePickerOptions: {
+        onPick: ({ minDate, maxDate }) => {
+          if (minDate && !maxDate) {
+            const maxTime = new Date(
+              minDate.getTime() + 30 * 24 * 60 * 60 * 1000
+            );
+            this.datePickerOptions.disabledDate = (time) => {
+              return (
+                time.getTime() < minDate.getTime() ||
+                time.getTime() > maxTime.getTime()
+              );
+            };
+          } else {
+            this.datePickerOptions.disabledDate = () => false;
+          }
+        },
+        disabledDate: () => false,
+      },
     };
   },
   created() {
@@ -241,9 +263,7 @@ export default {
     },
     parentChange(data) {
       const condition = this.tabConditions[this.activeTab];
-
       if (!data?.codeNumber) return;
-
       condition.unitvalue = "";
       condition.monitoringvalue = "";
       condition.frequencyvalue = "";
@@ -257,10 +277,14 @@ export default {
       });
 
       axios
-        .get(`/ETLapi/waveData/getAllSamplingFrequency/${data.codeNumber}`)
-        .then((res) => {
-          condition.frequencyoptions = res.data.datas;
-        });
+ .get(`/ETLapi/waveData/getAllSamplingFrequency/${data.codeNumber}`)
+.then((res) => {
+  condition.frequencyoptions = (res.data.datas || [])
+    .map(item => Number(item))
+    .filter(num => num >= 12800)
+    .map(num => num.toString());
+});
+
 
       condition.companyCode = data.codeNumber;
     },
@@ -275,7 +299,7 @@ export default {
           if (res.data.code === 500) {
             condition.monitoringoptions = [];
             this.$message({
-              message: res.data.message || "未知错误",
+              message: "当前风场不存在测点和采样频率数据" || "未知错误",
               type: "warning",
             });
             return;
@@ -309,82 +333,131 @@ export default {
       });
       return processedData;
     },
+    onSearchClick() {
+      this.conditions(1, false); // 主动查询,第一页,非分页触发
+    },
     handlePageChange(page) {
-      this.conditions(page);
+      this.conditions(page, true); // true 表示分页触发
     },
-    conditions(page) {
-      const tab = this.activeTab;
-      const condition = this.tabConditions[tab];
-
-      const params = {
-        samplingFrequency: condition.frequencyvalue,
-        windCode: condition.companyCode,
-        windTurbineNumberList: [condition.unitvalue],
-        mesureNameList: [condition.monitoringvalue],
-        startTime: this.$formatDateTWO(condition.timevalue[0]),
-        endTime: this.$formatDateTWO(condition.timevalue[1]),
-        pageNo: page,
-        pageSize: 10,
-      };
 
-      if (tab === "Temperature") {
-        const temperature = {
-          windCode: "WOF046400029",
-          windTurbineNumberList: ["WOG01312"],
-          startTime: "2023-10-01 00:00",
-          endTime: "2023-10-07 00:00",
-          pageNo: page,
-          pageSize: 500,
-        };
-
-        const loading = this.$loading({
-          lock: true,
-          text: "温度诊断数据加载中,请稍候…",
-          spinner: "el-icon-loading",
-          background: "rgba(0, 0, 0, 0.8)", // 稍浅一些,更柔和
-          customClass: "custom-loading-style", // 可选:如果你有样式可以加类名
-        });
+    conditions(page, isPageChange = false) {
+      const tab = this.activeTab;
+      this.$nextTick(() => {
+        const comp = this.$refs.activeComponent;
+        if (comp && typeof comp.reset === "function") {
+          comp.reset();
+        }
+      });
 
-        const thresholdReq = axios
-          .post("/AnalysisMulti/temperature/threshold", temperature)
-          .then((res) => {
-            const data = res.data.data.records || [];
-            this.tabData[tab].codedata = data;
-            this.tabData[tab].totalCount = res.data.data.totalSize || 0;
-            console.log("温度诊断总数:", res.data.data.totalSize);
-          })
-          .catch((err) => {
-            console.error("温度诊断请求失败:", err);
-            this.$message.error("温度诊断数据请求失败,请稍后再试");
+      // 把后面接口请求部分放进延迟里,确保 reset 先执行完成
+      setTimeout(() => {
+        const condition = this.tabConditions[tab];
+
+        if (tab === "Temperature") {
+          const temperature = {
+            windCode: condition.companyCode,
+            windTurbineNumberList: [condition.unitvalue],
+            startTime: this.$formatDateTWO(condition.timevalue[0]),
+            endTime: this.$formatDateTWO(condition.timevalue[1]),
+            pageNo: page,
+            pageSize: 500,
+          };
+
+          const loading = this.$loading({
+            lock: true,
+            text: "温度诊断数据加载中,请稍候…",
+            spinner: "el-icon-loading",
+            background: "rgba(0, 0, 0, 0.8)",
           });
 
-        const trendReq = axios
-          .post("/AnalysisMulti/SPRT/trend", temperature)
-          .then((res) => {
-            const echartsdata = res.data.data || {};
-            this.tabData[tab].echartsdata = echartsdata;
-            console.log("趋势图数据:", echartsdata);
-          })
-          .catch((err) => {
-            console.error("趋势图请求失败:", err);
-            this.$message.error("温度趋势图数据请求失败,请稍后再试");
-          });
+          const emptyEchartsData = {
+            gearbox_oil: { timestamps: [], values: [] },
+            generator_drive_end: { timestamps: [], values: [] },
+            generator_nondrive_end: { timestamps: [], values: [] },
+            main_bearing: { timestamps: [], values: [] },
+          };
+
+          const trendRequest = () => {
+            const trendStart = performance.now();
+            return axios
+              .post("/AnalysisMulti/SPRT/trend", temperature)
+              .then((res) => {
+                const trendEnd = performance.now();
+                console.log(
+                  `温度诊断 trend 接口耗时: ${(
+                    (trendEnd - trendStart) /
+                    1000
+                  ).toFixed(2)}s`
+                );
+                const echartsdata = res.data.data || {};
+                this.tabData[tab].echartsdata = echartsdata;
+              })
+              .catch((err) => {
+                console.error("趋势图请求失败:", err);
+                this.$message.error("温度趋势图数据请求失败,请稍后再试");
+              });
+          };
+
+          const thresholdStart = performance.now();
+          const thresholdReq = axios
+            .post("/AnalysisMulti/temperature/threshold", temperature)
+            .then((res) => {
+              const thresholdEnd = performance.now();
+              console.log(
+                `温度诊断 threshold 接口耗时: ${(
+                  (thresholdEnd - thresholdStart) /
+                  1000
+                ).toFixed(2)}s`
+              );
+
+              const data = res.data.data.records || [];
+              this.tabData[tab].codedata = data;
+              this.tabData[tab].totalCount = res.data.data.totalSize || 0;
+
+              if (!data.length) {
+                this.$message.warning("暂无诊断数据");
+                this.tabData[tab].echartsdata = emptyEchartsData;
+                return Promise.resolve("skip trend");
+              }
+
+              return isPageChange ? Promise.resolve() : trendRequest();
+            })
+            .catch((err) => {
+              console.error("温度诊断请求失败:", err);
+              this.$message.error("温度诊断数据请求失败,请稍后再试");
+            });
 
-        // 所有请求完成后关闭 loading
-        Promise.allSettled([thresholdReq, trendReq]).finally(() => {
-          loading.close();
-        });
-      } else {
-        // 默认其他组件逻辑
-        axios
-          .post("/ETLapi/waveData/getMesureDataWithSF", params)
-          .then((res) => {
-            const data = res.data || {};
-            this.tabData[tab].codedata = data.datas || [];
-            this.tabData[tab].totalCount = data.totalCount || 0;
-            this.tabData[tab].totalPage = data.totalPage || 0;
+          Promise.resolve(thresholdReq).finally(() => {
+            loading.close();
           });
-      }
+        } else {
+          const params = {
+            samplingFrequency: condition.frequencyvalue,
+            windCode: condition.companyCode,
+            windTurbineNumberList: [condition.unitvalue],
+            mesureNameList: [condition.monitoringvalue],
+            startTime: this.$formatDateTWO(condition.timevalue[0]),
+            endTime: this.$formatDateTWO(condition.timevalue[1]),
+            pageNo: page,
+            pageSize: 10,
+          };
+
+          const startTime = performance.now();
+          axios
+            .post("/ETLapi/waveData/getMesureDataWithSF", params)
+            .then((res) => {
+              const endTime = performance.now();
+              console.log(
+                `其他 tab 接口请求耗时: ${(endTime - startTime).toFixed(2)}ms`
+              );
+
+              const data = res.data || {};
+              this.tabData[tab].codedata = data.datas || [];
+              this.tabData[tab].totalCount = data.totalCount || 0;
+              this.tabData[tab].totalPage = data.totalPage || 0;
+            });
+        }
+      }, 300); // 延迟100毫秒执行接口请求逻辑
     },
   },
 };

+ 16 - 6
src/views/health/vibration.vue

@@ -403,11 +403,10 @@ export default {
       return point ? point?.detectionPointCn : null; // 如果没有找到对应项,返回 null
     },
 
-     NewgetDetectionPointCn(key) {
-      return this.pointNameMap[key] || key
+    NewgetDetectionPointCn(key) {
+      return this.pointNameMap[key] || key;
     },
-  
-  
+
     getCompanyLabel(companyCode) {
       const selectedOption = this.parentOpt?.find(
         (option) => option.codeNumber === companyCode
@@ -763,10 +762,21 @@ export default {
       axios
         .post("/AnalysisMulti/analysis/trend", params)
         .then((res) => {
-          this.qsList = JSON.parse(res.data);
+          let jsonStr = res.data;
+          // ① 仅字符串才处理
+          if (typeof jsonStr === "string") {
+            // ② 将 "NaN" 或裸 NaN 替换为 null(更安全的方式)
+            jsonStr = jsonStr.replace(/\bNaN\b/g, "null"); // 替换裸 NaN
+          }
+          console.log(jsonStr, "jsonStr");
+          
+          // ③ 再解析为对象
+          this.qsList = JSON.parse(jsonStr);
           this.fourList.push(newItem);
         })
-        .catch((error) => {});
+        .catch((error) => {
+          console.error("趋势图接口报错:", error);
+        });
     },
 
     conditions() {

+ 1 - 1
src/views/ledger/windsite.vue

@@ -861,7 +861,7 @@ export default {
           params.fieldCode = this.detail.fieldCode;
         }
         console.log(this.form, params);
-        return;
+        // return;
 
         // Determine which API to call
         const API = this.isEdit

+ 2 - 2
vue.config.js

@@ -66,8 +66,8 @@ module.exports = {
         // target: "http://192.168.5.4:16200", // 石月
         // target: "http://192.168.50.235:16200", // 内网
         // target: "http://192.168.5.15:16200",
-        target: "http://192.168.50.235:16500", //演示环境
-        // target: "http://106.120.102.238:26500", //外网演示环境
+        // target: "http://192.168.50.235:16500", //演示环境
+        target: "http://106.120.102.238:26500", //外网演示环境
         // target: "http://106.120.102.238:16700", // 外网16700  生产16600
         // target: "http://10.96.137.5",
         changeOrigin: true,