| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.service.AreaAgvService; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.LocService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | private AreaGovernService areaGovernService; |
| | | @Autowired |
| | | private AreaAgvService areaAgvService; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | } |
| | | |
| | | public List<Long> getAgvNosByTask(Task task) { |
| | | public List<Long> getAgvIdsByTask(Task task) { |
| | | if (null == task) { |
| | | return null; |
| | | } |
| | |
| | | Sta destSta = null; |
| | | if (null != task.getOriLoc()) { |
| | | oriLoc = locService.getById(task.getOriLoc()); |
| | | return this.getAgvIdsByCode(oriLoc.getCode$()); |
| | | Code code = codeService.getCacheById(oriLoc.getCode()); |
| | | return this.getAgvIdsByCode(code.getData()); |
| | | } |
| | | if (null != task.getOriSta()) { |
| | | oriSta = staService.getById(task.getOriSta()); |
| | | return this.getAgvIdsByCode(oriSta.getCode$()); |
| | | Code code = codeService.getCacheById(oriSta.getCode()); |
| | | return this.getAgvIdsByCode(code.getData()); |
| | | } |
| | | if (null != task.getDestLoc()) { |
| | | destLoc = locService.getById(task.getDestLoc()); |
| | | return this.getAgvIdsByCode(destLoc.getCode$()); |
| | | Code code = codeService.getCacheById(destLoc.getCode()); |
| | | return this.getAgvIdsByCode(code.getData()); |
| | | } |
| | | if (null != task.getDestSta()) { |
| | | destSta = staService.getById(task.getDestSta()); |
| | | return this.getAgvIdsByCode(destSta.getCode$()); |
| | | Code code = codeService.getCacheById(destSta.getCode()); |
| | | return this.getAgvIdsByCode(code.getData()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public List<Long> getAgvIdsByCode(String code) { |
| | | if (Cools.isEmpty(code)) { |
| | | return Collections.emptyList(); |
| | | public List<Long> getAgvIdsByCode(String codeData) { |
| | | if (Cools.isEmpty(codeData)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<Long> areaIds = areaGovernService.queryAreas(code); |
| | | return areaAgvService.queryAgvIdsByAreaIds(areaIds); |
| | | List<Long> areaIds = areaGovernService.queryAreas(codeData); |
| | | List<Long> agvIds = areaAgvService.queryAgvIdsByAreaIds(areaIds); |
| | | agvIds.addAll(areaAgvService.findAgvIdsWithoutAreaAgv()); |
| | | return agvIds; |
| | | } |
| | | |
| | | public List<String> getAgvNosByStaNo(String staNo) { |
| | | return null; |
| | | } |
| | | |
| | | public List<String> getAreaCodeListByAgvNo(String agvNo) { |
| | | List<String> areaCodeList = new ArrayList<>(); |
| | | return areaCodeList; |
| | | public Boolean match(Long agvId, Long codeId) { |
| | | Code code = codeService.getCacheById(codeId); |
| | | if (Cools.isEmpty(agvId, code)) { |
| | | return false; |
| | | } |
| | | List<Long> agvIds = this.getAgvIdsByCode(code.getData()); |
| | | if (Cools.isEmpty(agvIds)) { |
| | | return false; |
| | | } |
| | | if (!agvIds.contains(agvId)) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | // 如果都没有命中,就返回全部code |
| | | public List<String> getCodesByAgvId(Long agvId) { |
| | | List<Long> areaIds = areaAgvService.queryAreaIdsByAgvId(agvId); |
| | | return areaGovernService.queryCodes(areaIds); |
| | | } |
| | | |
| | | // 判断车辆是否被area绑定,如果绑定返回 true, 如果没绑定返回 false |
| | | public Boolean isAgvExistsInAnyArea(Long agvId) { |
| | | List<Long> agvIdsWithoutAreaAgv = areaAgvService.findAgvIdsWithoutAreaAgv(); // 没有被绑定的车辆集合 |
| | | if (Cools.isEmpty(agvIdsWithoutAreaAgv)) { |
| | | return true; |
| | | } |
| | | return !agvIdsWithoutAreaAgv.contains(agvId); |
| | | } |
| | | |
| | | } |