nitrogenHome_lt.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <div id="nitrogen3D" style="width: 100%; height: 100%; position: absolute; overflow: hidden"></div>
  3. <div id="nitrogenCss3D" class="threejs-Object-CSS"
  4. style="width: 100%; height: 100%; position: absolute; pointer-events: none; overflow: hidden; z-index: 2; top: 0px; left: 0px">
  5. <a-spin :spinning="loading" />
  6. <div v-for="groupNum in monitorDataGroupNum" :key="groupNum" class="modal-monitor">
  7. <fourBorderBg :class="`kyj${groupNum}`" :id="`nitrogenMonitor${groupNum}`">
  8. <div class="title">空压机{{ groupNum }} </div>
  9. <template v-for="(preMonitor, preMonitorIndex) in preMonitorList" :key="preMonitorIndex">
  10. <div class="monitor-item">
  11. <span class="monitor-title">{{ preMonitor.title }}:</span>
  12. <span class="monitor-val"><span class="val">{{ monitorData[preMonitor.code] ?
  13. formatNum(monitorData[preMonitor.code]) : '-' }}</span><span class="unit">{{
  14. preMonitor.unit }}</span></span>
  15. </div>
  16. </template>
  17. </fourBorderBg>
  18. </div>
  19. </div>
  20. <div class="nitrogen-home">
  21. <div class="nitrogen-container">
  22. <div class="top-box">
  23. <!-- 左边监测数据 -->
  24. <div class="lr-box left-box">
  25. <ventBox1>
  26. <template #title>
  27. <div>注氮机监测</div>
  28. </template>
  29. <template #container>
  30. <div class="input-item" v-for="(preFan, index) in nitrogenMonitorData" :key="index">
  31. <div class="title">{{ preFan.title }}</div>
  32. <div class="value">{{
  33. monitorData[preFan.code] >= 0 ? formatNum(Number(monitorData[preFan.code])) : '-'
  34. }}</div>
  35. <div class="unit">{{ preFan.unit !== 'signal' ? `(${preFan.unit})` : '' }}</div>
  36. </div>
  37. </template>
  38. </ventBox1>
  39. <div class="item item-l" v-for="groupNum in monitorDataGroupNum" :key="groupNum">
  40. <ventBox1>
  41. <template #title>
  42. <div>空压机{{ groupNum }}</div>
  43. </template>
  44. <template #container>
  45. <div class="monitor-box">
  46. <div class="monitor-item">
  47. <div class="state-item" v-for="(preFan, index) in preFanMonitorData"
  48. :key="index">
  49. <div class="state-title">{{ preFan.title + (preFan.unit !== 'signal' ?
  50. `(${preFan.unit})` : '') }}</div>
  51. <div :class="{
  52. 'signal-round': true,
  53. 'signal-round-warning': monitorData[preFan.code] == '1',
  54. 'signal-round-run': monitorData[preFan.code] == '0',
  55. 'signal-round-gry':monitorData[preFan.code] != '0' && monitorData[preFan.code] != '1'
  56. }"></div>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. </ventBox1>
  62. </div>
  63. </div>
  64. <!-- 右边控制状态 -->
  65. <div class="lr-box right-box">
  66. <ventBox1 class="vent-margin-t-10">
  67. <template #title>
  68. <div>设备实时监测曲线</div>
  69. </template>
  70. <template #container>
  71. <BarAndLine v-if="chartsColumns.length > 0" xAxisPropType="readTime"
  72. :dataSource="echartData" height="340px" :chartsColumns="chartsColumns"
  73. chartsType="listMonitor" :option="echatsOption" />
  74. </template>
  75. </ventBox1>
  76. <div ref="playerRef" style="height: auto; width: 100%; margin-top: 10px"></div>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </template>
  82. <script lang="ts" setup name="nitrogenHome">
  83. import { onMounted, onUnmounted, ref, watch, reactive, defineProps, nextTick, inject } from 'vue';
  84. import ventBox1 from '/@/components/vent/ventBox1.vue';
  85. import fourBorderBg from '../../../comment/components/fourBorderBg.vue';
  86. import { mountedThree, destroy, setModelType } from '../nitrogen.threejs';
  87. import { getDevice } from '../nitrogen.api';
  88. import BarAndLine from '/@/components/chart/BarAndLine.vue';
  89. import { preMonitorList, preFanMonitorData, nitrogenMonitorData } from '../nitrogen.data.lt';
  90. import { formatNum } from '/@/utils/ventutil';
  91. import { useCamera } from '/@/hooks/system/useCamera';
  92. import lodash from 'lodash';
  93. const props = defineProps({
  94. deviceId: {
  95. type: String,
  96. require: true,
  97. },
  98. modalType: {
  99. type: String,
  100. require: true,
  101. },
  102. });
  103. const playerRef = ref();
  104. const refresh = ref(false);
  105. const loading = ref(true);
  106. // const kyjs = ['1号空压机', '1号空压机', '1号空压机', '1号空压机'];
  107. const flvURL1 = () => {
  108. // return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  109. return '';
  110. };
  111. const echatsOption = {
  112. grid: {
  113. top: '35%',
  114. left: '15%',
  115. right: '20px',
  116. bottom: '8%',
  117. // containLabel: true
  118. },
  119. toolbox: {
  120. feature: {},
  121. },
  122. };
  123. const monitorDataGroupNum = ref(1);
  124. const chartsColumns = ref([
  125. {
  126. legend: '瞬时流量',
  127. seriesName: '(m³/h)',
  128. ymax: 2000,
  129. yname: 'm³/h',
  130. linetype: 'line',
  131. yaxispos: 'left',
  132. color: '#FDB146',
  133. sort: 1,
  134. xRotate: 0,
  135. dataIndex: 'InputFlux',
  136. },
  137. ]);
  138. const { getCamera, removeCamera } = useCamera();
  139. const monitorData = ref({});
  140. //图表数据
  141. let echartData = ref<any>([]);
  142. // https获取监测数据
  143. let timer: null | NodeJS.Timeout = null;
  144. async function getMonitor(flag?) {
  145. if (Object.prototype.toString.call(timer) === '[object Null]') {
  146. return new Promise(async (resolve) => {
  147. timer = await setTimeout(
  148. async () => {
  149. if (props.deviceId) {
  150. await getDataSource(props.deviceId);
  151. }
  152. if (timer) {
  153. timer = null;
  154. }
  155. resolve(null);
  156. await getMonitor();
  157. },
  158. flag ? 0 : 3000
  159. );
  160. });
  161. }
  162. }
  163. async function getDataSource(systemID) {
  164. const res = await getDevice({ devicetype: 'sys', systemID, type: 'all' });
  165. if (res) {
  166. const result = res;
  167. if (!result || result.msgTxt.length < 1) return;
  168. result.msgTxt.forEach((item) => {
  169. if (item.type && item.type.startsWith('nitrogen')) {
  170. monitorData.value = Object.assign(item['datalist'][0], item['datalist'][0]['readData']);
  171. const airCompressor = { readTime: monitorData.value['readTime'].substring(11) };
  172. const dataArr = lodash.cloneDeep(echartData.value);
  173. //图表数据
  174. if (dataArr.length <= 5) {
  175. airCompressor[`InputFlux`] = monitorData.value['InputFlux'] || 0;
  176. dataArr.push(airCompressor);
  177. } else {
  178. dataArr.shift();
  179. dataArr.push(airCompressor);
  180. }
  181. echartData.value = dataArr;
  182. }
  183. });
  184. refresh.value = true;
  185. nextTick(() => {
  186. refresh.value = false;
  187. });
  188. }
  189. }
  190. watch([monitorDataGroupNum, loading], ([newMonitorDataGroupNum, newLoading]) => {
  191. nextTick(() => {
  192. if (newMonitorDataGroupNum && !newLoading) {
  193. setModelType(props.modalType, newMonitorDataGroupNum);
  194. }
  195. });
  196. });
  197. onMounted(async () => {
  198. await getMonitor(true);
  199. await mountedThree().then(() => {
  200. loading.value = false;
  201. });
  202. await getCamera(props.deviceId, playerRef.value);
  203. });
  204. onUnmounted(() => {
  205. destroy();
  206. removeCamera();
  207. if (timer) {
  208. clearTimeout(timer);
  209. timer = undefined;
  210. }
  211. });
  212. </script>
  213. <style lang="less" scoped>
  214. @ventSpace: zxm;
  215. .nitrogen-box {
  216. width: 100%;
  217. height: 100%;
  218. display: flex;
  219. justify-content: center;
  220. }
  221. #nitrogenCss3D {
  222. .modal-monitor {
  223. width: 200px;
  224. position: absolute;
  225. left: 0px;
  226. top: 0px;
  227. }
  228. &:deep(.win) {
  229. margin: 0 !important;
  230. background: #00000044;
  231. }
  232. }
  233. .nitrogen-home {
  234. width: 100%;
  235. height: 100%;
  236. position: fixed;
  237. z-index: 9999;
  238. display: flex;
  239. flex-direction: column;
  240. justify-content: center;
  241. align-items: center;
  242. pointer-events: none;
  243. top: 20px;
  244. .nitrogen-container {
  245. width: 100%;
  246. height: calc(100% - 100px);
  247. display: flex;
  248. justify-content: space-between;
  249. margin-bottom: 100px;
  250. .device-state {
  251. width: 100%;
  252. position: absolute;
  253. top: 20px;
  254. color: #e90000;
  255. display: flex;
  256. justify-content: center;
  257. font-size: 20px;
  258. }
  259. .top-box {
  260. width: 100%;
  261. padding: 10px;
  262. overflow: hidden;
  263. display: flex;
  264. justify-content: space-between;
  265. // margin-top: 40px;
  266. .center-item-box {
  267. position: absolute;
  268. left: 50%;
  269. top: 50px;
  270. transform: translate(-48%, 0);
  271. width: calc(100% - 720px);
  272. height: 50px;
  273. display: flex;
  274. align-items: center;
  275. pointer-events: auto;
  276. .top-left {
  277. display: flex;
  278. flex: 1.5;
  279. color: #fff;
  280. .button-box {
  281. position: relative;
  282. width: auto;
  283. height: 32px;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. border-radius: 5px;
  288. color: #fff;
  289. padding: 10px 15px;
  290. margin: 0px 10px;
  291. box-sizing: border-box;
  292. cursor: pointer;
  293. background: linear-gradient(#1fa6cb, #127cb5);
  294. &:hover {
  295. background: linear-gradient(#1fa6cbcc, #127cb5cc);
  296. }
  297. }
  298. }
  299. .top-center {
  300. display: flex;
  301. flex: 1;
  302. justify-content: center;
  303. align-items: center;
  304. font-size: 20px;
  305. color: #fff;
  306. .top-c-label {
  307. color: yellow;
  308. }
  309. }
  310. .top-right {
  311. display: flex;
  312. flex: 2;
  313. justify-content: right;
  314. align-items: center;
  315. color: #fff;
  316. .control-type {
  317. display: flex;
  318. color: #fff;
  319. .control-title {
  320. color: #73e8fe;
  321. }
  322. }
  323. }
  324. }
  325. .lr-box {
  326. height: 90%;
  327. display: flex;
  328. flex-direction: column;
  329. position: relative;
  330. // overflow: hidden;
  331. z-index: 9999;
  332. pointer-events: auto;
  333. overflow-y: auto;
  334. overflow-x: hidden;
  335. }
  336. .item {
  337. width: 305px;
  338. height: 450px;
  339. position: relative;
  340. border-radius: 5px;
  341. margin-top: 10px;
  342. margin-bottom: 0px;
  343. pointer-events: auto;
  344. color: #fff;
  345. // overflow: hidden;
  346. &:first-child {
  347. margin-top: 0px;
  348. }
  349. .base-title {
  350. color: #fff;
  351. margin-bottom: 8px;
  352. padding-left: 10px;
  353. position: relative;
  354. font-size: 16px;
  355. &::after {
  356. content: '';
  357. position: absolute;
  358. display: block;
  359. width: 4px;
  360. height: 12px;
  361. top: 7px;
  362. left: 0px;
  363. background: #45d3fd;
  364. border-radius: 4px;
  365. }
  366. }
  367. .monitor-item {
  368. width: 100%;
  369. display: flex;
  370. flex-direction: row;
  371. flex-wrap: wrap;
  372. .state-item {
  373. width: 50%;
  374. padding: 5px;
  375. display: flex;
  376. align-items: center;
  377. justify-content: space-between;
  378. .state-title {
  379. width: 100px;
  380. color: #ffffffdd;
  381. flex: 9;
  382. font-size: 14px;
  383. .unit {
  384. // color: #ffffffbb;
  385. }
  386. }
  387. .state-val {
  388. flex: 1;
  389. color: #e4a300;
  390. margin-right: 5px;
  391. text-align: right;
  392. font-size: 14px;
  393. }
  394. }
  395. }
  396. .signal-box {
  397. margin: 5px 0;
  398. display: flex;
  399. align-items: center;
  400. .signal-title {
  401. color: #7af5ff;
  402. margin: 0 5px;
  403. }
  404. &:last-child {
  405. margin-right: 0px;
  406. }
  407. }
  408. .list-item {
  409. padding: 0 10px;
  410. display: flex;
  411. justify-content: space-between;
  412. align-items: center;
  413. .item-data-key {
  414. color: #ffffff99;
  415. }
  416. }
  417. .item-data-box {
  418. color: #fff;
  419. .state-icon {
  420. display: inline-block;
  421. width: 12px;
  422. height: 12px;
  423. border-radius: 12px;
  424. }
  425. .open {
  426. border: 5px solid #133a56;
  427. background: #4ecb73;
  428. }
  429. .close {
  430. border: 5px solid #192961;
  431. background: #6d7898;
  432. }
  433. }
  434. }
  435. .item-l {
  436. width: 100%;
  437. .monitor-box {
  438. width: 100%;
  439. .parameter-title {
  440. position: relative;
  441. width: 100%;
  442. height: 14px;
  443. margin-top: 10px;
  444. .icon,
  445. span {
  446. position: absolute;
  447. top: -10px;
  448. }
  449. }
  450. .group-parameter-title {
  451. background-image: linear-gradient(to right, #39a3ff50, #39a3ff00);
  452. .icon {
  453. left: -12px;
  454. top: -17px;
  455. }
  456. span {
  457. left: 18px;
  458. }
  459. .item-col {
  460. background-image: linear-gradient(to right, #39a3ff00, #39a3ff10);
  461. }
  462. }
  463. .device-parameter-title {
  464. background-image: linear-gradient(to right, #3df6ff40, #3df6ff00);
  465. .icon {
  466. left: -10px;
  467. top: -14px;
  468. }
  469. span {
  470. left: 18px;
  471. }
  472. .item-col {
  473. background-image: linear-gradient(to right, #3df6ff10, #3df6ff00);
  474. }
  475. }
  476. }
  477. }
  478. .right-box {
  479. width: 300px;
  480. margin-top: 50px;
  481. }
  482. .left-box {
  483. width: 335px;
  484. margin-top: 80px;
  485. .input-item {
  486. display: flex;
  487. justify-content: space-between;
  488. align-items: center;
  489. padding: 4px 8px;
  490. margin: 6px 0;
  491. background-image: linear-gradient(to right, #39deff15, #3977e500);
  492. .title {
  493. width: 200px;
  494. }
  495. .title-auto {
  496. width: auto;
  497. }
  498. .input-value {
  499. width: 80px;
  500. height: 28px;
  501. line-height: 28px !important;
  502. background: transparent !important;
  503. border-color: #228da2 !important;
  504. color: #fff !important;
  505. }
  506. .value {
  507. width: 100px;
  508. color: #00d8ff;
  509. padding-right: 20px;
  510. }
  511. .unit {
  512. width: 80px;
  513. }
  514. }
  515. }
  516. }
  517. &:deep(.win) {
  518. width: 100%;
  519. margin: 0 !important;
  520. }
  521. }
  522. }
  523. &:deep(.main) {
  524. .title {
  525. height: 34px;
  526. text-align: center;
  527. font-weight: 600;
  528. color: #7af5ff;
  529. // background-image: url('../../../assets/img/yfj/light.png');
  530. background-repeat: no-repeat;
  531. background-position-x: center;
  532. background-position-y: 100%;
  533. background-size: 80%;
  534. font-size: 16px;
  535. }
  536. .monitor-item {
  537. width: 200px;
  538. display: flex;
  539. flex-direction: row;
  540. width: auto;
  541. margin-bottom: 3px;
  542. .monitor-val {
  543. color: #ffb700;
  544. display: flex;
  545. width: auto;
  546. .val {
  547. width: 80px;
  548. font-size: 14px;
  549. }
  550. .unit {
  551. color: #ffffffbb;
  552. font-size: 14px;
  553. }
  554. }
  555. }
  556. .monitor-title {
  557. width: 100px;
  558. color: #7af5ff;
  559. font-weight: 400;
  560. font-size: 14px;
  561. }
  562. .signal-item {
  563. display: flex;
  564. justify-content: space-between;
  565. // margin-bottom: 5px;
  566. .signal-round {
  567. display: inline-block;
  568. width: 8px;
  569. height: 8px;
  570. border-radius: 50%;
  571. margin: 0 10px;
  572. position: relative;
  573. &::after {
  574. display: block;
  575. content: '';
  576. position: absolute;
  577. width: 12px;
  578. height: 12px;
  579. top: -2px;
  580. left: -2px;
  581. border-radius: 50%;
  582. }
  583. }
  584. .signal-round-gry {
  585. background-color: #858585;
  586. &::after {
  587. background-color: #85858544;
  588. box-shadow: 0 0 1px 1px #85858599;
  589. }
  590. }
  591. .signal-round-run {
  592. background-color: #67fc00;
  593. &::after {
  594. background-color: #67fc0044;
  595. box-shadow: 0 0 1px 1px #c6ff77;
  596. }
  597. }
  598. .signal-round-warning {
  599. background-color: #e9170b;
  600. &::after {
  601. background-color: #e9170b44;
  602. box-shadow: 0 0 1px 1px #e9170b;
  603. }
  604. }
  605. }
  606. }
  607. :deep(.zxm-radio-wrapper) {
  608. color: #fff !important;
  609. }
  610. </style>