From e162b8189ab7d307d95f58cbef1fd9b5191e8636 Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Wed, 5 Mar 2025 19:07:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 2 +- src/api/map/map.ts | 12 + src/views/mapPage/example/editMap.vue | 2517 +++++++++++++++++++++ src/views/mapPage/realTimeMap/editMap.vue | 247 +- 4 files changed, 2729 insertions(+), 49 deletions(-) create mode 100644 src/views/mapPage/example/editMap.vue diff --git a/.env.local b/.env.local index a3752946..c22b406f 100644 --- a/.env.local +++ b/.env.local @@ -4,7 +4,7 @@ NODE_ENV=development VITE_DEV=true # 请求路径 -VITE_BASE_URL='http://192.168.0.74:48080' +VITE_BASE_URL='http://192.168.0.172:48080' # VITE_BASE_URL='http://192.168.0.189:48080' # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务 diff --git a/src/api/map/map.ts b/src/api/map/map.ts index 43303bad..7112ab98 100644 --- a/src/api/map/map.ts +++ b/src/api/map/map.ts @@ -136,3 +136,15 @@ export const mapLineGet = async (params) => { export const mapLineListGet = async (params) => { return await request.get({ url: `/system/position-map-line/list`, params }) } + +// 获得车辆信息分页 +export const getRobotInformationPage = async (params) => { + return await request.get({ url: `/system/robot/information/page`, params }) +} + +//获取AGV点位信息 +export const getAGVPointInformation = async (macAddress) => { + return await request.get({ + url: `/system/position-map-item/getAGVPointInformation?macAddress=` + macAddress + }) +} diff --git a/src/views/mapPage/example/editMap.vue b/src/views/mapPage/example/editMap.vue new file mode 100644 index 00000000..58974c5c --- /dev/null +++ b/src/views/mapPage/example/editMap.vue @@ -0,0 +1,2517 @@ + + + + + diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 366604ac..2409b26d 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -155,6 +155,62 @@ > + + + + + + + + + + + + + + + + +
+ 确认 +
+
+
@@ -535,10 +566,10 @@ :key="index" :style="{ position: 'absolute', - left: `${point.x}px`, - top: `${point.y}px`, - width: '10px', - height: '10px', + left: `${point.x - 3}px`, + top: `${point.y - 3}px`, + width: '6px', + height: '6px', backgroundColor: '#00329F', borderRadius: '50%' }" @@ -547,8 +578,8 @@ v-if="state.measureDistancesPoints.length === 2" :style="{ position: 'absolute', - left: `${state.measureDistancesPoints[0].x + 5}px`, - top: `${state.measureDistancesPoints[0].y + 5}px`, + left: `${state.measureDistancesPoints[0].x}px`, + top: `${state.measureDistancesPoints[0].y}px`, width: `${computedLineWidth}px`, height: '2px', backgroundColor: '#00329F', @@ -674,6 +705,15 @@ const inputBoxRef = ref() //文字输入框 const message = useMessage() // 消息弹窗 +const nodeStyle = (item, index) => { + return { + verticalAlign: 'top', + width: item.locationWidePx + 'px', + height: item.locationDeepPx + 'px', + border: state.currentItemIndex === index ? '1px dashed #000' : 'none' + } +} + // 缩放停止 const interfaceRefreshed = ref(true) const resizeEnd = (locationX, locationY, w, h, item, index) => { @@ -717,8 +757,6 @@ const dragEnd = (locationX, locationY, item, index) => { let x = Number(locationX) + Number(item.locationWidePx) / 2 let y = Number(locationY) + Number(item.locationDeepPx) / 2 - console.log(x, y) - if (x === item.locationX && y === item.locationY) return let actualPoint = disposeEventPoint(x, y) state.allMapPointInfo[index].locationX = x @@ -1156,7 +1194,14 @@ const state = reactive({ allMapPointInfo: [], //当前页面上的所有节点的列表 mapRouteList: [], //当前页面上所有路线的列表 currentIndex: 0, //当前处在哪条历史记录 - currentItemIndex: -1 //当前处在哪个工具 + currentItemIndex: -1, //当前处在哪个工具 + markForm: { + macAddress: '', // mac地址 + markProperty: '', //标记属性 + originalNode: '', //原节点 + robotNo: '' //AGV编号 + }, //标记的表单 + mapMarkCarList: [] //标记的车辆列表 }) const toolbarClick = async (item) => { @@ -1347,6 +1392,7 @@ const toolbarClick = async (item) => { break case 'marker': // 标记 + mapMark() break case 'grid': //网格 @@ -1475,6 +1521,108 @@ const rotationFormSubmit = () => { addEditHistory() } +//标记 +const mapMark = async () => { + let res = await MapApi.getRobotInformationPage({ + pageNo: 1, + pageSize: 20 + }) + state.mapMarkCarList = res.list + + if (state.currentItemIndex != -1) { + let item = state.allMapPointInfo[state.currentItemIndex] + state.markForm.originalNode = `[${item.locationX},${item.locationY}]` + if (item.type == 1) { + state.markForm.markProperty = '路径点' + } else if (item.type == 2) { + state.markForm.markProperty = '库位点' + } else if (item.type == 3) { + state.markForm.markProperty = '设备点' + } else if (item.type == 4) { + state.markForm.markProperty = '停车点' + } else if (item.type == 5) { + state.markForm.markProperty = '区域变更点' + } else if (item.type == 6) { + state.markForm.markProperty = '等待点' + } + } else { + state.markForm.markProperty = '' + state.markForm.originalNode = '' + } +} +//标记提交 +const macAddressChange = (e) => { + const targetItem = state.mapMarkCarList.find((item) => item.macAddress === e) + if (targetItem) { + state.markForm.robotNo = targetItem.robotNo + } +} +const markFormSubmit = async () => { + if (!state.markForm.macAddress) { + message.warning('请选择车辆') + return + } + let res = await MapApi.getAGVPointInformation(state.markForm.macAddress) + let content = JSON.parse(res.content) + let point = JSON.parse(content[state.markForm.robotNo]) //标记传过来的数据 + let pointPx = convertActualToBrowser(point.x, point.y) + let actualPoint = disposeEventPoint(pointPx.x, pointPx.y) + + if (state.currentItemIndex !== -1) { + state.allMapPointInfo[state.currentItemIndex].locationX = pointPx.x + state.allMapPointInfo[state.currentItemIndex].locationY = pointPx.y + state.allMapPointInfo[state.currentItemIndex].actualLocationX = actualPoint.actualLocationX + state.allMapPointInfo[state.currentItemIndex].actualLocationY = actualPoint.actualLocationY + + //更改路线里的 + let item = state.allMapPointInfo[state.currentItemIndex] + state.mapRouteList.forEach((route) => { + if (item.id === route.startingPointId) { + route.startPointX = pointPx.x + route.startPointY = pointPx.y + route.beginHigh = Number(item.locationDeepPx) + route.beginWidth = Number(item.locationWidePx) + route.actualStartPointX = actualPoint.actualLocationX + route.actualStartPointY = actualPoint.actualLocationY + } + if (item.id === route.endPointId) { + route.endPointX = pointPx.x + route.endPointY = pointPx.y + route.endHigh = Number(item.locationDeepPx) + route.endWidth = Number(item.locationWidePx) + route.actualEndPointX = actualPoint.actualLocationX + route.actualEndPointY = actualPoint.actualLocationY + } + }) + + addEditHistory() + } else { + //新增一个节点 + state.allMapPointInfo.push({ + positionMapId: imgBgObj.positionMapId, //地图的id + layerSelectionShow: true, + locationX: pointPx.x, + locationY: pointPx.y, + actualLocationX: actualPoint.actualLocationX, + actualLocationY: actualPoint.actualLocationY, + locationDeep: 50, + locationWide: 50, + locationDeepPx: 10, + locationWidePx: 10, + angle: 0, + draggable: true, + resizable: true, + rotatable: false, + lockAspectRatio: false, //横纵比 + mapImageUrl: '', + type: 1, //默认类型1 路径节点 + dataList: [], //存库位的 + dataObj: {} //存 设备点 停车点 文字 + }) + addEditHistory() + } +} + //鼠标拖动绘制节点 // 从点开始绘制 const startFromPoint = (index, event) => { @@ -2020,8 +2168,10 @@ const getMapList = async () => { imgBgObj.positionMapId = res.id imgBgObj.floor = res.floor imgBgObj.area = res.area - imgBgObj.width = yamlJson.width - imgBgObj.height = yamlJson.height + // imgBgObj.width = yamlJson.width + // imgBgObj.height = yamlJson.height + imgBgObj.width = 1423 + imgBgObj.height = 1406 imgBgObj.origin = yamlJson.origin imgBgObj.resolution = yamlJson.resolution // 调转换成png的接口 @@ -2220,14 +2370,15 @@ const disposeEventPoint = (x, y) => { } } // 传入实际现场的数据,转换成浏览器坐标的数据 -const convertActualToBrowser = (x, y) => { - let browserX = Math.max(Number(x) - imgBgObj.origin[0], 0) - let browserY = Math.max( - imgBgObj.origin[1] + Number(imgBgObj.height) * imgBgObj.resolution - Number(y), - 0 - ) +const convertActualToBrowser = (pointX, pointY) => { + const y1 = Number(imgBgObj.origin[1]) + Number(imgBgObj.height) * Number(imgBgObj.resolution) + let x = Math.max(Number(pointX) - Number(imgBgObj.origin[0]), 0) + let y = Math.max(y1 - Number(pointY), 0) - console.log(browserX, browserY) + return { + x, + y + } } //将节点实际宽高cm转换成px const cmConversionPx = (cWidth, cHeight) => { From e338647105dd765ea85c13bd60cee4473b49e64a Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Thu, 6 Mar 2025 09:00:23 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mapPage/realTimeMap/editMap.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 2409b26d..93b92910 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -2168,10 +2168,10 @@ const getMapList = async () => { imgBgObj.positionMapId = res.id imgBgObj.floor = res.floor imgBgObj.area = res.area - // imgBgObj.width = yamlJson.width - // imgBgObj.height = yamlJson.height - imgBgObj.width = 1423 - imgBgObj.height = 1406 + imgBgObj.width = yamlJson.width + imgBgObj.height = yamlJson.height + // imgBgObj.width = 1423 + // imgBgObj.height = 1406 imgBgObj.origin = yamlJson.origin imgBgObj.resolution = yamlJson.resolution // 调转换成png的接口 From 85aa1503c1684e155367f0a00bd03d9e2581cfae Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Thu, 6 Mar 2025 09:31:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.local | 2 +- src/views/mapPage/realTimeMap/editMap.vue | 69 ++++++++++++----------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.env.local b/.env.local index c22b406f..a3752946 100644 --- a/.env.local +++ b/.env.local @@ -4,7 +4,7 @@ NODE_ENV=development VITE_DEV=true # 请求路径 -VITE_BASE_URL='http://192.168.0.172:48080' +VITE_BASE_URL='http://192.168.0.74:48080' # VITE_BASE_URL='http://192.168.0.189:48080' # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务 diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 93b92910..a4eb5632 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -325,7 +325,7 @@ style="border: none; z-index: 999" > -
+
{ return } let res = await MapApi.getAGVPointInformation(state.markForm.macAddress) - let content = JSON.parse(res.content) - let point = JSON.parse(content[state.markForm.robotNo]) //标记传过来的数据 - let pointPx = convertActualToBrowser(point.x, point.y) - let actualPoint = disposeEventPoint(pointPx.x, pointPx.y) + if (res) { + let content = JSON.parse(res.content) + let point = JSON.parse(content[state.markForm.robotNo]) //标记传过来的数据 + let pointPx = convertActualToBrowser(point.x, point.y) + let actualPoint = disposeEventPoint(pointPx.x, pointPx.y) - if (state.currentItemIndex !== -1) { - state.allMapPointInfo[state.currentItemIndex].locationX = pointPx.x - state.allMapPointInfo[state.currentItemIndex].locationY = pointPx.y - state.allMapPointInfo[state.currentItemIndex].actualLocationX = actualPoint.actualLocationX - state.allMapPointInfo[state.currentItemIndex].actualLocationY = actualPoint.actualLocationY + if (state.currentItemIndex !== -1) { + state.allMapPointInfo[state.currentItemIndex].locationX = pointPx.x + state.allMapPointInfo[state.currentItemIndex].locationY = pointPx.y + state.allMapPointInfo[state.currentItemIndex].actualLocationX = actualPoint.actualLocationX + state.allMapPointInfo[state.currentItemIndex].actualLocationY = actualPoint.actualLocationY - //更改路线里的 - let item = state.allMapPointInfo[state.currentItemIndex] - state.mapRouteList.forEach((route) => { - if (item.id === route.startingPointId) { - route.startPointX = pointPx.x - route.startPointY = pointPx.y - route.beginHigh = Number(item.locationDeepPx) - route.beginWidth = Number(item.locationWidePx) - route.actualStartPointX = actualPoint.actualLocationX - route.actualStartPointY = actualPoint.actualLocationY - } - if (item.id === route.endPointId) { - route.endPointX = pointPx.x - route.endPointY = pointPx.y - route.endHigh = Number(item.locationDeepPx) - route.endWidth = Number(item.locationWidePx) - route.actualEndPointX = actualPoint.actualLocationX - route.actualEndPointY = actualPoint.actualLocationY - } - }) + //更改路线里的 + let item = state.allMapPointInfo[state.currentItemIndex] + state.mapRouteList.forEach((route) => { + if (item.id === route.startingPointId) { + route.startPointX = pointPx.x + route.startPointY = pointPx.y + route.beginHigh = Number(item.locationDeepPx) + route.beginWidth = Number(item.locationWidePx) + route.actualStartPointX = actualPoint.actualLocationX + route.actualStartPointY = actualPoint.actualLocationY + } + if (item.id === route.endPointId) { + route.endPointX = pointPx.x + route.endPointY = pointPx.y + route.endHigh = Number(item.locationDeepPx) + route.endWidth = Number(item.locationWidePx) + route.actualEndPointX = actualPoint.actualLocationX + route.actualEndPointY = actualPoint.actualLocationY + } + }) - addEditHistory() + addEditHistory() + } else { + message.warning('未采集到该AGV点位信息') + } } else { //新增一个节点 state.allMapPointInfo.push({ @@ -2170,8 +2174,6 @@ const getMapList = async () => { imgBgObj.area = res.area imgBgObj.width = yamlJson.width imgBgObj.height = yamlJson.height - // imgBgObj.width = 1423 - // imgBgObj.height = 1406 imgBgObj.origin = yamlJson.origin imgBgObj.resolution = yamlJson.resolution // 调转换成png的接口 @@ -2194,6 +2196,7 @@ const getAllNodeList = async () => { let list = await MapApi.getPositionMapItemList({ positionMapId: imgBgObj.positionMapId }) + console.log(imgBgObj.width) state.allMapPointInfo = [] state.currentIndex = 0 list.forEach((item) => {