Przeglądaj źródła

生成报告代码,

liujiejie 2 miesięcy temu
rodzic
commit
0cdd0b0744
35 zmienionych plików z 688 dodań i 187 usunięć
  1. BIN
      downLoadServer/downLoadServer.textClipping
  2. BIN
      downLoadServer/src/public/file/文字文稿1.docx
  3. 101 9
      downLoadServer/src/server/controllers/chartController.js
  4. 11 4
      downLoadServer/src/server/controllers/uploadController.js
  5. 5 0
      downLoadServer/src/server/routes/chartRoutes.js
  6. 2 0
      downLoadServer/src/server/routes/exampleRoutes.js
  7. 3 3
      downLoadServer/src/server/utils/chartsCom/3DDrawingChart.js
  8. 2 2
      downLoadServer/src/server/utils/chartsCom/BarChart.js
  9. 2 2
      downLoadServer/src/server/utils/chartsCom/BoxLineCharts.js
  10. 3 3
      downLoadServer/src/server/utils/chartsCom/BoxMarkersCharts.js
  11. 3 3
      downLoadServer/src/server/utils/chartsCom/ColorbarInitTwoDmarkersChart.js
  12. 2 2
      downLoadServer/src/server/utils/chartsCom/FaultAll.js
  13. 2 2
      downLoadServer/src/server/utils/chartsCom/FaultUnit.js
  14. 2 2
      downLoadServer/src/server/utils/chartsCom/GeneratorTemperature.js
  15. 2 2
      downLoadServer/src/server/utils/chartsCom/HeatmapCharts.js
  16. 165 7
      downLoadServer/src/server/utils/chartsCom/PlotlyCharts.js
  17. 217 0
      downLoadServer/src/server/utils/chartsCom/PlotlyChartsFen.js
  18. 2 2
      downLoadServer/src/server/utils/chartsCom/Radar.js
  19. 2 2
      downLoadServer/src/server/utils/chartsCom/Time3DChart.js
  20. 2 2
      downLoadServer/src/server/utils/chartsCom/TwoDMarkersChart.js
  21. 2 2
      downLoadServer/src/server/utils/chartsCom/TwoDMarkersChart1.js
  22. 2 2
      downLoadServer/src/server/utils/chartsCom/WindRoseChart.js
  23. 2 2
      downLoadServer/src/server/utils/chartsCom/YewErrorBarChart.js
  24. 2 17
      downLoadServer/src/server/utils/chartsCom/lineAndChildLine.js
  25. 2 3
      downLoadServer/src/server/utils/chartsCom/lineChartsFen.js
  26. 3 3
      downLoadServer/src/server/utils/chartsCom/powerMarkers2DCharts.js
  27. 0 49
      downLoadServer/src/server/utils/chartsCom/productionIndicatorTotal.js
  28. 2 2
      downLoadServer/src/server/utils/chartsCom/yawErrorBarSum.js
  29. 3 3
      downLoadServer/src/server/utils/chartsCom/yawErrorLine.js
  30. 5 2
      downLoadServer/src/server/utils/copyFileCsv.js
  31. 25 0
      src/utils/common.js
  32. 34 0
      src/utils/downloadFile.js
  33. 75 52
      src/views/performance/assetssMag.vue
  34. 3 3
      src/views/performance/js/allAnalysisType.js
  35. BIN
      归档.zip

BIN
downLoadServer/downLoadServer.textClipping


BIN
downLoadServer/src/public/file/文字文稿1.docx


+ 101 - 9
downLoadServer/src/server/controllers/chartController.js

@@ -19,10 +19,15 @@ import { getFaultAllCharts } from "../utils/chartsCom/FaultAll.js";
 import { getFaultUnitCharts } from "../utils/chartsCom/FaultUnit.js";
 import { getYawErrorBarSumCharts } from "../utils/chartsCom/yawErrorBarSum.js";
 import { getYewErrorBarChart } from "../utils/chartsCom/YewErrorBarChart.js";
+import { generatePlotlyCharts } from "../utils/chartsCom/PlotlyCharts.js";
+import { generatePlotlyChartsFen } from "../utils/chartsCom/PlotlyChartsFen.js";
 // import { getProductionIndicatorTotal } from "../utils/chartsCom/productionIndicatorTotal.js";
 import { copyFileDocx } from "../utils/copyFileCsv.js";
 import axios from "axios";
 import Papa from "papaparse";
+import fs from "fs-extra";
+import path from "path";
+import FormData from "form-data";
 
 // 提取公共逻辑到辅助函数
 const handleChartGeneration = async (
@@ -213,7 +218,23 @@ export const createLineAndChildLine = async (req, res) => {
     "折线图生成成功"
   );
 };
+//createPlotlyChartsFen
+export const createPlotlyChartsFen = async (req, res) => {
+  const { fieldEngineCode } = req.body;
+  await handleChartGeneration(
+    req,
+    res,
+    generatePlotlyChartsFen,
+    "折线图生成成功",
+    {
+      fieldEngineCode,
+    }
+  );
+};
 
+export const createPlotlyCharts = async (req, res) => {
+  await handleChartGeneration(req, res, generatePlotlyCharts, "折线图生成成功");
+};
 export const createHeatmapCharts = async (req, res) => {
   await handleChartGeneration(req, res, generateHeatmapChart, "热力图生成成功");
 };
@@ -312,29 +333,100 @@ export const createRadarCharts = async (req, res) => {
   await fetchCsvAndParse(req, res, getRadarCharts, "雷达图生成成功");
 };
 
