opt: 仓库驱动优化
This commit is contained in:
@@ -177,6 +177,11 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
|
||||
if (1 == move && task != 0) {
|
||||
finishInstruction();
|
||||
}
|
||||
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
@@ -191,9 +196,6 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
if (10 == this.mode && !requireSuccess) {
|
||||
doCallEmptyPalletStack();
|
||||
}
|
||||
if (1 == move && task != 0) {
|
||||
finishInstruction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.nl.acs.device.deviceDriver.service.driver.plugin.DeviceStageMonitorPl
|
||||
import org.nl.acs.device.deviceDriver.service.driver.plugin.DriverExecutePlugin;
|
||||
import org.nl.acs.task.instruction.domain.Instruction;
|
||||
import org.nl.acs.task.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.task.instruction.enums.SendStatusEnum;
|
||||
import org.nl.acs.task.instruction.service.InstructionService;
|
||||
import org.nl.acs.task.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.task.service.TaskService;
|
||||
@@ -207,6 +208,12 @@ public class BoxPackingInManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
if (this.mode != this.lastMode) {
|
||||
this.requireSuccess = false;
|
||||
}
|
||||
|
||||
// 更新指令状态
|
||||
if (mode == 3 && task > 0) {
|
||||
updateInstructionStatus();
|
||||
}
|
||||
|
||||
if (!this.online) {
|
||||
this.message = "设备离线";
|
||||
} else if (this.mode == 0) {
|
||||
@@ -221,10 +228,6 @@ public class BoxPackingInManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
if (mode == 2 && move == 0 && task == 0 && action == 0 && !requireSuccess) {
|
||||
issueInstruction();
|
||||
}
|
||||
// 更新指令状态
|
||||
if (mode == 3 && task > 0 && !requireActionSuccess) {
|
||||
updateInstructionStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,13 +268,13 @@ public class BoxPackingInManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
continue;
|
||||
}
|
||||
|
||||
Instruction instruction = instructionService.findByTaskCodeAndStatus(taskDto.getTask_code());
|
||||
Instruction instruction = instructionService.findByCodeFromCache(taskDto.getTask_code());
|
||||
if (instruction == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Device startDevice = deviceAppService.findDeviceByCode(taskDto.getStart_device_code());
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(taskDto.getNext_device_code());
|
||||
Device startDevice = deviceAppService.findDeviceByCode(taskDto.getStart_point_code());
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(taskDto.getNext_point_code());
|
||||
String startAddress = getDeviceAddress(startDevice);
|
||||
String nextAddress = getDeviceAddress(nextDevice);
|
||||
|
||||
@@ -288,53 +291,31 @@ public class BoxPackingInManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
* 更新指令
|
||||
*/
|
||||
public void updateInstructionStatus() {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (!isTimeValid(currentTimeMillis)) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
|
||||
} else {
|
||||
this.requireTime = currentTimeMillis;
|
||||
//更改指令状态
|
||||
if (task > 0) {
|
||||
Instruction inst = checkInst();
|
||||
// 任务执行中
|
||||
if (inst != null) {
|
||||
if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) {
|
||||
inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
|
||||
instructionService.update(inst);
|
||||
}
|
||||
//更改指令状态
|
||||
if (task > 0) {
|
||||
Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
// 任务执行中
|
||||
if (inst != null) {
|
||||
if (StrUtil.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex())) {
|
||||
inst.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
|
||||
inst.setSend_status(SendStatusEnum.SUCCESS.getCode());
|
||||
instructionService.update(inst);
|
||||
}
|
||||
//任务完成
|
||||
if (action == 5 && move == 0) {
|
||||
if (inst != null) {
|
||||
try {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
writing("to_command", 5);
|
||||
requireActionSuccess = true;
|
||||
} catch (Exception e) {
|
||||
message = "指令完成触发失败: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
//任务完成
|
||||
if (action == 5 && move == 0) {
|
||||
if (inst != null) {
|
||||
try {
|
||||
instructionService.finish(inst.getInstruction_id());
|
||||
writing("to_command", 5);
|
||||
} catch (Exception e) {
|
||||
message = "指令完成触发失败: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (this.task <= 0) {
|
||||
return null;
|
||||
}
|
||||
String taskCode = String.valueOf(this.task);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(this.inst) && taskCode.equals(this.inst.getInstruction_code())) {
|
||||
return this.inst;
|
||||
}
|
||||
|
||||
this.inst = instructionService.findByCodeFromCache(taskCode);
|
||||
return this.inst;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备电气调度号
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SurayToAcsServiceImpl implements SurayToAcsService {
|
||||
// 任务完成
|
||||
if (instruction != null) {
|
||||
try {
|
||||
instructionService.finish(request.getTaskId());
|
||||
instructionService.finish(instruction.getInstruction_id());
|
||||
} catch (Exception e) {
|
||||
return TaskStatusReportResponse.failed(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.nl.extInterface.wms;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.nl.extInterface.wms.data.req.TaskIssueReqVO;
|
||||
import org.nl.extInterface.wms.data.resp.TaskIssueResultRespVO;
|
||||
import org.nl.extInterface.wms.service.WmsToAcsService;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* WMS 任务下发接口集成测试。
|
||||
*
|
||||
* <p>运行前请确认点位 {@code 010101} 和 {@code CK_AGV01} 已在库位表中配置。</p>
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class WmsToAcsServiceTest {
|
||||
|
||||
@Resource
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
|
||||
@Test
|
||||
void shouldIssueTaskFrom010101ToCkAgv01() {
|
||||
long uniqueId = IdUtil.getSnowflakeNextId();
|
||||
TaskIssueReqVO task = new TaskIssueReqVO();
|
||||
task.setTaskId(uniqueId);
|
||||
task.setTaskCode("TEST_123456");
|
||||
task.setTaskType("2");
|
||||
task.setStartDeviceCode("010101");
|
||||
task.setNextDeviceCode("CK_AGV01");
|
||||
|
||||
TaskIssueResultRespVO result = wmsToAcsService.issueTask(Collections.singletonList(task));
|
||||
|
||||
assertNotNull(result, "任务下发响应不能为空");
|
||||
assertNotNull(result.getFailedTasks(), "失败任务列表不能为空");
|
||||
assertTrue(result.getFailedTasks().isEmpty(),
|
||||
"任务下发失败:" + result.getFailedTasks());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user