//package me.zhengjie.modules.dm.daypc.rest;
//
//import com.alibaba.fastjson.JSON;
//import com.rabbitmq.client.BuiltinExchangeType;
//import com.rabbitmq.client.Channel;
//import com.rabbitmq.client.Connection;
//import me.zhengjie.modules.dm.daypc.domain.DmDayPc;
//import me.zhengjie.modules.dm.daypc.service.DmDayPcService;
//import me.zhengjie.modules.dm.daypc.service.dto.DmDayPcDto;
//import me.zhengjie.utils.ConnectionUtil;
//import me.zhengjie.utils.SpringContextHolder;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.springframework.amqp.core.AmqpTemplate;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.ObjectOutputStream;
//import java.io.Serializable;
//import java.nio.charset.StandardCharsets;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.TimeoutException;
//
////@SpringBootTest
////@RunWith(SpringRunner.class)
//@Component
//public class SendMsg {
////    @Autowired
////    RabbitTemplate rabbitTemplate;
//    @Autowired
//    DmDayPcService dmDayPcService;
//    private static String isEable = "0";
//
//    //每天10点执行
////    @Scheduled(cron = "0 0 10 * * ?")
////    //异步执行,指定线程池(配置类里配置)
////    @Async("threadPoolTaskExecutor1")
////    public void timer(){
////        isEable = "1";
////    }
////
////    //每五分钟执行一次
////    @Scheduled(cron = "0 */5 * * * ?")
////    @Async("threadPoolTaskExecutor2")
////    public void timer2(){
////        if(isEable!=null&&isEable=="1"){
////            send();
////            isEable = "0";
////        }
////    }
//
//
//
////    @Test
//    public void send(){
//        //获取连接
////        Connection connection = ConnectionUtil.getConnection();
////        try {
//
////            List<DmDayPc> dmDayPc = dmDayPcService.foodRepository();
//        String userString = "sendtest";
////            String userString = JSON.toJSONString(dmDayPc);
////            Channel channel = connection.createChannel();
////            String exchangeName = "schedule_produce";//交换机
////            channel.exchangeDeclare(exchangeName, BuiltinExchangeType.DIRECT, true,false, null);
////            String queue1Name = "schedule_produce";//队列名称
////            channel.queueDeclare(queue1Name, true, false, false, null);
////            channel.queueBind(queue1Name, exchangeName, "schedule_produce");// 队列绑定hello路由
////            channel.basicPublish(exchangeName, "schedule_produce", null, userString.getBytes());
//        /**
//         * 参数：
//         * 1、交换机名称
//         * 2、routingKey
//         * 3、消息内容
//         */
////            rabbitTemplate.convertAndSend("schedule_produce", "inform.email", userString.getBytes(StandardCharsets.UTF_8));
////            System.out.println("sned排菜:"+dmDayPc);
//            System.out.println("sned排菜string:"+userString);
////            channel.close();
////            connection.close();
////        } catch (IOException | TimeoutException e) {
////            e.printStackTrace();
////        }
//    }
//
//    //对象转化为字节码
////    public  byte[] getBytesFromObject(Serializable obj) throws Exception {
////        if (obj == null) {
////            return null;
////        }
////        ByteArrayOutputStream bo = new ByteArrayOutputStream();
////        ObjectOutputStream oo = new ObjectOutputStream(bo);
////        oo.writeObject(obj);
////        return bo.toByteArray();
////    }
//}
