package com.zy.acs.manager.manager.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zy.acs.manager.manager.entity.Action; import com.zy.acs.manager.manager.entity.Agv; import com.zy.acs.manager.manager.enums.ActionTypeType; import com.zy.acs.manager.manager.mapper.ActionMapper; import com.zy.acs.manager.manager.service.ActionService; import com.zy.acs.manager.manager.service.AgvService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; @Service("actionService") public class ActionServiceImpl extends ServiceImpl implements ActionService { @Autowired private AgvService agvService; @Override public Boolean updateStsByGroupId(String groupId, Long actionSts) { return baseMapper.updateStsByGroupId(groupId, actionSts) > 0; } @Override public List> selectRecentForInout() { return this.baseMapper.selectRecentForInout(); } @Override public List> selectCountGroupByType() { return this.baseMapper.selectCountGroupByType(); } @Override public List selectPrepareGroup() { return this.baseMapper.selectPrepareGroup(); } @Override public List selectTaskIdsByGroupId(String groupId) { return this.baseMapper.selectTaskIdsByGroupId(groupId); } @Override public List optimizeSort(List actionList) { long readyTakeFromAgvSite = ActionTypeType.ReadyTakeFromAgvSite.val(); long turnCorner = ActionTypeType.TurnCorner.val(); long readyReleaseToAgvSite = ActionTypeType.ReadyReleaseToAgvSite.val(); long readyReleaseToShelvesLoc = ActionTypeType.ReadyReleaseToShelvesLoc.val(); boolean hasFlag = false; int destTaskFromAgvSiteIdx = -1; for (int i = 0; i < actionList.size(); i++) { Action curr = actionList.get(i); if (curr.getActionType().equals(readyTakeFromAgvSite)) { hasFlag = true; destTaskFromAgvSiteIdx = i; break; } } List sortList = new ArrayList<>(actionList.size()); if (hasFlag) { int turnCornerIdx = -1; for (int i = 0; i < actionList.size(); i++) { Action curr = actionList.get(i); if (curr.getActionType().equals(turnCorner)) { turnCornerIdx = i; } } if (turnCornerIdx != -1) { Action tmp = actionList.get(destTaskFromAgvSiteIdx);//取货动作 for (int i = 0; i < actionList.size(); i++) { Action curr = actionList.get(i); if (i == destTaskFromAgvSiteIdx) { continue; } sortList.add(curr); if (i == turnCornerIdx) { tmp.setCode(curr.getCode());//更换条码 sortList.add(tmp); } } }else { Action tmp = actionList.get(destTaskFromAgvSiteIdx);//取货动作 for (int i = 0; i < actionList.size(); i++) { Action curr = actionList.get(i); if (i == destTaskFromAgvSiteIdx) { continue; } if (i == 0) { tmp.setCode(curr.getCode());//更换条码 sortList.add(tmp); } sortList.add(curr); } } }else { sortList = actionList; } return sortList; } @Override public List getPathListByAgv(String agvNo) { Agv agv = agvService.selectByUuid(agvNo); return this.baseMapper.selectSortCodeByAgv(agv.getId()); } }