|
@@ -1,7 +1,7 @@
|
|
|
<!--
|
|
|
* @Author: your name
|
|
|
* @Date: 2024-09-11 14:32:12
|
|
|
- * @LastEditTime: 2025-07-14 13:39:59
|
|
|
+ * @LastEditTime: 2025-07-15 14:16:27
|
|
|
* @LastEditors: bogon
|
|
|
* @Description: In User Settings Edit
|
|
|
* @FilePath: /performance-test/src/views/performance/components/chartsCom/powerMarkers2DCharts.vue
|
|
@@ -153,7 +153,6 @@ export default {
|
|
|
try {
|
|
|
this.loading = true;
|
|
|
this.cancelToken = axios.CancelToken.source();
|
|
|
-
|
|
|
const resultChartsData = await axios.get(this.fileAddr, {
|
|
|
cancelToken: this.cancelToken.token,
|
|
|
});
|
|
@@ -185,7 +184,7 @@ export default {
|
|
|
const uniqueTimeLabels = data.colorbar
|
|
|
? [...new Set(data.colorbar)]
|
|
|
: [...new Set(data.color)]; // 从 colorbar 中提取唯一的时间标签
|
|
|
- // console.log(data.colorbar, "data.colorbar 1");
|
|
|
+
|
|
|
const tickvals = uniqueTimeLabels.map((label, index) => index + 1); // 根据时间标签生成 tickvals
|
|
|
const ticktext = uniqueTimeLabels.map((dateStr) => {
|
|
|
const date = new Date(dateStr);
|
|
@@ -392,8 +391,8 @@ export default {
|
|
|
"Download plot as a png": "保存图片",
|
|
|
Autoscale: "缩放",
|
|
|
Pan: "平移",
|
|
|
- "Zoom out": "放大",
|
|
|
- "Zoom in": "缩小",
|
|
|
+ "Zoom out": "缩小",
|
|
|
+ "Zoom in": "放大",
|
|
|
"Box Select": "选择框操作",
|
|
|
"Lasso Select": "套索选择操作",
|
|
|
"Reset axes": "重置操作",
|
|
@@ -450,10 +449,8 @@ export default {
|
|
|
}
|
|
|
return inside;
|
|
|
}
|
|
|
-
|
|
|
// 用于跟踪已添加的 (x, y) 组合
|
|
|
const addedPoints = {};
|
|
|
-
|
|
|
// 遍历图表数据中的所有点,检查是否在多边形内
|
|
|
gd.data[0].x.forEach((xVal, i) => {
|
|
|
const yVal = gd.data[0].y[i];
|
|
@@ -517,34 +514,66 @@ export default {
|
|
|
},
|
|
|
|
|
|
async downloadCSV() {
|
|
|
- const paramValueTypes = await axios.get("/ETLapi/sysConf/getByType", {
|
|
|
- params: { type: "en_cn_mapping" },
|
|
|
- });
|
|
|
- console.log(paramValueTypes, "paramValueTypes");
|
|
|
- const headers = [this.chartData.xaixs, this.chartData.yaixs];
|
|
|
- const csvRows = [headers]; // 保存标头
|
|
|
+ try {
|
|
|
+ const paramValueTypes = await axios.get("/ETLapi/sysConf/getByType", {
|
|
|
+ params: { type: "en_cn_mapping" },
|
|
|
+ });
|
|
|
+ // 使用 Set 或 Map 去重
|
|
|
+ const uniquePoints = [];
|
|
|
+ this.selectedPoints.forEach((point) => {
|
|
|
+ if (!uniquePoints.some((p) => p.x === point.x && p.y === point.y)) {
|
|
|
+ uniquePoints.push(point);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const newTimedata = uniquePoints.map((item) => item.time);
|
|
|
|
|
|
- // 使用 Set 或 Map 去重
|
|
|
- const uniquePoints = [];
|
|
|
- // this.selectedPoints.forEach((point) => {
|
|
|
- // if (!uniquePoints.some((p) => p.x === point.x && p.y === point.y)) {
|
|
|
- // uniquePoints.push(point);
|
|
|
- // }
|
|
|
- // });
|
|
|
+ const result = await axios.post(
|
|
|
+ "/ETLapi/dataTransfer/getWindTurbineAndTimestamps",
|
|
|
+ {
|
|
|
+ timestamps: [...newTimedata],
|
|
|
+ transferType: this.chartData.scada || "", //分析数据源类型
|
|
|
+ windFarmCode: this.chartData.field_code || "", //风场编号
|
|
|
+ windTurbineNumber: this.chartData.data[0].engineCode || "", //风机编号
|
|
|
+ }
|
|
|
+ );
|
|
|
+ const allData = result?.data?.datas || [];
|
|
|
+ if (!allData.length) {
|
|
|
+ console.warn("无数据返回");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const firstItem = allData[0];
|
|
|
+
|
|
|
+ // 4. 获取可用映射字段
|
|
|
+ const mapping = paramValueTypes?.data?.datas || [];
|
|
|
+ const matchedMapping = mapping.filter((m) =>
|
|
|
+ firstItem.hasOwnProperty(m.paramKey)
|
|
|
+ );
|
|
|
|
|
|
- // // 将去重后的点加入 CSV 数据
|
|
|
- // uniquePoints.forEach((point) => {
|
|
|
- // csvRows.push(`${point.x},${point.y}`);
|
|
|
- // });
|
|
|
+ // 5. 构建 CSV 表头(中文)
|
|
|
+ const headers = matchedMapping.map((m) => m.paramValue).join(",");
|
|
|
|
|
|
- // const csvString = csvRows.join("\n");
|
|
|
- // const blob = new Blob([csvString], { type: "text/csv; charset=utf-8" });
|
|
|
- // const url = URL.createObjectURL(blob);
|
|
|
- // const a = document.createElement("a");
|
|
|
- // a.href = url;
|
|
|
- // a.download = "selected_data.csv";
|
|
|
- // a.click();
|
|
|
- // URL.revokeObjectURL(url);
|
|
|
+ // 6. 构建 CSV 内容行
|
|
|
+ const rows = allData.map((item) => {
|
|
|
+ return matchedMapping.map((m) => item[m.paramKey] ?? "").join(",");
|
|
|
+ });
|
|
|
+
|
|
|
+ // 7. 合并为 CSV 字符串
|
|
|
+ const csvString = [headers, ...rows].join("\n");
|
|
|
+
|
|
|
+ // 8. 下载
|
|
|
+ const blob = new Blob([csvString], { type: "text/csv; charset=utf-8" });
|
|
|
+ const url = URL.createObjectURL(blob);
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = url;
|
|
|
+ a.download = "selected_data.csv";
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click();
|
|
|
+ document.body.removeChild(a);
|
|
|
+ URL.revokeObjectURL(url);
|
|
|
+ } catch (err) {
|
|
|
+ console.error(err);
|
|
|
+ }
|
|
|
},
|
|
|
updateChartColor(color) {
|
|
|
// 更新图表颜色
|