rev:优化烘箱行架任务逻辑

This commit is contained in:
2024-11-18 13:43:57 +08:00
parent 32b0710a37
commit 4135200271
20 changed files with 194 additions and 174 deletions

View File

@@ -124,4 +124,6 @@ public interface XianGongAgvService {
* @return
*/
HttpResponse sendOrderSequencesToForklift(Instruction dto, InteractionJsonDTO interactionJsonDTO);
}

View File

@@ -1,5 +1,6 @@
package org.nl.acs.agv.server.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -74,17 +75,15 @@ public class NDCAgvServiceImpl implements NDCAgvService {
}
@Override
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) {
log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() +
",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() +
log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() +
",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() +
",nextAddress:" + inst.getNext_point_code());
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
if (!StrUtil.equals(agv_system_type, "1")) {
String instcode = inst.getInstruction_code();
int type = Integer.parseInt(inst.getAgv_inst_type());
int carNo = Integer.parseInt(inst.getCarno());
int priority = Integer.parseInt(inst.getPriority()) + 128;
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
@@ -96,8 +95,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode));
byte typehigh = (byte) IntToHexHigh(type);
byte typelow = (byte) IntToHexLow(type);
byte agvnohigh = (byte) IntToHexHigh(carNo);
byte agvnolow = (byte) IntToHexLow(carNo);
byte qhdhigh = (byte) IntToHexHigh(startAddress);
byte qhdlow = (byte) IntToHexLow(startAddress);
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2);
@@ -107,7 +104,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2);
byte fhdlow2 = (byte) IntToHexLow(nextAddress2);
byte prioritylow = (byte) IntToHexLow(priority);
String str = "十进制下发:";
String str1 = "十六进制下发:";
str += "任务号 ikey:" + (Integer.parseInt(instcode));
@@ -128,8 +124,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
str += "优先级 /priority:" + (priority);
str1 += "优先级 /priority:" + hexToString(prioritylow & 0xFF);
str += "agv车号 /carNo:" + (carNo);
str1 += "agv车号 /carNo:" + hexToString(agvnolow & 0xFF);
byte[] b = new byte[]{};
if (type == 1) {
@@ -341,7 +335,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
}
@Override
public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity) {
public byte[] sendAgvTwoModeInst(int phase, int index, int result, int offset, int quantity) {
if (phase < 0 || index < 0)
return null;
byte indexhigh = (byte) IntToHexHigh(index);
@@ -368,7 +362,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:"
+ hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)+",是否侧移: "+(offset == 1?"侧移":"不测移") + ",偏离量: " + quantity);
+ hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF) + ",是否侧移: " + (offset == 1 ? "侧移" : "不测移") + ",偏离量: " + quantity);
System.out.println("反馈agv动作数据:" + Bytes2HexString(b));
return b;
@@ -520,7 +514,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
}
@Override
public Map<String, AgvDto> findAllAgvFromCache() {
return AGVDeviceStatus;

View File

@@ -1082,6 +1082,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
}
/**
* 追加动作块
*

View File

@@ -338,16 +338,26 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
List<TaskDto> taskDtoStream = taskDtos.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(taskDtoStream)) {
TaskDto taskDto = taskDtos.get(0);
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
String start_device_code = instruction.getStart_device_code();
String next_device_code = instruction.getNext_device_code();
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver;
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
//存在行架->暂存的AGV任务 需要过滤
// 6 行架任务 8烘箱任务
if (!StrUtil.equals(taskDto.getTask_type(), "6") && !StrUtil.equals(taskDto.getTask_type(), "8")) {
taskDto = null;
continue;
}
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
if (ObjectUtil.isEmpty(instruction)) {
break;
}
String start_device_code = instruction.getStart_device_code();
String next_device_code = instruction.getNext_device_code();
Device nextdevice = deviceAppService.findDeviceByCode(next_device_code);
Device startdevice = deviceAppService.findDeviceByCode(start_device_code);
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver;
OvenInspectSiteDeviceDriver ovenInspectSiteDeviceDriver;
/*if (startdevice.getDeviceDriver() instanceof OvenInspectSiteDeviceDriver && nextdevice.getDeviceDriver() instanceof RangingStationsDeviceDriver) {
ovenInspectSiteDeviceDriver = (OvenInspectSiteDeviceDriver) startdevice.getDeviceDriver();
standardInspectSiteDeviceDriver = (RangingStationsDeviceDriver) nextdevice.getDeviceDriver();
@@ -378,111 +388,104 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
return false;
}
}*/
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
}
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
//判断关联的同一列烘箱设备是否都关门 都关门返回false有一个不关门就返回true
boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code);
//未关门结束
if (isCloseDoor) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
// if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
// }
}
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或无货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
// if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "有货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
// }
}
if (nextdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextdevice.getDeviceDriver();
if (hongXiangConveyorDeviceDriver.getMode() == 0 || hongXiangConveyorDeviceDriver.getMove() == 1) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->放货位-烘箱:" + hongXiangConveyorDeviceDriver.getDevice_code() + "未联机或者有货,无法下发指令!指令号:" + instruction.getInstruction_code();
return false;
}
}
//判断关联的同一列烘箱设备是否都关门 都关门返回false有一个不关门就返回true
boolean isCloseDoor = this.judgeCloseDoor(start_device_code, next_device_code);
//未关门结束
if (isCloseDoor) {
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
return false;
}
/*instruction.setInstruction_status("1");
instruction.setUpdate_time(DateUtil.now());
instructionService.update(instruction);*/
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
String msg = "当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(msg)
.build();
logDto.setLog_level(3);
luceneExecuteLogService.deviceExecuteLog(logDto);
List list = new ArrayList<>();
Map map = new HashMap();
map.put("code", "to_onset");
map.put("value", StrUtil.isNotBlank(start_addr) ? start_addr : "0");
Map map1 = new HashMap();
map1.put("code", "to_target");
map1.put("value", StrUtil.isNotBlank(next_addr) ? next_addr : "0");
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", instruction.getInstruction_code());
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map);
list.add(map1);
list.add(map2);
list.add(map3);
this.writing(list);
this.setRequireSucess(true);
return true;
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!");
}
if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) {
throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!");
}
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
String msg = "当前设备:" + device_code + ",下发指令:"
+ instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code()
+ ",指令终点:" + instruction.getNext_device_code();
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(msg)
.build();
logDto.setLog_level(3);
luceneExecuteLogService.deviceExecuteLog(logDto);
List list = new ArrayList<>();
Map map = new HashMap();
map.put("code", "to_onset");
map.put("value", StrUtil.isNotBlank(start_addr) ? start_addr : "0");
Map map1 = new HashMap();
map1.put("code", "to_target");
map1.put("value", StrUtil.isNotBlank(next_addr) ? next_addr : "0");
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", instruction.getInstruction_code());
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map);
list.add(map1);
list.add(map2);
list.add(map3);
this.writing(list);
this.setRequireSucess(true);
return true;
} else {
List<TaskDto> taskDtoList = taskserver.findByTrappedManipulatorReady();
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtoList)) {
List<TaskDto> taskDtosReady = new ArrayList<>();
for (TaskDto taskDto1 : taskDtoList) {
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
taskDtosReady.add(taskDto1);
for (int j = 0; j < taskDtoList.size(); j++) {
//按照优先级排序 优先级相等按照创建时间排序
taskDtoList = this.sortTask(taskDtoList);
task = taskDtoList.get(j);
// 6 行架任务 8烘箱任务
if (!StrUtil.equals(task.getTask_type(), "6") && !StrUtil.equals(task.getTask_type(), "8")) {
task = null;
continue;
}
if (ObjectUtil.isNotEmpty(task)) {
break;
}
}
// task = taskDtosReady.get(0);
List<TaskDto> readyTaskDtos = new ArrayList<>();
for (int j = 0; j < taskDtosReady.size(); j++) {
task = taskDtosReady.get(j);
readyTaskDtos.add(task);
}
//按照优先级排序 优先级相等按照创建时间排序
readyTaskDtos = this.sortTask(readyTaskDtos);
task = readyTaskDtos.get(0);
}
if (ObjectUtil.isNotEmpty(task)) {
break;
}
}
}
@@ -524,12 +527,12 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}*/
if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver();
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电无货,无法生成指令!";
return false;
}
// if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 1) {
notCreateInstMessage = "就绪任务未创建指令原因->取货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电无货,无法生成指令!";
return false;
}
// }
}
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
@@ -548,12 +551,12 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver();
if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电有货,无法生成指令!";
return false;
}
// if (ObjectUtil.equal("true", standardInspectSiteDeviceDriver.getExtraValue().get("input_move"))) {
if (standardInspectSiteDeviceDriver.getMove() != 0) {
notCreateInstMessage = "就绪任务未创建指令原因->放货位-烘箱对接位:" + standardInspectSiteDeviceDriver.getDevicecode() + "光电有货,无法生成指令!";
return false;
}
// }
}
String taskid = task.getTask_id();
@@ -664,11 +667,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
list.add(map3);
this.writing(list);
this.setRequireSucess(true);
return true;
} else {
notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
}
return true;
}
}

