| | |
| | | package com.zy.acs.common.utils; |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.math.BigInteger; |
| | | import java.nio.charset.Charset; |
| | |
| | | /** |
| | | * 地码编解码规则,按进程级配置生效。 |
| | | */ |
| | | @Slf4j |
| | | public final class QrCodeCodecSupport { |
| | | |
| | | private static volatile CodecConfig config = CodecConfig.defaultConfig(); |
| | |
| | | if (config.mode == Mode.NUMERIC) { |
| | | return normalizeNumericValue(value, config.bytes, config.displayLength); |
| | | } |
| | | return normalizeStringValue(value, config.bytes, config.charset); |
| | | return normalizeStringValue(value, config.bytes, config.displayLength, config.charset); |
| | | } |
| | | |
| | | public static String decode(byte[] bytes, int pos) { |
| | |
| | | } |
| | | |
| | | private static byte[] toFixedStringBytes(String qrCode, int size, Charset charset) { |
| | | String value = normalizeStringValue(qrCode, size, charset); |
| | | return value.getBytes(charset); |
| | | String value = normalizeStringValue(qrCode, size, config.displayLength, charset); |
| | | byte[] raw = value.getBytes(charset); |
| | | byte[] result = new byte[size]; |
| | | System.arraycopy(raw, 0, result, 0, raw.length); |
| | | return result; |
| | | } |
| | | |
| | | private static String normalizeNumericValue(String qrCode, int size, int displayLength) { |
| | |
| | | return Utils.zeroFill(numeric.toString(), displayLength); |
| | | } |
| | | |
| | | private static String normalizeStringValue(String qrCode, int size, Charset charset) { |
| | | private static String normalizeStringValue(String qrCode, int size, int displayLength, Charset charset) { |
| | | String value = requireNonEmpty(qrCode); |
| | | byte[] raw = value.getBytes(charset); |
| | | if (raw.length != size) { |
| | | throw new IllegalArgumentException("qrCode byte length must be " + size + ": " + qrCode); |
| | | if (raw.length > size) { |
| | | log.error("qrCode exceeds configured byte size: " + qrCode); |
| | | // throw new IllegalArgumentException("qrCode byte length exceeds protocol size " + size + ": " + qrCode); |
| | | } |
| | | if (displayLength > 0 && raw.length != displayLength) { |
| | | // throw new IllegalArgumentException("qrCode byte length must be " + displayLength + ": " + qrCode); |
| | | } |
| | | return value; |
| | | } |
| | |
| | | static CodecConfig of(String mode, Integer bytes, Integer displayLength, String charsetName) { |
| | | Mode resolvedMode = Mode.of(mode); |
| | | int resolvedBytes = bytes == null || bytes <= 0 ? 4 : bytes; |
| | | int resolvedDisplayLength = displayLength == null || displayLength <= 0 ? 8 : displayLength; |
| | | int resolvedDisplayLength; |
| | | if (displayLength == null || displayLength <= 0) { |
| | | resolvedDisplayLength = resolvedMode == Mode.STRING ? resolvedBytes : 8; |
| | | } else { |
| | | resolvedDisplayLength = displayLength; |
| | | } |
| | | if (resolvedMode == Mode.STRING && resolvedDisplayLength > resolvedBytes) { |
| | | throw new IllegalArgumentException("qrCode display length exceeds protocol size"); |
| | | } |
| | | Charset resolvedCharset = charsetName == null || charsetName.trim().isEmpty() |
| | | ? StandardCharsets.US_ASCII |
| | | : Charset.forName(charsetName.trim()); |
| | |
| | | @ConfigurationProperties(prefix = "agv-codec") |
| | | public class AgvCodecProperties { |
| | | |
| | | private String qrCodeMode = "numeric"; |
| | | private String qrCodeMode; |
| | | |
| | | private Integer qrCodeBytes = 4; |
| | | private Integer qrCodeBytes; |
| | | |
| | | private Integer qrCodeDisplayLength = 8; |
| | | private Integer qrCodeDisplayLength; |
| | | |
| | | private String qrCodeCharset = "ASCII"; |
| | | private String qrCodeCharset; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | |
| | | if (null == destSta) { |
| | | return R.error("目标站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) { |
| | | Long locToStaDestCodeId = staService.resolveWorkCodeId(destSta, agv.getId()); |
| | | if (!agvAreaDispatcher.match(agv.getId(), locToStaDestCodeId)) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标站点【" + destSta.getStaNo() + "】"); |
| | | } |
| | |
| | | task.setOriLoc(oriLoc.getId()); |
| | | task.setOriCode(oriLoc.getCode()); |
| | | task.setDestSta(destSta.getId()); |
| | | task.setDestCode(destSta.getCode()); |
| | | task.setDestCode(locToStaDestCodeId); |
| | | |
| | | staReserveService.allocateCallBack(task, agv.getId()); |
| | | break; |
| | |
| | | if (null == oriSta) { |
| | | return R.error("起始站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) { |
| | | Long staToLocOriCodeId = staService.resolveWorkCodeId(oriSta, agv.getId()); |
| | | if (!agvAreaDispatcher.match(agv.getId(), staToLocOriCodeId)) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始站点【" + oriSta.getStaNo() + "】"); |
| | | } |
| | |
| | | |
| | | // task |
| | | task.setOriSta(oriSta.getId()); |
| | | task.setOriCode(oriSta.getCode()); |
| | | task.setOriCode(staToLocOriCodeId); |
| | | task.setDestLoc(destLoc.getId()); |
| | | task.setDestCode(destLoc.getCode()); |
| | | |
| | |
| | | if (null == oriSta) { |
| | | return R.error("起始站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), oriSta.getCode())) { |
| | | Long staToStaOriCodeId = staService.resolveWorkCodeId(oriSta, agv.getId()); |
| | | if (!agvAreaDispatcher.match(agv.getId(), staToStaOriCodeId)) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + oriSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达起始站点【" + oriSta.getStaNo() + "】"); |
| | | } |
| | |
| | | if (null == destSta) { |
| | | return R.error("目标站点不存在"); |
| | | } |
| | | if (!agvAreaDispatcher.match(agv.getId(), destSta.getCode())) { |
| | | Long staToStaDestCodeId = staService.resolveWorkCodeId(destSta, agv.getId()); |
| | | if (!agvAreaDispatcher.match(agv.getId(), staToStaDestCodeId)) { |
| | | // throw new BusinessException("AGV " + agv.getUuid() + " failed to reach target code " + destSta.getCode$()); |
| | | throw new BusinessException("AGV【" + agv.getUuid() + "】无法到达目标站点【" + destSta.getStaNo() + "】"); |
| | | } |
| | |
| | | |
| | | // task |
| | | task.setOriSta(oriSta.getId()); |
| | | task.setOriCode(oriSta.getCode()); |
| | | task.setOriCode(staToStaOriCodeId); |
| | | task.setDestSta(destSta.getId()); |
| | | task.setDestCode(destSta.getCode()); |
| | | task.setDestCode(staToStaDestCodeId); |
| | | |
| | | staReserveService.allocateCallBack(task, agv.getId()); |
| | | break; |
| | |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | } |
| | | if (null != task.getOriSta()) { |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | Code code = codeService.getCacheById(oriSta.getCode()); |
| | | return this.getAgvIdsByCode(code.getData()); |
| | | return this.getAgvIdsBySta(oriSta); |
| | | } |
| | | if (null != task.getDestLoc()) { |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | |
| | | } |
| | | if (null != task.getDestSta()) { |
| | | destSta = staService.getById(task.getDestSta()); |
| | | Code code = codeService.getCacheById(destSta.getCode()); |
| | | return this.getAgvIdsByCode(code.getData()); |
| | | return this.getAgvIdsBySta(destSta); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private List<Long> getAgvIdsBySta(Sta sta) { |
| | | if (sta == null) { |
| | | return new ArrayList<>(); |
| | | } |
| | | Set<Long> agvIds = new LinkedHashSet<>(); |
| | | this.collectAgvIdsByCodeId(agvIds, sta.getCode()); |
| | | this.collectAgvIdsByCodeId(agvIds, sta.getLatentCode()); |
| | | return new ArrayList<>(agvIds); |
| | | } |
| | | |
| | | private void collectAgvIdsByCodeId(Set<Long> agvIds, Long codeId) { |
| | | if (codeId == null) { |
| | | return; |
| | | } |
| | | Code code = codeService.getCacheById(codeId); |
| | | if (code == null) { |
| | | return; |
| | | } |
| | | agvIds.addAll(this.getAgvIdsByCode(code.getData())); |
| | | } |
| | | |
| | | public List<Long> getAgvIdsByCode(String codeData) { |
| | | if (Cools.isEmpty(codeData)) { |
| | | return new ArrayList<>(); |
| | |
| | | if (Cools.isEmpty(agvNo)) { |
| | | return null; |
| | | } |
| | | |
| | | // record lane hash for later dispatch/traffic-control logic |
| | | if (filterLaneDto.getOriginLaneDto() != null) { |
| | | task.setOriLaneHash(filterLaneDto.getOriginLaneDto().getHashCode()); |
| | | } |
| | | if (filterLaneDto.getDestinationLaneDto() != null) { |
| | | task.setDestLaneHash(filterLaneDto.getDestinationLaneDto().getHashCode()); |
| | | } |
| | | this.refreshLaneHash(task, agvNo); |
| | | |
| | | return agvNo; |
| | | } |
| | |
| | | if (null == filterLaneDto) { |
| | | return null; |
| | | } |
| | | LaneDto originLaneDto = filterLaneDto.getOriginLaneDto(); |
| | | LaneDto destinationLaneDto = filterLaneDto.getDestinationLaneDto(); |
| | | List<String> actualAvailableAgvNos = filterLaneDto.getActualAvailableAgvNos(); |
| | | if (Cools.isEmpty(actualAvailableAgvNos)) { |
| | | return null; |
| | |
| | | calcAllocateWeight(o2, task), |
| | | calcAllocateWeight(o1, task) |
| | | )); |
| | | |
| | | if (null != originLaneDto) { |
| | | task.setOriLaneHash(originLaneDto.getHashCode()); |
| | | } |
| | | if (null != destinationLaneDto) { |
| | | task.setDestLaneHash(destinationLaneDto.getHashCode()); |
| | | } |
| | | |
| | | return actualAvailableAgvNos.get(0); |
| | | String agvNo = actualAvailableAgvNos.get(0); |
| | | this.refreshLaneHash(task, agvNo); |
| | | return agvNo; |
| | | } |
| | | |
| | | private String checkoutAgvForInboundRoller(Task task, Sta sta, List<String> availableAgvNos) { |
| | |
| | | } |
| | | |
| | | // only checkout the agv which at sta code position |
| | | if (!sta.getCode().equals(currentCode.getId())) { |
| | | Long staCodeId = staService.resolveWorkCodeId(sta, agvId); |
| | | if (!Objects.equals(staCodeId, currentCode.getId())) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | Integer maxAgvCountInLane = configService.getVal("maxAgvCountInLane", Integer.class); |
| | | |
| | | // checkout lane |
| | | LaneDto originLaneDto = taskService.checkoutOriginLane(task); |
| | | LaneDto destinationLaneDto = taskService.checkoutDestinationLane(task); |
| | | |
| | | // allocate about origin |
| | | List<String> availableAgvNosByOriLane = new ArrayList<>(availableAgvNos); |
| | | if (null != originLaneDto) { |
| | | List<String> agvNosByOriLane = findAgvNosByLane(originLaneDto); // the agv list that had tasks in this lane |
| | | // if full lane |
| | | if (agvNosByOriLane.size() >= maxAgvCountInLane) { |
| | | |
| | | availableAgvNosByOriLane = Cools.getIntersection(agvNosByOriLane, availableAgvNos); |
| | | } |
| | | } |
| | | // valid backpack limit |
| | | availableAgvNosByOriLane = this.validBackpackLimit(availableAgvNosByOriLane); |
| | | |
| | | |
| | | // allocate about destination |
| | | List<String> availableAgvNosByDestLane = new ArrayList<>(availableAgvNos); |
| | | if (null != destinationLaneDto) { |
| | | List<String> agvNosByDestLane = findAgvNosByLane(destinationLaneDto); |
| | | if (agvNosByDestLane.size() >= maxAgvCountInLane) { |
| | | |
| | | availableAgvNosByDestLane = Cools.getIntersection(agvNosByDestLane, availableAgvNos); |
| | | } |
| | | } |
| | | availableAgvNosByDestLane = this.validBackpackLimit(availableAgvNosByDestLane); |
| | | |
| | | // valid |
| | | if (Cools.isEmpty(availableAgvNosByOriLane)) { |
| | | News.warn("No available agv to assign the task origin[{}]", task.getSeqNum()); |
| | | return null; |
| | | } |
| | | if (Cools.isEmpty(availableAgvNosByDestLane)) { |
| | | News.warn("No available agv to assign the task destination[{}]", task.getSeqNum()); |
| | | return null; |
| | | } |
| | | List<String> actualAvailableAgvNos = Cools.getIntersection(availableAgvNosByOriLane, availableAgvNosByDestLane); |
| | | List<String> actualAvailableAgvNos = this.validBackpackLimit(availableAgvNos).stream() |
| | | .filter(agvNo -> this.hitLaneLimit(task, agvNo, maxAgvCountInLane)) |
| | | .collect(Collectors.toList()); |
| | | if (Cools.isEmpty(actualAvailableAgvNos)) { |
| | | News.warn("No available agv to assign the task[{}]", task.getSeqNum()); |
| | | return null; |
| | | } |
| | | |
| | | return new FilterLaneDto(originLaneDto, destinationLaneDto, actualAvailableAgvNos); |
| | | return new FilterLaneDto(null, null, actualAvailableAgvNos); |
| | | } |
| | | |
| | | public List<String> findAgvNosByLane(LaneDto laneDto) { |
| | |
| | | case STA_TO_LOC: |
| | | case STA_TO_STA: |
| | | Sta oriSta = staService.getById(task.getOriSta()); |
| | | firstCode = codeService.getCacheById(oriSta.getCode()); |
| | | firstCode = codeService.getCacheById(staService.resolveWorkCodeId(oriSta, agvId)); |
| | | break; |
| | | case TO_CHARGE: |
| | | case TO_STANDBY: |
| | |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | private void refreshLaneHash(Task task, String agvNo) { |
| | | Long agvId = agvService.getAgvId(agvNo); |
| | | LaneDto originLaneDto = taskService.checkoutOriginLane(task, agvId); |
| | | LaneDto destinationLaneDto = taskService.checkoutDestinationLane(task, agvId); |
| | | task.setOriLaneHash(originLaneDto == null ? null : originLaneDto.getHashCode()); |
| | | task.setDestLaneHash(destinationLaneDto == null ? null : destinationLaneDto.getHashCode()); |
| | | } |
| | | |
| | | private boolean hitLaneLimit(Task task, String agvNo, Integer maxAgvCountInLane) { |
| | | Long agvId = agvService.getAgvId(agvNo); |
| | | return hitLaneLimit(taskService.checkoutOriginLane(task, agvId), agvNo, maxAgvCountInLane) |
| | | && hitLaneLimit(taskService.checkoutDestinationLane(task, agvId), agvNo, maxAgvCountInLane); |
| | | } |
| | | |
| | | private boolean hitLaneLimit(LaneDto laneDto, String agvNo, Integer maxAgvCountInLane) { |
| | | if (laneDto == null) { |
| | | return true; |
| | | } |
| | | List<String> agvNosByLane = findAgvNosByLane(laneDto); |
| | | return agvNosByLane.size() < maxAgvCountInLane || agvNosByLane.contains(agvNo); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | loadSeg.setAgvId(agvId); |
| | | loadSeg.setTaskId(task.getId()); |
| | | loadSeg.setSerial(currSeg.getSerial() - 1); |
| | | loadSeg.setEndNode(sta.getCode()); |
| | | loadSeg.setEndNode(staService.resolveWorkCodeId(sta, agvId)); |
| | | loadSeg.setPosType(TaskPosDto.PosType.ORI_STA.toString()); |
| | | loadSeg.setState(SegmentStateType.WAITING.toString()); |
| | | loadSeg.setBackpack(backpackLev); |
| | |
| | | case STA_TO_STA: |
| | | posType = TaskPosDto.PosType.DEST_STA; |
| | | Sta destSta = staService.getById(task.getDestSta()); |
| | | endCode = codeService.getCacheById(destSta.getCode()); |
| | | endCode = codeService.getCacheById(staService.resolveWorkCodeId(destSta, agvId)); |
| | | break; |
| | | default: |
| | | throw new BusinessException("[Agv:" + agvNo + "] allocate inbound only supports STA_TO_LOC/STA_TO_STA"); |
| | |
| | | |
| | | // update task |
| | | task.setAgvId(agvId); |
| | | taskService.refreshWorkCodes(task, agvId); |
| | | task.setTaskSts(TaskStsType.ASSIGN.val()); |
| | | task.setIoTime(now); |
| | | task.setUpdateTime(now); |
| | |
| | | Long agvId = agvService.getAgvId(agvNo); |
| | | // update task |
| | | task.setAgvId(agvId); |
| | | taskService.refreshWorkCodes(task, agvId); |
| | | task.setTaskSts(TaskStsType.WAITING.val()); |
| | | task.setIoTime(now); |
| | | task.setUpdateTime(now); |
| | |
| | | destSta = staService.getById(task.getDestSta()); |
| | | |
| | | startCode = codeService.getCacheById(oriLoc.getCode()); |
| | | endCode = codeService.getCacheById(destSta.getCode()); |
| | | endCode = codeService.getCacheById(staService.resolveWorkCodeId(destSta, agvId)); |
| | | |
| | | TaskPosDto.packagePosGroup(groups, task, startCode, TaskPosDto.PosType.ORI_LOC, sameGroupXy); |
| | | TaskPosDto.packagePosGroup(groups, task, endCode, TaskPosDto.PosType.DEST_STA, sameGroupXy); |
| | |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | |
| | | startCode = codeService.getCacheById(oriSta.getCode()); |
| | | startCode = codeService.getCacheById(staService.resolveWorkCodeId(oriSta, agvId)); |
| | | endCode = codeService.getCacheById(destLoc.getCode()); |
| | | |
| | | TaskPosDto.packagePosGroup(groups, task, startCode, TaskPosDto.PosType.ORI_STA, sameGroupXy); |
| | |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | destSta = staService.getById(task.getDestSta()); |
| | | |
| | | startCode = codeService.getCacheById(oriSta.getCode()); |
| | | endCode = codeService.getCacheById(destSta.getCode()); |
| | | startCode = codeService.getCacheById(staService.resolveWorkCodeId(oriSta, agvId)); |
| | | endCode = codeService.getCacheById(staService.resolveWorkCodeId(destSta, agvId)); |
| | | |
| | | TaskPosDto.packagePosGroup(groups, task, startCode, TaskPosDto.PosType.ORI_STA, sameGroupXy); |
| | | TaskPosDto.packagePosGroup(groups, task, endCode, TaskPosDto.PosType.DEST_STA, sameGroupXy); |
| | |
| | | |
| | | // task |
| | | for (Task task : taskList) { |
| | | taskService.refreshWorkCodes(task, agvId); |
| | | task.setTaskSts(TaskStsType.ASSIGN.val()); |
| | | task.setStartTime(now); |
| | | task.setUpdateTime(now); |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 充电 回待机位任务 |
| | |
| | | public synchronized void initRouteMap(Integer lev) { |
| | | News.info("There is initializing Route Map......"); |
| | | lev = Optional.ofNullable(lev).orElse(MAP_DEFAULT_LEV); |
| | | Set<String> routeKeys = redis.getMapKeys(RedisConstant.AGV_MAP_ROUTE_HASH_FLAG); |
| | | Set<String> routeCdaKeys = redis.getMapKeys(RedisConstant.AGV_MAP_ROUTE_CDA_HASH_FLAG); |
| | | Set<String> routeKeys = Optional.ofNullable(redis.getMapKeys(RedisConstant.AGV_MAP_ROUTE_HASH_FLAG)).orElse(Collections.emptySet()); |
| | | Set<String> routeCdaKeys = Optional.ofNullable(redis.getMapKeys(RedisConstant.AGV_MAP_ROUTE_CDA_HASH_FLAG)).orElse(Collections.emptySet()); |
| | | |
| | | List<Route> routeList = routeService.list(new LambdaQueryWrapper<Route>().eq(Route::getStatus, StatusType.ENABLE.val)); |
| | | if (routeKeys.size() == routeList.size() && routeKeys.size() == routeCdaKeys.size()) { |
| | |
| | | |
| | | AgvModel getByAgvNo(String agvNo); |
| | | |
| | | Boolean isUnderdriveAgv(Long agvId); |
| | | |
| | | Boolean isUnderdriveAgv(String agvNo); |
| | | |
| | | void refreshCacheByModelId(Long modelId); |
| | | |
| | | void evictCacheByAgv(Long agvId, String agvNo); |
| | |
| | | |
| | | StaTypeType resolveStaType(Sta sta); |
| | | |
| | | Long resolveWorkCodeId(Sta sta, Long agvId); |
| | | |
| | | boolean allowAgvWorkAtSta(String agvNo, Sta sta, Task task, Segment seg, StaReserveType type); |
| | | |
| | | Boolean hasWorkingAgv(Long staId); |
| | |
| | | |
| | | LaneDto checkoutOriginLane(Task task); |
| | | |
| | | LaneDto checkoutOriginLane(Task task, Long agvId); |
| | | |
| | | LaneDto checkoutDestinationLane(Task task); |
| | | |
| | | LaneDto checkoutDestinationLane(Task task, Long agvId); |
| | | |
| | | List<Task> findRunningTasksByLaneHash(String laneHash); |
| | | |
| | |
| | | |
| | | Task findLatestTask(Long agvId, TaskStsType taskSts); |
| | | |
| | | void refreshWorkCodes(Task task, Long agvId); |
| | | |
| | | void maintainLocAndSta(Task task); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.manager.manager.entity.Agv; |
| | | import com.zy.acs.manager.manager.entity.AgvModel; |
| | | import com.zy.acs.manager.manager.enums.AgvModelType; |
| | | import com.zy.acs.manager.manager.mapper.AgvModelMapper; |
| | | import com.zy.acs.manager.manager.service.AgvModelService; |
| | | import com.zy.acs.manager.manager.service.AgvService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Boolean isUnderdriveAgv(Long agvId) { |
| | | AgvModel agvModel = this.getByAgvId(agvId); |
| | | return agvModel != null && AgvModelType.UNDERDRIVE_AGV.toString().equals(agvModel.getType()); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean isUnderdriveAgv(String agvNo) { |
| | | AgvModel agvModel = this.getByAgvNo(agvNo); |
| | | return agvModel != null && AgvModelType.UNDERDRIVE_AGV.toString().equals(agvModel.getType()); |
| | | } |
| | | |
| | | @Override |
| | | public void refreshCacheByModelId(Long modelId) { |
| | | if (modelId == null) { |
| | | return; |
| | |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private ConveyorStationService conveyorStationService; |
| | | @Autowired |
| | | private AgvModelService agvModelService; |
| | | |
| | | @Override |
| | | public Sta selectByStaNo(String staNo) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Long resolveWorkCodeId(Sta sta, Long agvId) { |
| | | if (sta == null) { |
| | | return null; |
| | | } |
| | | if (agvId != null |
| | | && Boolean.TRUE.equals(agvModelService.isUnderdriveAgv(agvId)) |
| | | && sta.getLatentCode() != null) { |
| | | return sta.getLatentCode(); |
| | | } |
| | | return sta.getCode(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean allowAgvWorkAtSta(String agvNo, Sta sta, Task task, Segment seg, StaReserveType type) { |
| | | if (sta == null) { |
| | | return false; |
| | |
| | | @Override |
| | | public Boolean hasWorkingAgv(Long staId) { |
| | | Sta sta = this.getById(staId); |
| | | Long codeId = sta.getCode(); |
| | | if (null == codeId) { |
| | | if (sta == null) { |
| | | return false; |
| | | } |
| | | |
| | |
| | | return false; |
| | | } |
| | | for (Long agvId : agvIds) { |
| | | Long codeId = resolveWorkCodeId(sta, agvId); |
| | | if (codeId == null) { |
| | | continue; |
| | | } |
| | | Code currentCode = agvDetailService.getCurrentCode(agvId); |
| | | if (null == currentCode) { continue; } |
| | | |
| | |
| | | |
| | | @Override |
| | | public LaneDto checkoutOriginLane(Task task) { |
| | | return checkoutOriginLane(task, null); |
| | | } |
| | | |
| | | @Override |
| | | public LaneDto checkoutOriginLane(Task task, Long agvId) { |
| | | Long codeId = null; |
| | | TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | switch (Objects.requireNonNull(typeType)) { |
| | |
| | | break; |
| | | case STA_TO_LOC: |
| | | case STA_TO_STA: |
| | | codeId = staService.getById(task.getOriSta()).getCode(); |
| | | codeId = staService.resolveWorkCodeId(staService.getById(task.getOriSta()), agvId); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | |
| | | @Override |
| | | public LaneDto checkoutDestinationLane(Task task) { |
| | | return checkoutDestinationLane(task, null); |
| | | } |
| | | |
| | | @Override |
| | | public LaneDto checkoutDestinationLane(Task task, Long agvId) { |
| | | Long codeId = null; |
| | | TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | switch (Objects.requireNonNull(typeType)) { |
| | |
| | | break; |
| | | case LOC_TO_STA: |
| | | case STA_TO_STA: |
| | | codeId = staService.getById(task.getDestSta()).getCode(); |
| | | codeId = staService.resolveWorkCodeId(staService.getById(task.getDestSta()), agvId); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | wrapper.eq(Task::getTaskSts, taskSts.val()); |
| | | } |
| | | return this.list(wrapper).stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public void refreshWorkCodes(Task task, Long agvId) { |
| | | if (task == null) { |
| | | return; |
| | | } |
| | | task.setOriCode(resolveOriginCodeId(task, agvId)); |
| | | task.setDestCode(resolveDestinationCodeId(task, agvId)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | |
| | | private Long resolveOriginCodeId(Task task, Long agvId) { |
| | | TaskTypeType taskType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | if (taskType == null) { |
| | | return task.getOriCode(); |
| | | } |
| | | switch (taskType) { |
| | | case LOC_TO_LOC: |
| | | case LOC_TO_STA: |
| | | return task.getOriLoc() == null ? null : locService.getById(task.getOriLoc()).getCode(); |
| | | case STA_TO_LOC: |
| | | case STA_TO_STA: |
| | | return task.getOriSta() == null ? null : staService.resolveWorkCodeId(staService.getById(task.getOriSta()), agvId); |
| | | default: |
| | | return task.getOriCode(); |
| | | } |
| | | } |
| | | |
| | | private Long resolveDestinationCodeId(Task task, Long agvId) { |
| | | TaskTypeType taskType = TaskTypeType.get(task.getTaskTypeEl()); |
| | | if (taskType == null) { |
| | | return task.getDestCode(); |
| | | } |
| | | switch (taskType) { |
| | | case LOC_TO_LOC: |
| | | case STA_TO_LOC: |
| | | return task.getDestLoc() == null ? null : locService.getById(task.getDestLoc()).getCode(); |
| | | case LOC_TO_STA: |
| | | case STA_TO_STA: |
| | | return task.getDestSta() == null ? null : staService.resolveWorkCodeId(staService.getById(task.getDestSta()), agvId); |
| | | default: |
| | | return task.getDestCode(); |
| | | } |
| | | } |
| | | |
| | | } |