fix: 堆垛机对接位通过补码生成到货架的任务
This commit is contained in:
@@ -199,6 +199,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
String vehicle_code;
|
||||
String inst_message;
|
||||
|
||||
String hand_barcode = null;
|
||||
|
||||
/**
|
||||
* led点阵屏信息
|
||||
*/
|
||||
@@ -314,9 +316,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.conveyor.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
|
||||
@@ -424,8 +423,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 申请任务
|
||||
*/
|
||||
@@ -469,6 +466,53 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
//判断是否有相同起点的,任务状态就绪的任务
|
||||
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
||||
if (ObjectUtil.isNull(taskdto)) {
|
||||
//补码生成堆垛机对接位到货架的指令
|
||||
if (StrUtil.isNotEmpty(hand_barcode)) {
|
||||
TaskDto taskDtoHandCode = taskserver.findByVehicleCodeCodeAndReady(hand_barcode);
|
||||
if (Objects.nonNull(taskDtoHandCode)) {
|
||||
String taskid = taskDtoHandCode.getTask_id();
|
||||
String taskcode = taskDtoHandCode.getTask_code();
|
||||
String priority = taskDtoHandCode.getPriority();
|
||||
String start_point_code = taskDtoHandCode.getStart_point_code();
|
||||
String start_device_code = "";
|
||||
String route_plan_code = taskDtoHandCode.getRoute_plan_code();
|
||||
String next_device_code = taskDtoHandCode.getNext_device_code();
|
||||
String interactionJson = taskDtoHandCode.getInteraction_json();
|
||||
String containerType = "";
|
||||
if (StrUtil.isNotEmpty(interactionJson)) {
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
containerType = interactionJsonDTO.getContainerType();
|
||||
}
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskDtoHandCode.getStart_device_code(), next_device_code, route_plan_code);
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
String path = routeLineDto.getPath();
|
||||
String[] str = path.split("->");
|
||||
List<String> pathlist = Arrays.asList(str);
|
||||
int index = 0;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(next_device_code)) {
|
||||
index = m - 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
start_device_code = pathlist.get(index);
|
||||
//校验路由关系
|
||||
List<RouteLineDto> shortPathsList2 = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList2) || shortPathsList2.size() < 1) {
|
||||
throw new RuntimeException("路由不通!");
|
||||
}
|
||||
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||
String next_point_code;
|
||||
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||
next_point_code = taskDtoHandCode.getTo_x() + "-" + taskDtoHandCode.getTo_y() + "-" + taskDtoHandCode.getTo_z();
|
||||
Instruction instdto = new Instruction();
|
||||
packageData(instdto, route_plan_code, taskDtoHandCode, taskid, taskcode, start_device_code, next_device_code, start_point_code, next_point_code, priority, containerType);
|
||||
return updateTask(taskDtoHandCode, nextdevice, instdto);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(taskdto)) {
|
||||
@@ -484,9 +528,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
String start_device_code = taskdto.getStart_device_code();
|
||||
String route_plan_code = taskdto.getRoute_plan_code();
|
||||
String next_device_code = "";
|
||||
String containerType = "";
|
||||
String interactionJson = taskdto.getInteraction_json();
|
||||
if (StrUtil.isNotEmpty(interactionJson)) {
|
||||
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
|
||||
String containerType = interactionJsonDTO.getContainerType();
|
||||
containerType = interactionJsonDTO.getContainerType();
|
||||
}
|
||||
/**
|
||||
* 开始平均分配
|
||||
*/
|
||||
@@ -534,6 +581,15 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
log.error("指令创建失败!,{}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
return updateTask(taskdto, nextdevice, instdto);
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateTask(TaskDto taskdto, Device nextdevice, Instruction instdto) {
|
||||
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
@@ -544,10 +600,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeData(String next_addr, List list, Instruction inst) {
|
||||
List list1 = new ArrayList();
|
||||
@@ -694,6 +746,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
jo.put("is_click", true);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("requireSucess", requireSucess);
|
||||
jo.put("hand_barcode", hand_barcode);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@@ -755,6 +808,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
} else if (StrUtil.equals(requestSucess, "1")) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
String hand_barcode = data.getString("hand_barcode");
|
||||
this.setHand_barcode(hand_barcode);
|
||||
}
|
||||
|
||||
public static boolean arrayEquals(int[] a, int[] b) {
|
||||
|
||||
@@ -389,6 +389,15 @@ public interface TaskService extends CommonService<Task> {
|
||||
*/
|
||||
TaskDto findByStartCodeAndReady(String device_code);
|
||||
|
||||
|
||||
/**
|
||||
* 根据起载具号查询就绪任务
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
TaskDto findByVehicleCodeCodeAndReady(String device_code);
|
||||
|
||||
/**
|
||||
* 根据起点设备编号查询当前是否有执行中任务
|
||||
*
|
||||
|
||||
@@ -1076,6 +1076,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
return optionalTask.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByVehicleCodeCodeAndReady(String vehicleCode) {
|
||||
Optional<TaskDto> optionalTask = tasks.stream()
|
||||
.filter(task -> StrUtil.equals(task.getVehicle_code(), vehicleCode)
|
||||
&& StrUtil.equals(task.getTask_status(), TaskStatusEnum.READY.getIndex()))
|
||||
.findFirst();
|
||||
return optionalTask.orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByCodeAndExcute(String start_code, String next_code) {
|
||||
Task task = this.lambdaQuery()
|
||||
|
||||
@@ -90,21 +90,21 @@ public class CreateDDJInst {
|
||||
StandardStackerDeviceDriver standardStackerDeviceDriver;
|
||||
if (deviceByCode.getDeviceDriver() instanceof StandardStackerDeviceDriver) {
|
||||
standardStackerDeviceDriver = (StandardStackerDeviceDriver) deviceByCode.getDeviceDriver();
|
||||
if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
|
||||
log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
|
||||
return;
|
||||
}
|
||||
// if (standardStackerDeviceDriver.getMode() != 3 || standardStackerDeviceDriver.getMove() == 1 || standardStackerDeviceDriver.getCommand() != 0) {
|
||||
// log.error("堆垛机,{}未联机或者在执行中", deviceByCode.getDevice_code());
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
String next_device_code = taskDto.getNext_device_code();
|
||||
Device nextDevice = appService.findDeviceByCode(next_device_code);
|
||||
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
|
||||
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||
if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
|
||||
log.error("输送机,{}未联机或执行中", next_device_code);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
|
||||
// beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
|
||||
// if (beltConveyorDeviceDriver.getMode() != 2 || beltConveyorDeviceDriver.getMove() == 1) {
|
||||
// log.error("输送机,{}未联机或执行中", next_device_code);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
String taskid = taskDto.getTask_id();
|
||||
String taskcode = taskDto.getTask_code();
|
||||
String task_type = taskDto.getTask_type();
|
||||
|
||||
Reference in New Issue
Block a user