+const MAX_FILE_SIZE = 100 * 1024 * 1024; // 10MB
+const ALLOWED_EXTENSIONS = [".docx"];
+const TEMP_FILE_DIR = path.join(process.cwd(), "src", "public", "file");
+
 export const createCopyFileCsv = async (req, res) => {
+  let result = null;
+  let tempFilePath = null;
+
   try {
-    // 从请求体中获取 fieldInfo
-    const { fieldInfo } = req.body;
+    const { fieldInfo, bucketName, objectName } = req.body;
 
-    if (!fieldInfo) {
+    // 1. 参数验证
+    if (!fieldInfo || !bucketName || !objectName) {
       return res.status(400).json({
         success: false,
-        message: "缺少必要的 fieldInfo 参数",
+        message: "缺少必要的参数",
       });
     }
 
-    const result = await copyFileDocx(fieldInfo, req.body);
+    // 2. 生成文档
+    result = await copyFileDocx(fieldInfo, req.body);
+    tempFilePath = result.url;
+
+    // 3. 验证生成的文件
+    const stats = await fs.stat(tempFilePath);
+
+    // 检查文件大小
+    if (stats.size > MAX_FILE_SIZE) {
+      throw new Error(
+        `生成的文件超过大小限制 (${MAX_FILE_SIZE / 1024 / 1024}MB)`
+      );
+    }
+
+    console.log("开始上传文件到 MinIO...");
+    // 直接调用上传接口,传递文件路径
+    const response = await axios.post(
+      `${process.env.API_BASE_URL}/examples/upload`,
+      {
+        filePath: tempFilePath,
+        bucketName,
+        objectName: `${objectName}/${path.basename(tempFilePath)}`,
+      }
+    );
+
+    if (!response?.data?.url) {
+      throw new Error("文件上传失败:未获取到URL");
+    }
+
+    console.log("文件上传成功");
+
+    // 4. 清理临时文件
+    await fs.unlink(tempFilePath).catch(console.error);
+    console.log("临时文件已清理");
+
+    // 5. 返回成功响应
     res.json({
       success: true,
-      message: result,
+      message: response.data.url,
+      data: {
+        url: response.data.url,
+        fileName: path.basename(tempFilePath),
+        fileSize: stats.size,
+        uploadTime: new Date().toISOString(),
+      },
     });
   } catch (error) {
-    console.error("生成文档失败:", error);
+    console.error("文件处理失败:", error);
+
+    // 6. 错误处理
+    let errorMessage = "文件处理失败";
+
+    if (error.response) {
+      errorMessage = `上传失败: ${
+        error.response.data?.message || error.message
+      }`;
+    } else if (error.code === "ENOENT") {
+      errorMessage = "文件不存在或无法访问";
+    } else if (error.code === "EACCES") {
+      errorMessage = "文件访问权限不足";
+    } else {
+      errorMessage = error.message;
+    }
+
+    // 7. 清理临时文件
+    if (tempFilePath) {
+      await fs.unlink(tempFilePath).catch(console.error);
+      console.log("临时文件已清理");
+    }
+
+    // 8. 返回错误响应
     res.status(500).json({
       success: false,
-      message: "生成文档失败",
-      error: error.message,
+      message: errorMessage,
+      error: process.env.NODE_ENV === "development" ? error.stack : undefined,
     });
   }
 };

+ 11 - 4
downLoadServer/src/server/controllers/uploadController.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-04-28 14:46:54
- * @LastEditTime: 2025-05-14 13:42:13
+ * @LastEditTime: 2025-05-26 16:19:14
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/controllers/uploadController.js
@@ -34,14 +34,13 @@ export const uploadFile = async (req, res) => {
   const bucketName = req.body.bucketName; // 您的桶名称
   const filePath = req.body.filePath; // 从 req.body 中获取文件路径
   const objectName = req.body.objectName; // 在 MinIO 中的文件名
-  // const bucketName = "bucket-zhzn"; // 您的桶名称
-  // const filePath = req.body.filePath; // 从 req.body 中获取文件路径
-  // const objectName = "charts/analysisTypeAll/bar.png"; // 在 MinIO 中的文件名
   // 检查 filePath 是否有效
   if (typeof filePath !== "string" || !filePath) {
     return res.status(400).json({ message: "Invalid file path" });
   }
   try {
+    // 确保文件存在
+    await fs.access(filePath);
     // 调用 uploadFileToMinIO 函数上传文件
     await uploadFileToMinIO(bucketName, filePath, objectName);
     // 构造文件的 URL
@@ -60,3 +59,11 @@ export const uploadFile = async (req, res) => {
   }
 };
 export const uploadMiddleware = upload.single("file");
+
+export const downloadFile = async (req, res) => {
+  const bucketName = req.body.bucketName;
+  const objectName = req.body.objectName;
+  const filePath = req.body.filePath;
+  const url = `http://${process.env.MINIO_ENDPOINT}:${process.env.MINIO_PORT}/${bucketName}/${objectName}`;
+  res.status(200).json({ url, message: "File downloaded successfully" });
+};

+ 5 - 0
downLoadServer/src/server/routes/chartRoutes.js

@@ -22,6 +22,8 @@ import {
   createyawErrorBarSumCharts,
   createProductionIndicatorTotal,
   createCopyFileCsv,
+  createPlotlyChartsFen,
+  createPlotlyCharts,
 } from "../controllers/chartController.js";
 
 const router = express.Router();
@@ -52,4 +54,7 @@ router.post("/yawErrorBarSumChart", createyawErrorBarSumCharts);
 router.post("/productionIndicatorTotal", createProductionIndicatorTotal);
 router.post("/radarChart", createRadarCharts);
 router.post("/CopyFileCsv", createCopyFileCsv);
+router.post("/PlotlyChartsFen", createPlotlyChartsFen);
+router.post("/PlotlyCharts", createPlotlyCharts);
+
 export default router;

+ 2 - 0
downLoadServer/src/server/routes/exampleRoutes.js

@@ -3,6 +3,7 @@ import { getExample, createExample } from "../controllers/exampleController.js";
 import {
   uploadFile,
   uploadMiddleware,
+  downloadFile,
 } from "../controllers/uploadController.js"; // 导入上传控制器
 
 const router = express.Router();
@@ -10,4 +11,5 @@ const router = express.Router();
 router.get("/", getExample);
 router.post("/", createExample);
 router.post("/upload", uploadMiddleware, uploadFile); // 添加上传路由
+router.post("/downLoadCsv", downloadFile);
 export default router;

+ 3 - 3
downLoadServer/src/server/utils/chartsCom/3DDrawingChart.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-04-14 16:09:13
- * @LastEditTime: 2025-05-21 15:09:29
+ * @LastEditTime: 2025-05-26 10:55:37
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/utils/chartsCom/3DDrawingChart.js
@@ -22,7 +22,7 @@ export const generate3DDrawingChart = async (data, bucketName, objectName) => {
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_heatmap_chart_${Date.now()}.png`
+      `temp_heatmap_chart_${Date.now()}.jpeg`
     );
     // 获取 plotly.js 的绝对路径
     const plotlyPath = path.join(
@@ -199,7 +199,7 @@ export const generate3DDrawingChart = async (data, bucketName, objectName) => {
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/BarChart.js

@@ -18,7 +18,7 @@ export const generateBarChart = async (data, bucketName, objectName) => {
     // 创建临时目录
     const tempDir = path.join(process.cwd(), "images");
     await fs.ensureDir(tempDir);
-    const tempFilePath = path.join(tempDir, `temp_chart_${Date.now()}.png`);
+    const tempFilePath = path.join(tempDir, `temp_chart_${Date.now()}.jpeg`);
 
     // 获取 plotly.js 的绝对路径
     const plotlyPath = path.join(
@@ -175,7 +175,7 @@ export const generateBarChart = async (data, bucketName, objectName) => {
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/BoxLineCharts.js

@@ -28,7 +28,7 @@ export const generateBoxLineChart = async (data, bucketName, objectName) => {
     // 创建临时目录
     const tempDir = path.join(process.cwd(), "images");
     await fs.ensureDir(tempDir);
-    const tempFilePath = path.join(tempDir, `temp_chart_${Date.now()}.png`);
+    const tempFilePath = path.join(tempDir, `temp_chart_${Date.now()}.jpeg`);
 
     // 获取 plotly.js 的绝对路径
     const plotlyPath = path.join(
@@ -158,7 +158,7 @@ export const generateBoxLineChart = async (data, bucketName, objectName) => {
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 3 - 3
downLoadServer/src/server/utils/chartsCom/BoxMarkersCharts.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-05-13 11:02:32
- * @LastEditTime: 2025-05-21 15:10:00
+ * @LastEditTime: 2025-05-26 10:57:41
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/utils/chartsCom/BoxMarkersCharts.js
@@ -177,10 +177,10 @@ export const generateBoxMarkersCharts = async (
     const tempFilePath = path.join(
       process.cwd(),
       "images",
-      `chart_${Date.now()}.png`
+      `chart_${Date.now()}.jpeg`
     );
     const chartElement = await page.$("#chart");
-    await chartElement.screenshot({ path: tempFilePath, type: "png" });
+    await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
 
     // 上传图片到服务器
     const formData = new FormData();

+ 3 - 3
downLoadServer/src/server/utils/chartsCom/ColorbarInitTwoDmarkersChart.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-04-28 10:27:00
- * @LastEditTime: 2025-05-23 15:32:06
+ * @LastEditTime: 2025-05-26 10:58:01
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/utils/chartsCom/ColorbarInitTwoDmarkersChart.js
@@ -25,7 +25,7 @@ export const generateColorbarInitTwoDmarkersChart = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_scatter_chart_${Date.now()}.png`
+      `temp_scatter_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -196,7 +196,7 @@ export const generateColorbarInitTwoDmarkersChart = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/FaultAll.js

@@ -112,7 +112,7 @@ export const getFaultAllCharts = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_fault_all_chart_${Date.now()}.png`
+      `temp_fault_all_chart_${Date.now()}.jpeg`
     );
 
     // 使用 Puppeteer 生成图表的截图
@@ -156,7 +156,7 @@ export const getFaultAllCharts = async (
       });
       // 截图并保存到临时文件
       const chartElement = await page.$("#chart");
-      await chartElement.screenshot({ path: tempFilePath, type: "png" });
+      await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
       // 上传图片到服务器
       const formData = new FormData();
       formData.append("file", fs.createReadStream(tempFilePath));

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/FaultUnit.js

@@ -112,7 +112,7 @@ export const getFaultUnitCharts = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_fault_unit_chart_${Date.now()}.png`
+      `temp_fault_unit_chart_${Date.now()}.jpeg`
     );
 
     // 使用 Puppeteer 生成图表的截图
@@ -156,7 +156,7 @@ export const getFaultUnitCharts = async (
       });
       // 截图并保存到临时文件
       const chartElement = await page.$("#chart");
-      await chartElement.screenshot({ path: tempFilePath, type: "png" });
+      await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
       // 上传图片到服务器
       const formData = new FormData();
       formData.append("file", fs.createReadStream(tempFilePath));

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/GeneratorTemperature.js

@@ -33,7 +33,7 @@ export const generateGeneratorTemperature = async (
     // 创建临时目录
     const tempDir = path.join(process.cwd(), "images");
     await fs.ensureDir(tempDir);
-    const tempFilePath = path.join(tempDir, `temp_chart_${Date.now()}.png`);
+    const tempFilePath = path.join(tempDir, `temp_chart_${Date.now()}.jpeg`);
 
     // 获取 plotly.js 的绝对路径
     const plotlyPath = path.join(
@@ -162,7 +162,7 @@ export const generateGeneratorTemperature = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/HeatmapCharts.js

@@ -23,7 +23,7 @@ export const generateHeatmapChart = async (data, bucketName, objectName) => {
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_heatmap_chart_${Date.now()}.png`
+      `temp_heatmap_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -142,7 +142,7 @@ export const generateHeatmapChart = async (data, bucketName, objectName) => {
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 165 - 7
downLoadServer/src/server/utils/chartsCom/PlotlyCharts.js

@@ -1,25 +1,183 @@
 /*
  * @Author: your name
  * @Date: 2025-05-15 15:22:19
- * @LastEditTime: 2025-05-16 11:10:47
+ * @LastEditTime: 2025-05-26 11:00:41
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/utils/chartsCom/PlotlyCharts.js
  */
+
 import puppeteer from "puppeteer";
 import fs from "fs-extra";
 import path from "path";
 import FormData from "form-data";
-import axios from "axios"; // 导入 axios
 import { colorSchemes } from "../colors.js";
-export const getPlotlyCharts = async (
-  data,
+import axios from "axios";
+import { text } from "stream/consumers";
+
+/**
+ * 生成折线图并上传
+ * @param {Object} options - 配置选项
+ * @param {string} options.fileAddr - 数据文件地址
+ * @param {string[]} options.color1 - 颜色数组1
+ * @param {string[]} options.colors - 颜色数组2
+ * @returns {Promise<String>} - 返回图片URL
+ */
+export const generatePlotlyCharts = async (
+  chartData,
   bucketName,
-  objectName,
-  analysisTypeCode
+  objectName
 ) => {
+  const colorSchemesItem = colorSchemes[0].colors;
+  const tempDir = path.join(process.cwd(), "images");
+  const tempFilePath = path.join(tempDir, `temp_line_chart_${Date.now()}.jpeg`);
+  let browser;
+
   try {
+    // 构建数据
+    const data = [];
+    const newData = chartData.data.filter(
+      (item) => item.enginName !== "合同功率曲线"
+    );
+
+    newData.forEach((turbine, index) => {
+      data.push({
+        x: turbine.xData,
+        y: turbine.yData,
+        name: turbine.enginName,
+        mode: "lines",
+        connectgaps: false,
+        line: { color: colorSchemesItem[index % colorSchemesItem.length] },
+        marker: { color: colorSchemesItem[index % colorSchemesItem.length] },
+      });
+    });
+
+    if (
+      chartData.data[chartData.data.length - 1] &&
+      chartData.data[chartData.data.length - 1].enginName === "合同功率曲线" &&
+      chartData.data[chartData.data.length - 1].yData.length > 0
+    ) {
+      data.push({
+        x: chartData.data[chartData.data.length - 1].xData,
+        y: chartData.data[chartData.data.length - 1].yData,
+        mode: "lines+markers",
+        name: "合同功率曲线",
+        line: {
+          color: "red",
+          width: 1,
+        },
+        marker: { color: "red", size: 4 },
+      });
+    }
+
+    const layout = {
+      title: {
+        text: `有功功率曲线分析${chartData.engineTypeName}`,
+        font: { size: 16, weight: "bold" },
+      },
+      xaxis: { title: { text: "风速(m / s)" || "X轴" }, gridcolor: "#fff" },
+      yaxis: { title: { text: "功率(kW)" || "Y轴" }, gridcolor: "#fff" },
+      margin: { l: 50, r: 50, t: 50, b: 50 },
+      plot_bgcolor: "#e5ecf6",
+      bgcolor: "#e5ecf6",
+      autosize: true,
+      barmode: "group",
+      legend: {
+        orientation: "h",
+        xanchor: "center",
+        x: 0.5,
+        y: -0.2,
+      },
+    };
+
+    await fs.ensureDir(tempDir);
+    const plotlyPath = path.join(
+      process.cwd(),
+      "src",
+      "public",
+      "js",
+      "plotly-latest.min.js"
+    );
+    const plotlyContent = await fs.readFile(plotlyPath, "utf-8");
+
+    browser = await puppeteer.launch({
+      headless: "new",
+      args: ["--no-sandbox", "--disable-setuid-sandbox"],
+    });
+
+    const page = await browser.newPage();
+
+    const htmlContent = `
+      <!DOCTYPE html>
+      <html>
+        <head>
+          <script>${plotlyContent}</script>
+          <style>body { margin: 0; } #chart { width: 800px; height: 600px; }</style>
+        </head>
+        <body>
+          <div id="chart"></div>
+          <script>
+            window.onload = function () {
+              const data = ${JSON.stringify(data)};
+              const layout = ${JSON.stringify(layout)};
+              Plotly.newPlot('chart', data, layout, { responsive: true }).then(() => {
+                window.chartRendered = true;
+              });
+            };
+          </script>
+        </body>
+      </html>`;
+
+    await page.setContent(htmlContent, { waitUntil: "networkidle0" });
+
+    await page.waitForFunction(() => window.chartRendered === true, {
+      timeout: 60000,
+    });
+
+    const chartElement = await page.$("#chart");
+    await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
+
+    // ✅ 上传前判断文件是否存在
+    if (!(await fs.pathExists(tempFilePath))) {
+      console.error("❌ 图表文件未生成:", tempFilePath);
+      throw new Error("图表截图文件未生成");
+    }
+
+    // ✅ 发起上传
+    try {
+      const response = await axios.post(
+        `${process.env.API_BASE_URL}/examples/upload`,
+        {
+          filePath: tempFilePath,
+          bucketName,
+          objectName,
+        }
+      );
+
+      const imageUrl = response?.data?.url;
+      console.log("✅ 上传成功:", imageUrl);
+
+      return imageUrl;
+    } catch (uploadError) {
+      console.error("❌ 上传失败:", uploadError.message);
+      throw uploadError;
+    } finally {
+      // ✅ 上传后安全删除
+      try {
+        if (await fs.pathExists(tempFilePath)) {
+          await fs.unlink(tempFilePath);
+          console.log("🧹 临时文件已删除:", tempFilePath);
+        }
+      } catch (deleteError) {
+        console.warn("⚠️ 删除临时文件失败:", deleteError.message);
+      }
+    }
   } catch (error) {
-    console.error("发生错误:", error);
+    console.error("❌ 生成折线图失败:", error.message);
+    throw error;
+  } finally {
+    if (browser) {
+      await browser.close();
+    }
   }
 };

+ 217 - 0
downLoadServer/src/server/utils/chartsCom/PlotlyChartsFen.js

@@ -0,0 +1,217 @@
+/*
+ * @Author: your name
+ * @Date: 2025-05-23 17:19:20
+ * @LastEditTime: 2025-05-26 11:36:31
+ * @LastEditors: bogon
+ * @Description: In User Settings Edit
+ * @FilePath: /downLoadServer/src/server/utils/chartsCom/PlotlyChartsFen.js
+ */
+import puppeteer from "puppeteer";
+import fs from "fs-extra";
+import path from "path";
+import FormData from "form-data";
+import { colorSchemes } from "../colors.js";
+import axios from "axios";
+
+/**
+ * 生成折线图并上传
+ * @param {Object} data - 图表数据
+ * @returns {Promise<String>} - 返回图片URL
+ */
+export const generatePlotlyChartsFen = async (
+  data,
+  bucketName,
+  objectName,
+  fieldEngineCode
+) => {
+  try {
+    // 创建临时目录
+    const tempDir = path.join(process.cwd(), "images");
+    await fs.ensureDir(tempDir);
+    const tempFilePath = path.join(
+      tempDir,
+      `temp_heatmap_chart_${Date.now()}.jpeg`
+    );
+
+    // 获取 plotly.js 的绝对路径
+    const plotlyPath = path.join(
+      process.cwd(),
+      "src",
+      "public",
+      "js",
+      "plotly-latest.min.js"
+    );
+    const plotlyContent = await fs.readFile(plotlyPath, "utf-8");
+
+    // 创建浏览器实例
+    const browser = await puppeteer.launch({
+      headless: "new",
+      args: ["--no-sandbox", "--disable-setuid-sandbox"],
+    });
+
+    try {
+      const page = await browser.newPage();
+
+      // 准备图表数据
+      const sortedData = data.data.sort((a, b) => {
+        if (
+          a.enginCode === fieldEngineCode &&
+          b.enginCode !== fieldEngineCode
+        ) {
+          return 1;
+        }
+        if (
+          a.enginCode !== fieldEngineCode &&
+          b.enginCode === fieldEngineCode
+        ) {
+          return -1;
+        }
+        return 0;
+      });
+
+      const finalData = [];
+      let enginName = "";
+      console.log(fieldEngineCode, "fieldEngineCode");
+      sortedData
+        .filter((item) => item.enginName !== "合同功率曲线")
+        .forEach((turbine) => {
+          const color =
+            turbine.enginCode === fieldEngineCode ? "#406DAB" : "#D3D3D3";
+          enginName =
+            turbine.enginCode === fieldEngineCode ? turbine.enginName : "";
+          const chartConfig = {
+            x: turbine.xData,
+            y: turbine.yData,
+            connectgaps: false,
+            name: turbine.enginName,
+            mode: "lines",
+            fill: "none",
+            line: { color },
+            marker: { color },
+          };
+          finalData.push(chartConfig);
+        });
+      const filterData = data.data.filter(
+        (item) => item.enginName === "合同功率曲线"
+      );
+      console.log(filterData, "合同功率曲线");
+      // 添加合同功率曲线
+      if (filterData && filterData[0].enginName === "合同功率曲线") {
+        finalData.push({
+          x: filterData[0].xData,
+          y: filterData[0].yData,
+          mode: "lines+markers",
+          name: "合同功率曲线",
+          line: {
+            color: "red",
+            width: 1,
+          },
+          marker: { color: "red", size: 4 },
+        });
+      }
+
+      // 准备布局配置
+      const layout = {
+        title: {
+          text: `有功功率曲线分析${enginName}`,
+          font: {
+            size: 16,
+            weight: "bold",
+          },
+        },
+        xaxis: {
+          title: {
+            text: "风速(m/s)" || "x轴",
+          },
+          gridcolor: "rgb(255,255,255)",
+          tickcolor: "rgb(255,255,255)",
+          backgroundcolor: "#e5ecf6",
+        },
+        yaxis: {
+          title: { text: "功率(kW)" || "Y轴" },
+          gridcolor: "rgb(255,255,255)",
+          tickcolor: "rgb(255,255,255)",
+          backgroundcolor: "#e5ecf6",
+        },
+        margin: {
+          l: 50,
+          r: 50,
+          t: 50,
+          b: 50,
+        },
+        autosize: true,
+        plot_bgcolor: "#e5ecf6",
+        gridcolor: "#fff",
+        bgcolor: "#e5ecf6",
+        legend: {
+          orientation: "h",
+          xanchor: "center",
+          x: 0.5,
+          y: -0.2,
+        },
+      };
+
+      // 创建HTML内容
+      const htmlContent = `
+        <!DOCTYPE html>
+        <html>
+          <head>
+            <script>${plotlyContent}</script>
+            <style>
+              body { margin: 0; }
+              #chart { width: 800px; height: 600px; }
+            </style>
+          </head>
+          <body>
+            <div id="chart"></div>
+            <script>
+              window.onload = function() {
+                const data = ${JSON.stringify(finalData)};
+                const layout = ${JSON.stringify(layout)};
+                Plotly.newPlot('chart', data, layout, {
+                  responsive: true
+                }).then(() => {
+                  window.chartRendered = true;
+                });
+              };
+            </script>
+          </body>
+        </html>
+      `;
+
+      // 设置页面内容
+      await page.setContent(htmlContent, {
+        waitUntil: "networkidle0",
+      });
+
+      // 等待图表渲染完成
+      await page.waitForFunction(() => window.chartRendered === true, {
+        timeout: 60000,
+      });
+
+      // 截图并保存到临时文件
+      // 截图并保存到临时文件
+      const chartElement = await page.$("#chart");
+      await chartElement.screenshot({
+        path: tempFilePath,
+        type: "jpeg",
+      });
+
+      // 上传图片到服务器
+      const formData = new FormData();
+      formData.append("file", fs.createReadStream(tempFilePath));
+      // return formData;
+      // 发送上传请求
+      const response = await axios.post(
+        `${process.env.API_BASE_URL}/examples/upload`,
+        { filePath: tempFilePath, bucketName, objectName }
+      );
+      return response?.data?.url;
+    } finally {
+      await browser.close();
+    }
+  } catch (error) {
+    console.error("生成折线图失败:", error);
+    throw error;
+  }
+};

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/Radar.js

@@ -119,7 +119,7 @@ export const getRadarCharts = async (
   await fs.ensureDir(tempDir);
   const tempFilePath = path.join(
     tempDir,
-    `temp_scatter_chart_${Date.now()}.png`
+    `temp_scatter_chart_${Date.now()}.jpeg`
   );
 
   await page.setContent(getHtmlContent(), { waitUntil: "load" });
@@ -146,7 +146,7 @@ export const getRadarCharts = async (
   const chartElement = await page.$("#chart");
   await chartElement.screenshot({
     path: tempFilePath,
-    type: "png",
+    type: "jpeg",
   });
 
   try {

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/Time3DChart.js

@@ -26,7 +26,7 @@ export const generateTime3DChart = async (data, bucketName, objectName) => {
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_heatmap_chart_${Date.now()}.png`
+      `temp_heatmap_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -212,7 +212,7 @@ export const generateTime3DChart = async (data, bucketName, objectName) => {
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/TwoDMarkersChart.js

@@ -25,7 +25,7 @@ export const generateTwoDMarkersChart = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_scatter_chart_${Date.now()}.png`
+      `temp_scatter_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -163,7 +163,7 @@ export const generateTwoDMarkersChart = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/TwoDMarkersChart1.js

@@ -16,7 +16,7 @@ export const generateTwoDMarkersChart1 = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_scatter_chart_${Date.now()}.png`
+      `temp_scatter_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -185,7 +185,7 @@ export const generateTwoDMarkersChart1 = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/WindRoseChart.js

@@ -28,7 +28,7 @@ export const getWindRoseChart = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_wind_rose_chart_${Date.now()}.png`
+      `temp_wind_rose_chart_${Date.now()}.jpeg`
     );
 
     // 定义风向的 16 等分
