| | |
| | | import com.zy.acs.common.enums.AgvStatusType; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.common.utils.CommonUtil; |
| | | import com.zy.acs.manager.core.constant.AgvAreaDispatcher; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.FuncStaType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | |
| | | private AgvModelService agvModelService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private AgvAreaDispatcher agvAreaDispatcher; |
| | | |
| | | @Override |
| | | public FuncSta getByCodeAndType(Long codeId, String type) { |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | |
| | | Collections.shuffle(funcStaList); |
| | | // area limit |
| | | List<String> areaCodeList = agvAreaDispatcher.getAreaCodeListByAgvNo(agvService.getAgvNo(agvId)); |
| | | if (Cools.isEmpty(areaCodeList)) { |
| | | funcStaList.clear(); |
| | | } else { |
| | | funcStaList.removeIf(funcSta -> { |
| | | Code code = codeService.getCacheById(funcSta.getCode()); |
| | | if (Cools.isEmpty(code, code.getData())) { return true; } |
| | | return !areaCodeList.contains(code.getData()); |
| | | }); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(funcStaList)) { |
| | | Collections.shuffle(funcStaList); |
| | | } |
| | | |
| | | // filter idle |
| | | funcStaList = funcStaList.stream().filter(funcSta -> { |
| | | |
| | |
| | | } |
| | | |
| | | if (null != codeId) { |
| | | Code currCode = codeService.getById(codeId); |
| | | Code currCode = codeService.getCacheById(codeId); |
| | | Double[] startPos = new Double[]{currCode.getX(), currCode.getY()}; |
| | | |
| | | // checkout one funSta which is the closest |
| | |
| | | funcStaList.sort(new Comparator<FuncSta>() { |
| | | @Override |
| | | public int compare(FuncSta o1, FuncSta o2) { |
| | | Code o1Code = codeService.getById(o1.getCode()); |
| | | Code o1Code = codeService.getCacheById(o1.getCode()); |
| | | int o1Distance = CommonUtil.calcDistance(startPos, new Double[]{o1Code.getX(), o1Code.getY()}); |
| | | |
| | | Code o2Code = codeService.getById(o2.getCode()); |
| | | Code o2Code = codeService.getCacheById(o2.getCode()); |
| | | int o2Distance = CommonUtil.calcDistance(startPos, new Double[]{o2Code.getX(), o2Code.getY()}); |
| | | |
| | | return o1Distance - o2Distance; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FuncSta checkoutFurthestFunSta(Long codeId, List<FuncSta> funcStaList) { |
| | | if (Cools.isEmpty(funcStaList)) { |
| | | return null; |
| | | } |
| | | |
| | | if (null != codeId) { |
| | | Code currCode = codeService.getCacheById(codeId); |
| | | Double[] startPos = new Double[]{currCode.getX(), currCode.getY()}; |
| | | |
| | | // checkout one funSta which is the closest |
| | | |
| | | // compare => compare返回负数,则排在集合前面 (asc) |
| | | funcStaList.sort(new Comparator<FuncSta>() { |
| | | @Override |
| | | public int compare(FuncSta o1, FuncSta o2) { |
| | | Code o1Code = codeService.getCacheById(o1.getCode()); |
| | | int o1Distance = CommonUtil.calcDistance(startPos, new Double[]{o1Code.getX(), o1Code.getY()}); |
| | | |
| | | Code o2Code = codeService.getCacheById(o2.getCode()); |
| | | int o2Distance = CommonUtil.calcDistance(startPos, new Double[]{o2Code.getX(), o2Code.getY()}); |
| | | |
| | | return o2Distance - o1Distance; |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | return funcStaList.stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean isCanBeIdle(FuncSta funcSta) { |
| | | Agv agv; |
| | | switch (Objects.requireNonNull(FuncStaType.query(funcSta.getType()))) { |