123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308 |
- <template>
- <div style="width: 100%; height: 100%">
- <el-button-group class="buttonGroupClass" style="position: abs">
-
-
- <el-button type="primary" size="small">二厂</el-button>
- <video
- ref="videoMsg"
- src="../../../../assets/alarm/14184.mp3"
- loop="loop"
- style="display: none"
- />
- </el-button-group>
- <div
- style="
- position: absolute;
- top: 15px;
- left: 195px;
- z-index: 10;
- background: #fffb;
- padding: 10px;
- border-radius: 5px;
- "
- >
- <el-switch v-model="isOpenFlow" inactive-text="开启动画" />
- </div>
- <div
- style="
- position: absolute;
- top: 15px;
- left: 330px;
- z-index: 10;
- background: #fffb;
- padding: 10px;
- border-radius: 5px;
- "
- >
- <el-switch v-model="isOpenAlarm" inactive-text="开启报警" />
- </div>
- <div
- v-show="craftShow"
- id="graphContainer"
- ref="graphContainer"
- v-loading="loading"
- class="graph"
- style="width: 100%; height: 100%; background: rgb(5, 37, 58)"
- />
- <div
- v-show="!craftShow"
- id="graphContainer2"
- ref="graphContainer2"
- v-loading="loading"
- class="graph"
- style="width: 100%; height: 100%; background: rgb(5, 37, 58)"
- />
- <el-dialog
- :title="siteTitle"
- :visible.sync="siteVisible"
- width="1400px"
- top="calc(50vh - 350px)"
- >
- <el-row style="margin-top: 8px">
- <span class="title2">时间</span>
-
- <el-time-picker
- v-model="startTime"
- format="HH:mm:ss"
- value-format="HH:mm:ss"
- size="small"
- :picker-options="{
- selectableRange: `00:00:00 - 23:59:00`,
- }"
- />
- <el-time-picker
- v-model="endTime"
- format="HH:mm:ss"
- value-format="HH:mm:ss"
- size="small"
- :picker-options="{
- selectableRange: `${startTime ? startTime : '00:00:00'}-23:59:59`,
- }"
- />
-
- <el-button size="small" type="primary" @click="showResult"
- >查询</el-button
- >
- <el-checkbox v-model="dontShow">去除特殊值(-9999)</el-checkbox>
- </el-row>
- <div
- v-loading="infoLoading"
- style="width: 100%; height: 500px; margin-top: 8px; display: flex"
- >
- <div style="width: 25%; height: 100%">
- <el-table
- :data="siteDatas"
- border
- height="calc(100% - 43px)"
- style="width: 100%"
- >
- <el-table-column prop="scadaTime" label="时间" />
- <el-table-column prop="value" label="测量值" />
- </el-table>
- <el-row style="margin-top: 8px">
- <el-col :span="20">
- <el-pagination
- ref="pagination2"
- small
- background
- layout="total, sizes, prev, next"
- :page-sizes="[10, 20, 50, 100, 1000]"
- :total="total2"
- @current-change="pagRefersh"
- @size-change="pagRefersh"
- />
- </el-col>
- <el-col :span="4">
- <span
- ref="pageLength2"
- style="font-size: 13px"
- class="el-pagination__total"
- >1/30 页</span
- >
- </el-col>
- </el-row>
- </div>
- <div ref="chart" style="width: 75%; height: 100%" />
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { allConfig2, allConfig } from "./craftConfig";
- import siteIndex from "./siteIndex";
- import mxgraph from "mxgraph";
- import request from "@/utils/request";
- import { parseTime } from "@/utils/index";
- import Echarts from "echarts";
- import { getScadaAlarmDataPage } from "@/api/mbsys/scada";
- export default {
- name: "CraftMap2",
- components: { Echarts },
- data() {
- return {
- craftShow: true,
- activeName: "first",
- loading: false,
- infoLoading: false,
- elements: {},
- siteTitle: "",
- siteVisible: false,
- timss: ["", ""],
- startTime: "00:00:00",
- endTime: "23:59:59",
- total2: 0,
- siteDatas: [],
- isOpenFlow: true,
- isOpenFlow2: true,
- isOpenAlarm: true,
- isAlarm: false,
- dontShow: true,
- twinkle: null,
- indexCodes: [],
- };
- },
- watch: {
- isOpenFlow(e) {
- var flows = this.flowLines;
- var flows2 = this.flowLines2;
- var text = e ? "flow" : "flowN";
- for (let i = 0, ii = flows.length; i < ii; i++) {
- flows[i].classList.value = text;
- }
- for (let i = 0, ii = flows2.length; i < ii; i++) {
- flows2[i].classList.value = text;
- }
- },
- isOpenAlarm(e) {
- this.speckVideo(e);
- },
- },
- created() {
- this.indexCodes = [];
- for (var i = 0; i < siteIndex.deviceValue.length; i++) {
- const deviceValue = siteIndex.deviceValue[i];
- if (deviceValue) {
- deviceValue.value.map((item) => {
- if (item.itnm && item.itnm !== "") this.indexCodes.push(item.itnm);
- });
- }
- }
- },
- mounted() {
- this.ready = 0;
- this.loadCraft();
- this.loadCraft2();
- this.getSide();
- var date = new Date();
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- if (month < 10) month = "0" + month;
- if (day < 10) day = "0" + day;
- this.timss = [
- year + "-" + month + "-" + day,
- year + "-" + month + "-" + day,
- ];
- },
- destroyed() {
- if (this.nextDo) clearTimeout(this.nextDo);
- if (this.twinkle) this.twinkle = null;
- },
- methods: {
- init(div) {
- var mx = mxgraph();
- var mxGraphHandler = mx.mxGraphHandler;
- var mxConstants = mx.mxConstants;
- var mxEvent = mx.mxEvent;
- mxEvent.disableContextMenu(div);
- const graph = new mx.mxGraph(div);
- graph.setConnectable(true);
- graph.setTooltips(false);
- graph.setEnabled(false);
- graph.setCellsResizable(true);
- graph.connectionHandler.setCreateTarget(false);
- graph.foldingEnabled = false;
- mxGraphHandler.prototype.setMoveEnabled(false);
- mxGraphHandler.prototype.guidesEnabled = true;
- const p = graph.getDefaultParent();
- const styleE = graph.getStylesheet().getDefaultEdgeStyle();
- styleE[mxConstants.STYLE_EDGE] = "orthogonalEdgeStyle";
- styleE[mxConstants.STYLE_ENDARROW] = "none";
- styleE[mxConstants.STYLE_STROKECOLOR] = "#029ac9";
- if (!this.test) {
- styleE[mxConstants.STYLE_STROKEWIDTH] = 5;
- }
- const styleV = graph.getStylesheet().getDefaultVertexStyle();
- if (!this.test) {
- styleV[mxConstants.STYLE_VERTICAL_LABEL_POSITION] = "bottom";
- styleV[mxConstants.STYLE_VERTICAL_ALIGN] = "top";
- styleV[mxConstants.STYLE_FILLCOLOR] = "none";
- styleV[mxConstants.STYLE_TEXT_OPACITY] = 0;
- styleV[mxConstants.STYLE_STROKECOLOR] = "none";
- }
- return [graph, p];
- },
-
- loadCraft() {
- this.test = false;
- var test = this.test;
- var div = this.$refs.graphContainer;
- var flowLines = (this.flowLines = []);
- const cache = {};
- const modulesFiles = require.context("./images", true, /\.(png|gif)$/);
- modulesFiles.keys().forEach((key) => (cache[key] = modulesFiles(key)));
- var mxPoint = mxgraph().mxPoint;
- var width = div.offsetWidth;
- var height = div.offsetHeight;
- div.innerHTML +=
- '<div class="underSvg"></div><div class="onSvg"><div class="text"></div><div></div></div>';
- var children = div.children;
- var backgroundDiv = children[children.length - 2];
- var backgroundstr = "";
- var showNodeDiv = children[children.length - 1];
- var textDiv = showNodeDiv.children[0];
- var textStr = "";
- var imageDiv = showNodeDiv.children[1];
- var imagestr = "";
- const [graph, p] = this.init(div);
- var nodeMx = [];
- var nodes = [];
- var nodesIndex = {};
- var imagesUrl = "./";
- var that = this;
- setTimeout(() => {
- thenDo().then(() => {
-
- div.parentElement.style.overflow = "auto";
- });
- }, 500);
- async function thenDo() {
-
- let config = allConfig.filter((p) => 1 == 1);
- config.push(...siteIndex.deviceValue);
- for (var i = 0, ii = config.length; i < ii; i++) {
- var node = config[i];
- if (nodesIndex.hasOwnProperty(node.id)) alert("重复ID" + node.id);
- switch (node.type) {
- case "point":
- var x, y;
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- var dx = margin.x[0] * width + margin.x[1];
- var dy = margin.y[0] * height + margin.y[1];
- x = fromNode.x + dx;
- y = fromNode.y + dy;
- } else if (node.locationFrom) {
- var fromInfo = node.locationFrom;
- var fromNodeX = nodesIndex[fromInfo.xFrom];
- var fromNodeY = nodesIndex[fromInfo.yFrom];
- var margin = node.margin;
- x = fromNodeX.x + width * margin.x[0] + margin.x[1];
- y = fromNodeY.y + height * margin.y[0] + margin.y[1];
- } else {
- x = width * node.x[0] - 1 + node.x[1];
- y = height * node.y[0] - 1 + node.y[1];
- }
- var nodeGraph = graph.insertVertex(
- p,
- node.id,
- node.id,
- x,
- y,
- 2,
- 2
- );
- nodeMx.push(nodeGraph);
- nodes.push(
- (nodesIndex[node.id] = {
- type: "point",
- x: x,
- y: y,
- width: 2,
- height: 2,
- graph: nodeGraph,
- })
- );
- break;
- case "image":
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- var x = fromNode.x + margin.x[0] * width + margin.x[1];
- var y = fromNode.y + margin.y[0] * height + margin.y[1];
- var str =
- '<div class="img" style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y.toFixed(2) +
- "px; left: " +
- x.toFixed(2) +
- "px; width: " +
- node.width +
- "px; height: " +
- node.height +
- "px; " +
- (test
- ? "opacity: 0.5;border: 1px solid #0ff;"
- : "background-image: url(" +
- cache[imagesUrl + node.src] +
- ");") +
- '">';
-
- if (node.text) {
- str +=
- '<span class="' +
- (node.class || "unText") +
- '">' +
- (test ? node.id : node.text) +
- "</span>";
- }
- str += "</div>";
- imagestr += str;
- nodes.push(
- (nodesIndex[node.id] = {
- type: "image",
- x: x,
- y: y,
- width: node.width,
- height: node.height,
- })
- );
- }
- break;
- case "text":
- var x;
- var y;
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- x = (fromNode.x + margin.x[0] * width + margin.x[1]).toFixed(2);
- y = (fromNode.y + margin.y[0] * height + margin.y[1]).toFixed(
- 2
- );
- }
- var str;
- if (node.text) {
- str =
- '<div class="inPic" style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y +
- "px; left: " +
- x +
- 'px"><span>' +
- node.text +
- "</span></div>";
- } else {
- str =
- '<ul style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y +
- "px; left: " +
- x +
- "px;" +
- (node.style || "") +
- '">';
- var textIndex = {};
- for (let j = 0, jl = node.value, jj = jl.length; j < jj; j++) {
- var text = jl[j];
- let value = text.value;
- if (text.isType == "1") {
- let types = text.type;
- value = types[text.value] ? types[text.value] : text.value;
- }
- if (text.isType == "2" && text.hasOwnProperty("toFixed")) {
- value = parseFloat(value).toFixed(parseInt(text.toFixed));
- }
- str +=
- '<li class="tf-li" data="' +
- (text.itnm || "") +
- '"><div class="' +
- (node.class || "title") +
- " tfStyleTitle" +
- '"><span>' +
- text.name +
- '</span></div><span class="value tfStyle">' +
- value +
- '</span><span class="unit tfStyle">' +
- text.unit +
- "</span></li>";
- }
- str += "</ul>";
- }
- textStr += str;
- break;
- case "arrow":
- var arrowGraph = graph.insertEdge(
- p,
- null,
- null,
- nodesIndex[node.from].graph,
- nodesIndex[node.to].graph,
- node.style
- );
- var jl = node.road;
- if (jl && jl.length > 0) {
- var arrowGeomentry = arrowGraph.geometry;
- arrowGeomentry.relative = true;
- var points = [];
- for (let j = 0, jj = jl.length; j < jj; j++) {
- var arrowNode = jl[j];
- var id = arrowNode.id;
- if (id) {
- var nodeF = nodesIndex[id];
- var offer = [1, 1];
- if (nodeF.type == "image") offer = [0, 0];
- points.push(
- new mxPoint(
- nodeF.x +
- offer[0] +
- arrowNode.x[0] * width +
- arrowNode.x[1],
- nodeF.y +
- offer[1] +
- arrowNode.y[0] * height +
- arrowNode.y[1]
- )
- );
- } else {
- points.push(
- new mxPoint(
- arrowNode.x[0] * width + arrowNode.x[1],
- arrowNode.y[0] * height + arrowNode.y[1]
- )
- );
- }
- }
- arrowGeomentry.points = points;
- }
- graph.refresh(arrowGraph);
- if (node.flow && !test) {
- var state = graph.view
- .getState(arrowGraph)
- .shape.node.getElementsByTagName("path");
- var [backGroundLine, flowLine] = state;
- backGroundLine.removeAttribute("visibility");
- backGroundLine.setAttribute("class", "flowBack");
- backGroundLine.setAttribute("stroke-width", "12");
- backGroundLine.setAttribute("stroke", "#72a8d4");
- flowLine.setAttribute("class", "flow");
- flowLines.push(flowLine);
- }
- break;
- case "background":
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- var x = fromNode.x + margin.x[0] * width + margin.x[1];
- var y = fromNode.y + margin.y[0] * height + margin.y[1];
- var str =
- '<div style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y.toFixed(2) +
- "px; left: " +
- x.toFixed(2) +
- "px; width: " +
- node.width +
- "px; height: " +
- node.height +
- 'px;">';
- if (node.text) {
- str +=
- '<span class="' +
- (node.class || "onText") +
- '">' +
- (test ? node.id : node.text) +
- "</span>";
- }
- str += "</div>";
- backgroundstr += str;
- nodes.push(
- (nodesIndex[node.id] = {
- type: "background",
- x: x,
- y: y,
- width: node.width,
- height: node.height,
- })
- );
- }
- break;
- }
- }
- textDiv.innerHTML = textStr;
- backgroundDiv.innerHTML = backgroundstr;
- imageDiv.innerHTML = imagestr;
- that.setSide();
- }
- },
- loadCraft2() {
- this.test = false;
- var test = this.test;
- var div = this.$refs.graphContainer;
- var div2 = this.$refs.graphContainer;
- var flowLines = (this.flowLines2 = []);
- const cache = {};
- const modulesFiles = require.context("./images", true, /\.(png|gif)$/);
- modulesFiles.keys().forEach((key) => (cache[key] = modulesFiles(key)));
- var mxPoint = mxgraph().mxPoint;
- var width = div.offsetWidth || div2.offsetWidth;
- var height = div.offsetHeight || div2.offsetHeight;
- div.innerHTML +=
- '<div class="underSvg"></div><div class="onSvg"><div class="text"></div><div></div></div>';
- var children = div.children;
- var backgroundDiv = children[children.length - 2];
- var backgroundstr = "";
- var showNodeDiv = children[children.length - 1];
- var textDiv = showNodeDiv.children[0];
- var textStr = "";
- var imageDiv = showNodeDiv.children[1];
- var imagestr = "";
- const [graph, p] = this.init(div);
- var nodeMx = [];
- var nodes = [];
- var nodesIndex = {};
- var imagesUrl = "./";
- var that = this;
- setTimeout(() => {
- thenDo().then(() => {
-
- div.parentElement.style.overflow = "auto";
- });
- }, 200);
- async function thenDo() {
- let config = allConfig.filter((p) => 1 == 1);
- config.push(...siteIndex.deviceValue);
- for (var i = 0, ii = config.length; i < ii; i++) {
- var node = config[i];
- if (nodesIndex.hasOwnProperty(node.id)) alert("重复ID" + node.id);
- switch (node.type) {
- case "point":
- var x, y;
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- var dx = margin.x[0] * width + margin.x[1];
- var dy = margin.y[0] * height + margin.y[1];
- x = fromNode.x + dx;
- y = fromNode.y + dy;
- } else if (node.locationFrom) {
- var fromInfo = node.locationFrom;
- var fromNodeX = nodesIndex[fromInfo.xFrom];
- var fromNodeY = nodesIndex[fromInfo.yFrom];
- var margin = node.margin;
- x = fromNodeX.x + width * margin.x[0] + margin.x[1];
- y = fromNodeY.y + height * margin.y[0] + margin.y[1];
- } else {
- x = width * node.x[0] - 1 + node.x[1];
- y = height * node.y[0] - 1 + node.y[1];
- }
- var nodeGraph = graph.insertVertex(
- p,
- node.id,
- node.id,
- x,
- y,
- 2,
- 2
- );
- nodeMx.push(nodeGraph);
- nodes.push(
- (nodesIndex[node.id] = {
- type: "point",
- x: x,
- y: y,
- width: 2,
- height: 2,
- graph: nodeGraph,
- })
- );
- break;
- case "image":
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- var x = fromNode.x + margin.x[0] * width + margin.x[1];
- var y = fromNode.y + margin.y[0] * height + margin.y[1];
- var str =
- '<div class="img" style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y.toFixed(2) +
- "px; left: " +
- x.toFixed(2) +
- "px; width: " +
- node.width +
- "px; height: " +
- node.height +
- "px; " +
- (test
- ? "opacity: 0.5;border: 1px solid #0ff;"
- : "background-image: url(" +
- cache[imagesUrl + node.src] +
- ");") +
- '">';
-
- if (node.text) {
- str +=
- '<span class="' +
- (node.class || "unText") +
- '">' +
- (test ? node.id : node.text) +
- "</span>";
- }
- str += "</div>";
- imagestr += str;
- nodes.push(
- (nodesIndex[node.id] = {
- type: "image",
- x: x,
- y: y,
- width: node.width,
- height: node.height,
- })
- );
- }
- break;
- case "text":
- var x;
- var y;
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- x = (fromNode.x + margin.x[0] * width + margin.x[1]).toFixed(2);
- y = (fromNode.y + margin.y[0] * height + margin.y[1]).toFixed(
- 2
- );
- }
- var str;
- if (node.text) {
- str =
- '<div class="inPic" style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y +
- "px; left: " +
- x +
- 'px"><span>' +
- node.text +
- "</span></div>";
- } else {
- const className =
- node.id == "m1t6" || node.id == "m1t7" ? true : false;
- str =
- '<ul style="' +
- (className ? "color:#fff;" : "") +
- "transform: translate(-" +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y +
- "px; left: " +
- x +
- "px;" +
- (node.style || "") +
- '">';
- var textIndex = {};
- for (let j = 0, jl = node.value, jj = jl.length; j < jj; j++) {
- var text = jl[j];
- let value = text.value;
- if (text.isType == "1") {
- let types = text.type;
- value = types[text.value] ? types[text.value] : text.value;
- }
- if (text.isType == "2" && text.hasOwnProperty("toFixed")) {
- value = parseFloat(value).toFixed(parseInt(text.toFixed));
- }
- str +=
- '<li class="tf-li" data="' +
- (text.itnm || "") +
- '"><div class="' +
- (node.class || "title") +
- " tfStyleTitle" +
- '"><span>' +
- text.name +
- '</span></div><span class="value tfStyle">' +
- value +
- '</span><span class="unit tfStyle">' +
- text.unit +
- "</span></li>";
- }
- str += "</ul>";
- }
- textStr += str;
- break;
- case "arrow":
- var arrowGraph = graph.insertEdge(
- p,
- null,
- null,
- nodesIndex[node.from].graph,
- nodesIndex[node.to].graph,
- node.style
- );
- var jl = node.road;
- if (jl && jl.length > 0) {
- var arrowGeomentry = arrowGraph.geometry;
- arrowGeomentry.relative = true;
- var points = [];
- for (let j = 0, jj = jl.length; j < jj; j++) {
- var arrowNode = jl[j];
- var id = arrowNode.id;
- if (id) {
- var nodeF = nodesIndex[id];
- var offer = [1, 1];
- if (nodeF.type == "image") offer = [0, 0];
- points.push(
- new mxPoint(
- nodeF.x +
- offer[0] +
- arrowNode.x[0] * width +
- arrowNode.x[1],
- nodeF.y +
- offer[1] +
- arrowNode.y[0] * height +
- arrowNode.y[1]
- )
- );
- } else {
- points.push(
- new mxPoint(
- arrowNode.x[0] * width + arrowNode.x[1],
- arrowNode.y[0] * height + arrowNode.y[1]
- )
- );
- }
- }
- arrowGeomentry.points = points;
- }
- graph.refresh(arrowGraph);
- if (node.flow && !test) {
- var state = graph.view
- .getState(arrowGraph)
- .shape.node.getElementsByTagName("path");
- var [backGroundLine, flowLine] = state;
- backGroundLine.removeAttribute("visibility");
- backGroundLine.setAttribute("class", "flowBack");
- backGroundLine.setAttribute("stroke-width", "12");
- backGroundLine.setAttribute("stroke", "#72a8d4");
- flowLine.setAttribute("class", "flow");
- flowLines.push(flowLine);
- }
- break;
- case "background":
- if (node.from) {
- var fromNode = nodesIndex[node.from];
- var margin = node.margin;
- var x = fromNode.x + margin.x[0] * width + margin.x[1];
- var y = fromNode.y + margin.y[0] * height + margin.y[1];
- var str =
- '<div style="transform: translate(-' +
- node.point[0] * 100 +
- "%,-" +
- node.point[1] * 100 +
- "%); top: " +
- y.toFixed(2) +
- "px; left: " +
- x.toFixed(2) +
- "px; width: " +
- node.width +
- "px; height: " +
- node.height +
- 'px;">';
- if (node.text) {
- str +=
- '<span class="' +
- (node.class || "onText") +
- '">' +
- (test ? node.id : node.text) +
- "</span>";
- }
- str += "</div>";
- backgroundstr += str;
- nodes.push(
- (nodesIndex[node.id] = {
- type: "background",
- x: x,
- y: y,
- width: node.width,
- height: node.height,
- })
- );
- }
- break;
- }
- }
- textDiv.innerHTML = textStr;
- backgroundDiv.innerHTML = backgroundstr;
- imageDiv.innerHTML = imagestr;
- that.setSide();
- }
- },
- getSide() {
- request({
- url: "/tofly-scada/scada/app/data",
- method: "post",
- data: {
- type: 1,
- },
- }).then((res) => {
- if (res && res.code == 1) {
- var scada = (this.scada = {});
- res.result.map((e) => {
- if (e.allocations) {
- for (const i in e.allocations) {
- scada[e.allocations[i].variableCode] = e.allocations[i];
- }
- }
- });
- this.setSide();
- } else {
- this.$message.error("获取指标失败:" + res.message);
-
- }
- });
- this.getAlarmData();
- },
- getAlarmData() {
- if (this.indexCodes.length < 1) return;
- const frontHelfTime = parseTime(
- new Date(new Date().getTime() - 24 * 60 * 30 * 1000),
- "{y}-{m}-{d} {h}:{i}:{s}"
- );
- const nowTime = parseTime(new Date(), "{y}-{m}-{d} {h}:{i}:{s}");
- const params = {
- codes: this.indexCodes.toString(),
- status: 0,
- start: frontHelfTime,
- end: nowTime,
- current: 1,
- size: 20,
- };
-
-
-
- },
- setSide() {
- this.ready += 1;
- if (this.ready == 3) {
- var scada = this.scada;
- var allLis = [];
- var lis = this.$refs.graphContainer.querySelectorAll("li");
-
- allLis.push.apply(allLis, lis);
-
-
- var infos = {};
- var loadSite = () => {
- for (var i = 0, ii = allLis.length; i < ii; i++) {
- var dl = allLis[i];
- var att = dl.getAttribute("data");
- if (att && scada.hasOwnProperty(att)) {
- dl.onclick = this.showHistoty;
- dl = dl.children;
- var datt = scada[att];
-
- dl[1].innerHTML = "-";
- dl[2].innerHTML = datt.unit;
- infos[datt.variableCode] = dl[1];
- }
- }
-
- this.$nextTick(loadInfo);
- };
- var loadInfo = () => {
- try {
-
- request({
- url: "/tofly-scada/scada/app/data",
- method: "post",
- data: {
- type: 1,
- },
- })
- .then((res) => {
- if (res && res.code && res.code == 1) {
- res = res.result;
- for (var item in res) {
- var di = res[item];
- if (di.allocations) {
- for (const i in di.allocations) {
- var t = di.allocations[i].variableCode;
- if (infos.hasOwnProperty(t)) {
- let n = di.allocations[i]
- ? di.allocations[i].scada.value
- : "null";
- if (n == "null") n = "-";
- if (t == "S7.300.1#F_POWER_FAULT")
- n = n == "1" ? "开" : "关";
- if (t == "S7.300.1#F_OPEN")
- n = n == "1" ? "开" : "关";
- if (t == "S7.300.2#F_OPEN")
- n = n == "1" ? "开" : "关";
- if (t == "S7.300.2#F_POWER_FAULT")
- n = n == "1" ? "开" : "关";
- if (t == "S7.300.CHU_SS")
- n = parseFloat(n).toFixed(3);
- if (t == "S7.300.CHU_CL")
- n = parseFloat(n).toFixed(3);
- if (t == "S7.300.CHU_FT")
- n = parseFloat(n).toFixed(3);
- if (t == "S7.300.1#QSYW")
- n = parseFloat(n).toFixed(3);
- if (t == "S7.300.2#QSYW")
- n = parseFloat(n).toFixed(3);
- infos[t].innerHTML = n;
- }
- }
- }
- }
- this.nextDo = setTimeout(loadInfo, 1000 * 10);
- this.setAlarm(res, infos);
- } else {
- this.$message.error("获取指标失败:" + res.message);
- this.nextDo = setTimeout(loadInfo, 1000 * 10);
- }
-
- })
- .catch((ex) => {
- this.$message.error("连接异常:" + ex);
- this.nextDo = setTimeout(loadInfo, 1000 * 10);
- });
- } catch (ex) {
- this.nextDo = setTimeout(loadInfo, 1000 * 10);
- }
- };
- this.$nextTick(loadSite);
- }
- },
- showHistoty(e) {
- var att = e.currentTarget.getAttribute("data");
- var scada = this.scada;
- if (att && scada.hasOwnProperty(att)) {
- this.siteVisible = true;
- this.$nextTick(() => {
- var ec = this.$refs.chart;
- this.chart = Echarts.init(ec);
- var datt = scada[att];
- this.siteTitle = datt.displayName;
- this.selectSite = att;
- this.showResult();
- });
- }
- },
- showResult() {
- if (this.selectSite) {
-
- var datt = this.scada[this.selectSite];
- this.getAllDate(datt.variableCode, datt.displayName);
- this.pagRefersh(false);
- }
- },
- getAllDate(stid, zbx) {
- var times = [
- this.timss[0] + " " + this.startTime,
- this.timss[1] + " " + this.endTime,
- ];
-
-
- var datt = this.scada[this.selectSite];
- request({
- url:
- "/tofly-scada/scada/page?code=" +
- stid +
- "&start=" +
- times[0] +
- "&end=" +
- times[1] +
- "&size=" +
- 10000 +
- "&statisticsType=" +
- 0,
- method: "get",
- }).then((res) => {
- var chart = this.chart;
- chart.clear();
- if (res.code == 1) {
- res = res.result.records;
- var dataX = [];
- var dataY = [];
- var dontShow = this.dontShow;
- var max = -Infinity;
- var min = Infinity;
- var Xmax = -Infinity;
- var Xmin = Infinity;
- var d;
- var symbol = "none";
- for (var i = 0, il = res, ii = il.length; i < ii; i++) {
- var v = parseFloat(il[i].value);
- if (dontShow && v == -9999) continue;
- var x = il[i].startTime
- ? il[i].startTime.split(" ")[1]
- : il[i].scadaTime
- ? il[i].scadaTime.split(" ")[1]
- : "";
- dataX.push(x);
- dataY.push(v);
- }
- var unit = datt.unit;
- var type = zbx;
- chart.setOption({
- title: {
- text: zbx,
- left: "center",
- subtext: times[0] + "至" + times[1],
- },
- color: "rgb(45, 116, 231)",
- grid: { left: "50px", right: "50px", bottom: "80px" },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- toolbox: { feature: { saveAsImage: {} } },
- tooltip: {
- trigger: "axis",
- formatter(a) {
- return (
- "记录时间:" +
- a[0].axisValue +
- "<br>" +
- type +
- " " +
- a[0].data +
- " " +
- unit
- );
- },
- },
- xAxis: [
- {
- name: "日期",
- type: "category",
- data: dataX,
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- },
- ],
- yAxis: [{ name: unit, type: "value" }],
- series: [{ type: "line", smooth: false, data: dataY }],
- });
- } else this.$message(res.message);
-
- });
- },
-
- setAlarm(data, infos) {
- if (data.length > 0) {
- const alarmData = data[0].allocations.filter(
- (item) => item.scadaReports != null
- );
- let alarmArr = [];
- let openAlarm = false;
- this.isAlarm = false;
- alarmData.forEach((alarm) => {
- const value = parseFloat(alarm.scada.value);
- const scadaReports = alarm.scadaReports;
- const variableCode = alarm.variableCode;
- if (scadaReports) {
- scadaReports.forEach((p) => {
- const max = parseFloat(p.reportUpper);
- const min = parseFloat(p.reportLower);
- if (value > max || value < min) {
- openAlarm = true;
- this.isAlarm = true;
- const obj = Object.assign(
- { variableCode: variableCode },
- parseFloat
- );
- alarmArr.push(obj);
- }
- });
- }
- });
-
- if (this.isOpenAlarm) {
- this.speckVideo(openAlarm);
- this.twinkle = setInterval(() => {
- alarmArr.forEach((op) => {
- const color = infos[op.variableCode].style.color;
- let clr = "red";
- if (
- ["S7.300.1#QSYW", "S7.300.2#QSYW"].includes(op.variableCode)
- ) {
- clr = color == "red" ? "#fff" : "red";
- } else {
- clr = color == "red" ? "#fff" : "red";
- }
- infos[op.variableCode].style.color = clr;
- });
- }, 500);
- } else {
- for (key in infos) {
- if (["S7.300.1#QSYW", "S7.300.2#QSYW"].includes(key)) {
- infos[key].style.color = "#ffffff";
- } else {
- infos[key].style.color = "#ffffff";
- }
- }
- if (this.twinkle) this.twinkle = null;
- }
- }
- },
-
- speckVideo(alarm) {
- this.$nextTick(() => {
- const _videoMsg = this.$refs.videoMsg;
- alarm && this.isAlarm ? _videoMsg.play() : _videoMsg.pause();
- });
- },
- pagRefersh(bool) {
- var datt = this.scada[this.selectSite];
- var pages = this.$refs.pagination2;
- var times = [
- this.timss[0] + " " + this.startTime,
- this.timss[1] + " " + this.endTime,
- ];
-
- request({
- url:
- "/tofly-scada/scada/page?code=" +
- datt.variableCode +
- "&start=" +
- times[0] +
- "&end=" +
- times[1] +
- "&statisticsType=" +
- 0 +
- "¤t=" +
- pages.internalCurrentPage +
- "&size=" +
- pages.internalPageSize,
- method: "get",
- }).then((res) => {
- if (res.code == 1) {
- res = res.result;
- this.siteDatas = res.records;
- this.$refs.pageLength2.innerHTML =
- pages.internalCurrentPage +
- "/" +
- Math.ceil((this.total2 = res.total) / pages.internalPageSize) +
- " 页";
- } else {
- this.$message.error(res.message);
- this.siteDatas = [];
- this.$refs.pageLength2.innerHTML = "1/1 页";
- }
-
- });
- },
- },
- };
- </script>
- <style lang='scss' scoped>
- .buttonGroupClass {
- border-radius: unset;
- border-right: none;
- position: absolute;
- top: 20px;
- left: 50px;
- z-index: 999;
- }
- .onWhiteText {
- color: #8ac9fb !important;
- }
- .inPic {
- color: #8ac9fb !important;
- font-size: 17px;
- }
- >>> .tfStyleTitle {
- font-size: 24px !important;
- margin-bottom: 10px !important;
- }
- >>> .tfStyle {
- font-size: 24px !important;
- margin-bottom: 10px !important;
- }
- >>> .tf-li {
- margin-bottom: 16px !important;
- }
- </style>
|