| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.domain.AgvProtocol; |
| | | import com.zy.acs.common.domain.protocol.AGV_01_DOWN; |
| | | import com.zy.acs.common.domain.protocol.AGV_01_UP; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.core.service.MapService; |
| | | import com.zy.acs.manager.manager.entity.Action; |
| | | import com.zy.acs.manager.manager.entity.Agv; |
| | | import com.zy.acs.manager.manager.entity.AgvDetail; |
| | | import com.zy.acs.manager.manager.enums.ActionStsType; |
| | | import com.zy.acs.manager.manager.enums.StatusType; |
| | | import com.zy.acs.manager.manager.service.AgvDetailService; |
| | | import com.zy.acs.manager.manager.service.AgvService; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | |
| | | /** |
| | | * Created by vincent on 11/9/2024 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class FakeProcessor { |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | public static final Map<Long, Boolean> AGV_PROCESSING_MAP = new ConcurrentHashMap<>(); |
| | | |
| | | private ExecutorService executorService; |
| | | |
| | | @Autowired |
| | | private AgvService agvService; |
| | | @Autowired |
| | | private AgvDetailService agvDetailService; |
| | | @Autowired |
| | | private ActionService actionService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private CodeService codeService; |
| | | @Autowired |
| | | private MapService mapService; |
| | | @Autowired |
| | | private JamService jamService; |
| | | |
| | | /** |
| | | * 1.AgvDataService.dataProcess [ agvDetail: vol, code, agvAngle, agvStatus ] |
| | |
| | | } |
| | | |
| | | List<Agv> agvList = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | // init executorService |
| | | if (null == this.executorService) { |
| | | int count = agvList.size(); |
| | | this.executorService = Executors.newFixedThreadPool(count); |
| | | } |
| | | |
| | | this.responseTheRequest(); |
| | | |
| | | for (Agv agv : agvList) { |
| | | AgvDetail agvDetail = agvDetailService.selectByAgvId(agv.getId()); |
| | | AGV_PROCESSING_MAP.putIfAbsent(agv.getId(), false); |
| | | |
| | | this.processOnline(agv); |
| | | |
| | | if (!AGV_PROCESSING_MAP.get(agv.getId())) { |
| | | List<Action> actionList = actionService.queryLatestGroup(agv.getId(), ActionStsType.ISSUED); |
| | | if (!Cools.isEmpty(actionList)) { |
| | | executorService.submit(new AgvSimulatorTask( |
| | | agv |
| | | , redis |
| | | , agvDetailService |
| | | , actionService |
| | | , codeService |
| | | , mapService |
| | | , jamService |
| | | , actionList |
| | | )); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | Thread.sleep(100); |
| | | } catch (InterruptedException ignore) {} |
| | | |
| | | AGV_01_DOWN agv_01_down = (AGV_01_DOWN) protocol.getMessageBody(); |
| | | |
| | | // redis.setObject(RedisConstant.AGV_PATH_UP_FLAG |
| | | // , protocol.getAgvNo() + "_" + agv_01_up.getSerialNo() |
| | | // , agv_01_up); |
| | | AGV_01_UP agv_01_up = new AGV_01_UP(); |
| | | agv_01_up.setSerialNo(agv_01_down.getSerialNo()); |
| | | |
| | | redis.setObject(RedisConstant.AGV_PATH_UP_FLAG |
| | | , protocol.getAgvNo() + "_" + agv_01_up.getSerialNo() |
| | | , agv_01_up); |
| | | } |
| | | } |
| | | |