index.vue 15 KB

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