From 039f791c9770e1fc231a986984435eeaccd433d1 Mon Sep 17 00:00:00 2001 From: lgh Date: Thu, 4 Aug 2022 13:57:24 +0800 Subject: [PATCH] =?UTF-8?q?update:=20bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/empty/controller/CurrTaskController.java | 9 ++++++--- .../com/mt/wms/empty/task/AsynRunTaskService.java | 15 ++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index 44e96b5..e00049b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -68,6 +68,8 @@ public class CurrTaskController extends BaseController { private CurrTaskServiceBiz currTaskServiceBiz; @Autowired private AutoExeTaskServiceBiz autoExeTaskServiceBiz; + @Autowired + private TaskDistanceUtils taskDistanceUtils; @PostMapping(value = "createProcessTask") @@ -306,9 +308,10 @@ public class CurrTaskController extends BaseController { } @PostMapping(value = "testRgv") @ApiOperation(value = "测试rgv避让逻辑") - private Boolean testRgv(@RequestBody TestRgv testRgv) throws IOException { - TaskDistanceUtils taskDistanceUtils=new TaskDistanceUtils(); - return taskDistanceUtils.conflictForVehicle(testRgv.getVehicleId(),testRgv.getStartPoint(),testRgv.getEndPoint(),testRgv.getOtherVehicle()); + private String testRgv(@RequestBody TestRgv testRgv) throws IOException { + Long aLong = taskDistanceUtils.chooseVehicle(testRgv.getStartPoint(), testRgv.getEndPoint()); + Boolean aBoolean = taskDistanceUtils.conflictForVehicle(testRgv.getVehicleId(), testRgv.getStartPoint(), testRgv.getEndPoint(), testRgv.getOtherVehicle()); + return String.valueOf(aLong)+String.valueOf(aBoolean); } private Integer sendTaskToRgv(Integer taskType,Long vehicleId, Long currTaskId, Long startPoint, Long endPoint, Integer processNumber) { Map json = new HashMap(); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index e91f6c9..aba695b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -91,7 +91,7 @@ public class AsynRunTaskService extends BaseService { VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask)); //检查车辆是否冲突,冲突则避让 - rgvStatus(vehicleId, currTask); + rgvStatus(vehicleId, currTask,currTask.getStartPosition(),currTask.getTargetPosition()); //新建一条执行任务的关系表存放任务执行信息 RunTask runTask = new RunTask(); runTask.setTaskId(currTask.getId()); @@ -180,7 +180,7 @@ public class AsynRunTaskService extends BaseService { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId);List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask)); //检查车辆是否冲突,冲突则避让 - rgvStatus(vehicleId, currTask); + rgvStatus(vehicleId, currTask,location.getCode(),currTask.getTargetPosition()); //新建一条执行任务的关系表存放任务执行信息 RunTask runTask = new RunTask(); runTask.setTaskId(currTask.getId()); @@ -280,7 +280,7 @@ public class AsynRunTaskService extends BaseService { //Location location = locationServiceBiz.getById(currTask.getLocationId()); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); //检查车辆是否冲突,冲突则避让 - rgvStatus(vehicleId, currTask); + rgvStatus(vehicleId, currTask,currTask.getStartPosition(),location.getCode()); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask = new RunTask(); runTask.setTaskId(currTask.getId()); @@ -367,8 +367,9 @@ public class AsynRunTaskService extends BaseService { public void asynRunTaskForKilnToWarehouse(Long currTaskId, Long vehicleId) throws IOException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); + Location location = locationServiceBiz.getOne(new QueryWrapper().eq(Location.CODE, currTask.getOutTargetPosition())); //检查车辆是否冲突,冲突则避让 - rgvStatus(vehicleId, currTask); + rgvStatus(vehicleId, currTask,currTask.getStartPosition(),location.getCode()); //新建一条执行任务的关系表存放任务执行信息,终点为缓存区空闲库位 RunTask runTask = new RunTask(); runTask.setTaskId(currTask.getId()); @@ -379,7 +380,7 @@ public class AsynRunTaskService extends BaseService { runTask.setEndPosition(currTask.getOutTargetPosition()); runTaskServiceBiz.save(runTask); //更新 location 表对应库位状态为占用 - Location location = locationServiceBiz.getOne(new QueryWrapper().eq(Location.CODE, currTask.getOutTargetPosition())); + location.setStatus(1); location.setUpdateTime(LocalDateTime.now()); locationServiceBiz.updateById(location); @@ -1337,7 +1338,7 @@ public class AsynRunTaskService extends BaseService { * @param currTask * @throws IOException */ - private void rgvStatus(Long vehicleId,CurrTask currTask) throws IOException { + private void rgvStatus(Long vehicleId,CurrTask currTask,String startPosition,String targetPosition) throws IOException { Long currTaskId = currTask.getId(); if (vehicleId==1){ Long anotherVehicleId=2L; @@ -1346,7 +1347,7 @@ public class AsynRunTaskService extends BaseService { //获取RGV2当前位置 Double rgv2CurrPosition = RGVCurrPosition(2); //两辆小车是否冲突 - Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, currTask.getStartPosition(), currTask.getTargetPosition(), rgv2CurrPosition); + Boolean conflictBoolean = taskDistanceUtils.conflictForVehicle(vehicleId, startPosition, targetPosition, rgv2CurrPosition); if (conflictBoolean){ Integer status = moveRgv(2, currTaskId, 2,0); if (status!=1){