From 2265a4ba25b765d08795018f78ac9bceb87e4f45 Mon Sep 17 00:00:00 2001
From: skyouc <958836976@qq.com>
Date: 星期一, 13 四月 2026 16:23:28 +0800
Subject: [PATCH] 屏蔽AI

---
 src/main/webapp/static/js/wrkAnalysis/wrkAnalysis.js |   86 +++++++++++++++++++++++++++++++++++++------
 1 files changed, 74 insertions(+), 12 deletions(-)

diff --git a/src/main/webapp/static/js/wrkAnalysis/wrkAnalysis.js b/src/main/webapp/static/js/wrkAnalysis/wrkAnalysis.js
index 2570f46..ee5fe57 100644
--- a/src/main/webapp/static/js/wrkAnalysis/wrkAnalysis.js
+++ b/src/main/webapp/static/js/wrkAnalysis/wrkAnalysis.js
@@ -35,6 +35,7 @@
                 taskEndTime$: "",
                 taskDurationMs: null,
                 avgTaskBeatDurationMs: null,
+                avgTaskPerHour: null,
                 avgTotalDurationMs: null,
                 avgStationDurationMs: null,
                 avgCraneDurationMs: null,
@@ -69,7 +70,7 @@
                 listLoading: false,
                 analyzeLoading: false,
                 exportingPdf: false,