View File

@@ -226,9 +226,4 @@ public class CreateTaskRequest extends BaseRequest {
* 17 木箱堆叠行架任务
*/
private String class_type;
/**
* agv编号
*/
private String agv_no;
}

View File

@@ -133,7 +133,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String route_plan_code = request.getRoute_plan_code();
String task_type = request.getTask_type();
String class_type = request.getClass_type();
String agv_no = request.getAgv_no();
String truss_type = request.getTruss_type();
Integer agv_action_type = request.getAgv_action_type();
String empty_site = request.getEmpty_site();
@@ -355,7 +354,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("next_device_code2", next_device_code2);
jo.put("put_device_code", put_device_code);
jo.put("agv_action_type", agv_action_type);
jo.put("agv_no", agv_no);
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("vehicle_code2", vehicle_code2);

View File

@@ -247,11 +247,6 @@ public class Task extends CommonModel<Task> implements Serializable {
private Integer agv_action_type;
/**
* agv编号
*/
private String agv_no;
/**
* 任务类型
* 9 子卷下线行架任务

View File

@@ -370,9 +370,4 @@ public class TaskDto implements Serializable {
* 15 RGV输送任务
*/
private String class_type;
/**
* agv编号
*/
private String agv_no;
}

View File

@@ -88,7 +88,6 @@ public class AutoCreateInst {
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String agv_no = acsTask.getAgv_no();
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
@@ -167,7 +166,6 @@ public class AutoCreateInst {
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
instdto.setAgv_action_type(agvActionType);
instdto.setCarno(agv_no);
//判断agv系统
//1、1楼叉车系统
//2、2楼1区域AGV系统

View File

@@ -130,6 +130,9 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
}catch (Exception ex){
throw new RuntimeException();
}
if ("123456".equals(sysUser.getPassword())) {
sysUser.setPassword(SaSecureUtil.md5BySalt("123456", "salt"));
}
sysUser.setUpdate_time(new Date());
sysUser.setUpdate_id(SecurityUtils.getCurrentUserId());
this.updateById(sysUser);