1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360 |
- <template>
- <div class="global-variable">
- <div class="condition">
- <!-- <el-alert
- title="分析前请核对数据是否导入,点击查看是否导入即可查看"
- type="warning"
- show-icon
- >
- </el-alert> -->
- <el-form
- :inline="true"
- ref="ruleForm"
- :model="formInline"
- class="demo-form-inline"
- :rules="rules"
- >
- <el-form-item label="分析主题:" prop="analysisName">
- <el-input
- size="small"
- v-model="formInline.analysisName"
- placeholder="请输入分析主题"
- ></el-input>
- </el-form-item>
- <el-form-item label="风场名称:" prop="fieldName">
- <el-input
- size="small"
- v-model="formInline.fieldName"
- placeholder="请输入风场名称"
- ></el-input>
- </el-form-item>
- <el-form-item label="分析状态:" prop="analysisState">
- <el-select
- size="small"
- v-model="formInline.analysisState"
- placeholder="请选择分析状态"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="() => fetchData()" size="small"
- >查询</el-button
- >
- <el-button @click="reset('ruleForm')" size="small">重置</el-button>
- </el-form-item>
- <el-form-item class="right-align">
- <el-button @click="Newanalyse" size="small">创建分析</el-button>
- <el-button
- @click="examine"
- size="small"
- v-hasPermi="['home:offlinedata']"
- >查看导入数据</el-button
- >
- <el-button
- @click="handleAutoAsstessList"
- size="small"
- v-hasPermi="['home:performance:autoAssetss']"
- >查看自动分析列表</el-button
- >
- <!-- <el-button @click="handleDownLoadChart" size="small">下载</el-button> -->
- </el-form-item>
- </el-form>
- <!-- <div class="progress" v-if="downloadDisabled">
- <div class="progressText">文档生成进度:</div>
- <el-progress
- :percentage="progressPercent"
- :color="colors"
- ></el-progress>
- </div> -->
- </div>
- <div class="list-page">
- <el-table
- class="center-align-table"
- :data="tableData"
- border
- :cell-style="rowStyle"
- >
- <el-table-column
- align="center"
- label="分析主题"
- prop="analysisName"
- min-width="200"
- fixed
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- :content="scope.row.sketch || '暂无分析简述'"
- placement="top"
- >
- <span>{{ scope.row.analysisName }}</span>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- prop="fieldName"
- label="风场名称"
- min-width="200"
- >
- </el-table-column>
- <el-table-column
- prop="loginName"
- align="center"
- label="分析状态"
- min-width="150"
- >
- <template slot-scope="scope">
- <span v-if="scope.row.analysisState == -1">未关联</span>
- <span
- v-else-if="
- scope.row.analysisState == 20 && scope.row.errState == 0
- "
- style="color: #f90"
- >分析中</span
- >
- <span
- v-else-if="
- scope.row.errState == 1 && scope.row.analysisState == 30
- "
- style="color: #f00"
- >分析异常</span
- >
- <span
- v-else-if="scope.row.analysisState == 30"
- style="color: #4caf50"
- >分析完成</span
- >
- <span
- v-else-if="scope.row.analysisState == 10"
- style="color: #4caf50"
- >排队中</span
- >
- <span v-else>/</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="loginName"
- align="center"
- label="进度"
- min-width="150"
- >
- <template slot-scope="scope">
- <el-progress
- v-if="scope.row.analysisState == 20"
- :text-inside="true"
- :stroke-width="20"
- :percentage="scope.row.analysisProgress"
- :class="{
- 'indeterminate-progress': scope.row.analysisProgress < 100,
- 'animated-progress': true,
- }"
- ></el-progress>
- <span v-else>/</span>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="排队序号"
- prop="orderNum"
- min-width="200"
- >
- <template slot-scope="scope">
- <span> {{ scope.row.orderNum }}</span>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="数据类型名称"
- prop="dataTypeName"
- min-width="200"
- >
- </el-table-column>
- <el-table-column
- v-hasPermi="['home:performance:autoAssetss']"
- prop="onOffCall"
- align="center"
- label="自动分析状态"
- min-width="140"
- >
- <template slot-scope="scope">
- <span>
- {{
- scope.row.onOffCall == 0
- ? "暂停"
- : scope.row.onOffCall === 1
- ? "开启"
- : "/"
- }}</span
- >
- </template>
- </el-table-column>
- <el-table-column
- prop="roleName"
- align="center"
- label="异常信息"
- min-width="120"
- >
- <template slot-scope="scope">
- <el-button
- v-if="scope.row.errState == 1"
- @click="abnormalDialog(scope.row, '异常详情')"
- type="text"
- size="small"
- >异常详情</el-button
- >
- <span v-else>/</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="roleName"
- align="center"
- label="分析记录"
- min-width="120"
- >
- <template slot-scope="scope">
- <!-- 分析完成 -->
- <el-button
- v-if="scope.row.analysisState == 30 && scope.row.errState !== 1"
- @click="handleAssetssDetail(scope.row, '1')"
- type="text"
- size="small"
- >分析详情</el-button
- >
- <!-- 分析中 -->
- <el-button
- v-else-if="
- scope.row.analysisState == 20 && scope.row.errState == 0
- "
- @click="handleAssetssDetail(scope.row, '0')"
- type="text"
- size="small"
- >分析详情</el-button
- >
- <span v-else>/</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="reportVos"
- align="center"
- label="报告"
- min-width="120"
- >
- <template slot-scope="scope">
- <el-dropdown v-if="scope.row.reportVos.length > 0" trigger="click">
- <el-button type="text" size="small" class="el-dropdown-link">
- 查看报告
- </el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- v-for="val in scope.row.reportVos"
- class="reportItemVal"
- >
- <div class="reportLeft">
- <span>{{ val.reportName }}</span>
- </div>
- <div class="reportRight">
- <el-button
- type="text"
- size="small"
- @click="detailReportAssetss(val)"
- >
- 查看
- </el-button>
- <el-button
- type="text"
- size="small"
- @click="downLoadeAssetss(val)"
- >
- 下载
- </el-button>
- </div>
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <span v-else>/</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="dataStartTime"
- align="center"
- label="开始时间"
- min-width="230"
- >
- </el-table-column>
- <el-table-column
- prop="dataEndTime"
- align="center"
- label="结束时间"
- min-width="230"
- >
- </el-table-column>
- <el-table-column
- prop="transition"
- align="center"
- fixed="right"
- label="操作"
- min-width="300"
- >
- <template slot-scope="scope">
- <el-button
- @click="handleDownLoadChart(scope.row)"
- type="text"
- size="small"
- :disabled="downloadDisabled"
- v-if="
- (scope.row.errState == 1 && scope.row.analysisState == 30) ||
- scope.row.analysisState == 30
- "
- >
- 下载报告
- </el-button>
- <el-button
- @click="abnormalDialog(scope.row, '上传报告')"
- type="text"
- size="small"
- >上传报告</el-button
- >
- <el-button
- @click="handleAssetss(scope.row)"
- type="text"
- :disabled="
- (scope.row.analysisState == 20 && scope.row.errState == 0) ||
- scope.row.analysisState == 10
- "
- size="small"
- >分析</el-button
- >
- <el-button
- @click="abnormalDialog(scope.row, '机组异常记录')"
- type="text"
- size="small"
- >机组异常记录</el-button
- >
- <el-button
- v-if="scope.row.analysisState == 10"
- @click="insertQueue(scope.row, 1)"
- type="text"
- size="small"
- >插队</el-button
- >
- <el-button
- v-if="scope.row.analysisState == 10"
- @click="insertQueue(scope.row, 0)"
- type="text"
- size="small"
- >取消插队</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <div class="pagination-container">
- <el-pagination
- @current-change="handleCurrentChange"
- :current-page.sync="formInline.pageNum"
- layout="total, prev, pager, next"
- :page-size="formInline.pageSize"
- :total="formInline.totalSize"
- >
- </el-pagination>
- </div>
- </div>
- <!-- 弹出层 -->
- <!-- 异常信息 /机组异常记录 /上传报告-->
- <my-dialog
- :visible="dialogVisible"
- :title="title"
- :rowInfo="rowInfo"
- @confirm="handleConfirm"
- :errorInfo="errorInfo"
- @getTableList="fetchData"
- >
- <div slot="tableEl">
- <el-empty description="暂无数据"></el-empty>
- </div>
- </my-dialog>
- <!-- 查看报告详情 -->
- <el-dialog
- title="PDF 预览"
- :visible.sync="dialogReportVisible"
- :width="dialogWidth"
- class="pdfDialog"
- :before-close="handleCloses"
- >
- <span>
- <div
- style="
- float: right;
- color: #fff;
- cursor: pointer;
- position: absolute;
- left: 90%;
- top: 21px;
- "
- >
- <span
- v-if="dialogWidth === '80%'"
- @click="() => (dialogWidth = '100%')"
- >全屏查看</span
- >
- <span
- v-if="dialogWidth === '100%'"
- @click="() => (dialogWidth = '80%')"
- >还原</span
- >
- <!-- {{ isFullscreen ? "还原" : "全屏" }} -->
- </div>
- </span>
- <div class="pdf-container" ref="viewer">
- <iframe :src="pdfUrl" width="100%" height="100%"></iframe>
- </div>
- <div></div>
- </el-dialog>
- <!-- 创建分析弹出框 -->
- <el-dialog
- title="创建分析"
- :visible.sync="addDialogVisible"
- width="30%"
- :before-close="AddHandleCloses"
- >
- <el-form
- :model="addRuleForm"
- :rules="addRules"
- ref="addRuleForm"
- label-width="100px"
- class="add-ruleForm"
- >
- <el-form-item label="关联风场" prop="fieldCode">
- <el-select
- v-model="addRuleForm.fieldCode"
- placeholder="请选择关联风场"
- >
- <el-option
- :label="item.fieldName"
- v-for="item in fieldCodeList"
- :value="item.codeNumber"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="" prop="analysisName">
- <b style="color: #f00; font-size: 12px"
- >不填写分析主题,自动采用系统生成的主题!</b
- >
- </el-form-item>
- <el-form-item label="分析主题" prop="analysisName">
- <el-input v-model="addRuleForm.analysisName"></el-input>
- </el-form-item>
- <el-form-item label="分析简述" prop="sketch">
- <el-input type="textarea" v-model="addRuleForm.sketch"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="addRuleFormSubmit">提交</el-button>
- <el-button @click="AddHandleCloses">取消</el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
- </div>
- </template>
- <script>
- import MyDialog from "./components/dialogCom.vue";
- import { downloadPDF } from "@/utils/common";
- import {
- analysisResultList,
- addAnalysisResult,
- queryCodeNum,
- editPriority,
- analysisDetail,
- } from "@/api/performance";
- import { downloadDocx } from "@/utils/common";
- import { getFieldInfo } from "@/api/overview";
- import axios from "axios";
- import pLimit from "p-limit";
- import { allAnalysisType } from "./js/allAnalysisType";
- import { mapMutations, mapState } from "vuex";
- import {
- windEngineMillPage,
- getWindEngineGroupByFieldCode,
- } from "@/api/ledger.js";
- export default {
- components: {
- MyDialog,
- },
- data() {
- return {
- progress: {
- current: 0,
- total: 0,
- },
- colors: [
- { color: "#f56c6c", percentage: 20 },
- { color: "#e6a23c", percentage: 40 },
- { color: "#5cb87a", percentage: 60 },
- { color: "#1989fa", percentage: 80 },
- { color: "#6f7ad3", percentage: 100 },
- ],
- fileDataList: {},
- fieldInfo: {}, //风场信息
- firstLoad: false, // 是否是第一次加载
- fieldCodeList: [],
- addDialogVisible: false,
- dialogWidth: "80%",
- intervalId: null,
- startTime: null,
- maxPollingTime: 3 * 60 * 1000, //轮询最大时间
- dialogVisible: false,
- loadingView: false,
- loading: false, //数据加载中
- errorInfo: "",
- options: [
- {
- value: "-1",
- label: "未关联",
- },
- {
- value: "10",
- label: "排队中",
- },
- {
- value: "20",
- label: "分析中",
- },
- {
- value: "30",
- label: "已分析",
- },
- ],
- addRules: {
- fieldCode: [
- { required: true, message: "请选择关联风场", trigger: "change" },
- ],
- },
- addRuleForm: {
- fieldCode: "",
- analysisName: "",
- sketch: "",
- },
- rules: {
- fieldName: { trigger: "blur" },
- },
- roleList: [],
- formInline: {
- fieldName: undefined,
- pageNum: 1,
- pageSize: 10,
- totalSize: 0,
- analysisName: undefined,
- analysisState: undefined,
- },
- allAnalysis: [],
- tableData: [],
- rowInfo: {},
- title: "",
- viewerInstance: null, // PDF 文件 URL
- dialogReportVisible: false,
- pdfUrl: "",
- isPolling: false, // 轮询状态标识
- firstLoad: true, // 是否是第一次加载
- };
- },
- created() {
- this.firstLoad = true;
- window.addEventListener("message", this.handleMessage); //江
- this.fetchData();
- },
- computed: {
- ...mapState("settings", {
- downloadDisabled: "downloadDisabled",
- }),
- progressPercent() {
- if (this.progress.total === 0) return 0;
- return Math.round((this.progress.current / this.progress.total) * 100);
- },
- },
- methods: {
- ...mapMutations("settings", ["setDownloadDisabled"]),
- async postChartData(
- urlType,
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- typeChart
- ) {
- try {
- if (itemField.analysisTypeName === "环境温度传感器") {
- console.log(itemField, "itemField");
- }
- const objectname =
- itemAnalysis.analysisTypeCode === "temperature_large_components"
- ? filterAnalysis.filterFileAddr +
- "/" +
- itemField.fieldEngineName +
- ".jpg"
- : itemField.engineTypeCode
- ? urlType + itemField.engineTypeCode + ".jpg"
- : urlType + itemField.fieldEngineName + ".jpg";
- const res = await axios.post(
- `/downLoadChart/chartServer/charts/${urlType}`,
- {
- fieldEngineCode: itemField.fieldEngineCode,
- bucketName: "bucket-zhzn",
- engineTypeCode: itemField.machineTypeCode,
- objectName:
- `charts/${row.fieldCode}/${row.batchCode}/${itemAnalysis.analysisTypeCode}/` +
- objectname,
- fieldInfo: this.fieldInfo,
- fileAddr: itemField.fileAddr,
- chartType:
- filterAnalysis.typeDocxName === "production_indicator_unit"
- ? "radar"
- : urlType,
- }
- );
- // 每完成 10% 提示一次(可调)
- const percent = Math.floor(
- (this.progress.current / this.progress.total) * 100
- );
- if (percent % 5 === 0 && !this._shownPercents?.includes(percent)) {
- this._shownPercents = this._shownPercents || [];
- this._shownPercents.push(percent);
- this.$notify.info(
- `📈 已完成 ${percent}%/${this.progress.current}张,共 ${this.progress.total} 张图表`
- );
- }
- let key = `zn-techcn-replace-tags-${filterAnalysis.typeDocxName}-${typeChart}`;
- if (urlType === "yawErrorBarSumChart") {
- key = `zn-techcn-replace-tags-${filterAnalysis.typeDocxName}-generalFiles2`;
- if (!this.fileDataList["yawErrorRows"]) {
- this.$set(this.fileDataList, "yawErrorRows", []); // Vue 2 中响应式设置对象属性
- }
- this.fileDataList["yawErrorRows"] = res?.data?.data?.data;
- } else if (urlType === "yawErrorChart") {
- key = `zn-techcn-replace-tags-${filterAnalysis.typeDocxName}-generalFiles1`;
- }
- if (filterAnalysis.typeDocxName === "production_indicator_all") {
- if (!this.fileDataList["rows"]) {
- this.$set(this.fileDataList, "rows", []); // Vue 2 中响应式设置对象属性
- }
- this.fileDataList["rows"] = res?.data?.data?.data;
- }
- if (itemField.engineTypeCode === "total_fault_result") {
- if (!this.fileDataList["faultRows"]) {
- this.$set(this.fileDataList, "faultRows", []); // Vue 2 中响应式设置对象属性
- }
- this.fileDataList["faultRows"] = res?.data?.data?.data;
- }
- if (itemField.engineTypeCode === "turbine_fault_result") {
- if (!this.fileDataList["windTurbineRows"]) {
- this.$set(this.fileDataList, "windTurbineRows", []); // Vue 2 中响应式设置对象属性
- }
- this.fileDataList["windTurbineRows"] = res?.data?.data?.data;
- }
- if (filterAnalysis.typeDocxName === "production_indicator_unit") {
- if (!this.fileDataList[key]) {
- this.$set(this.fileDataList, key, []); // Vue 2 中响应式设置对象属性
- }
- res?.data?.data?.imageUrls.map((imgval) => {
- this.fileDataList[key].push(imgval);
- });
- } else {
- if (!this.fileDataList[key]) {
- this.$set(this.fileDataList, key, []); // Vue 2 中响应式设置对象属性
- }
- this.fileDataList[key].push(res?.data?.data?.imageUrl);
- }
- } catch (err) {
- console.error("生成失败:", err);
- }
- },
- async handleDownLoadChart(row) {
- this.progress.current = 0;
- this.progress.total = 0;
- this.fileDataList = {};
- this.setDownloadDisabled(true);
- this.$notify.warning("开始生成 Word 文档...");
- try {
- 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) {
- const filterAnalysis = allAnalysisType.filter(
- (itemType) => itemType.typeName === itemAnalysis.analysisTypeName
- )[0];
- if (itemAnalysis.generalFiles) {
- //这里过滤的是发电机温度的类型 在url 中是否能找到filterFileAddr
- for (const itemField of filterAnalysis.filterFileAddr
- ? itemAnalysis.generalFiles
- .filter((item) => item.fileAddr.endsWith(".json"))
- .filter((item) =>
- item.fileAddr.includes(filterAnalysis.filterFileAddr)
- ) || []
- : itemAnalysis.generalFiles) {
- //静态偏航误差 --通过allAnalysisType.js文件配置实现需求
- if (Array.isArray(filterAnalysis.generalFiles.urlType)) {
- filterAnalysis.generalFiles.urlType.map(
- (itemUrlType, indUrlType) => {
- tasks.push(
- limit(async () => {
- await this.postChartData(
- itemUrlType,
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "generalFiles"
- );
- this.progress.current++;
- })
- );
- }
- );
- } else if (filterAnalysis.typeCode === "fault") {
- if (itemField.fileAddr.includes("turbine_fault_result")) {
- if (itemField.engineTypeCode === "turbine_fault_result") {
- tasks.push(
- limit(async () => {
- await this.postChartData(
- "faultUnitChart",
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "generalFiles"
- );
- this.progress.current++;
- })
- );
- }
- } else {
- if (itemField.engineTypeCode === "total_fault_result") {
- tasks.push(
- limit(async () => {
- await this.postChartData(
- "faultAllChart",
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "generalFiles"
- );
- this.progress.current++;
- })
- );
- }
- }
- } else if (filterAnalysis.typeCode === "production_indicator") {
- //总图全场
- if (
- itemField.fileAddr.includes(
- filterAnalysis.generalFiles.FileTypeFromUrl
- )
- ) {
- tasks.push(
- limit(async () => {
- await this.postChartData(
- filterAnalysis.generalFiles.urlType,
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "generalFiles"
- );
- this.progress.current++;
- // 每完成 10% 提示一次(可调)
- })
- );
- } else {
- tasks.push(
- limit(async () => {
- await this.postChartData(
- "radarChart",
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "generalFiles"
- );
- this.progress.current++;
- })
- );
- }
- } else {
- tasks.push(
- limit(async () => {
- await this.postChartData(
- filterAnalysis.generalFiles.urlType,
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "generalFiles"
- );
- this.progress.current++;
- })
- );
- }
- }
- }
- if (itemAnalysis.diagramRelations) {
- for (const itemField of filterAnalysis.filterFileAddr
- ? itemAnalysis.diagramRelations
- .filter((item) => item.fileAddr.endsWith(".json"))
- .filter((item) =>
- item.fileAddr.includes(filterAnalysis.filterFileAddr)
- ) || []
- : itemAnalysis.diagramRelations) {
- const urlType = Array.isArray(
- filterAnalysis.diagramRelations.urlType
- )
- ? this.getFileTypeFromUrl(
- itemField.fileAddr,
- filterAnalysis.diagramRelations.FileTypeFromUrl
- ) === filterAnalysis.diagramRelations.FileTypeFromUrl
- ? filterAnalysis.diagramRelations.urlType[0]
- : filterAnalysis.diagramRelations.urlType[1]
- : filterAnalysis.diagramRelations.urlType;
- tasks.push(
- limit(async () => {
- await this.postChartData(
- urlType,
- row,
- itemAnalysis,
- itemField,
- filterAnalysis,
- "diagramRelations"
- );
- this.progress.current++;
- })
- );
- }
- }
- }
- this.progress.total = tasks.length;
- await Promise.all(tasks);
- const engineTypeList = await this.getEngineTypeList(
- this.fieldInfo.engineMillTypes,
- row.batchCode
- );
- this.$notify.success("✅ 图表全部生成完成,开始生成 Word 文档...");
- const wordFilePath = await axios.post(
- "/downLoadChart/chartServer/charts/CopyFileCsv",
- {
- fieldInfo: this.fieldInfo,
- dataTime: `${this.analysisInfo.dataStartTime}-${this.analysisInfo.dataEndTime}`,
- bucketName: "bucket-zhzn",
- objectName: `charts/${row.fieldCode}/${row.batchCode}`,
- engineTypeList: engineTypeList,
- ...this.fileDataList,
- }
- );
- // //下载minio 文件
- downloadDocx(
- wordFilePath.data.data.url,
- wordFilePath.data.data.fileName
- );
- this.$notify.success("🎉 Word 文档生成并已下载!");
- this.setDownloadDisabled(false);
- } catch (error) {
- console.log(error, "error");
- this.$notify.error("🎉 Word 文档生成并下载失败!");
- this.setDownloadDisabled(false);
- }
- },
- async getEngineTypeList(typeList, batchCode) {
- return await Promise.all(
- typeList.map((item) => this.getEngineMillList(item, batchCode))
- );
- },
- // 查询
- async getEngineMillList(machineTypeCode, batchCode) {
- let dataArr = {
- fieldCode: this.fieldInfo.fieldCode,
- batchCode: batchCode,
- };
- const fieldRes = await getWindEngineGroupByFieldCode(dataArr);
- const map = new Map();
- const uniqueList = [];
- for (const item of fieldRes.data.windEngineGroupVoList) {
- if (!map.has(item.millTypeCode)) {
- map.set(item.millTypeCode, true);
- uniqueList.push(item);
- }
- }
- let paramsData = {
- machineTypeCode: machineTypeCode || undefined,
- pageNum: 1,
- pageSize: 10,
- };
- this.loading = true;
- const res = await windEngineMillPage(paramsData);
- const filterMill = uniqueList.filter(
- (item) => item.millTypeCode === res.data.list[0].millTypeCode
- );
- return { ...res.data.list[0], ratedPower: filterMill[0].ratedCapacity };
- },
- getFileTypeFromUrl(url, keyword) {
- return url.includes(keyword) ? keyword : "Unknown";
- },
- async getFieldDetail(batchCode) {
- const res = await getFieldInfo({ batchCode });
- this.fieldInfo = res.data.fieldInfo; //风场信息
- this.analysisInfo = res.data.analysisInfo;
- },
- //获取所有分析类型,分析结果接口
- async getAllAnalysis(batchCode) {
- const res = await analysisDetail({ batchCode });
- // console.log(res.data, "分析全部结果");
- this.allAnalysis = res.data;
- },
- //自动分析列表页面跳转
- handleAutoAsstessList() {
- window.open(
- this.$router.resolve({ path: "/home/performance/autoAssetss" }).href,
- "_blank"
- );
- },
- // 创建分析时请求
- async addRuleFormSubmit() {
- this.$refs.addRuleForm.validate(async (valid) => {
- if (valid) {
- try {
- const res = await addAnalysisResult(this.addRuleForm);
- if (res.code === 200) {
- this.$message({
- type: "success",
- message: "创建成功",
- });
- this.addDialogVisible = false;
- this.loading = false;
- this.isPolling = false;
- await this.fetchData();
- let obj = this.fieldCodeList.filter((itemS) => {
- if (itemS.codeNumber === this.addRuleForm.fieldCode) {
- return itemS;
- }
- });
- this.$router.push({
- path: "/home/performance/editAssets",
- query: {
- batchCode: this.tableData[0].batchCode,
- analysisTypeCode: this.tableData[0].analysisTypeCode,
- fieldEngineCode: this.tableData[0].fieldCode,
- fieldName: obj[0].fieldName,
- analysisName: this.addRuleForm.analysisName,
- },
- });
- }
- } catch (err) {
- console.error(err);
- }
- }
- });
- },
- AddHandleCloses(done) {
- this.$confirm("确认关闭?")
- .then((_) => {
- this.addDialogVisible = false;
- done();
- })
- .catch((_) => {});
- },
- //获取风场列表
- async getQueryCodeNumList() {
- this.loading = true;
- try {
- const result = await queryCodeNum();
- this.fieldCodeList = result.data.fieldCodeList;
- this.loading = false;
- } catch (error) {
- console.error(error);
- this.loading = false;
- }
- },
- handleCloses(done) {
- this.$confirm("确认关闭?")
- .then((_) => {
- done();
- })
- .catch((_) => {});
- },
- //查看pdf 文件
- detailReportAssetss(row) {
- this.dialogReportVisible = true;
- this.pdfUrl = row.reportAddr;
- },
- //下载pdf 文件
- downLoadeAssetss(row) {
- downloadPDF(row.reportAddr, row.reportName);
- },
- //插队接口
- async insertQueue(row, index) {
- this.$confirm(`确认插队?`, "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(async () => {
- const formData = new FormData();
- formData.append("batchCode", row.batchCode);
- formData.append("priority", index);
- const result = await editPriority(formData);
- if (result.code === 200) {
- this.$message({
- type: "success",
- message: "插队成功",
- });
- await this.fetchData();
- }
- })
- .catch(() => {});
- },
- //分析
- handleAssetss(row) {
- this.$router.push({
- path: "/home/performance/editAssets",
- query: {
- batchCode: row.batchCode,
- analysisTypeCode: row.analysisTypeCode,
- fieldEngineCode: row.fieldCode,
- fieldName: row.fieldName,
- analysisName: row.analysisName,
- },
- });
- },
- //分析详情
- handleAssetssDetail(row, state) {
- const navigateToDetails = () => {
- this.$router.push({
- path: "/home/performance/overview",
- query: {
- batchCode: row.batchCode,
- // analysisTypeCode: row.analysisTypeCode,
- fieldCode: row.fieldCode,
- },
- });
- };
- if (state === "0") {
- // 分析状态为分析中
- this.$confirm(
- "当前查看的分析记录为历史分析结果,最新分析记录还未分析完成不展示!"
- )
- .then(() => {
- navigateToDetails();
- })
- .catch(() => {});
- } else {
- navigateToDetails();
- }
- },
- abnormalDialog(row, title) {
- this.dialogVisible = true;
- if (title === "异常详情") {
- this.errorInfo = row.errInfo;
- this.rowInfo = {};
- } else if (title === "机组异常记录") {
- this.errorInfo = "";
- this.rowInfo = { ...row };
- } else if (title === "上传报告") {
- this.errorInfo = "";
- this.rowInfo = {};
- this.rowInfo.batchCode = row.batchCode;
- }
- this.title = title;
- },
- handleConfirm() {
- this.dialogVisible = false;
- },
- // 页码变化时才触发查询
- handleCurrentChange(val) {
- this.formInline.pageNum = val;
- this.fetchData();
- },
- // 修改 getTableList 方法,避免重复请求
- async getTableList() {
- // 如果正在请求中,跳过此次调用
- if (this.loading || this.isPolling) return;
- this.loading = true;
- try {
- const params = { ...this.formInline, totalSize: undefined };
- // 传递条件参数
- if (this.formInline.analysisState !== undefined) {
- params.analysisState = this.formInline.analysisState;
- }
- if (this.formInline.errState !== undefined) {
- params.errState = this.formInline.errState;
- }
- const result = await analysisResultList(params);
- this.tableData = result.data.list;
- this.formInline.totalSize = result.data.totalSize;
- } catch (error) {
- this.$message({
- type: "error",
- message: "请检查是否连接网络",
- });
- } finally {
- this.loading = false;
- }
- },
- // 改进 handleMessage,避免频繁请求
- handleMessage(event) {
- // 确保消息来自当前域
- if (event.origin !== window.location.origin) {
- return;
- }
- const { fieldName, analysisState, errState } = event.data;
- // 更新表单字段
- if (fieldName !== undefined) {
- this.formInline.fieldName = fieldName;
- }
- if (analysisState !== undefined) {
- this.formInline.analysisState = analysisState;
- }
- if (errState !== undefined) {
- this.formInline.errState = errState;
- }
- if (!this.loading) {
- if (this.firstLoad && (analysisState || errState || fieldName)) {
- // this.getTableList();
- this.startPolling();
- this.fetchData();
- }
- //
- }
- },
- rowStyle() {
- return "text-align:center";
- },
- // 重置
- reset(formName) {
- this.$refs[formName].resetFields();
- this.formInline.fieldName = "";
- this.formInline.analysisName = "";
- this.formInline.analysisState = "";
- this.formInline.errState = "";
- this.fetchData();
- },
- // fetchData 方法在轮询中调用
- async fetchData() {
- if (
- this.formInline.fieldName ||
- this.formInline.analysisState ||
- this.formInline.errState
- ) {
- this.firstLoad = false;
- }
- try {
- const result = await analysisResultList({
- ...this.formInline,
- totalSize: undefined,
- });
- this.tableData = result.data.list;
- this.formInline.totalSize = result.data.totalSize;
- } catch (error) {
- this.$message({
- type: "error",
- message: "请检查是否连接网络",
- });
- }
- },
- stopPolling() {
- // 停止轮询
- if (this.intervalId) {
- clearInterval(this.intervalId);
- this.intervalId = null;
- }
- this.isPolling = false;
- },
- // 启动轮询时,避免重复请求
- startPolling() {
- this.startTime = new Date().getTime();
- this.isPolling = true;
- this.intervalId = setInterval(() => {
- const currentTime = new Date().getTime();
- if (currentTime - this.startTime >= this.maxPollingTime) {
- this.stopPolling();
- } else {
- // 轮询期间不重复请求,检查是否可以调用 fetchData
- if (!this.loading) {
- this.fetchData();
- }
- }
- }, 10000); // 每10秒检查一次
- },
- //创建分析
- Newanalyse() {
- this.addDialogVisible = true;
- this.getQueryCodeNumList();
- },
- examine() {
- const targetUrl = this.$router.resolve({ name: "transition" }).href;
- window.open(targetUrl, "_blank");
- },
- },
- mounted() {
- this.startPolling();
- },
- beforeDestroy() {
- this.stopPolling();
- // 销毁消息监听器
- window.removeEventListener("message", this.handleMessage); //江
- },
- };
- </script>
- <style lang="scss" scoped>
- @keyframes striped-flow {
- from {
- background-position: 0 100px;
- }
- to {
- background-position: 1.25em 1.25em;
- }
- }
- .general {
- display: flex;
- flex-wrap: wrap;
- .condition {
- width: 50%;
- display: flex;
- p {
- width: 100px;
- text-align: right;
- line-height: 40px;
- }
- span {
- line-height: 40px;
- padding-left: 20px;
- }
- .el-select {
- width: 100%;
- margin-bottom: 20px;
- }
- .el-input {
- margin-bottom: 20px;
- }
- }
- }
- .progress {
- display: flex;
- align-items: center;
- position: fixed;
- top: 25px;
- right: 300px;
- .progressText {
- font-size: 14px;
- color: #606266;
- }
- .el-progress {
- width: 300px;
- }
- }
- .attachment {
- display: flex;
- padding-top: 10px;
- p {
- margin-right: 20px;
- color: #409eff;
- }
- }
- .add-ruleForm {
- .el-select {
- width: 100%;
- }
- }
- .addition {
- display: flex;
- justify-content: flex-end;
- margin-bottom: 10px;
- }
- .demo-ruleForm {
- .el-form-item {
- margin-bottom: 25px;
- }
- }
- ::v-deep .animated-progress .el-progress-bar__outer {
- height: 15px; /* Adjust height as needed */
- background-color: rgb(235, 238, 245);
- background-image: linear-gradient(
- 45deg,
- rgba(0, 0, 0, 0.1) 25%,
- transparent 25%,
- transparent 50%,
- rgba(0, 0, 0, 0.1) 50%,
- rgba(0, 0, 0, 0.1) 75%,
- transparent 75%,
- transparent
- );
- background-size: 1.25em 1.25em;
- animation: striped-flow 3s linear infinite;
- }
- .reportItemVal {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .reportLeft {
- margin-right: 50px;
- }
- }
- ::v-deep .pdfDialog .el-dialog {
- height: 100vh;
- display: flex;
- flex-direction: column;
- margin: 0 auto !important;
- .el-dialog__body {
- // height: 100% !important;
- flex: 1;
- background: #fff;
- .pdf-container {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100% !important;
- }
- }
- }
- canvas {
- border: 1px solid #dcdfe6;
- }
- .right-align {
- white-space: nowrap;
- }
- </style>
|