-                selectedWrkNoMap: {},
+                selectedLogIdMap: {},
                 analysis: createEmptyAnalysis(),
                 analysisReady: false,
                 charts: {
@@ -82,8 +83,8 @@
             };
         },
         computed: {
-            selectedWrkNos: function () {
-                return Object.keys(this.selectedWrkNoMap).map(function (key) {
+            selectedLogIds: function () {
+                return Object.keys(this.selectedLogIdMap).map(function (key) {
                     return Number(key);
                 }).filter(function (value) {
                     return !!value;
@@ -180,7 +181,7 @@
                 this.filters = createDefaultFilters();
                 this.currentPage = 1;
                 this.pageSize = 20;
-                this.selectedWrkNoMap = {};
+                this.selectedLogIdMap = {};
                 this.analysis = createEmptyAnalysis();
                 this.analysisReady = false;
                 this.disposeCharts();
@@ -203,24 +204,24 @@
                 }
                 table.clearSelection();
                 (this.tableData || []).forEach(function (row) {
-                    if (self.selectedWrkNoMap[row.wrkNo]) {
+                    if (self.selectedLogIdMap[row.logId]) {
                         table.toggleRowSelection(row, true);
                     }
                 });
             },
             syncCurrentPageSelection: function (selection) {
-                var nextMap = Object.assign({}, this.selectedWrkNoMap);
+                var nextMap = Object.assign({}, this.selectedLogIdMap);
                 var selectedMap = {};
                 (selection || []).forEach(function (row) {
-                    selectedMap[row.wrkNo] = true;
+                    selectedMap[row.logId] = true;
                 });
                 (this.tableData || []).forEach(function (row) {
-                    delete nextMap[row.wrkNo];
+                    delete nextMap[row.logId];
                 });
                 Object.keys(selectedMap).forEach(function (key) {
                     nextMap[key] = true;
                 });
-                this.selectedWrkNoMap = nextMap;
+                this.selectedLogIdMap = nextMap;
             },
             runAnalysis: function () {
                 var self = this;
@@ -233,11 +234,11 @@
                     deviceType: this.filters.deviceType
                 };
                 if (this.filters.mode === "TASK") {
-                    if (!this.selectedWrkNos.length) {
+                    if (!this.selectedLogIds.length) {
                         this.$message.warning("璇峰厛鍕鹃�夎鍒嗘瀽鐨勪换鍔�");
                         return;
                     }
-                    request.wrkNos = this.selectedWrkNos;
+                    request.wrkLogIds = this.selectedLogIds;
                     request.timeField = this.filters.timeField;
                 } else {
                     if (!this.filters.timeRange || this.filters.timeRange.length !== 2) {
@@ -316,10 +317,15 @@
                     window.html2canvas(visualRoot, this.buildCaptureOptions(visualRoot)),
                     window.html2canvas(detailRoot, this.buildCaptureOptions(detailRoot))
                 ]).then(function (results) {
+                    var visualAvoidSplitBounds = self.collectAvoidSplitBounds(visualRoot, results[0], [
+                        ".quality-banner",
+                        ".chart-card"
+                    ]);
                     self.appendCanvasSlicesToPdf(pdf, results[0], {
                         margin: 8,
                         startY: 8,
-                        addNewPage: false
+                        addNewPage: false,
+                        avoidSplitBounds: visualAvoidSplitBounds
                     });
                     self.appendDetailTableToPdf(pdf, results[1], detailRoot, detailTable, 8);
                     pdf.save(self.buildPdfFileName());
@@ -360,6 +366,7 @@
                 while (renderedHeight < canvas.height) {
                     var currentPageHeightPx = Math.max(1, Math.floor((pageHeight - margin - currentY) * pxPerMm));
                     var sliceHeight = Math.min(currentPageHeightPx, canvas.height - renderedHeight);
+                    sliceHeight = this.resolveSliceHeight(renderedHeight, sliceHeight, settings.avoidSplitBounds);
                     pageCanvas.width = canvas.width;
                     pageCanvas.height = sliceHeight;
                     pageContext.fillStyle = "#ffffff";
@@ -394,6 +401,51 @@
                     renderedHeight += sliceHeight;
                     currentY = margin;
                 }
+            },
+            collectAvoidSplitBounds: function (rootElement, rootCanvas, selectors) {
+                if (!rootElement || !rootCanvas || !selectors || !selectors.length) {
+                    return [];
+                }
+                var rootRect = rootElement.getBoundingClientRect();
+                if (!rootRect.width) {
+                    return [];
+                }
+                var scale = rootCanvas.width / rootRect.width;
+                var elements = [];
+                selectors.forEach(function (selector) {
+                    Array.prototype.push.apply(elements, Array.prototype.slice.call(rootElement.querySelectorAll(selector)));
+                });
+                return elements.map(function (element) {
+                    var rect = element.getBoundingClientRect();
+                    return {
+                        top: Math.max(0, Math.round((rect.top - rootRect.top) * scale)),
+                        bottom: Math.max(0, Math.round((rect.bottom - rootRect.top) * scale))
+                    };
+                }).filter(function (item) {
+                    return item.bottom > item.top;
+                }).sort(function (a, b) {
+                    return a.top - b.top;
+                });
+            },
+            resolveSliceHeight: function (renderedHeight, desiredHeight, avoidSplitBounds) {
+                if (!avoidSplitBounds || !avoidSplitBounds.length) {
+                    return desiredHeight;
+                }
+                var sliceEnd = renderedHeight + desiredHeight;
+                var adjustedHeight = desiredHeight;
+                avoidSplitBounds.forEach(function (bound) {
+                    if (bound.top <= renderedHeight) {
+                        return;
+                    }
+                    if (bound.top >= sliceEnd || bound.bottom <= sliceEnd) {
+                        return;
+                    }
+                    var candidateHeight = bound.top - renderedHeight;
+                    if (candidateHeight > 0 && candidateHeight < adjustedHeight) {
+                        adjustedHeight = candidateHeight;
+                    }
+                });
+                return adjustedHeight > 0 ? adjustedHeight : desiredHeight;
             },
             appendDetailTableToPdf: function (pdf, rootCanvas, detailRoot, detailTable, margin) {
                 var tbody = detailTable && detailTable.tBodies && detailTable.tBodies[0];
@@ -768,6 +820,16 @@
                 }
                 return this.formatDurationBySeconds(ms / 1000);
             },
+            formatTaskPerHour: function (value) {
+                if (value === null || value === undefined || value === "") {
+                    return "--";
+                }
+                var num = Number(value);
+                if (!isFinite(num)) {
+                    return "--";
+                }
+                return this.trimTrailingZeros(num.toFixed(2)) + " 浠诲姟/灏忔椂";
+            },
             formatDurationBySeconds: function (seconds) {
                 var totalSeconds = Number(seconds || 0);
                 if (!isFinite(totalSeconds)) {

--
Gitblit v1.9.1