operate.ts 7.9 KB

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