@@ -160,7 +160,7 @@ export const getWindRoseChart = async (
       });
       // 截图并保存到临时文件
       const chartElement = await page.$("#chart");
-      await chartElement.screenshot({ path: tempFilePath, type: "png" });
+      await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
       // 上传图片到服务器
       const formData = new FormData();
       formData.append("file", fs.createReadStream(tempFilePath));

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/YewErrorBarChart.js

@@ -103,7 +103,7 @@ export const getYewErrorBarChart = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_yew_error_bar_chart_${Date.now()}.png`
+      `temp_yew_error_bar_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -156,7 +156,7 @@ export const getYewErrorBarChart = async (
       });
       // 截图并保存到临时文件
       const chartElement = await page.$("#chart");
-      await chartElement.screenshot({ path: tempFilePath, type: "png" });
+      await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
       // 上传图片到服务器
       const formData = new FormData();
       formData.append("file", fs.createReadStream(tempFilePath));

+ 2 - 17
downLoadServer/src/server/utils/chartsCom/lineAndChildLine.js

@@ -104,7 +104,7 @@ export const generateLineAndChildLine = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_line_chart_${Date.now()}.png`
+      `temp_line_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -168,7 +168,7 @@ export const generateLineAndChildLine = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器
@@ -179,21 +179,6 @@ export const generateLineAndChildLine = async (
       formData.append("engineCode", chartData.engineCode || "");
       formData.append("analysisTypeCode", chartData.analysisTypeCode || "");
 
-      // const uploadResponse = await axios.post(
-      //   "http://localhost:6900/upload",
-      //   formData,
-      //   {
-      //     headers: {
-      //       ...formData.getHeaders(),
-      //     },
-      //   }
-      // );
-
-      // 删除临时文件
-      // await fs.remove(tempFilePath);
-      // console.log("折线图生成并上传成功:", uploadResponse.data.url);
-      // return uploadResponse.data.url;
-      // return formData;
       // 发送上传请求
       const response = await axios.post(
         `${process.env.API_BASE_URL}/examples/upload`,

+ 2 - 3
downLoadServer/src/server/utils/chartsCom/lineChartsFen.js

@@ -17,13 +17,12 @@ export const generateLineChart = async (
   fieldEngineCode
 ) => {
   try {
-
     // 创建临时目录
     const tempDir = path.join(process.cwd(), "images");
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_line_chart_${Date.now()}.png`
+      `temp_line_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -173,7 +172,7 @@ export const generateLineChart = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 3 - 3
downLoadServer/src/server/utils/chartsCom/powerMarkers2DCharts.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-04-28 14:15:23
- * @LastEditTime: 2025-05-21 15:10:44
+ * @LastEditTime: 2025-05-26 11:01:22
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/utils/chartsCom/powerMarkers2DCharts.js
@@ -25,7 +25,7 @@ export const generatepowerMarkers2DCharts = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_scatter_chart_${Date.now()}.png`
+      `temp_scatter_chart_${Date.now()}.jpeg`
     );
 
     // 获取 plotly.js 的绝对路径
@@ -232,7 +232,7 @@ export const generatepowerMarkers2DCharts = async (
       const chartElement = await page.$("#chart");
       await chartElement.screenshot({
         path: tempFilePath,
-        type: "png",
+        type: "jpeg",
       });
 
       // 上传图片到服务器

+ 0 - 49
downLoadServer/src/server/utils/chartsCom/productionIndicatorTotal.js

@@ -1,49 +0,0 @@
-// import fs from "fs-extra";
-// import path from "path";
-// import PizZip from "pizzip";
-// import Docxtemplater from "docxtemplater";
-// import { fileURLToPath } from "url";
-// import ImageModule from "docxtemplater-image-module-free";
-// const __filename = fileURLToPath(import.meta.url);
-// const __dirname = path.dirname(__filename);
-
-// export const getProductionIndicatorTotal = async (
-//   data,
-//   bucketName,
-//   objectName,
-//   fieldInfo
-// ) => {
-//   try {
-//     // 目标文件路径
-//     const targetFilePath = path.join(
-//       process.cwd(),
-//       "src",
-//       "public",
-//       "file",
-//       `${fieldInfo.companyName}.docx`
-//     );
-
-//     // 读取复制后的文件
-//     const content = await fs.readFile(targetFilePath, "binary");
-//     const zip = new PizZip(content);
-//     const doc = new Docxtemplater(zip, {
-//       /* options */
-//       paragraphLoop: true,
-//       linebreaks: true,
-//     });
-
-//     // 设置模板数据(行数据传 rows)
-//     doc.render({
-//       rows: data,
-//     });
-
-//     // 生成新 Word 文件
-//     const buffer = doc.getZip().generate({ type: "nodebuffer" });
-//     await fs.writeFile(targetFilePath, buffer);
-//     console.log(`文档生成成功:${targetFilePath}`);
-//     return data;
-//   } catch (error) {
-//     console.error("生成 Word 文档失败:", error);
-//     throw error;
-//   }
-// };

+ 2 - 2
downLoadServer/src/server/utils/chartsCom/yawErrorBarSum.js

@@ -90,7 +90,7 @@ export const getYawErrorBarSumCharts = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_yaw_error_bar_sum_chart_${Date.now()}.png`
+      `temp_yaw_error_bar_sum_chart_${Date.now()}.jpeg`
     );
     // 获取 plotly.js 的绝对路径
     const plotlyPath = path.join(
@@ -141,7 +141,7 @@ export const getYawErrorBarSumCharts = async (
       });
       // 截图并保存到临时文件
       const chartElement = await page.$("#chart");
-      await chartElement.screenshot({ path: tempFilePath, type: "png" });
+      await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
       // 上传图片到服务器
       const formData = new FormData();
       formData.append("file", fs.createReadStream(tempFilePath));

+ 3 - 3
downLoadServer/src/server/utils/chartsCom/yawErrorLine.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-05-14 10:49:00
- * @LastEditTime: 2025-05-21 15:11:44
+ * @LastEditTime: 2025-05-26 11:02:41
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /downLoadServer/src/server/utils/chartsCom/yawErrorLine.js
@@ -122,7 +122,7 @@ export const generateYawErrorLine = async (
     await fs.ensureDir(tempDir);
     const tempFilePath = path.join(
       tempDir,
-      `temp_yaw_error_chart_${Date.now()}.png`
+      `temp_yaw_error_chart_${Date.now()}.jpeg`
     );
 
     try {
@@ -161,7 +161,7 @@ export const generateYawErrorLine = async (
 
       // 截图并保存到临时文件
       const chartElement = await page.$("#chart");
-      await chartElement.screenshot({ path: tempFilePath, type: "png" });
+      await chartElement.screenshot({ path: tempFilePath, type: "jpeg" });
 
       // 上传图片到服务器
       const formData = new FormData();

+ 5 - 2
downLoadServer/src/server/utils/copyFileCsv.js

@@ -73,7 +73,7 @@ export const copyFileDocx = async (fieldInfo, chartsImages) => {
       "src",
       "public",
       "file",
-      `${fieldInfo.companyName}.docx`
+      `${fieldInfo.companyName}${fieldInfo.fieldName}可靠性和能效双提升数据分析报告.docx`
     );
 
     // 拷贝模板
@@ -160,7 +160,10 @@ export const copyFileDocx = async (fieldInfo, chartsImages) => {
     const buffer = doc.getZip().generate({ type: "nodebuffer" });
     await fs.writeFile(targetFilePath, buffer);
 
-    return `✅ 文档生成成功:${targetFilePath}`;
+    return {
+      url: targetFilePath,
+      message: `✅ 文档生成成功:${targetFilePath}`,
+    };
   } catch (error) {
     console.error("❌ 生成 Word 文档失败:", error);
     throw error;

+ 25 - 0
src/utils/common.js

@@ -392,6 +392,30 @@ export const downLoadCsvFile = (csvContent, fileName) => {
   document.body.removeChild(link);
   URL.revokeObjectURL(url);
 };
+
+export const downloadDocx = (url, fileName) => {
+  axios({
+    url: url,
+    method: "GET",
+    responseType: "blob", // 将响应类型设置为 blob
+  })
+    .then((response) => {
+      const blob = new Blob([response.data], {
+        type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+      });
+      const link = document.createElement("a");
+      link.href = URL.createObjectURL(blob);
+      link.download = fileName || "download.docx";
+      document.body.appendChild(link);
+      link.click();
+      document.body.removeChild(link);
+      URL.revokeObjectURL(link.href); // 释放 Blob URL 资源
+    })
+    .catch((error) => {
+      console.error("下载失败:", error);
+    });
+};
+
 export default {
   uuid,
   copy,
@@ -409,4 +433,5 @@ export default {
   downLoadChartsJsonFile,
   creatNewChartsJson,
   downLoadCsvFile,
+  downloadDocx,
 };

+ 34 - 0
src/utils/downloadFile.js

@@ -0,0 +1,34 @@
+/*
+ * @Author: your name
+ * @Date: 2025-05-26 16:57:22
+ * @LastEditTime: 2025-05-26 16:57:40
+ * @LastEditors: bogon
+ * @Description: In User Settings Edit
+ * @FilePath: /performance-test/src/utils/downloadFile.js
+ */
+// ... existing code ...
+import axios from "axios";
+export const downloadDocx = (url, fileName) => {
+  axios({
+    url: url,
+    method: "GET",
+    responseType: "blob", // 将响应类型设置为 blob
+  })
+    .then((response) => {
+      const blob = new Blob([response.data], {
+        type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+      });
+      const link = document.createElement("a");
+      link.href = URL.createObjectURL(blob);
+      link.download = fileName || "download.docx";
+      document.body.appendChild(link);
+      link.click();
+      document.body.removeChild(link);
+      URL.revokeObjectURL(link.href); // 释放 Blob URL 资源
+    })
+    .catch((error) => {
+      console.error("下载失败:", error);
+    });
+};
+
+// ... existing code ...

+ 75 - 52
src/views/performance/assetssMag.vue

@@ -466,6 +466,7 @@ import {
   editPriority,
   analysisDetail,
 } from "@/api/performance";
+import { downloadDocx } from "@/utils/common";
 import { getFieldInfo } from "@/api/overview";
 import axios from "axios";
 import pLimit from "p-limit";
@@ -554,38 +555,52 @@ export default {
     //   const diagramRelations = [
     //     {
     //       batchCode: "WOF039800012-WOB000001",
-    //       analysisTypeCode: "production_indicator",
-    //       analysisTypeName: "机组指标",
+    //       fieldEngineCode: "WOG00604",
+    //       fieldEngineName: "#01",
+    //       analysisTypeCode: "power_curve",
+    //       analysisTypeName: null,
     //       fileAddr:
-    //         "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/production_indicator/manual/WT2000%252F93-production-indicator.csv",
+    //         "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/power_curve/manual/power_curve-%2301.json",
     //       autoAnalysis: null,
-    //       createTime: "2025-01-21 16:35:46",
-    //       engineTypeCode: "WEM00012",
+    //       createTime: "2025-05-23 16:57:26",
+    //     },
+    //     {
+    //       batchCode: "WOF039800012-WOB000001",
+    //       fieldEngineCode: "WOG00604",
+    //       fieldEngineName: "#01",
+    //       analysisTypeCode: "power_curve",
+    //       analysisTypeName: null,
+    //       fileAddr:
+    //         "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/power_curve/manual/power_curve-%2301.json",
+    //       autoAnalysis: null,
+    //       createTime: "2025-05-23 16:57:26",
+    //     },
+    //     {
+    //       batchCode: "WOF039800012-WOB000001",
+    //       fieldEngineCode: "WOG00608",
+    //       fieldEngineName: "#05",
+    //       analysisTypeCode: "power_curve",
+    //       analysisTypeName: null,
+    //       fileAddr:
+    //         "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/power_curve/manual/power_curve-%2305.json",
+    //       autoAnalysis: null,
+    //       createTime: "2025-05-23 16:57:26",
+    //     },
+    //     {
+    //       batchCode: "WOF039800012-WOB000001",
+    //       fieldEngineCode: "WOG00613",
+    //       fieldEngineName: "#10",
+    //       analysisTypeCode: "power_curve",
+    //       analysisTypeName: null,
+    //       fileAddr:
+    //         "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/power_curve/manual/power_curve-%2310.json",
+    //       autoAnalysis: null,
+    //       createTime: "2025-05-23 16:57:26",
     //     },
-    //     // {
-    //     //   batchCode: "WOF039800012-WOB000001",
-    //     //   analysisTypeCode: "production_indicator",
-    //     //   analysisTypeName: "机组指标",
-    //     //   fileAddr:
-    //     //     "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/production_indicator/manual/WT2000%252F100-production-indicator.csv",
-    //     //   autoAnalysis: null,
-    //     //   createTime: "2025-01-21 16:35:46",
-    //     //   engineTypeCode: "WEM00013",
-    //     // },
-    //     // {
-    //     //   batchCode: "WOF039800012-WOB000001",
-    //     //   analysisTypeCode: "production_indicator",
-    //     //   analysisTypeName: "机组指标",
-    //     //   fileAddr:
-    //     //     "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/production_indicator/manual/WT2000%252F110-production-indicator.csv",
-    //     //   autoAnalysis: null,
-    //     //   createTime: "2025-01-21 16:35:46",
-    //     //   engineTypeCode: "WEM00018",
-    //     // },
     //   ];
     //   diagramRelations.map(async (item) => {
     //     const res = await axios.post(
-    //       "/downLoadChart/chartServer/charts/radarChart",
+    //       "/downLoadChart/chartServer/charts/PlotlyChartsFen",
     //       {
     //         fieldEngineCode: item.fieldEngineCode ? item.fieldEngineCode : "", //lineChartFen
     //         bucketName: "bucket-zhzn",
@@ -593,7 +608,8 @@ export default {
     //         objectName: "charts/111.jpg", //在 MinIO 中的文件名
     //         fieldInfo: this.fieldInfo,
     //         fileAddr: item.fileAddr,
-    //         chartType: "radar",
+    //         // chartType: "radar",
+    //         chartType: "",
     //         // "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/wind_speed_frequency/manual/wind_Speed_Frequency%2302.json", //barChart  url:bar
     //         // "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/cp_windspeed/manual/%2319.json", //lineChartFen  url:line
     //         // "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/cp/manual/WEM00013.json", //lineAndChartLine  url:lineAndChildLine
@@ -619,26 +635,26 @@ export default {
     //     );
     //   });
 
-    //   await axios.post("/downLoadChart/chartServer/charts/CopyFileCsv", {
-    //     fieldInfo: this.fieldInfo,
-    //     rows: [
-    //       {
-    //         Qdr: "-70352582.72",
-    //         Qp: "70352582.72",
-    //         Rdr: "0",
-    //         Thc: "1675.06",
-    //       },
-    //     ],
-    //     "zn-techcn-replace-tags-production_indicator_unit-generalFiles": [
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#03.jpg",
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#05.jpg",
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#06.jpg",
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#08.jpg",
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#09.jpg",
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#14.jpg",
-    //       "http://192.168.50.233:6900/bucket-zhzn/charts/#17.jpg",
-    //     ],
-    //   });
+    //   // await axios.post("/downLoadChart/chartServer/charts/CopyFileCsv", {
+    //   //   fieldInfo: this.fieldInfo,
+    //   //   rows: [
+    //   //     {
+    //   //       Qdr: "-70352582.72",
+    //   //       Qp: "70352582.72",
+    //   //       Rdr: "0",
+    //   //       Thc: "1675.06",
+    //   //     },
+    //   //   ],
+    //   //   "zn-techcn-replace-tags-production_indicator_unit-generalFiles": [
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#03.jpg",
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#05.jpg",
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#06.jpg",
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#08.jpg",
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#09.jpg",
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#14.jpg",
+    //   //     "http://192.168.50.233:6900/bucket-zhzn/charts/#17.jpg",
+    //   //   ],
+    //   // });
     // },
 
     // 获取 风机信息
@@ -646,7 +662,7 @@ export default {
     async handleDownLoadChart(row) {
       await this.getAllAnalysis(row.batchCode);
       await this.getFieldDetail(row.batchCode);
-
+      this.$message.info("开始生成word文档");
       const limit = pLimit(5); // 限制同时并发的请求数量为 5
       const tasks = [];
       for (const itemAnalysis of this.allAnalysis) {
@@ -797,10 +813,17 @@ export default {
       }
       await Promise.all(tasks);
 
-      await axios.post("/downLoadChart/chartServer/charts/CopyFileCsv", {
-        fieldInfo: this.fieldInfo,
-        ...this.fileDataList,
-      });
+      const wordFilePath = await axios.post(
+        "/downLoadChart/chartServer/charts/CopyFileCsv",
+        {
+          fieldInfo: this.fieldInfo,
+          bucketName: "bucket-zhzn",
+          objectName: `charts/${row.fieldCode}/${row.batchCode}`,
+          ...this.fileDataList,
+        }
+      );
+      // //下载minio 文件
+      downloadDocx(wordFilePath.data.data.url, wordFilePath.data.data.fileName);
 
       console.log("生成成功:", this.fileDataList);
       console.log("全部图表生成请求已完成");

+ 3 - 3
src/views/performance/js/allAnalysisType.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2025-05-06 17:01:14
- * @LastEditTime: 2025-05-22 14:41:36
+ * @LastEditTime: 2025-05-26 09:20:04
  * @LastEditors: bogon
  * @Description: In User Settings Edit
  * @FilePath: /performance-test/src/views/performance/js/allAnalysisType.js
@@ -85,10 +85,10 @@ export const allAnalysisType = [
     typeFlag: "minute",
     typeDocxName: "power_curve",
     generalFiles: {
-      urlType: "",
+      urlType: "PlotlyCharts",
     },
     diagramRelations: {
-      urlType: "",
+      urlType: "PlotlyChartsFen",
     },
   },
   {

BIN
归档.zip