| package com.zy.acs.manager.core.listen; | 
|   | 
| import com.zy.acs.common.constant.RedisConstant; | 
| import com.zy.acs.common.domain.AgvProtocol; | 
| import com.zy.acs.common.utils.RedisSupport; | 
| import com.zy.acs.manager.core.service.MainService; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import javax.annotation.PostConstruct; | 
| import javax.annotation.PreDestroy; | 
|   | 
| /** | 
|  * Created by vincent on 2023/6/16 | 
|  */ | 
| @Slf4j | 
| @Component | 
| public class AgvCompleteSubscriber { | 
|   | 
|     private Thread thread; | 
|     private final RedisSupport redis = RedisSupport.defaultRedisSupport; | 
|   | 
|     @Autowired | 
|     private MainService mainService; | 
|   | 
|     @PostConstruct | 
|     private void start(){ | 
|         thread = new Thread(() -> { | 
|             while (!Thread.currentThread().isInterrupted()) { | 
|                 try { | 
|                     // 间隔 | 
|                     Thread.sleep(30); | 
|   | 
|                     AgvProtocol protocol = redis.pop(RedisConstant.AGV_COMPLETE_FLAG); | 
|                     if (null != protocol){ | 
|   | 
|                         mainService.upDataSubscribe(protocol); | 
|                     } | 
|   | 
|                 } catch (Exception e) { | 
|                     log.error("AgvCompleteSubscriber mainService.upDataSubscribe fail", e); | 
|                 } | 
|             } | 
|         }); | 
|         thread.start(); | 
|     } | 
|   | 
|     @PreDestroy | 
|     public void shutDown(){ | 
|         if (thread != null) thread.interrupt(); | 
|     } | 
|   | 
|   | 
| } |