| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.manager.controller.result.MissionVo; |
| | | import com.zy.acs.manager.manager.entity.Action; |
| | | import com.zy.acs.manager.manager.entity.AgvDetail; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.enums.SegmentStateType; |
| | | import com.zy.acs.manager.manager.service.MissionService; |
| | | import com.zy.acs.manager.manager.service.SegmentService; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private SegmentService segmentService; |
| | | @Autowired |
| | | private ActionService actionService; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | | private AgvDetailService agvDetailService; |
| | | |
| | | @Override |
| | | public List<MissionVo> getList(Long agvId, String groupNo) { |
| | |
| | | vo.setTaskNos(list.stream().map(Segment::getTaskId$).collect(Collectors.toList())); |
| | | vo.setBackpack(segment.getBackpack()); |
| | | vo.setDestCode(segment.getEndNode$()); |
| | | vo.setProgress(calcProgress(groupNo)); |
| | | return vo; |
| | | } |
| | | |
| | | public Double calcProgress(String groupNo) { |
| | | double progress = 0D; |
| | | List<Action> actionList = actionService.list(new LambdaQueryWrapper<Action>() |
| | | .eq(Action::getGroupId, groupNo). |
| | | orderByDesc(Action::getPriority)); |
| | | |
| | | if (Cools.isEmpty(actionList)) { |
| | | 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).collect(Collectors.toList()); |
| | | |
| | | int totalCodes = codeList.size(); |
| | | int currentIndex = codeList.indexOf(code.getData()); |
| | | |
| | | if (currentIndex >= 0) { |
| | | progress = (currentIndex + 1) * 100.0 / totalCodes; |
| | | } |
| | | |
| | | return progress; |
| | | } |
| | | |
| | | } |