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"; 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 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 (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() } 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)); } /** * 设置站点基础数据 * @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 export function strategyMap(direction: any) { if (strategyMapState) { updateStrategyMapCoord(direction) } else { addStrategyMap(direction) } } /** * 添加太湖湖面图层 * @param data */ export function addStrategyMap(direction: any) { let descriptor = { "command": "AddStrategyMap", "data": { "id": "strategymap_id", "coord_type": "0", "cad_mapkey": "ea", "coord_z_type": "0", "type": "5", "is_gather": "true", "animation_type": "0", "start_coord": "119.938890, 31.106388", "start_coord_z": "600", "target_data": [ { "target_coord": "120.405242, 31.444280", "target_coord_z": "600", "color": "ff0000" } ] } } Bus.emit('emitUIInteraction', descriptor); console.log("-- 添加太湖湖面图层:", JSON.stringify(descriptor)); strategyMapState = true } /** * 更新太湖湖面图层 * @param data */ export function updateStrategyMapCoord(direction: any) { let descriptor = { "command": "UpdateStrategyMapCoord", "data": { "id": "strategymap_id", "coord_type": "0", "cad_mapkey": "ea", "coord_z_type": "0", "start_coord": "120.243630, 30.9273", "start_coord_z": "100", "target_data": [ { "target_coord": "120.405242, 31.444280", "target_coord_z": "200" } ] } } Bus.emit('emitUIInteraction', descriptor); console.log("-- 更新太湖湖面图层:", JSON.stringify(descriptor)); } /** * 删除太湖湖面图层 */ export function deleteStrategyMap() { let descriptor = { "command": "DelLevel", "data": { "id": "strategymap_id", "type": "3" } } Bus.emit('emitUIInteraction', descriptor); console.log("-- 删除太湖湖面图层:", JSON.stringify(descriptor)); strategyMapState = false }