index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div class="bg" style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden">
  3. <a-spin :spinning="loading" />
  4. <div id="window3D" v-show="!loading" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
  5. <!-- <div id="damper3DCSS" v-show="!loading" style="width: 100%; height: 100%; top:0; left: 0; position: absolute; overflow: hidden;">
  6. <div>
  7. <div ref="elementContent" class="elementContent">
  8. <p><span class="data-title">压力(Pa):</span>{{selectData.frontRearDP}}</p>
  9. <p><span class="data-title">动力源压力(MPa):</span>{{selectData.sourcePressure}}</p>
  10. <p><span class="data-title">故障诊断:</span>
  11. <i
  12. :class="{'state-icon': true, 'open': selectData.messageBoxStatus, 'close': !selectData.messageBoxStatus}"
  13. ></i>{{selectData.fault}}</p>
  14. </div>
  15. </div>
  16. </div> -->
  17. </div>
  18. <div class="scene-box">
  19. <div class="top-box">
  20. <div class="top-center">
  21. <!-- <div class="input-box">
  22. <span class="input-title">风窗面积:</span>
  23. <a-input-number size="small" placeholder="0" :min="0" :max="90" :step="1" v-model:value="windowAngle" />
  24. </div> -->
  25. <div v-if="selectData.nwindownum == 2" class="row">
  26. <div class="button-box" @click="setArea(1)">设定前窗面积</div>
  27. <div class="button-box" @click="setArea(2)">设定后窗面积</div>
  28. </div>
  29. <div v-if="selectData.nwindownum == 1" class="row">
  30. <div class="button-box" @click="setArea(1)">设定风窗面积</div>
  31. </div>
  32. </div>
  33. <!-- <div class="top-right row">
  34. <div class="control-type row">
  35. <div class="control-title">控制模式:</div>
  36. <a-radio-group v-model:value="controlType">
  37. <a-radio :value="1">就地</a-radio>
  38. <a-radio :value="2">远程</a-radio>
  39. </a-radio-group>
  40. </div>
  41. <div class="run-type row">
  42. <div class="control-title">运行状态:</div>
  43. <a-radio-group v-model:value="controlType">
  44. <a-radio :value="1">检修</a-radio>
  45. </a-radio-group>
  46. </div>
  47. <div class="run-state row">
  48. <div class="control-title">网络状态:</div>
  49. <a-radio-group v-model:value="controlType">
  50. <a-radio :value="1">运行</a-radio>
  51. </a-radio-group>
  52. </div>
  53. </div> -->
  54. </div>
  55. <div class="title-text">
  56. {{ selectData.strname }}
  57. </div>
  58. <div class="bottom-tabs-box" @mousedown="setDivHeight($event, 350, scroll)">
  59. <dv-border-box8 :dur="5" :style="`padding: 5px; height: ${scroll.y + 120}px`" >
  60. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  61. <a-tab-pane key="1" tab="实时监测">
  62. <MonitorTable
  63. v-if="activeKey === '1'"
  64. ref="MonitorDataTable"
  65. columnsType="window_monitor"
  66. :dataSource="dataSource"
  67. @selectRow="getSelectRow"
  68. design-scope="window-monitor"
  69. :scroll="{y: scroll.y - 40}"
  70. title="风窗监测"
  71. :isShowPagination="true"
  72. :isShowActionColumn="true"
  73. >
  74. <template #filterCell="{ column, record }">
  75. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == 0 ? 'green' : 'red'">{{
  76. record.warnFlag == 0 ? '正常' : '报警'
  77. }}</a-tag>
  78. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == 0 ? 'default' : 'green'">{{
  79. record.netStatus == 0 ? '断开' : '连接'
  80. }}</a-tag>
  81. <div v-if="record.nwindownum == 1 && column.dataIndex === 'rearArea'">/</div>
  82. </template>
  83. <template #action="{ record }">
  84. <a class="table-action-link" @click="deviceEdit($event, 'reportInfo', record)">报表录入</a>
  85. <a class="table-action-link" @click="deviceEdit($event, 'deviceInfo', record)">设备编辑</a>
  86. </template>
  87. </MonitorTable>
  88. </a-tab-pane>
  89. <a-tab-pane key="2" tab="实时曲线图" force-render>
  90. <div class="tab-item" v-if="activeKey === '2'">
  91. <DeviceEcharts
  92. chartsColumnsType="window_chart"
  93. xAxisPropType="strname"
  94. :dataSource="dataSource"
  95. height="100%"
  96. :chartsColumns="chartsColumns"
  97. :device-list-api="baseList"
  98. device-type="window"
  99. />
  100. </div>
  101. </a-tab-pane>
  102. <a-tab-pane key="3" tab="历史数据">
  103. <div class="tab-item" v-if="activeKey === '3'">
  104. <HistoryTable columns-type="window" device-type="window" :device-list-api="baseList" designScope="window-history" :scroll="scroll"/>
  105. </div>
  106. </a-tab-pane>
  107. <a-tab-pane key="4" tab="报警历史">
  108. <div class="tab-item" v-if="activeKey === '4'">
  109. <AlarmHistoryTable columns-type="alarm" device-type="window" :device-list-api="baseList" designScope="alarm-history" :scroll="scroll"/>
  110. </div>
  111. </a-tab-pane>
  112. <a-tab-pane key="5" tab="操作历史">
  113. <div class="tab-item" v-if="activeKey === '5'">
  114. <HandlerHistoryTable columns-type="operator_history" device-type="window" :device-list-api="baseList" designScope="alarm-history" :scroll="scroll"/>
  115. </div>
  116. </a-tab-pane>
  117. </a-tabs>
  118. </dv-border-box8>
  119. </div>
  120. </div>
  121. <div ref="playerRef" style="z-index: 999; position: absolute; top: 100px; right: 10px; width: 300px; height: 280px; margin: auto"></div>
  122. <LivePlayer id="fc-player1" style="height: 220px; width: 300px; position: absolute; top: 0px; z-index: -1;" ref="player1" :videoUrl="flvURL1()" muted loading autoplay controls loop fluent />
  123. <HandleModal :modal-is-show="modalIsShow" :modal-title="modalTitle" :modal-type="modalType" @handle-ok="handleOK" @handle-cancel="handleCancel" />
  124. <DeviceBaseInfo @register="regModal" :device-type="selectData['deviceType']"/>
  125. </template>
  126. <script setup lang="ts">
  127. import { message } from 'ant-design-vue';
  128. import DeviceEcharts from '../comment/DeviceEcharts.vue';
  129. import { onBeforeMount, ref, onMounted, onUnmounted, reactive, toRaw, watch, nextTick, inject } from 'vue';
  130. import MonitorTable from '../comment/MonitorTable.vue';
  131. import HistoryTable from '../comment/HistoryTable.vue';
  132. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  133. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  134. import HandleModal from './modal.vue';
  135. import DeviceBaseInfo from '../comment/components/DeviceBaseInfo.vue';
  136. import { mountedThree, destroy, addMonitorText, play, setModelType, initCameraCanvas } from './window.threejs';
  137. import { list, getTableList, cameraList, cameraAddrList } from './window.api';
  138. import { list as baseList } from '../../deviceManager/windWindowTabel/ventanalyWindow.api';
  139. import { chartsColumns } from './window.data';
  140. import { deviceControlApi } from '/@/api/vent/index';
  141. import lodash from 'lodash';
  142. import { setDivHeight } from '/@/utils/event';
  143. import { BorderBox8 as DvBorderBox8 } from '@kjgl77/datav-vue3';
  144. import { useRouter } from 'vue-router';
  145. import { deviceCameraInit } from '/@/utils/ventutil.ts'
  146. import LivePlayer from '@liveqing/liveplayer-v3';
  147. import { useModal } from '/@/components/Modal';
  148. const globalConfig = inject('globalConfig');
  149. const { currentRoute } = useRouter();
  150. const MonitorDataTable = ref()
  151. const playerRef = ref();
  152. let webRtcServer: any[] = []
  153. const scroll = reactive({
  154. y: 230
  155. })
  156. const modalIsShow = ref<boolean>(false); // 是否显示模态框
  157. const modalTitle = ref(''); // 模态框标题显示内容,根据设备操作类型决定
  158. const modalType = ref(''); // 模态框内容显示类型,设备操作类型
  159. const deviceBaseList = ref([]);
  160. const activeKey = ref('1');
  161. const loading = ref(false);
  162. const windowAngle = ref(0);
  163. const rotationParam = {
  164. frontDeg0: 0, // 前门初始
  165. frontDeg1: windowAngle.value, // 前门目标
  166. backDeg0: 0, // 后门初始
  167. backDeg1: windowAngle.value, // 后门目标
  168. };
  169. // 默认初始是第一行
  170. const selectRowIndex = ref(-1);
  171. const dataSource = ref([]);
  172. // 设备数据
  173. const controlType = ref(1);
  174. const flvURL1 = () => {
  175. return `/video/window.mp4`;
  176. };
  177. const [regModal, { openModal }] = useModal();
  178. const tabChange = (activeKeyVal) => {
  179. activeKey.value = activeKeyVal;
  180. if(activeKeyVal == 1){
  181. nextTick(() => {
  182. MonitorDataTable.value.setSelectedRowKeys([selectData.deviceID])
  183. })
  184. }
  185. };
  186. const initData = {
  187. deviceID: '',
  188. deviceType: '',
  189. strname: '',
  190. dataDh: '-', //压差
  191. dataDtestq: '-', //测试风量
  192. sourcePressure: '-', //气源压力
  193. dataDequivalarea: '-',
  194. netStatus: '0', //通信状态
  195. fault: '气源压力超限',
  196. forntArea: '0',
  197. rearArea: '0',
  198. frontRearDifference: '-',
  199. rearPresentValue: '-',
  200. maxarea: 0,
  201. nwindownum: 0
  202. };
  203. // 监测数据
  204. const selectData = reactive(lodash.cloneDeep(initData));
  205. // https获取监测数据
  206. let timer: null | NodeJS.Timeout = null;
  207. const getMonitor = (flag?) => {
  208. if (Object.prototype.toString.call(timer) === '[object Null]') {
  209. timer = setTimeout(async () => {
  210. const data = await getDataSource();
  211. Object.assign(selectData, data);
  212. playAnimation(selectData, selectData.maxarea);
  213. addMonitorText(selectData);
  214. if (timer) {
  215. timer = null;
  216. }
  217. getMonitor();
  218. }, flag ? 0 : 2000);
  219. }
  220. };
  221. const getDataSource = async () => {
  222. const res = await list({ devicetype: 'window', pagetype: 'normal' });
  223. dataSource.value = res.msgTxt[0].datalist || [];
  224. dataSource.value.forEach((data: any) => {
  225. const readData = data.readData;
  226. data = Object.assign(data, readData);
  227. });
  228. if (dataSource.value.length > 0 && selectRowIndex.value == -1) {
  229. // 初始打开页面
  230. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) {
  231. MonitorDataTable.value.setSelectedRowKeys([currentRoute.value['query']['id']])
  232. } else {
  233. MonitorDataTable.value.setSelectedRowKeys([dataSource.value[0]['deviceID']])
  234. }
  235. }
  236. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  237. return data;
  238. };
  239. // 获取设备基本信息列表
  240. const getDeviceBaseList = () => {
  241. getTableList({ pageSize: 1000 }).then((res) => {
  242. deviceBaseList.value = res.records;
  243. });
  244. };
  245. async function getCamera() {
  246. const res = await cameraList({ deviceid: selectData['deviceID'] })
  247. const cameras: [] = res.records || []
  248. let cameraAddrs: any[] = [], cameraNames: string[] = [];
  249. if (cameras.length > 0) {
  250. cameras.forEach(item => {
  251. if (item['devicekind'] == 'toRtsp' || item['devicekind'] == 'toHLS') {
  252. cameraNames.push(item['name'])
  253. } else {
  254. cameraAddrs.push({ name: item['name'], addr: item['addr'] })
  255. }
  256. })
  257. }
  258. if (cameraNames.length > 0) {
  259. // 请求接口从装备院拿数据
  260. const addrs: string[] = await cameraAddrList({ cameraNameList: cameraNames })
  261. for (let i = 0; i < addrs.length; i++) {
  262. cameraAddrs.push({ name: '摄像头' + i, addr: addrs[i] })
  263. }
  264. }
  265. const obj = await deviceCameraInit(cameraAddrs, playerRef.value, webRtcServer)
  266. webRtcServer = obj.webRtcServerList
  267. // const playerDoms = obj.playerDoms
  268. // 注意前后门适应需要对应 //[0] 后门 [1]前门
  269. // await initCameraCanvas(...playerDoms)
  270. }
  271. // 切换检测数据
  272. const getSelectRow = async (selectRow, index) => {
  273. if (!selectRow) return;
  274. selectRowIndex.value = index;
  275. loading.value = true;
  276. const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
  277. Object.assign(selectData, initData, selectRow, baseData);
  278. const type = selectData.nwindownum == 1 ? 'singleWindow' : 'doubleWindow';
  279. setModelType(type).then(() => {
  280. addMonitorText(selectData);
  281. playAnimation(selectRow, baseData.maxarea, true);
  282. loading.value = false;
  283. });
  284. await getCamera()
  285. };
  286. // 判断前后窗的面积是否发生改变,如果改变则开启动画
  287. const playAnimation = (data, maxarea = 90, isFirst = false) => {
  288. rotationParam.frontDeg0 = (90 / maxarea) * Number(isFirst ? 0 : selectData.forntArea);
  289. rotationParam.backDeg0 = (90 / maxarea) * Number(isFirst ? 0 : selectData.rearArea);
  290. rotationParam.frontDeg1 = (90 / maxarea) * Number(data.forntArea) || 0;
  291. rotationParam.backDeg1 = (90 / maxarea) * Number(data.rearArea) || 0;
  292. if (isFirst) {
  293. console.log('最大面积---->', maxarea, '前窗实际面积---->', selectData.forntArea, '后窗实际面积---->', selectData.rearArea, '计算的值---->', rotationParam);
  294. }
  295. console.log('最大面积---->', maxarea, '前窗实际面积---->', selectData.forntArea, '后窗实际面积---->', selectData.rearArea, '计算的值---->', rotationParam);
  296. if (!rotationParam.frontDeg1 && !rotationParam.backDeg1) {
  297. // 当返回值有误时默认关闭
  298. play(rotationParam, 0);
  299. } else {
  300. if (data.nwindownum == 1 || data.nwindownum == 2) {
  301. setTimeout(() => {
  302. play(rotationParam, 1);
  303. }, 0);
  304. }
  305. if (data.nwindownum == 2) {
  306. setTimeout(() => {
  307. play(rotationParam, 2);
  308. }, 0);
  309. }
  310. }
  311. };
  312. // 设置风窗面积
  313. const setArea = (flag) => {
  314. if(selectData.nwindownum == 2){
  315. modalTitle.value = flag === 1 ? '设定前窗面积' : '设定后窗面积';
  316. }else {
  317. modalTitle.value = '设定风窗面积'
  318. }
  319. modalType.value = flag+'';
  320. modalIsShow.value = true;
  321. };
  322. const handleOK = (passWord, handlerState, windowAngleNum) => {
  323. windowAngle.value = windowAngleNum;
  324. // if (passWord !== '123456') {
  325. // message.warning('密码不正确,请重新输入');
  326. // return;
  327. // }
  328. const data = {
  329. deviceid: selectData.deviceID,
  330. devicetype: selectData.deviceType,
  331. paramcode: handlerState == 1 ? 'frontSetValue' : 'rearSetValue',
  332. password: passWord,
  333. value: windowAngle.value,
  334. };
  335. deviceControlApi(data)
  336. .then(() => {
  337. if (globalConfig.History_Type == 'remote') {
  338. message.success('指令已下发至生产管控平台成功!')
  339. } else {
  340. message.success('指令已下发成功!')
  341. }
  342. })
  343. .finally(() => {
  344. handleCancel();
  345. });
  346. };
  347. const handleCancel = () => {
  348. modalIsShow.value = false;
  349. modalTitle.value = '';
  350. modalType.value = '';
  351. };
  352. function deviceEdit(e: Event, type: string, record) {
  353. e.stopPropagation()
  354. openModal(true, {
  355. type,
  356. deviceId: record['deviceID']
  357. })
  358. }
  359. onBeforeMount(() => {
  360. // const sendVal = JSON.stringify({ pagetype: 'normal', devicetype: 'window', orgcode: '', ids: '', systemID: '' });
  361. // initWebSocket(sendVal);
  362. getDeviceBaseList();
  363. });
  364. onMounted(() => {
  365. loading.value = true;
  366. const playerDom = document.getElementById('fc-player1')?.getElementsByClassName('vjs-tech')[0]
  367. mountedThree(playerDom).then(async () => {
  368. // await setModelType('singleWindow');
  369. getMonitor(true);
  370. loading.value = false;
  371. addMonitorText(selectData);
  372. });
  373. });
  374. onUnmounted(() => {
  375. destroy();
  376. if (timer) {
  377. clearTimeout(timer);
  378. timer = undefined;
  379. }
  380. if (webRtcServer && webRtcServer.length > 0) {
  381. webRtcServer.forEach(item => {
  382. item.disconnect()
  383. })
  384. }
  385. });
  386. </script>
  387. <style lang="less" scoped>
  388. @import '/@/design/vent/modal.less';
  389. @ventSpace: zxm;
  390. // :deep(.@{ventSpace}-tabs-tabpane-active) {
  391. // height: 100%;
  392. // }
  393. .input-box {
  394. display: flex;
  395. align-items: center;
  396. padding-left: 10px;
  397. .input-title {
  398. color: #73e8fe;
  399. width: auto;
  400. }
  401. .@{ventSpace}-input-number {
  402. border-color: #ffffff88 !important;
  403. }
  404. margin-right: 10px;
  405. }
  406. .scene-box{
  407. .bottom-tabs-box{
  408. height: 350px;
  409. }
  410. }
  411. </style>