nitrogenHome_lt.vue 18 KB

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