From 786c19b6fe294caf9f12a6ecc85d987fe6b379a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Mon, 14 Jul 2025 16:18:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=AD=A3=E5=96=B7=E6=B6=82?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/app/device/spray/SprayTaskExecutor.java | 38 ++++++++++------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java b/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java index 4a8cd80..0c0ce8a 100644 --- a/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java +++ b/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java @@ -68,6 +68,16 @@ public class SprayTaskExecutor { webSocketService.pushDebugMsg(FrontResponseGenerator.generateJson(sprayTask.getCmdId(), sprayTask.getCmdCode(), CommandStatus.DEVICE_ERROR, "设备正在喷涂,请先停止喷涂")); return; } + Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position1")); + Position slidePosition2 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position2")); + Position slidePosition3 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position3")); + Position slidePosition4 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position4")); + Double[][] slideArr = { + {slidePosition1.getX(), slidePosition1.getY()}, + {slidePosition2.getX(), slidePosition2.getY()}, + {slidePosition3.getX(), slidePosition3.getY()}, + {slidePosition4.getX(), slidePosition4.getY()} + }; taskThread = new Thread(() -> { try { @@ -88,6 +98,8 @@ public class SprayTaskExecutor { int currentIndex = 0; for (SprayTaskParams sprayTaskParam : sprayTaskParams) {//循环玻片 for (SprayTimes sprayTimes : sprayTaskParam.getTimes()) {//每个拨片有多次喷涂,循环每次喷涂 + Double[] slide = slideArr[sprayTaskParam.getIndex()];//获取玻片的坐标 + List sprayTaskStepList = getSprayPath(sprayTaskParam.getIndex(), sprayTimes);//计算本次喷涂的路线 //先移动到玻片位置 DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(slideArr[sprayTaskParam.getIndex()][0], 20.0); @@ -119,13 +131,13 @@ public class SprayTaskExecutor { Point2D currentPoint = sprayTaskStep.getSprayPathPointList().get(i); List commandFutureList = new ArrayList<>(); if (cacheXPoint != currentPoint.x) { - DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(currentPoint.x, sprayTimes.getMovingSpeed()); + DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(slide[0] + currentPoint.x, sprayTimes.getMovingSpeed()); CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), deviceCommand); commandFutureList.add(commandFuture); cacheXPoint = currentPoint.x; } if (cacheYPoint != currentPoint.y) { - DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(currentPoint.y, sprayTimes.getMovingSpeed()); + DeviceCommand deviceCommand = DeviceCommandGenerator.motorXPositionSet(slide[1] +currentPoint.y, sprayTimes.getMovingSpeed()); CommandFuture commandFuture = deviceCommandService.sendCommandSprayTask(sprayTask.getCmdId(), sprayTask.getCmdCode(), deviceCommand); commandFutureList.add(commandFuture); cacheYPoint = currentPoint.y; @@ -211,24 +223,10 @@ public class SprayTaskExecutor { private List getSprayPath(Integer index, SprayTimes sprayTimes) { String matrixPathType = sprayTimes.getMatrixPathType(); - Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position1")); - Position slidePosition2 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position2")); - Position slidePosition3 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position3")); - Position slidePosition4 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position4")); - Double[][] slideArr = { - {slidePosition1.getX(), slidePosition1.getY()}, - {slidePosition2.getX(), slidePosition2.getY()}, - {slidePosition3.getX(), slidePosition3.getY()}, - {slidePosition4.getX(), slidePosition4.getY()} - }; - Double[] upperLeft = {sprayTimes.getX1(), sprayTimes.getY1()}; //范围左上角 x1,y1 - Double[] lowerRight = {sprayTimes.getX2(), sprayTimes.getY2()}; //范围左上角 x1,y1 - Double[] slide = slideArr[index];//获取玻片的坐标 - DecimalFormat df = new DecimalFormat("#.##"); - double left = Double.parseDouble(df.format(slide[0] + upperLeft[0])); - double right = Double.parseDouble(df.format(slide[0] + lowerRight[0])); - double top = Double.parseDouble(df.format(slide[1] + upperLeft[1])); - double bottom = Double.parseDouble(df.format(slide[1] + lowerRight[1])); + double left = sprayTimes.getX1(); + double right = sprayTimes.getX2(); + double top = sprayTimes.getY1(); + double bottom = sprayTimes.getY2(); Double spacing = sprayTimes.getSpacing(); List sprayTaskStepList = new CopyOnWriteArrayList<>(); if ("horizontal".equals(matrixPathType)) {//喷涂路径类型 horizontal 横向 | vertical 纵向 | grid 网格先横向后纵向