| | |
| | | package com.zy.acs.manager.core.scheduler; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | 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.service.MainService; |
| | | import com.zy.acs.manager.core.service.TrafficService; |
| | | import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; |
| | | import com.zy.acs.manager.manager.entity.Agv; |
| | | import com.zy.acs.manager.manager.entity.AgvModel; |
| | | import com.zy.acs.manager.manager.entity.Bus; |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | |
| | | @Slf4j |
| | | @Component |
| | | public class AutoRunScheduler { |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | @Autowired |
| | | private AgvService agvService; |
| | |
| | | |
| | | String memo = "DEMO_" + startRow + "-" + endRow; |
| | | |
| | | int agvCount = agvGroupList.size(); |
| | | int availableAgvCount = this.getAvailableAgvCount(agvGroupList); |
| | | |
| | | // 最多 ? 组bus运行 |
| | | if (agvCount <= busService.count(new LambdaQueryWrapper<Bus>() |
| | | if (availableAgvCount <= busService.count(new LambdaQueryWrapper<Bus>() |
| | | .in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val()) |
| | | .eq(Bus::getMemo, memo) |
| | | )) { |
| | |
| | | } |
| | | |
| | | |
| | | private int getAvailableAgvCount(List<String> agvNos) { |
| | | int res = 0; |
| | | if (Cools.isEmpty(agvNos)) { |
| | | return res; |
| | | } |
| | | for (String agvNo : agvNos) { |
| | | if (null == redis.getObject(RedisConstant.AGV_ONLINE_FLAG, agvNo)) { |
| | | continue; |
| | | } |
| | | Agv agv = agvService.selectByUuid(agvNo); |
| | | if (!agv.getStatusBool()) { |
| | | continue; |
| | | } |
| | | res++; |
| | | } |
| | | |
| | | return res; |
| | | } |
| | | |
| | | } |