|
@@ -28,32 +28,6 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
},
|
|
},
|
|
trackHoverData: null,
|
|
trackHoverData: null,
|
|
trackMap: new Map(),
|
|
trackMap: new Map(),
|
|
- // [['123', {
|
|
|
|
- // data: {
|
|
|
|
- // targetSourceJson: '[]'
|
|
|
|
- // },
|
|
|
|
- // color: randomColor(1),
|
|
|
|
- // history: [],
|
|
|
|
- // real: [{}],
|
|
|
|
- // trackId: '123',
|
|
|
|
- // moveToTrack: () => {},
|
|
|
|
- // // 直接用图层的话declutter: true会报错,Uncaught TypeError: Failed to execute 'clip' on 'CanvasRenderingContext2D': parameter 1 is not of type 'Path2D'.
|
|
|
|
- // lineLayer: 'lineLayer_' + 123,
|
|
|
|
- // pointsLayer: 'pointsLayer_' + 123,
|
|
|
|
- // del: () => {},
|
|
|
|
- // visibleTrack: (visible) => {},
|
|
|
|
- // refreshTrackStyle: () => {},
|
|
|
|
- // showTrack: true,
|
|
|
|
- // showArchive: true,
|
|
|
|
- // archiveLayout: {
|
|
|
|
- // width: 480,
|
|
|
|
- // top: 10,
|
|
|
|
- // left: 200
|
|
|
|
- // },
|
|
|
|
- // archiveParams: {
|
|
|
|
- // tab: 1,
|
|
|
|
- // }
|
|
|
|
- // }]]
|
|
|
|
trackKeys: {
|
|
trackKeys: {
|
|
lon: 'targetLongitude',
|
|
lon: 'targetLongitude',
|
|
lat: 'targetLatitude',
|
|
lat: 'targetLatitude',
|
|
@@ -119,12 +93,14 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
const clickShip = (feature) => {
|
|
const clickShip = (feature) => {
|
|
if (feature && feature.get('_featureType') == 'ship') {
|
|
if (feature && feature.get('_featureType') == 'ship') {
|
|
if (!state.trackMap.has(feature.get('_id'))) {
|
|
if (!state.trackMap.has(feature.get('_id'))) {
|
|
|
|
+ const isWarning = feature.get('_warning')
|
|
const d = feature.get('_data')
|
|
const d = feature.get('_data')
|
|
state.trackMap.set(feature.get('_id'), {
|
|
state.trackMap.set(feature.get('_id'), {
|
|
|
|
+ isWarning: !!isWarning,
|
|
data: feature.get('_data'),
|
|
data: feature.get('_data'),
|
|
- color: '#FC60FF', //randomColor(1),
|
|
|
|
|
|
+ color: isWarning ? '#ea3147' : '#FC60FF', //randomColor(1),
|
|
history: [],
|
|
history: [],
|
|
- real: [d],
|
|
|
|
|
|
+ real: isWarning ? [] : [d],
|
|
trackId: feature.get('_trackId'),
|
|
trackId: feature.get('_trackId'),
|
|
moveToTrack: () => {
|
|
moveToTrack: () => {
|
|
const position: any = []
|
|
const position: any = []
|
|
@@ -133,20 +109,25 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
arr.forEach(v => {
|
|
arr.forEach(v => {
|
|
position.push([v[state.trackKeys.lon], v[state.trackKeys.lat]])
|
|
position.push([v[state.trackKeys.lon], v[state.trackKeys.lat]])
|
|
})
|
|
})
|
|
- getShapeView(state.map, position)
|
|
|
|
|
|
+ if (position.length > 0) {
|
|
|
|
+ getShapeView(state.map, position)
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// 直接用图层的话declutter: true会报错,Uncaught TypeError: Failed to execute 'clip' on 'CanvasRenderingContext2D': parameter 1 is not of type 'Path2D'.
|
|
// 直接用图层的话declutter: true会报错,Uncaught TypeError: Failed to execute 'clip' on 'CanvasRenderingContext2D': parameter 1 is not of type 'Path2D'.
|
|
lineLayer: 'lineLayer_' + feature.get('_id'),
|
|
lineLayer: 'lineLayer_' + feature.get('_id'),
|
|
pointsLayer: 'pointsLayer_' + feature.get('_id'),
|
|
pointsLayer: 'pointsLayer_' + feature.get('_id'),
|
|
|
|
+ warningLayer: 'warningLayer_' + feature.get('_id'),
|
|
del: () => {
|
|
del: () => {
|
|
state.map.removeLayer(state.map.getLayers().getArray().filter(v => v.get('__layerName') === state.trackMap.get(feature.get('_id')).lineLayer)[0])
|
|
state.map.removeLayer(state.map.getLayers().getArray().filter(v => v.get('__layerName') === state.trackMap.get(feature.get('_id')).lineLayer)[0])
|
|
state.map.removeLayer(state.map.getLayers().getArray().filter(v => v.get('__layerName') === state.trackMap.get(feature.get('_id')).pointsLayer)[0])
|
|
state.map.removeLayer(state.map.getLayers().getArray().filter(v => v.get('__layerName') === state.trackMap.get(feature.get('_id')).pointsLayer)[0])
|
|
|
|
+ state.map.removeLayer(state.map.getLayers().getArray().filter(v => v.get('__layerName') === state.trackMap.get(feature.get('_id')).warningLayer)[0])
|
|
state.trackMap.delete(feature.get('_id'))
|
|
state.trackMap.delete(feature.get('_id'))
|
|
},
|
|
},
|
|
visibleTrack: (visible) => {
|
|
visibleTrack: (visible) => {
|
|
const t = state.trackMap.get(feature.get('_id'))
|
|
const t = state.trackMap.get(feature.get('_id'))
|
|
state.map.getLayers().getArray().filter(v => v.get('__layerName') === t.lineLayer)[0]?.setVisible(visible)
|
|
state.map.getLayers().getArray().filter(v => v.get('__layerName') === t.lineLayer)[0]?.setVisible(visible)
|
|
state.map.getLayers().getArray().filter(v => v.get('__layerName') === t.pointsLayer)[0]?.setVisible(visible)
|
|
state.map.getLayers().getArray().filter(v => v.get('__layerName') === t.pointsLayer)[0]?.setVisible(visible)
|
|
|
|
+ state.map.getLayers().getArray().filter(v => v.get('__layerName') === t.warningLayer)[0]?.setVisible(visible)
|
|
t.showTrack = visible
|
|
t.showTrack = visible
|
|
if (visible) {
|
|
if (visible) {
|
|
t.moveToTrack()
|
|
t.moveToTrack()
|
|
@@ -230,16 +211,39 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
declutter: true,
|
|
declutter: true,
|
|
__layerName: state.trackMap.get(feature.get('_id')).pointsLayer
|
|
__layerName: state.trackMap.get(feature.get('_id')).pointsLayer
|
|
})
|
|
})
|
|
|
|
+ const warningLayer = new layer.Vector({
|
|
|
|
+ zIndex: 3999,
|
|
|
|
+ __layerName: state.trackMap.get(feature.get('_id')).warningLayer,
|
|
|
|
+ })
|
|
state.map.addLayer(lineLayer)
|
|
state.map.addLayer(lineLayer)
|
|
state.map.addLayer(pointsLayer)
|
|
state.map.addLayer(pointsLayer)
|
|
|
|
+ state.map.addLayer(warningLayer)
|
|
|
|
+ if (isWarning) {
|
|
|
|
+ console.log(d)
|
|
|
|
+ const wf: any = new format.WKT().readFeature(`POINT(${d[state.trackKeys.lon]} ${d[state.trackKeys.lat]})`)
|
|
|
|
+ wf.setStyle(MapStyle.warningStyle(feature.get('_warning').ruleInfo.level))
|
|
|
|
+ warningLayer.setSource(new source.Vector({
|
|
|
|
+ features: [wf],
|
|
|
|
+ wrapX: false,
|
|
|
|
+ }))
|
|
|
|
+ }
|
|
const ws = new WebSocket(`ws://${location.host}/history-track-ws-api/historyshiptrack`)
|
|
const ws = new WebSocket(`ws://${location.host}/history-track-ws-api/historyshiptrack`)
|
|
ws.onopen = (e) => {
|
|
ws.onopen = (e) => {
|
|
- const str = {
|
|
|
|
- mergeTarget: feature.get('_id'),
|
|
|
|
- startTime: YMDHms(new Date(d[state.trackKeys.mergeTime]).getTime() - 1000 * 60 * 60),
|
|
|
|
- endTime: YMDHms(d[state.trackKeys.mergeTime]),
|
|
|
|
|
|
+ if (isWarning) {
|
|
|
|
+ const str = {
|
|
|
|
+ mergeTarget: feature.get('_data')[state.trackKeys.mergeTarget],
|
|
|
|
+ startTime: YMDHms(new Date(feature.get('_warning').warnTime).getTime() - 1000 * 60 * 60),
|
|
|
|
+ endTime: YMDHms(new Date(feature.get('_warning').warnTime).getTime() + 1000 * 60 * 60),
|
|
|
|
+ }
|
|
|
|
+ ws.send(JSON.stringify(str))
|
|
|
|
+ } else {
|
|
|
|
+ const str = {
|
|
|
|
+ mergeTarget: feature.get('_id'),
|
|
|
|
+ startTime: YMDHms(new Date(d[state.trackKeys.mergeTime]).getTime() - 1000 * 60 * 60),
|
|
|
|
+ endTime: YMDHms(d[state.trackKeys.mergeTime]),
|
|
|
|
+ }
|
|
|
|
+ ws.send(JSON.stringify(str))
|
|
}
|
|
}
|
|
- ws.send(JSON.stringify(str))
|
|
|
|
}
|
|
}
|
|
ws.onmessage = (e) => {
|
|
ws.onmessage = (e) => {
|
|
try {
|
|
try {
|
|
@@ -249,6 +253,9 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
} else if (json?.length > 0) {
|
|
} else if (json?.length > 0) {
|
|
state.trackMap.get(feature.get('_id')).history.push(...json)
|
|
state.trackMap.get(feature.get('_id')).history.push(...json)
|
|
state.trackMap.get(feature.get('_id')).refreshTrackStyle()
|
|
state.trackMap.get(feature.get('_id')).refreshTrackStyle()
|
|
|
|
+ if (isWarning) {
|
|
|
|
+ state.trackMap.get(feature.get('_id')).moveToTrack()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} catch (e) {
|
|
} catch (e) {
|
|
}
|
|
}
|
|
@@ -324,7 +331,9 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
if (state.trackMap.size > 0) {
|
|
if (state.trackMap.size > 0) {
|
|
let arr = []
|
|
let arr = []
|
|
state.trackMap.forEach((v, k) => {
|
|
state.trackMap.forEach((v, k) => {
|
|
- arr.push(`'${k}'`)
|
|
|
|
|
|
+ if (!v.isWarning) {
|
|
|
|
+ arr.push(`'${k}'`)
|
|
|
|
+ }
|
|
})
|
|
})
|
|
idCql = `${state.trackKeys.mergeTarget} in (${arr.join(',')})`
|
|
idCql = `${state.trackKeys.mergeTarget} in (${arr.join(',')})`
|
|
}
|
|
}
|
|
@@ -396,7 +405,7 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
});
|
|
});
|
|
state.ws.layerShip.setSource(vectorSource)
|
|
state.ws.layerShip.setSource(vectorSource)
|
|
}
|
|
}
|
|
- const initShipFeature = (data) => {
|
|
|
|
|
|
+ const initShipFeature = (data, warning = null) => {
|
|
const feat: any = new format.WKT().readFeature(`POINT(${data[state.trackKeys.lon]} ${data[state.trackKeys.lat]})`)
|
|
const feat: any = new format.WKT().readFeature(`POINT(${data[state.trackKeys.lon]} ${data[state.trackKeys.lat]})`)
|
|
feat.set('_course', data[state.trackKeys.course] || 0)
|
|
feat.set('_course', data[state.trackKeys.course] || 0)
|
|
feat.set('_speed', data[state.trackKeys.speed] || 0)
|
|
feat.set('_speed', data[state.trackKeys.speed] || 0)
|
|
@@ -406,47 +415,13 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
feat.set('_trackId', data[state.trackKeys.mergeId])
|
|
feat.set('_trackId', data[state.trackKeys.mergeId])
|
|
feat.set('_data', data)
|
|
feat.set('_data', data)
|
|
feat.set('_featureType', 'ship')
|
|
feat.set('_featureType', 'ship')
|
|
|
|
+ if (warning) {
|
|
|
|
+ feat.set('_id', warning.id + '_' + data[state.trackKeys.mergeTarget])
|
|
|
|
+ feat.set('_warning', warning)
|
|
|
|
+ }
|
|
return feat
|
|
return feat
|
|
}
|
|
}
|
|
const initWarningWS = () => {
|
|
const initWarningWS = () => {
|
|
- // const js = {
|
|
|
|
- // "createBy" : "admin",
|
|
|
|
- // "createTime" : "2025-01-14 11:19:26",
|
|
|
|
- // "updateBy" : "admin",
|
|
|
|
- // "updateTime" : "2025-01-14 11:19:26",
|
|
|
|
- // "id" : "0b3bae57-c422-4b5e-a700-860e346755b1",
|
|
|
|
- // "modelCode" : "TJ_CB_00_01",
|
|
|
|
- // "modelId" : "1",
|
|
|
|
- // "ruleId" : "d4dde331749847618f163e6a0c25472d",
|
|
|
|
- // "ruleName" : "北斗终端异常-10分钟",
|
|
|
|
- // "modelName" : "北斗终端异常",
|
|
|
|
- // "warnTime" : "2025-01-14 11:10:18.464",
|
|
|
|
- // "dynamicShipList" : [ {
|
|
|
|
- // "mergeId" : "814640307768528896",
|
|
|
|
- // "mergeTarget" : "100000000015005642",
|
|
|
|
- // "mergeTime" : "2025-01-14 11:00:18.176",
|
|
|
|
- // "mergeType" : "BEIDOU",
|
|
|
|
- // "targetName" : "万0308014",
|
|
|
|
- // "targetShipType" : "30",
|
|
|
|
- // "targetNationality" : "412",
|
|
|
|
- // "targetSpeed" : 0.0,
|
|
|
|
- // "targetCourse" : 0.0,
|
|
|
|
- // "targetLongitude" : 110.390722,
|
|
|
|
- // "targetLatitude" : 18.704444,
|
|
|
|
- // "targetLength" : 13.7,
|
|
|
|
- // "targetSource" : [ {
|
|
|
|
- // "id" : "1724073477",
|
|
|
|
- // "time" : "2025-01-14 11:00:14",
|
|
|
|
- // "type" : "BEIDOU",
|
|
|
|
- // "signalLoss" : false,
|
|
|
|
- // "trackDeviceNo" : "15005642",
|
|
|
|
- // "trackId" : "15005642"
|
|
|
|
- // } ]
|
|
|
|
- // } ]
|
|
|
|
- // }
|
|
|
|
- // setTimeout(() => {
|
|
|
|
- // state.warningInfo = js
|
|
|
|
- // }, 1000)
|
|
|
|
const ws = new WebSocket(`ws://${location.host}/ws-api/shipwarnrecord`)
|
|
const ws = new WebSocket(`ws://${location.host}/ws-api/shipwarnrecord`)
|
|
ws.onopen = (e) => {
|
|
ws.onopen = (e) => {
|
|
}
|
|
}
|
|
@@ -497,6 +472,8 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
return {
|
|
return {
|
|
...toRefs(state),
|
|
...toRefs(state),
|
|
initMap,
|
|
initMap,
|
|
- toShip
|
|
|
|
|
|
+ toShip,
|
|
|
|
+ clickShip,
|
|
|
|
+ initShipFeature
|
|
}
|
|
}
|
|
})
|
|
})
|