| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- import Bus from '@/utils/bus'
- import bus from '@/utils/bus'
- import { useAppStore } from '@/stores/app'
- import { useTimeScrollbarStore } from '@/stores/timeScrollbar'
- import { useStationStore } from '@/stores/station'
- import { extractList } from '../list'
- import { stationList } from '@/assets/js/station'
- import { slopeCalculation } from '@/utils/slopeCalculation'
- import { getYuyanDataList } from '@/api/yuyan'
- import { convertDate } from '@/utils/date'
- import { useTyphoonStore } from '@/stores/typhoon'
- import {
- getRainfallForecastRadarMap,
- getRainfallForecastRadarMapList,
- } from '@/api/typhoon'
- import { Layer } from '@/utils/tdInstruction/index'
- import { formatd } from '@/utils/ruoyi'
- let waterLevel = ''
- let waterSpeed = ''
- /**
- * 设置测站水位
- * @param stcd 测站编码
- * @param value 水位
- */
- export async function setWaterLevel(
- stcd: any,
- value: any = waterLevel,
- speed: any = waterSpeed,
- ) {
- if (value) {
- waterLevel = value + ''
- } else {
- if (!waterLevel) {
- const store = useStationStore()
- store.setStcd(stcd)
- waterLevel = (await store.getZ()) + ''
- }
- }
- if (speed) {
- waterSpeed = speed + ''
- }
- let descriptor = {
- command: 'WaterLevel',
- data: {
- ID: stcd,
- code: waterLevel,
- wave: waterSpeed,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 设置测站水位,流速', JSON.stringify(descriptor))
- }
- export async function setUnderwaterState(stcd: any, show = true) {
- let value = '-5'
- if (!show) {
- const store = useStationStore()
- value = waterLevel ? waterLevel : (await store.getZ()) + ''
- }
- let descriptor = {
- command: 'WaterLevel',
- data: {
- ID: stcd,
- code: value,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 水下地形:', JSON.stringify(descriptor))
- }
- /**
- * 设置测站流速
- * @param stcd 测站编码
- * @param value 水位
- */
- export function setWaterSpeed(stcd: any, speed: any = waterSpeed) {
- let descriptor = {
- command: 'WaterLevel',
- data: {
- ID: stcd,
- speed: speed,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 设置测站流速', JSON.stringify(descriptor))
- }
- /**
- * 测验模拟
- * @param type 播放、暂停、继续、结束
- * @param stcd 测站编码
- */
- export function testSimulation(stcd: any, type: any = '播放') {
- let descriptor = {
- command: 'InstrumentMovie',
- data: {
- Type: type,
- ID: stcd,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 测验模拟:' + type, JSON.stringify(descriptor))
- }
- /**
- * 流量比对
- * @param type 播放、暂停、继续、结束
- * @param stcd 测站编码
- */
- export function flowComparative(stcd: any, type: any = '播放') {
- let descriptor = {
- command: 'ADCPship',
- data: {
- Type: type,
- ID: stcd,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 流量比对:' + type, JSON.stringify(descriptor))
- }
- /**
- * 漫游(太师桥)
- * @param type 远:河道;近:测站
- * @param operate 播放、暂停、继续、结束
- */
- export function roam(type: any = 'river', operate: any = 'play') {
- let descriptor = {
- command: 'Roaming',
- data: {
- tag: type === 'river' ? '太师桥远' : '太师桥近',
- Type: operate,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log(
- '-- 漫游:' + (type === 'river' ? '河道' : '测站'),
- JSON.stringify(descriptor),
- )
- }
- export function setPointState(stcd: any, name: string, type: string) {
- let descriptor = {
- command: 'POIwarning',
- data: {
- ID: stcd,
- Name: name,
- type: type,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 设置设备告警:', JSON.stringify(descriptor))
- }
- export async function addTyphoonTrack(tfid: string) {
- const typhoonStore = useTyphoonStore()
- let yuyanData: any[] = await getYuyanDataList('2025041714054696095').then(
- res => {
- return res.data.map(item => {
- return {
- ...item,
- YMDHM: convertDate(item.YMDHM),
- }
- })
- },
- )
- const appStore = useAppStore()
- const timeScrollbarStore = useTimeScrollbarStore()
- appStore.changeCurrentView('Globe')
- // 获取台风数据
- const typhoonData = await import(`@/assets/json/typhoon/${tfid}.json`).then(
- res => res.default,
- )
- typhoonData.points.length
- timeScrollbarStore.setTimeScrollbarShow(true)
- timeScrollbarStore.setMax(typhoonData.points.length)
- const timeList = typhoonData.points.map((element: any) => element.time)
- const timeObj = extractList(timeList, 4)
- for (let key in timeObj) {
- timeObj[key] = {
- style: {
- color: '#00c7e3',
- 'text-shadow': '0 0 4px #32003C',
- },
- label: timeObj[key].substring(0, 10) + '\n' + timeObj[key].substring(11),
- }
- }
- timeScrollbarStore.setMarks(timeObj)
- let time = ''
- timeScrollbarStore.sliderlTooltip = (value: number) => {
- if (typhoonStore.isRadar) {
- getRainfallForecastRadarMap(timeList[value]).then(res => {
- Layer.radarMap(res)
- })
- }
- const date = new Date(timeList[value])
- const list = yuyanData.filter(y => y.YMDHM.getTime() === date.getTime())
- const data = list.map(d => {
- let station: any = stationList.find(s => s.id === d.STCD)
- if (!station) {
- console.log(`未找到${d.STCD}`)
- }
- return {
- value: `${d.DATA.toFixed(2)}`,
- name: station.name,
- x: station.lgtd,
- y: station.lttd,
- }
- })
- if (data && data.length > 0) {
- const res: any = slopeCalculation(data)
- taihuUI(res.direction, res.slope, res.max, res.min)
- }
- if (timeList[value].substring(0, 10) != time) {
- time = timeList[value].substring(0, 10)
- bus.emit(
- 'chat',
- `汇报当前时间 ${time} 台风情况,太湖局应该如何响应,回复内容简单明了,条理清晰,通俗易懂,字数限制200字。如果没有信息就返回null。 台风信息如下:${JSON.stringify(typhoonData.points[value])}`,
- )
- }
- setTyphoonTrack(tfid, timeList[value])
- return timeList[value]
- }
- let descriptor = {
- command: 'AddTyphoonTrack',
- data: {
- tfid: tfid,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 台风路径:', JSON.stringify(descriptor))
- timeScrollbarStore.play()
- typhoonStore.setTyphoon(true)
- }
- export function setTyphoonTrack(tfid: string, time: string) {
- let descriptor = {
- command: 'TyphoonTime',
- data: {
- tfid: tfid,
- time: time,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 设置台风时间点:', JSON.stringify(descriptor))
- }
- /**
- * 删除台风路径
- * @param tfid
- */
- export function deleteTyphoonTrack(tfid: string) {
- const timeScrollbarStore = useTimeScrollbarStore()
- timeScrollbarStore.close()
- let descriptor = {
- command: 'DelLevel',
- data: {
- tfid: 'TyphoonTrack',
- // "tfid": tfid,
- type: '3',
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 删除台风路径:', JSON.stringify(descriptor))
- taihuUI('', '', '', '', false)
- const store = useTyphoonStore()
- store.setTyphoon(false)
- }
- /**
- * 实时台风
- */
- export function realTimeTyphoon(show = true) {
- let descriptor = {
- command: 'RuntimeTyphoon',
- data: {
- Display: show ? 'true' : 'false',
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 实时台风:', JSON.stringify(descriptor))
- }
- /**
- * 设置站点基础数据
- * @param data
- */
- export function setStationData(data: any) {
- let descriptor = {
- command: 'SetScene',
- data: {
- id: data.name,
- 堤顶高程: data.damel,
- 保证水位: data.grz,
- 青坎线: data.qingkang,
- 警戒水位: data.wrz,
- 当前水位: data.z,
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 设置站点基础数据:', JSON.stringify(descriptor))
- }
- let strategyMapState = false
- /**
- * 设置太湖湖面图层
- * @param direction
- * @param slope
- * @param show
- */
- export function strategyMap(direction: string, slope: string, show = true) {
- let descriptor = {
- command: 'InclinedAngle',
- data: {
- Direction: direction,
- Slope: slope,
- Display: show ? 'true' : 'false',
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 太湖湖面图层:', JSON.stringify(descriptor))
- }
- export function taihuUI(
- direction: string,
- slope: string,
- max: string,
- min: string,
- show = true,
- ) {
- let descriptor = {
- command: 'TaihuUI',
- data: {
- Direction: direction,
- Slope: slope,
- Max: max,
- Min: min,
- Display: show ? 'true' : 'false',
- },
- }
- Bus.emit('emitUIInteraction', descriptor)
- console.log('-- 台风太湖UI:', JSON.stringify(descriptor))
- }
- export async function addRadar(type: any) {
- let radarList: any = await getRainfallForecastRadarMapList(
- formatd(new Date(), 'yyyy-MM-dd'),
- formatd(new Date(), 'yyyy-MM-dd'),
- type,
- ).then(res => res)
- const appStore = useAppStore()
- const timeScrollbarStore = useTimeScrollbarStore()
- appStore.changeCurrentView('Globe')
- timeScrollbarStore.setTimeScrollbarShow(true)
- timeScrollbarStore.setMax(radarList.length)
- timeScrollbarStore.setStep(3)
- const timeList = radarList.map((element: any) => element.TBA_GETDATE)
- const timeObj = extractList(timeList, 4)
- for (let key in timeObj) {
- timeObj[key] = {
- style: {
- color: '#00c7e3',
- 'text-shadow': '0 0 4px #32003C',
- },
- label: timeObj[key].substring(0, 10) + '\n' + timeObj[key].substring(11),
- }
- }
- timeScrollbarStore.setMarks(timeObj)
- timeScrollbarStore.sliderlTooltip = (value: number) => {
- Layer.radarMap(radarList[value].TBA_FILENAME)
- return timeList[value]
- }
- }
- /**
- * 删除台风路径
- */
- export function deleteRadar() {
- const timeScrollbarStore = useTimeScrollbarStore()
- timeScrollbarStore.close()
- Layer.radarMap('', false)
- }
|