| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | //@Component |
| | | @Component |
| | | public class AutoRunScheduler { |
| | | |
| | | private static final AgvModelType DEFAULT_AGV_MODEL = AgvModelType.CTU_BOX_TRANSPORT_AGV; |
| | |
| | | |
| | | private void autoRun(AgvModel agvModel) { |
| | | |
| | | List<String> staPreNos = new ArrayList<>(); |
| | | String memo = "DEMO_STA_" + String.join("-", staPreNos); |
| | | String memo = "TEST" ; |
| | | String taskAssignModeArea = configService.getVal("TaskAssignModeArea", String.class); |
| | | if (Cools.isEmpty(taskAssignModeArea)) { |
| | | return; |
| | |
| | | } |
| | | List<Area> list = areaService.list(new LambdaQueryWrapper<Area>().eq(Area::getName, areaCode)); |
| | | Optional<Integer> max = list.stream().map(Area::getPriority).filter(Objects::nonNull).max(Integer::compareTo); |
| | | Integer priority = max.isPresent() ? max.get() : null; |
| | | if (!Cools.isEmpty(priority)) { |
| | | Integer priority = max.orElse(null); |
| | | if (Cools.isEmpty(priority) || priority == 0) { |
| | | // 入库 |
| | | this.runStaToLoc(agvModel, testAreaCodes, memo); |
| | | // 出库 |
| | | this.runLocToSta(agvModel, testAreaCodes, memo); |
| | | // 移库 |
| | | this.runLocToLoc(areaCode, agvModel, testAreaCodes, memo); |
| | | } else if (priority > 10) { |
| | | } else if (priority > 0 && priority < 10) { |
| | | // 出库 |
| | | this.runLocToSta(agvModel, testAreaCodes, memo); |
| | | // 移库 |
| | | this.runLocToLoc(areaCode, agvModel, testAreaCodes, memo); |
| | | } else if (priority > 100) { |
| | | } else { |
| | | // 移库 |
| | | this.runLocToLoc(areaCode, agvModel, testAreaCodes, memo); |
| | | } |
| | |
| | | TaskDto taskDto = new TaskDto(); |
| | | taskDto.setOriSta(stockSta.getStaNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setPriority(9999); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTasks().add(taskDto); |
| | |
| | | TaskDto taskDto = new TaskDto(); |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestSta(idleSta.getStaNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setPriority(9999); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTasks().add(taskDto); |
| | |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setTaskNo(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | taskDto.setPriority(9999); |
| | | param.getTasks().add(taskDto); |
| | | } |
| | | if (Cools.isEmpty(param.getTasks())) { |