Merge branch 'master' of http://103.135.160.14:9034/r/NslWeb
| | |
| | | return response.data; |
| | | } |
| | | |
| | | // 查询孙胡沟避险场所 |
| | | export async function getSafePoint() { |
| | | // 查询北京市避险场所 |
| | | export async function getSafePoint(data) { |
| | | const response = await axios.get("/hp/safeHavenLocation/getDataSelect", { |
| | | params: { |
| | | divisionId: 110116110218 |
| | | divisionId: data |
| | | } |
| | | }); |
| | | return response.data; |
| | | } |
| | | // 110116110218 |
| | | |
| | | |
| | | |
| | | // 查询北京市 |
| | | export async function getAllCode() { |
| | |
| | | } |
| | | }); |
| | | return response.data; |
| | | } |
| | | |
| | | // 监测设备中关联的隐患点的具体信息 |
| | | export async function hdByDevice(data) { |
| | | const response = await axios.get("/hp/sinoDzHiddenDangerPoint/getDetail", { |
| | | params: { |
| | | unifiedCode: data |
| | | } |
| | | }); |
| | | return response.data; |
| | | } |
| | |
| | | if (selectedScheme.value.type === 2) { |
| | | try { |
| | | await ElMessageBox.confirm("方案未停止时结束模拟后,后台将停止计算", { |
| | | confirmButtonText: "返回列表", |
| | | cancelButtonText: "结束模拟", |
| | | confirmButtonText: "结束模拟", |
| | | cancelButtonText: "返回列表", |
| | | type: "warning", |
| | | }); |
| | | // 用户点击了确认,这里不执行任何操作,仅关闭对话框 |
| | | |
| | | const res = await stopSim(selectedScheme.value.id); |
| | | if (res.code == 404) { |
| | | ElMessage.warning("该服务已停止"); |
| | | } else { |
| | | ElMessage.success("服务正在停止中"); |
| | | } |
| | | } catch (error) { |
| | | stopSim(selectedScheme.value.id).then((res) => { |
| | | if (res.code == 404) { |
| | | ElMessage.warning("该服务已停止"); |
| | | } else { |
| | | ElMessage.success("服务正在停止中"); |
| | | } |
| | | }); |
| | | // return; |
| | | // 用户点击了【返回列表】或者出现错误 |
| | | return; |
| | | } |
| | | } |
| | | // 不管type是不是2,最终都执行结束模拟的操作 |
| | | |
| | | // 不管 type 是不是 2,最终都执行结束模拟操作 |
| | | endSimulation(); |
| | | } |
| | | |
| | |
| | | return; // 阻止后续操作 |
| | | } else { |
| | | simStore.rePlayList = res.data; |
| | | console.log(simStore.rePlayList, "lisi"); |
| | | console.log(simStore.rePlayList, "实时模拟历史回放列表"); |
| | | } |
| | | // 使用 nextTick 确保 DOM 更新后再执行后续操作 |
| | | nextTick(() => { |
| | |
| | | |
| | | // 生命周期钩子 |
| | | onMounted(() => { |
| | | console.log(filteredData); |
| | | // console.log(filteredData); |
| | | updateThreatData(); |
| | | getRainfallData(); |
| | | }); |
| | |
| | | dialogPositon, |
| | | } from "@/store"; |
| | | |
| | | import { hdByDevice } from "@/api/hpApi"; |
| | | |
| | | const detailList = ref([]); |
| | | const detailTitle = ref("设备详情"); |
| | | const name = ref(""); |
| | |
| | | showDeviceDetail.value = false; |
| | | coloseDialog(); |
| | | } |
| | | |
| | | // 监测设备具体信息 |
| | | function handlDeviceDetail() { |
| | | detailTitle.value = deviceDetail.value.deviceForShort; |
| | | detailList.value = [ |
| | | { |
| | | name: "设备编号", |
| | | value: |
| | | deviceDetail.value.deviceCode || Math.floor(Math.random() * 100000), |
| | | }, |
| | | { |
| | | name: "设备类型", |
| | | value: deviceDetail.value.type || deviceDetail.value.deviceTypeName, |
| | | }, |
| | | { |
| | | name: "关联隐患点", |
| | | value: deviceDetail.value.hdName, |
| | | }, |
| | | { |
| | | name: "群防员", |
| | | value: deviceDetail.value.groupTestGroupDefenseUserName, |
| | | }, |
| | | { |
| | | name: "群防员电话", |
| | | value: deviceDetail.value.groupTestGroupDefenseMobile, |
| | | }, |
| | | ]; |
| | | async function handlDeviceDetail() { |
| | | const hdInfo = ref(); |
| | | |
| | | try { |
| | | const res = await hdByDevice(deviceDetail.value.hdUnifiedCode); |
| | | hdInfo.value = res.data; |
| | | |
| | | detailList.value = [ |
| | | { |
| | | name: "设备编号", |
| | | value: deviceDetail.value.deviceCode || Math.floor(Math.random() * 100000), |
| | | }, |
| | | { |
| | | name: "设备类型", |
| | | value: deviceDetail.value.type || deviceDetail.value.deviceTypeName, |
| | | }, |
| | | { |
| | | name: "关联隐患点", |
| | | value: deviceDetail.value.hdName, |
| | | }, |
| | | { |
| | | name: "群测群防员", |
| | | value: hdInfo.value?.groupTestGroupDefenseUserName || "暂无信息", |
| | | }, |
| | | { |
| | | name: "群测群防员电话", |
| | | value: hdInfo.value?.groupTestGroupDefenseMobile || "暂无信息", |
| | | }, |
| | | ]; |
| | | |
| | | detailTitle.value = deviceDetail.value.deviceForShort; |
| | | } catch (err) { |
| | | console.error("获取 hdInfo 失败", err); |
| | | } |
| | | } |
| | | |
| | | // 隐患点具体信息 |
| | | function handleDistrictDetail() { |
| | | const name = deviceDetail.value.hdName; |
| | |
| | | if (list && Array.isArray(list)) { |
| | | for (const item of list) { |
| | | const entity = await item; |
| | | console.log(entity,'eeeeeeeee') |
| | | |
| | | let shouldRemove = true; // 默认要删除 |
| | | |
| | |
| | | * 添加避险场所数据 |
| | | */ |
| | | function addTetrahedron() { |
| | | getSafePoint().then((res) => { |
| | | getSafePoint(110116110218).then((res) => { |
| | | const geoJsonData = convertToGeoJson(res.data); // 转换为 GeoJSON |
| | | // 加载 GeoJSON 数据到地图 |
| | | loadAreaPolygon(geoJsonData, true).then((entities) => { |
| | |
| | | // stores/ui.js |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | import { showDeviceDetail } from "@/store"; |
| | | export const useSimStore = defineStore('simulation', () => { |
| | | // 断面数据 |
| | | const crossSection = ref([]) |
| | |
| | | const startMNPG = () => { |
| | | init() |
| | | isShowEarth.value = false |
| | | |
| | | } |
| | | |
| | | const setBackToHome = (value) => { |
| | |
| | | |
| | | // 导航点击 |
| | | const handleNavClick = (index) => { |
| | | showDeviceDetail.value = false; |
| | | switch (index) { |
| | | case 1: |
| | | startYHGL() |
| | |
| | | import { showDeviceDetail } from "@/store"; |
| | | import { setupTokenRefresh, getDangerPoint, getAllCode } from "@/api/hpApi.js"; |
| | | import { convertToWKT } from "@/utils/wktUtils"; |
| | | import { getDeviceInfoSHG, getSafePoint } from "@/api/hpApi"; |
| | | import { getDeviceInfoSHG, getWeather } from "@/api/hpApi"; |
| | | |
| | | const route = useRoute(); |
| | | const simStore = useSimStore(); |
| | |
| | | // 计算属性 |
| | | const showDetail = computed(() => showDeviceDetail.value); |
| | | |
| | | function extractAllChildrenInfoUnique(dataArray) { |
| | | const map = new Map(); |
| | | function groupTopWithLeafNodes(dataArray) { |
| | | const result = {}; |
| | | |
| | | function traverse(nodes) { |
| | | function traverse(nodes, topLevelName = null) { |
| | | if (!Array.isArray(nodes)) return; |
| | | |
| | | for (const node of nodes) { |
| | | const key = node.code; |
| | | const isLeaf = !node.children || node.children.length === 0; |
| | | |
| | | // 检查是否是最后一层(没有子节点或子节点为空数组) |
| | | if (!node.children || node.children.length === 0) { |
| | | if (key && !map.has(key)) { |
| | | map.set(key, { name: node.nameChn, code: key }); |
| | | // 如果是顶层节点,记录它的名字作为 key |
| | | if (!topLevelName && !isLeaf) { |
| | | topLevelName = node.nameChn; |
| | | if (!result[topLevelName]) { |
| | | result[topLevelName] = []; |
| | | } |
| | | } else { |
| | | // 如果有子节点,继续递归遍历 |
| | | traverse(node.children); |
| | | } |
| | | |
| | | // 如果是叶子节点,加入对应数组 |
| | | if (isLeaf && topLevelName) { |
| | | result[topLevelName].push({ |
| | | name: node.nameChn, |
| | | code: node.code, |
| | | }); |
| | | } |
| | | |
| | | // 继续递归子节点(保持当前顶层名称) |
| | | if (node.children && node.children.length > 0) { |
| | | traverse(node.children, topLevelName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | traverse(dataArray); |
| | | return Array.from(map.values()); |
| | | } |
| | | // 遍历整个大数组中的每一项(即每一个区域) |
| | | for (const item of dataArray) { |
| | | if (item && item.children && Array.isArray(item.children)) { |
| | | traverse([item]); // 把当前项包装成数组,方便统一处理 |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | onMounted(async () => { |
| | | getAllCode().then((res) => { |
| | | // 北京市所有村以及街道code |
| | | simStore.townCodeAll = extractAllChildrenInfoUnique(res.data[0].children); |
| | | simStore.townCodeAll = groupTopWithLeafNodes(res.data[0].children); |
| | | console.log(simStore.townCodeAll, "中科软接口获取乡镇code"); |
| | | }); |
| | | setupTokenRefresh(); // 获取宏图token |
| | | // getSimData(); //测试tr后端 |
| | |
| | | }); |
| | | dataSources.length = 0; |
| | | } |
| | | |
| | | // 避险场所,绿色富文本 |
| | | async function addTetrahedron(visible) { |
| | | const emergencyAreaList = []; |
| | | |
| | | try { |
| | | const res = await getSafePoint(); |
| | | let codesToFetch = []; |
| | | |
| | | const geoJsonData = convertToGeoJson(res.data); |
| | | // 判断当前选择区域是否为“区” |
| | | if (simStore.selectedScheme.areaName.includes("区")) { |
| | | // 从 simStore.townCodeAll 中拿到该区下的所有乡镇 code |
| | | const townList = simStore.townCodeAll[simStore.selectedScheme.areaName]; |
| | | |
| | | // 假设 townList 是一个数组,里面每个元素有 .code 字段 |
| | | if (Array.isArray(townList)) { |
| | | codesToFetch = townList.map((item) => item.code); |
| | | } else { |
| | | console.warn("未找到对应的乡镇列表"); |
| | | return; |
| | | } |
| | | } else { |
| | | // 不是“区”,就使用默认 code |
| | | codesToFetch = ["110116110218"]; |
| | | } |
| | | |
| | | // 并发请求所有 code 的避险点数据 |
| | | const allRes = await Promise.all( |
| | | codesToFetch.map((code) => getSafePoint(code)) |
| | | ); |
| | | |
| | | // 合并结果(假设每个 res.data 是一个数组) |
| | | const allSafePoints = allRes.flatMap((res) => res.data); |
| | | |
| | | // 转换为 GeoJSON(如果每个 data 都需要单独处理) |
| | | const geoJsonData = convertToGeoJson(allSafePoints); |
| | | |
| | | // 加载底层面片(多边形) |
| | | const polygonEntities = await loadAreaPolygon(geoJsonData, true); |
| | | emergencyAreaList.push(...polygonEntities); |
| | | |
| | | // 添加绿色富文本标注 |
| | | const textPromises = res.data.map(async (item) => { |
| | | const textPromises = allSafePoints.map(async (item) => { |
| | | const point = earthCtrl.factory.createRichTextPoint( |
| | | "避险场所", |
| | | [item.lon , item.lat , 540], |
| | | [item.lon, item.lat, 540], |
| | | { |
| | | distanceDisplayCondition: |
| | | new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000), |
| | | fontColor: "#fff", |
| | | fontColor: "#fff", |
| | | fontSize: 20, |
| | | }, |
| | | "0" |
| | |
| | | console.error("加载避险场所失败:", error); |
| | | } |
| | | } |
| | | |
| | | // 删除避险场所的富文本实体 |
| | | function removeEmergencyPoints() { |
| | | const emergencyAreaList = treeMap.get("避险场所"); // 获取存储的避险场所实体列表 |