operate.ts 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. import Bus from "@/utils/bus";
  2. import bus from "@/utils/bus";
  3. import {useAppStore} from '@/stores/app'
  4. import {useTimeScrollbarStore} from '@/stores/timeScrollbar'
  5. import {useStationStore} from "@/stores/station";
  6. import {extractList} from "../list";
  7. import {stationList} from "@/assets/js/station";
  8. import {slopeCalculation} from "@/utils/slopeCalculation";
  9. import {getYuyanDataList} from "@/api/yuyan";
  10. import {convertDate} from "@/utils/date";
  11. import {useTyphoonStore} from "@/stores/typhoon";
  12. import {getRainfallForecastRadarMap} from "@/api/typhoon";
  13. import {Layer} from "@/utils/tdInstruction/index";
  14. let waterLevel = "";
  15. let waterSpeed = "";
  16. /**
  17. * 设置测站水位
  18. * @param stcd 测站编码
  19. * @param value 水位
  20. */
  21. export async function setWaterLevel(stcd: any, value: any = waterLevel, speed: any = waterSpeed) {
  22. if (value) {
  23. waterLevel = value + ""
  24. } else {
  25. if (!waterLevel) {
  26. const store = useStationStore()
  27. waterLevel = await store.getZ() + ''
  28. }
  29. }
  30. if (speed) {
  31. waterSpeed = speed + ""
  32. }
  33. let descriptor = {
  34. "command": "WaterLevel",
  35. "data": {
  36. "ID": stcd,
  37. "code": waterLevel,
  38. "wave": waterSpeed
  39. }
  40. }
  41. Bus.emit('emitUIInteraction', descriptor)
  42. console.log("-- 设置测站水位,流速", JSON.stringify(descriptor));
  43. }
  44. export async function setUnderwaterState(stcd: any, show = true) {
  45. let value = "-5"
  46. if (!show) {
  47. const store = useStationStore()
  48. value = waterLevel ? waterLevel : await store.getZ() + ''
  49. }
  50. let descriptor = {
  51. "command": "WaterLevel",
  52. "data": {
  53. "ID": stcd,
  54. "code": value,
  55. }
  56. }
  57. Bus.emit('emitUIInteraction', descriptor)
  58. console.log("-- 水下地形:", JSON.stringify(descriptor));
  59. }
  60. /**
  61. * 设置测站流速
  62. * @param stcd 测站编码
  63. * @param value 水位
  64. */
  65. export function setWaterSpeed(stcd: any, speed: any = waterSpeed) {
  66. let descriptor = {
  67. "command": "WaterLevel",
  68. "data": {
  69. "ID": stcd,
  70. "speed": speed
  71. }
  72. }
  73. Bus.emit('emitUIInteraction', descriptor)
  74. console.log("-- 设置测站流速", JSON.stringify(descriptor));
  75. }
  76. /**
  77. * 测验模拟
  78. * @param type 播放、暂停、继续、结束
  79. * @param stcd 测站编码
  80. */
  81. export function testSimulation(stcd: any, type: any = '播放') {
  82. let descriptor = {
  83. "command": "InstrumentMovie",
  84. "data": {
  85. "Type": type,
  86. "ID": stcd
  87. }
  88. }
  89. Bus.emit('emitUIInteraction', descriptor)
  90. console.log("-- 测验模拟:" + type, JSON.stringify(descriptor));
  91. }
  92. /**
  93. * 流量比对
  94. * @param type 播放、暂停、继续、结束
  95. * @param stcd 测站编码
  96. */
  97. export function flowComparative(stcd: any, type: any = '播放') {
  98. let descriptor = {
  99. "command": "ADCPship",
  100. "data": {
  101. "Type": type,
  102. "ID": stcd
  103. }
  104. }
  105. Bus.emit('emitUIInteraction', descriptor)
  106. console.log("-- 流量比对:" + type, JSON.stringify(descriptor));
  107. }
  108. /**
  109. * 漫游(太师桥)
  110. * @param type 远:河道;近:测站
  111. * @param operate 播放、暂停、继续、结束
  112. */
  113. export function roam(type: any = 'river', operate: any = 'play') {
  114. let descriptor = {
  115. "command": "Roaming",
  116. "data": {
  117. "tag": type === 'river' ? "太师桥远" : "太师桥近",
  118. "Type": operate
  119. }
  120. }
  121. Bus.emit('emitUIInteraction', descriptor)
  122. console.log("-- 漫游:" + (type === 'river' ? "河道" : "测站"), JSON.stringify(descriptor));
  123. }
  124. export function setPointState(stcd: any, name: string, type: string) {
  125. let descriptor = {
  126. "command": "POIwarning",
  127. "data": {
  128. "ID": stcd,
  129. "Name": name,
  130. "type": type
  131. }
  132. }
  133. Bus.emit('emitUIInteraction', descriptor);
  134. console.log("-- 设置设备告警:", JSON.stringify(descriptor));
  135. }
  136. export async function addTyphoonTrack(tfid: string) {
  137. const typhoonStore = useTyphoonStore()
  138. let yuyanData: any[] = await getYuyanDataList("2025041714054696095")
  139. .then(res => {
  140. return res.data.map(item => {
  141. return {
  142. ...item,
  143. YMDHM: convertDate(item.YMDHM)
  144. }
  145. })
  146. })
  147. const appStore = useAppStore()
  148. const timeScrollbarStore = useTimeScrollbarStore()
  149. appStore.changeCurrentView("台风")
  150. // 获取台风数据
  151. const typhoonData = await import(`@/assets/json/typhoon/${tfid}.json`).then(res => res.default);
  152. typhoonData.points.length
  153. timeScrollbarStore.setTimeScrollbarShow(true)
  154. timeScrollbarStore.setMax(typhoonData.points.length)
  155. const timeList = typhoonData.points.map((element: any) => element.time);
  156. const timeObj = extractList(timeList, 4)
  157. for (let key in timeObj) {
  158. timeObj[key] = {
  159. style: {
  160. color: '#00c7e3',
  161. 'text-shadow': '0 0 4px #32003C'
  162. },
  163. label: timeObj[key].substring(0, 10) + '\n' + timeObj[key].substring(11)
  164. }
  165. }
  166. timeScrollbarStore.setMarks(timeObj)
  167. let time = ''
  168. timeScrollbarStore.sliderlTooltip = (value: number) => {
  169. if (typhoonStore.isRadar) {
  170. getRainfallForecastRadarMap(timeList[value]).then(res => {
  171. Layer.radarMap(res)
  172. })
  173. }
  174. const date = new Date(timeList[value])
  175. const list = yuyanData.filter(y => y.YMDHM.getTime() === date.getTime())
  176. const data = list.map(d => {
  177. let station: any = stationList.find(s => s.id === d.STCD)
  178. if (!station) {
  179. console.log(`未找到${d.STCD}`)
  180. }
  181. return {
  182. value: `${(d.DATA).toFixed(2)}`,
  183. name: station.name,
  184. x: station.lgtd,
  185. y: station.lttd
  186. }
  187. })
  188. if (data && data.length > 0) {
  189. const res: any = slopeCalculation(data);
  190. debugger
  191. taihuUI(res.direction, res.slope, res.max, res.min);
  192. }
  193. if (timeList[value].substring(0, 10) != time) {
  194. time = timeList[value].substring(0, 10)
  195. bus.emit('chat', `汇报当前时间 ${time} 台风情况,太湖局应该如何响应,回复内容简单明了,条理清晰,通俗易懂,字数限制200字。如果没有信息就返回null。 台风信息如下:${JSON.stringify(typhoonData.points[value])}`)
  196. }
  197. setTyphoonTrack(tfid, timeList[value])
  198. return timeList[value]
  199. }
  200. let descriptor = {
  201. "command": "AddTyphoonTrack",
  202. "data": {
  203. "tfid": tfid
  204. }
  205. }
  206. Bus.emit('emitUIInteraction', descriptor);
  207. console.log("-- 台风路径:", JSON.stringify(descriptor));
  208. timeScrollbarStore.play()
  209. typhoonStore.setTyphoon(true)
  210. }
  211. export function setTyphoonTrack(tfid: string, time: string) {
  212. let descriptor = {
  213. "command": "TyphoonTime",
  214. "data": {
  215. "tfid": tfid,
  216. "time": time
  217. }
  218. }
  219. Bus.emit('emitUIInteraction', descriptor);
  220. console.log("-- 设置台风时间点:", JSON.stringify(descriptor));
  221. }
  222. /**
  223. * 删除台风路径
  224. * @param tfid
  225. */
  226. export function deleteTyphoonTrack(tfid: string) {
  227. const timeScrollbarStore = useTimeScrollbarStore()
  228. timeScrollbarStore.close()
  229. let descriptor = {
  230. "command": "DelLevel",
  231. "data": {
  232. "tfid": 'TyphoonTrack',
  233. // "tfid": tfid,
  234. "type": "3"
  235. }
  236. }
  237. Bus.emit('emitUIInteraction', descriptor);
  238. console.log("-- 删除台风路径:", JSON.stringify(descriptor));
  239. taihuUI('', '', '', '', false);
  240. const store = useTyphoonStore()
  241. store.setTyphoon(false)
  242. }
  243. /**
  244. * 设置站点基础数据
  245. * @param data
  246. */
  247. export function setStationData(data: any) {
  248. let descriptor = {
  249. "command": "SetScene",
  250. "data": {
  251. "id": data.name,
  252. "堤顶高程": data.damel,
  253. "保证水位": data.grz,
  254. "青坎线": data.qingkang,
  255. "警戒水位": data.wrz,
  256. "当前水位": data.z,
  257. }
  258. }
  259. Bus.emit('emitUIInteraction', descriptor);
  260. console.log("-- 设置站点基础数据:", JSON.stringify(descriptor));
  261. }
  262. let strategyMapState = false
  263. /**
  264. * 设置太湖湖面图层
  265. * @param direction
  266. * @param slope
  267. * @param show
  268. */
  269. export function strategyMap(direction: string, slope: string, show = true) {
  270. let descriptor = {
  271. "command": "InclinedAngle",
  272. "data": {
  273. "Direction": direction,
  274. "Slope": slope,
  275. "Diaplay": show ? 'true' : 'false'
  276. }
  277. }
  278. Bus.emit('emitUIInteraction', descriptor);
  279. console.log("-- 太湖湖面图层:", JSON.stringify(descriptor));
  280. }
  281. export function taihuUI(direction: string, slope: string, max: string, min: string, show = true) {
  282. let descriptor = {
  283. "command": "TaihuUI",
  284. "data": {
  285. "Direction": direction,
  286. "Slope": slope,
  287. "Max": max,
  288. "Min": min,
  289. "Display": show ? "true" : "false"
  290. }
  291. }
  292. Bus.emit('emitUIInteraction', descriptor);
  293. console.log("-- 台风太湖UI:", JSON.stringify(descriptor));
  294. }