|
@@ -1,5 +1,5 @@
|
|
|
import {defineStore} from "pinia";
|
|
|
-import {ElMessage} from "element-plus";
|
|
|
+import {ElMessage, ElLoading} from "element-plus";
|
|
|
import {computed, reactive, toRefs, watch} from "vue";
|
|
|
import * as format from "ol/format";
|
|
|
import * as layer from "ol/layer";
|
|
@@ -10,6 +10,7 @@ import {formatGetParam, randomColor, YMDHms} from "@/utils/util";
|
|
|
import {formatPosition, getShapeView} from "@/utils/easyMap";
|
|
|
import { v4 } from "uuid";
|
|
|
import {shipArchiveDetail} from "@/api/modules/web/archive";
|
|
|
+import axios from "axios";
|
|
|
|
|
|
export const useShipMapStore = defineStore('shipMap', () => {
|
|
|
const state: any = reactive({
|
|
@@ -113,6 +114,9 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
|
let feature = state.map.forEachFeatureAtPixel(pixel, function (feature) {
|
|
|
return feature
|
|
|
})
|
|
|
+ clickShip(feature)
|
|
|
+ }
|
|
|
+ const clickShip = (feature) => {
|
|
|
if (feature && feature.get('_featureType') == 'ship') {
|
|
|
if (!state.trackMap.has(feature.get('_id'))) {
|
|
|
const d = feature.get('_data')
|
|
@@ -209,7 +213,7 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
|
})
|
|
|
if (d[state.trackKeys.shipId]) {
|
|
|
shipArchiveDetail(formatGetParam({id: d[state.trackKeys.shipId]})).then(res => {
|
|
|
- // shipArchiveDetail(formatGetParam({id: '01d64e98bd904d2880ecd0e74d35383c'})).then(res => {
|
|
|
+ // shipArchiveDetail(formatGetParam({id: '01d64e98bd904d2880ecd0e74d35383c'})).then(res => {
|
|
|
if (res.code == 0) {
|
|
|
state.trackMap.get(feature.get('_id')).archiveParams.data = res.data
|
|
|
} else {
|
|
@@ -372,15 +376,7 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
|
// 动态拼接数据的唯一标识DATA,不可修改
|
|
|
const features = data.map(v => {
|
|
|
try {
|
|
|
- const feat: any = new format.WKT().readFeature(`POINT(${v[state.trackKeys.lon]} ${v[state.trackKeys.lat]})`)
|
|
|
- feat.set('_course', v[state.trackKeys.course] || 0)
|
|
|
- feat.set('_speed', v[state.trackKeys.speed] || 0)
|
|
|
- // feat.set('_head', v.targetHeading)
|
|
|
- feat.set('_mergeType', v[state.trackKeys.mergeType])
|
|
|
- feat.set('_id', v[state.trackKeys.mergeTarget])
|
|
|
- feat.set('_trackId', v[state.trackKeys.mergeId])
|
|
|
- feat.set('_data', v)
|
|
|
- feat.set('_featureType', 'ship')
|
|
|
+ const feat: any = initShipFeature(v)
|
|
|
// 实时轨迹
|
|
|
const t = state.trackMap.get(feat.get('_id'))
|
|
|
if (t && t.trackId !== feat.get('_trackId')) {
|
|
@@ -400,6 +396,18 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
|
});
|
|
|
state.ws.layerShip.setSource(vectorSource)
|
|
|
}
|
|
|
+ const initShipFeature = (data) => {
|
|
|
+ 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('_speed', data[state.trackKeys.speed] || 0)
|
|
|
+ // feat.set('_head', v.targetHeading)
|
|
|
+ feat.set('_mergeType', data[state.trackKeys.mergeType])
|
|
|
+ feat.set('_id', data[state.trackKeys.mergeTarget])
|
|
|
+ feat.set('_trackId', data[state.trackKeys.mergeId])
|
|
|
+ feat.set('_data', data)
|
|
|
+ feat.set('_featureType', 'ship')
|
|
|
+ return feat
|
|
|
+ }
|
|
|
const initWarningWS = () => {
|
|
|
// const js = {
|
|
|
// "createBy" : "admin",
|
|
@@ -452,11 +460,43 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ const toShip = (mergeTarget) => {
|
|
|
+ const loading = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: '船舶位置信息查询中……',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)',
|
|
|
+ })
|
|
|
+ axios.get('/geoserver-api/geoserver/kafka/wms', {
|
|
|
+ params: {
|
|
|
+ service: 'WFS',
|
|
|
+ version: '2.0.0',
|
|
|
+ request: 'GetFeature',
|
|
|
+ typeNames: 'kafka:fusion',
|
|
|
+ outputFormat: 'application/json',
|
|
|
+ CQL_FILTER: `${state.trackKeys.mergeTarget} = '${mergeTarget}'`
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status === 200) {
|
|
|
+ if (res.data.features.length > 0) {
|
|
|
+ const s = res.data.features[0]
|
|
|
+ clickShip(initShipFeature({...s.properties, targetSource: JSON.parse(s.properties.targetSource)}))
|
|
|
+ getShapeView(state.map, [s.geometry.coordinates])
|
|
|
+ } else {
|
|
|
+ ElMessage.warning('未查询到船舶位置信息,请稍后重试!')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ loading.close()
|
|
|
+ }).catch(e => {
|
|
|
+ loading.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
watch(() => state.warningOpen, (n) => {
|
|
|
localStorage.setItem('warningOpen', n)
|
|
|
}, {immediate: true})
|
|
|
return {
|
|
|
...toRefs(state),
|
|
|
initMap,
|
|
|
+ toShip
|
|
|
}
|
|
|
})
|