| | |
| | | if (Cools.isEmpty(groupNo)) { |
| | | return null; |
| | | } |
| | | // segment ------------------------------- |
| | | List<Segment> list = segmentService.list(new LambdaQueryWrapper<Segment>().eq(Segment::getGroupId, groupNo).orderByAsc(Segment::getSerial)); |
| | | if (Cools.isEmpty(list)) { |
| | | return null; |
| | | } |
| | | Segment segment = list.get(0); |
| | | |
| | | // agv ------------------------------- |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(segment.getAgvId()); |
| | | Long recentCode = agvDetail.getRecentCode(); |
| | | String currCode = null; |
| | | if (null != recentCode) { |
| | | currCode = codeService.getById(recentCode).getData(); |
| | | } |
| | | |
| | | // action ------------------------------- |
| | | List<Action> actionList = actionService.list(new LambdaQueryWrapper<Action>() |
| | | .eq(Action::getGroupId, groupNo).orderByDesc(Action::getPriority)); |
| | | if (Cools.isEmpty(actionList)) { |
| | | return null; |
| | | } |
| | | Segment segment = list.get(0); |
| | | |
| | | MissionVo vo = new MissionVo(); |
| | | vo.setGroupNo(groupNo); |
| | |
| | | vo.setTaskNos(list.stream().map(Segment::getTaskId$).collect(Collectors.toList())); |
| | | vo.setBackpack(segment.getBackpack()); |
| | | vo.setDestCode(segment.getEndNode$()); |
| | | vo.setProgress(calcProgress(actionList)); |
| | | vo.setCurrCode(currCode); |
| | | vo.setProgress(calcProgress(currCode, actionList)); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | return vo; |
| | | } |
| | | |
| | | public Double calcProgress(List<Action> actionList) { |
| | | public Double calcProgress(String currCode, List<Action> actionList) { |
| | | double progress = 0D; |
| | | if (Cools.isEmpty(actionList)) { |
| | | if (Cools.isEmpty(actionList, currCode)) { |
| | | return progress; |
| | | } |
| | | |
| | | Action action = actionList.get(0); |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(action.getAgvId()); |
| | | Long recentCode = agvDetail.getRecentCode(); |
| | | if (null == recentCode) { |
| | | return progress; |
| | | } |
| | | Code code = codeService.getById(recentCode); |
| | | |
| | | List<String> codeList = actionList.stream().map(Action::getCode).distinct().collect(Collectors.toList()); |
| | | |
| | | int totalCodes = codeList.size(); |
| | | int currentIndex = codeList.indexOf(code.getData()); |
| | | int currentIndex = codeList.indexOf(currCode); |
| | | |
| | | if (currentIndex >= 0) { |
| | | progress = (currentIndex + 1) * 100.0 / totalCodes; |