更新AGV类型判断

liweidong
liweidong-hj 1 month ago
parent b184306558
commit 1f575ac027
  1. 4
      blade-common/src/main/java/org/springblade/common/constant/LauncherConstant.java
  2. 121
      blade-service/blade-desk/src/main/java/org/springblade/desk/logistics/utils/AgvTaskTypeUtil.java

@ -31,8 +31,8 @@ public interface LauncherConstant {
/**
* nacos dev 地址
*/
// String NACOS_DEV_ADDR = "192.168.249.27:8848";
String NACOS_DEV_ADDR = "127.0.0.1:8848";
String NACOS_DEV_ADDR = "192.168.249.27:8848";
// String NACOS_DEV_ADDR = "127.0.0.1:8848";
/**
* nacos prod 地址

@ -7,6 +7,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
/**
* AGV任务类型工具类
*/
/**
* AGV任务类型工具类
*/
@ -20,12 +23,8 @@ public class AgvTaskTypeUtil {
@Autowired
ILocationService locationService;
/**
* 根据起点和终点获取AGV任务类型
* @param startPosition 起点位置编码 (1001/1002/站点code)
* @param endPosition 终点位置编码 (1001/1002/站点code)
* @return 任务类型 (QM, QM3, QM5, QM6, QM7)
*/
public String getTaskTypeByPositions(String startPosition, String endPosition) {
// 参数校验
@ -34,53 +33,25 @@ public class AgvTaskTypeUtil {
throw new IllegalArgumentException("起点和终点位置不能为空");
}
// 判断起点和终点的类型及楼层
log.info("获取任务类型,起点:{},终点:{}", startPosition, endPosition);
// 判断特殊点位
boolean isStartConveyorStart = "1002".equals(startPosition);
boolean isStartConveyorEnd = "1001".equals(startPosition);
boolean isEndConveyorStart = "1002".equals(endPosition);
boolean isEndConveyorEnd = "1001".equals(endPosition);
// 获取站点楼层(如果不是站点,返回null)
Integer startFloor = null;
Integer endFloor = null;
if (!isStartConveyorStart && !isStartConveyorEnd) {
// 起点是站点或梳齿架
Station startStation = stationService.getByStationCode(startPosition);
if (startStation != null) {
// 情况1:是站点 - 从站点获取楼层
startFloor = Integer.parseInt(startStation.getStationPosition());
log.info("起点是站点,站点编码:{},楼层:{}", startPosition, startFloor);
} else {
// 情况2:不是站点,可能是梳齿架 - 查询库位表
Location location = locationService.selectByLocationCode(startPosition, 1);
if (null == location) {
log.error("未找到起点信息,站点编码:{}", startPosition);
throw new IllegalArgumentException("无效的起点编码:" + startPosition);
}
// 梳齿架固定在一层
startFloor = 1;
log.info("起点是梳齿架,固定楼层为1层,位置编码:{}", startPosition);
}
}
// 获取起点楼层
Integer startFloor = getPositionFloor(startPosition, "起点", isStartConveyorStart, isStartConveyorEnd);
// 获取终点楼层
Integer endFloor = getPositionFloor(endPosition, "终点", false, isEndConveyorEnd);
log.info("起点楼层:{},终点楼层:{}", startFloor, endFloor);
if (!isEndConveyorStart && !isEndConveyorEnd) {
Station endStation = stationService.getByStationCode(endPosition);
if (endStation != null) {
endFloor = Integer.parseInt(endStation.getStationPosition());
log.info("终点是站点,编码:{},楼层:{}", endPosition, endFloor);
} else {
Location location = locationService.selectByLocationCode(endPosition, 1);
if (null == location) {
log.error("未找到终点信息,站点编码:{}", endPosition);
throw new IllegalArgumentException("无效的终点编码:" + endPosition);
}
endFloor = 1;
log.info("终点是梳齿架,编码:{},固定楼层:1", endPosition);
}
// 场景4: 输送线起点(1002)或梳齿架 ---> 站点(二层) -> QM3
if ((isStartConveyorStart || (startFloor != null && startFloor == 1))
&& endFloor != null && endFloor == 2) {
log.info("起点(输送线起点/1层梳齿架)到二层站点任务,使用QM3");
return "QM3";
}
// 场景1: 站点 <-----> 站点 -> QM
@ -89,23 +60,19 @@ public class AgvTaskTypeUtil {
return "QM";
}
// 场景2: 输送线起点(1002) ---> 站点(一层) -> QM7
if (isStartConveyorStart && endFloor != null && endFloor == 1) {
log.info("输送线起点到一层站点任务,使用QM7");
// 场景2: 输送线起点(1002)或梳齿架 ---> 站点(一层) -> QM7
if ((isStartConveyorStart || (startFloor != null && startFloor == 1))
&& endFloor != null && endFloor == 1) {
log.info("起点(输送线起点/1层梳齿架)到一层站点任务,使用QM7");
return "QM7";
}
// 场景3: 站点(一层) ----> 输送线终点(1001) -> QM6
if (startFloor != null && startFloor == 1 && isEndConveyorEnd) {
log.info("一层点到输送线终点任务,使用QM6");
// 场景3: 站点(一层)或梳齿架 ----> 输送线终点(1001) -> QM6
if ((startFloor != null && startFloor == 1) && isEndConveyorEnd) {
log.info("一层点到输送线终点任务,使用QM6");
return "QM6";
}
// 场景4: 输送线起点(1002) ---> 站点(二层) -> QM3
if (isStartConveyorStart && endFloor != null && endFloor == 2) {
log.info("输送线起点到二层站点任务,使用QM3");
return "QM3";
}
// 场景5: 站点(二层) ----> 输送线终点(1001) -> QM5
if (startFloor != null && startFloor == 2 && isEndConveyorEnd) {
@ -113,8 +80,46 @@ public class AgvTaskTypeUtil {
return "QM5";
}
// 其他情况,记录日志并抛出异常
log.error("无法确定任务类型,起点:{},终点:{}", startPosition, endPosition);
throw new IllegalArgumentException("无法确定任务类型,请检查起点和终点位置的组合");
}
}
/**
* 获取位置对应的楼层
*/
private Integer getPositionFloor(String positionCode, String positionType,
boolean isConveyorStart, boolean isConveyorEnd) {
// 特殊点位没有楼层
if (isConveyorStart || isConveyorEnd) {
return null;
}
// 先作为站点查询
Station station = stationService.getByStationCode(positionCode);
if (station != null) {
Integer floor = Integer.parseInt(station.getStationPosition());
log.info("{}是站点,编码:{},楼层:{}", positionType, positionCode, floor);
return floor;
}
// 作为梳齿架查询
Location location = locationService.selectByLocationCode(positionCode, 1);
if (location != null) {
// 从位置编码解析楼层
Integer floor = parseFloorFromLocationCode(location.getLocationCode());
log.info("{}是梳齿架,编码:{},解析楼层:{}", positionType, positionCode, floor);
return floor;
}
log.error("未找到{}位置信息:{}", positionType, positionCode);
throw new IllegalArgumentException("无效的位置编码:" + positionCode);
}
/**
* 从梳齿架编码解析楼层
*/
private Integer parseFloorFromLocationCode(String locationCode) {
return 1;
}
}
Loading…
Cancel
Save