opt: 堆垛机驱动优化

This commit is contained in:
yanps
2023-11-28 08:54:37 +08:00
parent 70652a6bfa
commit 5e8a7e3cf6
2 changed files with 83 additions and 84 deletions

View File

@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
@@ -388,9 +389,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
} else {
this.instruction_require_time = date;
//查找有没有对应的指令
//找指令类型是10的
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
if (ObjectUtil.isNotNull(inst) && "10".equals(inst.getInstruction_type())) {
if (ObjectUtil.isNotNull(inst) && "1".equals(inst.getInstruction_type())) {
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
TaskDto taskDto = taskserver.findByCodeFromCache(inst.getTask_code());
@@ -410,7 +410,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
return true;
} else {
//判断是否有相同起点的,任务状态就绪的任务
//任务类型是10
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
if (ObjectUtil.isNull(taskdto)) {
return false;

View File

@@ -240,94 +240,94 @@ public class CreateDDJInst {
max++;
}
}
List<DeviceExtra> deviceExtras = deviceExtra.list(Wrappers.lambdaQuery(DeviceExtra.class).
eq(DeviceExtra::getDevice_code, pathlist.get(1)).orderByDesc(DeviceExtra::getCreate_time));
for (DeviceExtra extra : deviceExtras) {
if (extra.getExtra_code().equals("count")) {
if (max <= Integer.parseInt(extra.getExtra_value())) {
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(taskDto.getRemark());
instdto.setMaterial(taskDto.getMaterial());
instdto.setQuantity(taskDto.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
/*List<DeviceExtra> deviceExtras = deviceExtra.list(Wrappers.lambdaQuery(DeviceExtra.class).
eq(DeviceExtra::getDevice_code, pathlist.get(1)).orderByDesc(DeviceExtra::getCreate_time));*/
String count = deviceByCode.getExtraValue().get("count").toString();
if (StrUtil.isNotEmpty(count) ) {
if (max <= Integer.parseInt(count)) {
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(taskDto.getRemark());
instdto.setMaterial(taskDto.getMaterial());
instdto.setQuantity(taskDto.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(start_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setPut_device_code(put_device_code);
instdto.setPut_point_code(put_point_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_device_code(start_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setPut_device_code(put_device_code);
instdto.setPut_point_code(put_point_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_point_code2(start_point_code2);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_point_code2(next_point_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setStart_point_code2(start_point_code2);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_point_code2(next_point_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
if (startDevice.getDevice_type().equals(DeviceType.storage.name())) {
instdto.setFrom_x(taskDto.getFrom_x());
instdto.setFrom_z(taskDto.getFrom_z());
instdto.setFrom_y(taskDto.getFrom_y());
}
if (nextDevice.getDevice_type().equals(DeviceType.storage.name())) {
instdto.setTo_x(taskDto.getTo_x());
instdto.setTo_z(taskDto.getTo_z());
instdto.setTo_y(taskDto.getTo_y());
}
//判断agv系统
//1、1楼叉车系统
//2、2楼1区域AGV系统
//3、2楼2区域AGV系统 -已废弃
if (!StrUtil.equals(agv_system_type, "1")) {
// task_type
//1、生箔 Itype=1:取空,取满,放空,放满;
//2、分切 Itype=3取满、取空、放满、放空
//3、普通任务 Itype=2:取货、放货;
//4、叉车任务
//5、输送任务
//6、行架
//7、立库
if (StrUtil.equals(task_type, "1")) {
instdto.setAgv_inst_type("1");
} else if (StrUtil.equals(task_type, "3")) {
instdto.setAgv_inst_type("2");
} else if (StrUtil.equals(task_type, "2")) {
instdto.setAgv_inst_type("3");
} else if (StrUtil.equals(task_type, "8")) {
instdto.setAgv_inst_type("2");
} else {
log.info("未找到对应的AGV指令类型任务号:" + taskDto.getTask_code() + ",task_type:" + taskDto.getTask_type());
}
} else {
instdto.setAgv_inst_type("4");
}
try {
instructionService.create(instdto);
} catch (Exception e) {
taskDto.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(taskDto);
}
//创建指令后修改任务状态
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskserver.update(taskDto);
continue;
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
if (startDevice.getDevice_type().equals(DeviceType.storage.name())) {
instdto.setFrom_x(taskDto.getFrom_x());
instdto.setFrom_z(taskDto.getFrom_z());
instdto.setFrom_y(taskDto.getFrom_y());
}
if (nextDevice.getDevice_type().equals(DeviceType.storage.name())) {
instdto.setTo_x(taskDto.getTo_x());
instdto.setTo_z(taskDto.getTo_z());
instdto.setTo_y(taskDto.getTo_y());
}
//判断agv系统
//1、1楼叉车系统
//2、2楼1区域AGV系统
//3、2楼2区域AGV系统 -已废弃
if (!StrUtil.equals(agv_system_type, "1")) {
// task_type
//1、生箔 Itype=1:取空,取满,放空,放满;
//2、分切 Itype=3取满、取空、放满、放空
//3、普通任务 Itype=2:取货、放货;
//4、叉车任务
//5、输送任务
//6、行架
//7、立库
if (StrUtil.equals(task_type, "1")) {
instdto.setAgv_inst_type("1");
} else if (StrUtil.equals(task_type, "3")) {
instdto.setAgv_inst_type("2");
} else if (StrUtil.equals(task_type, "2")) {
instdto.setAgv_inst_type("3");
} else if (StrUtil.equals(task_type, "8")) {
instdto.setAgv_inst_type("2");
} else {
log.info("未找到对应的AGV指令类型任务号:" + taskDto.getTask_code() + ",task_type:" + taskDto.getTask_type());
}
} else {
instdto.setAgv_inst_type("4");
}
try {
instructionService.create(instdto);
} catch (Exception e) {
taskDto.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(taskDto);
}
//创建指令后修改任务状态
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskserver.update(taskDto);
continue;
}
}
}
}
}