| | |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | | import com.zy.acs.manager.core.constant.AgvGroupConstant; |
| | | import com.zy.acs.manager.core.constant.LocGroupConstant; |
| | | import com.zy.acs.manager.core.domain.AgvTaskDto; |
| | | import com.zy.acs.manager.core.service.MainLockWrapService; |
| | | import com.zy.acs.manager.core.service.MainService; |
| | |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | import org.springframework.context.event.EventListener; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.PreDestroy; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | this.lock.unlock(); |
| | | } |
| | | |
| | | @PostConstruct |
| | | // @PostConstruct |
| | | @EventListener(ApplicationReadyEvent.class) |
| | | public void init() { |
| | | try { Thread.sleep(1200); } catch (InterruptedException ignore) {} |
| | | // traffic calculate |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // auto loc to loc ---------------------------------------------------------------------------------------------- |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | private void autoLocToLoc() { |
| | | if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; } |
| | | |
| | | // 最多两组bus运行 |
| | | // if (1 < busService.count(new LambdaQueryWrapper<Bus>().in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val()))) { |
| | | // return; |
| | | // } |
| | | this.runLocToLoc(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST, AgvGroupConstant.FIRST_AGV_GROUP); |
| | | this.runLocToLoc(LocGroupConstant.LEFT_LOC_ROW_LIST, AgvGroupConstant.SECOND_AGV_GROUP); |
| | | this.runLocToLoc(LocGroupConstant.MIDDLE_LOC_ROW_LIST, AgvGroupConstant.THIRD_AGV_GROUP); |
| | | this.runLocToLoc(LocGroupConstant.RIGHT_LOC_ROW_LIST, AgvGroupConstant.FOURTH_AGV_GROUP); |
| | | this.runLocToLoc(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST, AgvGroupConstant.FIFTH_AGV_GROUP); |
| | | } |
| | | |
| | | int agvCount = agvService.count(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString())); |
| | | if (null == agvModel || 0 == agvCount) { |
| | | private void runLocToLoc(List<Integer> locGroupList, List<String> agvGroupList) { |
| | | Integer startRow = Collections.min(locGroupList); |
| | | Integer endRow = Collections.max(locGroupList); |
| | | |
| | | String memo = "DEMO_" + startRow + "-" + endRow; |
| | | |
| | | int agvCount = agvGroupList.size(); |
| | | |
| | | // 最多 ? 组bus运行 |
| | | if (agvCount <= busService.count(new LambdaQueryWrapper<Bus>() |
| | | .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val()) |
| | | .eq(Bus::getMemo, memo) |
| | | )) { |
| | | return; |
| | | } |
| | | // int maxCapacity = agvModel.getBackpack() * agvCount; |
| | | |
| | | AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString())); |
| | | if (null == agvModel) { |
| | | return; |
| | | } |
| | | int maxCapacity = agvModel.getBackpack(); |
| | | |
| | | // STOCK |
| | | List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.STOCK.val())); |
| | | LambdaQueryWrapper<Loc> stockWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.STOCK.val()); |
| | | if (null != startRow) { stockWrapper.ge(Loc::getRow, startRow); } |
| | | if (null != endRow) { stockWrapper.le(Loc::getRow, endRow); } |
| | | List<Loc> stockList = locService.list(stockWrapper); |
| | | if (Cools.isEmpty(stockList) || stockList.size() < agvModel.getBackpack()) { |
| | | return; |
| | | } |
| | |
| | | int numOfStockLocList = stockList.size(); |
| | | |
| | | // IDLE |
| | | List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.IDLE.val())); |
| | | LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.IDLE.val()); |
| | | if (null != startRow) { idleWrapper.ge(Loc::getRow, startRow); } |
| | | if (null != endRow) { idleWrapper.le(Loc::getRow, endRow); } |
| | | List<Loc> idleList = locService.list(idleWrapper); |
| | | if (Cools.isEmpty(idleList)) { |
| | | return; |
| | | } |
| | |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | |
| | | } |
| | | |
| | | mainService.generateBusAndTask(param, "autoLocToLoc"); |
| | | mainService.generateBusAndTask(param, memo); |
| | | } |
| | | |
| | | } |