//package com.dashitech.redis.core.init;
//
//import com.dashitech.job.SpecimenStatusJob;
//import com.dashitech.redis.core.RedisKeys;
//import com.dashitech.redis.core.RedisListCmd;
//import com.dashitech.utils.ThreadPoolFactory;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.ApplicationArguments;
//import org.springframework.boot.ApplicationRunner;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Service;
//
//import java.util.concurrent.TimeUnit;
//
///**
// * Redis订阅服务，启动类
// * Created by CX on 2022/2/14.
// */
//@Service
//@Order(10)
//public class RedisInit implements ApplicationRunner {
//
//    @Autowired
//    SpecimenStatusJob specimenStatusJob;
//
//    @Override
//    public void run(ApplicationArguments applicationArguments) throws Exception {
//        System.out.println("标本状态，闭环上报消息订阅：" + RedisKeys.ITSM_SPECIMEN_STATUS_LIST);
//        //标本状态，闭环上报
//        //使用scheduleWithFixedDelay，任务结束才开始算间隔
//        ThreadPoolFactory.getScheduledPool().scheduleWithFixedDelay(new Runnable() {
//            @Override
//            public void run() {
//                try {
//                    onMessage();
//                } catch (Exception ex) {
//                    ex.printStackTrace();
//                }
//            }
//        }, 0, 5, TimeUnit.SECONDS);
//    }
//
//    /**
//     * 获取消息队列信息，循环自动建单，直到没有消息停止
//     */
//    public void onMessage() {
//        String message = RedisListCmd.pop(RedisKeys.ITSM_SPECIMEN_STATUS_LIST);
//        while (StringUtils.isNotEmpty(message)) {
//            specimenStatusJob.onMessage(message);
//            message = RedisListCmd.pop(RedisKeys.ITSM_SPECIMEN_STATUS_LIST);
//        }
//    }
//}
