package com.mvc.listener;

import com.mvc.forwarmana.ForwarderThread;
import com.mvc.iot.IotThreadManager;
import com.mvc.netty.ErrorParseThread;
import com.mvc.netty.PackLogThread;
import com.mvc.netty.ParseThread;
import com.mvc.service.aihcxd.IdenThread;
import com.mvc.service.aiiden.SystemReviewPushThread;
import com.mvc.service.alarm.AlarmThread;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

public class ApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        ApplicationContext ac = event.getApplicationContext();
        ParseThread parseThread = ac.getBean(ParseThread.class);
        ErrorParseThread errorThread = ac.getBean(ErrorParseThread.class);
        PackLogThread logThread = ac.getBean(PackLogThread.class);
        new Thread(parseThread).start();
        new Thread(errorThread).start();
        new Thread(logThread).start();

        //创建并启动系统自动向水利所推送审核数据的线程 2022-10-20 guozhao
        SystemReviewPushThread systemReviewPushThread = ac.getBean(SystemReviewPushThread.class);
        new Thread(systemReviewPushThread).start();

        //预留Java版服务识别
        IdenThread idenThread = ac.getBean(IdenThread.class);
        new Thread(idenThread).start();

        //数据转发线程(此线程有处理其它业务)
        ForwarderThread forwarderThread = ac.getBean(ForwarderThread.class);
        new Thread(forwarderThread).start();

        //燃气报警处理线程
        AlarmThread alarmThread = ac.getBean(AlarmThread.class);
        new Thread(alarmThread).start();

        //统一初始化IOT相关线程 2024-10-16 guozhao
        IotThreadManager.initIotThread(ac);
    }
}
