| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.core.service.MapService; |
| | | import com.zy.acs.manager.manager.controller.result.MissionVo; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.ActionStsType; |
| | | import com.zy.acs.manager.manager.enums.BusStsType; |
| | | import com.zy.acs.manager.manager.enums.SegmentStateType; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.enums.*; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import org.apache.ibatis.session.SqlSession; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | if (Cools.isEmpty(actionList)) { |
| | | return Boolean.FALSE; |
| | | } |
| | | List<Long> actionIds = actionList.stream().map(Action::getId).collect(Collectors.toList()); |
| | | Date now = new Date(); |
| | | |
| | | String actionGroupId = actionService.getById(actionIds.get(0)).getGroupId(); |
| | | List<Long> actionIds = actionList.stream().map(Action::getId).collect(Collectors.toList()); |
| | | Action firstAction = actionService.getById(actionIds.get(0)); |
| | | if (firstAction == null) { |
| | | return Boolean.FALSE; |
| | | } |
| | | |
| | | String actionGroupId = firstAction.getGroupId(); |
| | | actionService.updateStsByGroupId(actionGroupId, ActionStsType.EXPIRED.val()); |
| | | |
| | | // if firstAction is not turn, insert a new turn action |
| | | Action prependTurn = null; |
| | | if (!firstAction.getActionType().equals(ActionTypeType.TurnCorner.val())) { |
| | | String codeData = firstAction.getCode(); |
| | | Code code = codeService.getCacheByData(codeData); |
| | | AgvDetail agvDetail = agvDetailService.selectMajorByAgvId(firstAction.getAgvId()); |
| | | Double lastDirection = MapService.mapToNearest(agvDetail.getAgvAngle()); |
| | | |
| | | List<Action> fullActionList = actionService.list( |
| | | new LambdaQueryWrapper<Action>() |
| | | .eq(Action::getGroupId, actionGroupId) |
| | | .select(Action::getId, Action::getActionType, Action::getPriority) |
| | | .orderByDesc(Action::getPriority) |
| | | ); |
| | | |
| | | int idx = -1; |
| | | for (int k = 0; k < fullActionList.size(); k++) { |
| | | if (fullActionList.get(k).getId().equals(firstAction.getId())) { |
| | | idx = k; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (idx > 0) { |
| | | Long turnActionId = null; |
| | | // find out turn action |
| | | for (int k = idx - 1; k >= 0; k--) { |
| | | Action a = fullActionList.get(k); |
| | | if (a.getActionType().equals(ActionTypeType.TurnCorner.val())) { |
| | | turnActionId = a.getId(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (null != turnActionId) { |
| | | Action turn = actionService.getById(turnActionId); |
| | | Double direction = Double.parseDouble(turn.getParams()); |
| | | // new turn action |
| | | prependTurn = new Action( |
| | | null, // 编号 |
| | | firstAction.getBusId(), // 总线 |
| | | firstAction.getTaskId(), // 任务 |
| | | null, // 动作号 |
| | | null, // 优先级 |
| | | ActionTypeType.TurnCorner.desc, // 名称 |
| | | (double) MapService.calcSpinDirection(code, lastDirection, direction).val, // 属性值 |
| | | code.getData(), // 地面码 |
| | | String.valueOf(direction), // 动作参数 |
| | | ActionTypeType.TurnCorner.val(), // 动作类型 |
| | | ActionStsType.PREPARE.val(), // 动作进度 |
| | | firstAction.getAgvId(), // AGV |
| | | now // 工作时间 |
| | | ); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | List<Action> newActionList = new ArrayList<>(); |
| | | Date now = new Date(); |
| | | if (prependTurn != null) { |
| | | prependTurn.setGroupId(actionGroupId); |
| | | prependTurn.setCreateTime(now); |
| | | prependTurn.setUpdateTime(now); |
| | | newActionList.add(prependTurn); |
| | | } |
| | | for (Long actionId : actionIds) { |
| | | sqlSession.clearCache(); |
| | | Action action = actionService.getById(actionId); |