|
|
@ -6,10 +6,12 @@ import moment from 'moment'; |
|
|
|
import { OlMapRequest } from '$utils' |
|
|
|
|
|
|
|
const OlMap = (props) => { |
|
|
|
const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost, patrolList, roadProjectList, tab } = props |
|
|
|
const { dispatch, actions, user, olMapArcgisHost, olMapGeoDataHost, patrolList, roadProjectList, tab, busRunTime, busLine } = props |
|
|
|
const [olMapOpenData, setOlMapOpenData] = useState([]) |
|
|
|
const [olMap, setOlMap] = useState() |
|
|
|
const [pointItem, setPointItem] = useState({}) |
|
|
|
//
|
|
|
|
const [busRunData, setBusRunData] = useState([]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setOlMapOpenData([]) |
|
|
@ -158,9 +160,11 @@ const OlMap = (props) => { |
|
|
|
roadProjectList.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_road_' + index) |
|
|
|
}) |
|
|
|
busRunData.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_bus_' + index) |
|
|
|
}) |
|
|
|
|
|
|
|
patrolList.forEach((d, index) => { |
|
|
|
console.log(d, index); |
|
|
|
olMap.addGeometryLayer({ |
|
|
|
features: [ |
|
|
|
{ |
|
|
@ -221,6 +225,9 @@ const OlMap = (props) => { |
|
|
|
patrolList.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_patrol_' + index) |
|
|
|
}) |
|
|
|
busRunData.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_bus_' + index) |
|
|
|
}) |
|
|
|
|
|
|
|
roadProjectList.forEach((d, index) => { |
|
|
|
olMap.addGeometryLayer({ |
|
|
@ -268,7 +275,141 @@ const OlMap = (props) => { |
|
|
|
} |
|
|
|
}, [roadProjectList, olMap, tab]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (busRunTime && busRunTime.length) { |
|
|
|
setBusRunData(busRunTime) |
|
|
|
} |
|
|
|
}, [busRunTime]) |
|
|
|
|
|
|
|
const drawBusRunPoint = () => { |
|
|
|
patrolList.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_patrol_' + index) |
|
|
|
}) |
|
|
|
roadProjectList.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_road_' + index) |
|
|
|
}) |
|
|
|
|
|
|
|
busRunData.forEach((d, index) => { |
|
|
|
olMap.addGeometryLayer({ |
|
|
|
features: [ |
|
|
|
{ |
|
|
|
name: 'busPoint', |
|
|
|
attributes: { |
|
|
|
callbackParams: { |
|
|
|
type: 'busPoint', |
|
|
|
busNo: d.busNo, |
|
|
|
}, |
|
|
|
callback: (p) => { |
|
|
|
setPointItem(p) |
|
|
|
setOlMapOpenData([{ |
|
|
|
n: '车牌号', |
|
|
|
v: d.busNoChar |
|
|
|
}, { |
|
|
|
n: '司机', |
|
|
|
v: d.employeeName |
|
|
|
}, { |
|
|
|
n: '工号', |
|
|
|
v: d.opNo |
|
|
|
}, { |
|
|
|
n: '调度状态', |
|
|
|
v: d.willRun, |
|
|
|
map: [ |
|
|
|
{ text: '非运营', value: '0' }, |
|
|
|
{ text: '运营', value: '1' }, |
|
|
|
{ text: '维修', value: '2' }, |
|
|
|
{ text: '保养', value: '3' }, |
|
|
|
{ text: '专车', value: '4' }, |
|
|
|
{ text: '机动车', value: '5' }, |
|
|
|
{ text: '包车', value: '6' }, |
|
|
|
{ text: '班车', value: '7' }, |
|
|
|
{ text: '检车', value: '8' }, |
|
|
|
], |
|
|
|
}, { |
|
|
|
n: '实际发车时间', |
|
|
|
v: d.lastDepTime |
|
|
|
}, { |
|
|
|
n: '定位时间', |
|
|
|
v: d.siteTime |
|
|
|
},]) |
|
|
|
olMap.addOverlay('clickOpen', { |
|
|
|
id: 'clickOpen', |
|
|
|
offset: [0, 4], // 偏移
|
|
|
|
position: [d.lng, d.lat], // 坐标
|
|
|
|
// position: [115.944220000000, 28.545380000000],
|
|
|
|
autoPan: true, |
|
|
|
autoPanMargin: 100, |
|
|
|
positioning: 'top-right' |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
geometry: [d.lng, d.lat], |
|
|
|
// geometry: [115.944220000000, 28.545380000000],
|
|
|
|
geometryType: 'Point', |
|
|
|
}, |
|
|
|
], |
|
|
|
style: { |
|
|
|
icon: { |
|
|
|
src: '/assets/images/gis/bus.png', |
|
|
|
scale: 0.7, // 图标引用
|
|
|
|
}, |
|
|
|
}, |
|
|
|
selectStyle: { |
|
|
|
icon: { |
|
|
|
src: '/assets/images/gis/bus.png', |
|
|
|
scale: 0.8, // 图标引用
|
|
|
|
}, |
|
|
|
}, |
|
|
|
layerName: 'geometry_bus_' + index |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
useEffect(() => { |
|
|
|
if (busRunData.length && olMap && tab == 'operation') { |
|
|
|
if (!busLine.length) { |
|
|
|
drawBusRunPoint() |
|
|
|
} |
|
|
|
} |
|
|
|
}, [busRunData, olMap, tab]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (busLine && olMap && tab == 'operation') { |
|
|
|
olMap.addGeometryLayer({ |
|
|
|
features: [ |
|
|
|
{ |
|
|
|
name: 'busLine', |
|
|
|
attributes: { |
|
|
|
}, |
|
|
|
geometry: busLine.map(b => { |
|
|
|
return [b.pointLng, b.pointLat] |
|
|
|
}), |
|
|
|
// geometry: [115.944220000000, 28.545380000000],
|
|
|
|
geometryType: 'LineString', |
|
|
|
style: { stroke: { width: 5, color: '#9933FF' } }, |
|
|
|
selectStyle: { stroke: { width: 8, color: '#9933FF' } }, |
|
|
|
}, |
|
|
|
], |
|
|
|
style: { stroke: { width: 5, color: '#9933FF' } }, |
|
|
|
selectStyle: { stroke: { width: 8, color: '#9933FF' } }, |
|
|
|
layerName: 'geometry_bus_line' |
|
|
|
}); |
|
|
|
if (busLine.length) { |
|
|
|
olMap.setCenter([ |
|
|
|
(busLine[0].pointLng + busLine[busLine.length - 1].pointLng) / 2, |
|
|
|
(busLine[0].pointLat + busLine[busLine.length - 1].pointLat) / 2 |
|
|
|
]) |
|
|
|
busRunData.forEach((d, index) => { |
|
|
|
olMap.removeGeometryLayer('geometry_bus_' + index) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
drawBusRunPoint() |
|
|
|
} |
|
|
|
} else if (tab != 'operation' && olMap) { |
|
|
|
olMap.removeGeometryLayer('geometry_bus_line') |
|
|
|
} |
|
|
|
}, [busLine, olMap, tab]) |
|
|
|
|
|
|
|
const isRoadProject = pointItem.report_type == 'road' |
|
|
|
// const isBusPoint = pointItem.busNoChar
|
|
|
|
return ( |
|
|
|
<div id="olMap" style={{ position: 'absolute', height: '100%', width: "100%" }}> |
|
|
|
<div slot="overlays" style={{ display: 'none', }}> |
|
|
@ -278,25 +419,27 @@ const OlMap = (props) => { |
|
|
|
width: 340, |
|
|
|
backgroundPosition: 'center', |
|
|
|
backgroundSize: '100% 100%', |
|
|
|
minHeight: 240, |
|
|
|
minHeight: 180, |
|
|
|
padding: '24px', |
|
|
|
backgroundRepeat: 'no-repeat', |
|
|
|
color: '#fff' |
|
|
|
}}> |
|
|
|
{ |
|
|
|
olMapOpenData.map(s => { |
|
|
|
return <div style={{ display: 'flex' }}> |
|
|
|
<div style={{ width: 100, textAlign: 'right' }}>{s.n} </div> |
|
|
|
<div style={{ flex: 1 }}>: |
|
|
|
{ |
|
|
|
s.map ? |
|
|
|
s.map.find(sm => sm.value == s.v)?.text |
|
|
|
: s.v || s.v == 0 ? |
|
|
|
s.v |
|
|
|
: '-' |
|
|
|
} |
|
|
|
return ( |
|
|
|
<div style={{ display: 'flex' }}> |
|
|
|
<div style={{ width: 100, textAlign: 'right' }}>{s.n} </div> |
|
|
|
<div style={{ flex: 1 }}>: |
|
|
|
{ |
|
|
|
s.map ? |
|
|
|
s.map.find(sm => sm.value == s.v)?.text |
|
|
|
: s.v || s.v == 0 ? |
|
|
|
s.v |
|
|
|
: '-' |
|
|
|
} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
}) |
|
|
|
} |
|
|
|
</div> |
|
|
@ -425,12 +568,14 @@ const OlMap = (props) => { |
|
|
|
} |
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
|
const { auth, global } = state; |
|
|
|
const { auth, global, busRunTime, busLine } = state; |
|
|
|
return { |
|
|
|
user: auth.user, |
|
|
|
actions: global.actions, |
|
|
|
olMapArcgisHost: global.olMapArcgisHost, |
|
|
|
olMapGeoDataHost: global.olMapGeoDataHost, |
|
|
|
busRunTime: busRunTime.data || [], |
|
|
|
busLine: busLine.data || [], |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|