fix:普通输送线增加请求标记兜底

This commit is contained in:
miguannan
2026-08-14 10:41:36 +07:00
parent 1565e56f74
commit 5e89a4f8b6

View File

@@ -187,18 +187,21 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
Instruction inst = instructionService.findByCodeFromCache(String.valueOf(this.task));
if (ObjectUtil.isNotEmpty(inst))
{
if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code())) {
if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) && StrUtil.equals(this.currentDeviceCode, inst.getStart_device_code()))
{
inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
inst.setExecute_device_code(this.currentDeviceCode);
instructionService.update(inst);
} else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code())) {
} else if (StrUtil.equals(this.currentDeviceCode, inst.getNext_device_code()))
{
inst.setExecute_device_code(this.currentDeviceCode);
instructionService.finish(inst);
}
}
}
private boolean cancelTaskAndInstructionWhenError() {
private boolean cancelTaskAndInstructionWhenError()
{
if (!CANCEL_TASK_ERROR_CODES.contains(this.error)) {
this.lastCancelTaskInstructionCode = null;
return false;
@@ -353,7 +356,11 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
this.requireSuccess = false;
clearWrite();
}
// 电平兜底:设备已明显空闲但下发标记仍被锁定,说明边缘检测漏采,强制重置防止死锁
if (this.mode == 2 && this.move == 0 && this.task == 0 && this.requireSuccess) {
this.requireSuccess = false;
clearWrite();
}
boolean cancelTaskIntercepted = cancelTaskAndInstructionWhenError();
if (!cancelTaskIntercepted && this.move != 0 && this.task > 0) {
update_instruction_status();
@@ -634,10 +641,11 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
String interactionJson = taskDto.getInteraction_json();
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
String isUncap = "0";
List<String> keys = new ArrayList<>(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()));
List<Object> values = new ArrayList<>(Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(instDto.getInstruction_code()), ToCommandEnum.COMMAND_ONE.getSignalNum()));
List<String> keys = new ArrayList<>(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey()));
List<Object> values = new ArrayList<>(Arrays.asList(getTargetAddress(nextDevice), Integer.parseInt(instDto.getInstruction_code())));
if (ObjectUtil.isNotEmpty(interactionJsonDTO)) {
if (ObjectUtil.isNotEmpty(interactionJsonDTO))
{
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getType()))
{
keys.add(ItemProtocol.TO_BACK_UP_1.getKey());
@@ -649,6 +657,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
values.add(interactionJsonDTO.getContainerType());
}
}
keys.add(ItemProtocol.TO_COMMAND.getKey());
values.add(ToCommandEnum.COMMAND_ONE.getSignalNum());
this.writing(keys, values);
this.requireSuccess = true;
}