/** * 南宁武装押运管控 */ import React, { Component } from "react"; import { Icon, DatePicker, Form, Button, message, Select, Input, Switch } from 'antd'; import { getHaiKangApiUrl } from '../../../../services/api'; import { formItemLayout1 } from '../../../../constants/formItemLayout'; import NanNingTraiectory from '../../mapModule/Traiectory/NanNingTraiectory'; import moment from 'moment'; import { connect } from "dva"; import styles from './index.less'; import Video from './Video'; import MouseMovement from "../../../../components/MouseMovement" const FormItem = Form.Item; @Form.create() @connect((state) => ({ mapStyle: state.command.mapStyle })) export default class NanNing extends Component { constructor(props) { super(props); this.state = { rootData: [],//组装成json树格式 clickVehicle: null,//当前点击中的某个车辆id值 showVideo: false, videoUrl: "", licensePlate: "", //车牌号码 searchCarData: [], //查询车辆 onlineSwitch: true, //车辆是否在线 text: { isDown: false, offsetLeft: 0, offsetTop: 0, }, }; } componentDidMount() { const allHeight = document.documentElement.clientHeight - 140 - 16; let treeListHeight = allHeight - 140 this.setState({ allHeight, treeListHeight }); this._getAllRegionsValue(); // this.initH5Player(); } //获取所有的区域数据 _getAllRegionsValue(pageNo = 1, allRegionsData = []) { getHaiKangApiUrl({ apiPath: "/artemis/api/resource/v1/regions", "pageNo": pageNo, "pageSize": 500, "treeCode": "0" }).then(res => { console.log(res); let value = JSON.parse(res.data) console.log(value) if (value) { let data = value.data let { list } = data let regionsData = allRegionsData.concat(list) let { pageNo, pageSize, total } = data if (total > pageNo * pageSize) { this._getAllRegionsValue(pageNo + 1, regionsData) } else { this.sort(regionsData) } } }) } //对区域数据进行树节点排序组装 sort(list) { const idMapping = list.reduce((acc, el, i) => { acc[el.indexCode] = i; return acc; }, {}); let root; list.forEach((el, index) => { // 判断根节点 if (el.parentIndexCode == '-1') { el.place = [0] el.open = true root = el; return; } // 用映射表找到父元素 const parentEl = list[idMapping[el.parentIndexCode]]; const parentPlace = JSON.parse(JSON.stringify(parentEl.place)) let place = null if (parentEl.children) { place = parentPlace.concat(parentEl.children.length) } else { place = parentPlace.concat(0) } // 把当前元素添加到父元素的`children`数组中 parentEl.children = [...(parentEl.children || []), { ...el, open: false, place }]; }); this.setState({ rootData: [root] }) } //获取该区域下的所有车辆,然后塞进root树中 _getVehiclePage(pageNo = 1, id, place, allVehicleData = []) { getHaiKangApiUrl({ apiPath: "/artemis/api/rtsm/v1/resource/findVehiclePage", "exactCondition": { "orgIndexCodes": [id] }, "pageNo": pageNo, "pageSize": 5000, "treeCode": "0" }).then(res => { console.log(res); let value = JSON.parse(res.data) if (value) { let data = value.data if (data) { let { list } = data allVehicleData = allVehicleData.concat(list) let { pageNo, pageSize, total } = data if (total > pageNo * pageSize) { return this._getVehiclePage(pageNo + 1, id, place, allVehicleData) } } } const { rootData } = this.state const root = JSON.parse(JSON.stringify(rootData)) let data = null place.map((item, index) => { if (index == 0) {//暂时根节点没有车辆信息 data = root[item] if (index + 1 == place.length) { data.vehiclelist = allVehicleData } } else { data = data.children[item] if (index + 1 == place.length) { data.vehiclelist = allVehicleData } } }) this.setState({ rootData: root }) }) } //改变open的打开关闭状态 changeOpenStatus(place) { const { rootData } = this.state const root = JSON.parse(JSON.stringify(rootData)) let data = null place.map((item, index) => { if (index == 0) { data = root[item] if (index + 1 == place.length) { data.open = !data.open } } else { data = data.children[item] if (index + 1 == place.length) { data.open = !data.open } } }) this.setState({ rootData: root }) } //根据车辆编号与设备编号获取监控点信息列表 0为全部 1为查询车辆 _getMonitoringPoints(veh, pageNo = 1, place, type = 0) { //关联设备对象,默认是第一个 getHaiKangApiUrl({ apiPath: "/artemis/api/rtsm/v1/vehicle/findCameraPage", exactCondition: { "deviceIndexCodes": [veh.deviceResourceDTOList[0].deviceIndexCode], "vehicleIndexCodes": [veh.vehicleIndexCode] }, "pageNo": pageNo, "pageSize": 100, "treeCode": "0" }).then(res => { console.log(res) let value = JSON.parse(res.data) if (value) { let data = value.data if (type == 0) { const { rootData } = this.state const root = JSON.parse(JSON.stringify(rootData)) root[place[0]].children[place[1]].vehiclelist[place[2]].monitoringPointsList = data.list root[place[0]].children[place[1]].vehiclelist[place[2]].open = !root[place[0]].children[place[1]].vehiclelist[place[2]].open this.setState({ rootData: root }) } else { const { searchCarData } = this.state searchCarData[place].monitoringPointsList = data.list; searchCarData[place].open = !searchCarData[place].open this.setState({ searchCarData }) } } }) } //根据监控点预览取流URL _getVideoStream(indexCode) { console.log(indexCode) getHaiKangApiUrl({ apiPath: "/artemis/api/video/v1/cameras/previewURLs", "cameraIndexCode": indexCode, "streamType": 0, "protocol": "wss", "transmode": 1, "expand": "transcode=0", }).then(res => { console.log(res); let value = JSON.parse(res.data) if (value) { let data = value.data console.log(data); let { url } = data this.setState({ showVideo: true, videoUrl: url, }) } }) } //根据车牌号查询车辆 _getLicensePlate(licensePlate, onlineSwitch) { console.log(licensePlate) getHaiKangApiUrl({ apiPath: "/artemis/api/rtsm/v1/resource/findVehicleByLicensePlate", vehicleLicensePlate: licensePlate }).then(res => { console.log(res); let value = JSON.parse(res.data) if (value.code === "0") { value = value.data; if (value.status == 1 || (value.status == 0 && !onlineSwitch)) { value.clicked = false; value.monitoringPointsList = []; value.open = false this.setState({ searchCarData: [value], clickVehicle: null }) } else { message.info('该车辆未在线'); this.setState({ searchCarData: [], clickVehicle: null }) } } else { message.info('未查找到该车辆'); this.setState({ searchCarData: [], clickVehicle: null }) } }) } closeHaikangVideo() { this.setState({ showVideo: false, videoUrl: '', }) } // 渲染全部车辆数据 renderChild(value) { const { clickVehicle } = this.state return value.map((item) => { return ( <>