#
luxiaotao1123
2024-09-29 0114b079a32f03f69dfcd4d77ed89b54694126e2
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/MissionServiceImpl.java
@@ -49,16 +49,27 @@
        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);
@@ -68,7 +79,8 @@
        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;
    }
@@ -100,24 +112,16 @@
        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;