| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.core.domain.TaskPosDto; |
| | | import com.zy.acs.manager.manager.entity.Segment; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.ActionStsType; |
| | |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.mapper.SegmentMapper; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | .eq(Segment::getSerial, serial - 1) |
| | | .eq(Segment::getState, SegmentStateType.FINISH.toString()) |
| | | .orderByDesc(Segment::getId) |
| | | .last("limit 1") |
| | | ); |
| | | } |
| | | |
| | |
| | | public Boolean cancel(Long segmentId, Long userId) { |
| | | Date now = new Date(); |
| | | Segment segment = this.getById(segmentId); |
| | | Long travelId = segment.getTravelId(); |
| | | String groupId = segment.getGroupId(); |
| | | // update segment list |
| | | List<Segment> segmentList = this.list(new LambdaQueryWrapper<Segment>().eq(Segment::getGroupId, groupId)); |
| | | List<Segment> segmentList = this.list(new LambdaQueryWrapper<Segment>().eq(Segment::getTravelId, travelId)); |
| | | for (Segment seg : segmentList) { |
| | | Task task = taskService.getById(segment.getTaskId()); |
| | | if (task != null && |
| | |
| | | } |
| | | this.processNext(segmentList); |
| | | // update action list |
| | | actionService.updateStsByGroupId(groupId, ActionStsType.EXPIRED.val()); |
| | | if (!Cools.isEmpty(groupId)) { |
| | | actionService.updateStsByGroupId(groupId, ActionStsType.EXPIRED.val()); |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | @Override |
| | | public Segment getCurrRunningSeg(Long agvId, String qrCode) { |
| | | Code codeId = codeService.getCacheByData(qrCode); |
| | | public Segment getCurrRunningSeg(Long agvId, Long codeId) { |
| | | List<Segment> segments = this.list(new LambdaQueryWrapper<Segment>() |
| | | .eq(Segment::getAgvId, agvId) |
| | | .eq(Segment::getState, SegmentStateType.RUNNING.toString()) |
| | | .eq(Segment::getEndNode, codeId) |
| | | .orderByDesc(Segment::getId) |
| | | ); |
| | | |
| | | if (Cools.isEmpty(segments)) { |
| | |
| | | return segments.stream().findFirst().orElse(null); |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> selectUsedBackpacks(Long travelId, Long agvId) { |
| | | return this.baseMapper.selectUsedBackpacks(agvId, travelId); |
| | | } |
| | | |
| | | @Override |
| | | public Segment getRollerWaiting(Long agvId, Long codeId, TaskPosDto.PosType posType) { |
| | | List<Segment> segments = this.list(new LambdaQueryWrapper<Segment>() |
| | | .eq(Segment::getAgvId, agvId) |
| | | .eq(Segment::getState, SegmentStateType.WAITING.toString()) |
| | | .eq(Segment::getEndNode, codeId) |
| | | .eq(Segment::getPosType, posType.toString()) |
| | | .eq(Segment::getRollerWaiting, 1) |
| | | .orderByDesc(Segment::getId) |
| | | ); |
| | | if (Cools.isEmpty(segments)) { |
| | | return null; |
| | | } |
| | | return segments.get(0); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean isRollerWaiting(Long agvId) { |
| | | return 0 < this.count(new LambdaQueryWrapper<Segment>() |
| | | .eq(Segment::getAgvId, agvId) |
| | | .eq(Segment::getState, SegmentStateType.WAITING.toString()) |
| | | .eq(Segment::getRollerWaiting, 1) |
| | | ); |
| | | } |
| | | |
| | | } |