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} from "@/api/typhoon"; import {Layer} from "@/utils/tdInstruction/index"; 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() 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("台风") // 获取台风数据 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); debugger 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) } /** * 设置站点基础数据 * @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, "Diaplay": 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)); }