package cn.superdesk.uniorder.common.mq.redis.producer;

import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.common.mq.redis.constants.RedisCommonConstants;
import cn.superdesk.uniorder.common.mq.redis.dto.ExcelImportTaskMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @Description: 有空再整改吧
 * @Author: linjinyu
 * @CreateDate: 2021/2/4 上午10:57
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/2/4 上午10:57
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service
public class MessageProducerService {

	@Autowired
	private StringRedisTemplate stringRedisTemplate;
//	@Autowired
//	private RedisTemplate<String, String> redisTemplate;

	public Long sendMessage(String message) {
		Long ret = 1L;
		log.info("MessageProducerService sendMessage {}", message);
//		return stringRedisTemplate.opsForList().leftPush(RedisQueueChannelConstants.CHANNEL_QUEUE, message);
		stringRedisTemplate.convertAndSend(RedisCommonConstants.CHANNEL_QUEUE, message);
		return ret;
	}

	public Long pushMessage2CHANNEL_ACCOUNTING_UNIFIED_CUSTOMER(String message) {
		Long ret = 1L;
		log.info("MessageProducerService pushMessage2CHANNEL_ACCOUNTING_UNIFIED_CUSTOMER {}", message);
//		return stringRedisTemplate.opsForList().leftPush(RedisQueueChannelConstants.CHANNEL_ACCOUNTING_UNIFIED_CUSTOMER, message);

		stringRedisTemplate.convertAndSend(RedisCommonConstants.CHANNEL_ACCOUNTING_UNIFIED_CUSTOMER, message);

		return ret;
	}

	public Long pushMessage2CHANNEL_ACCOUNTING_UNIFIED_SUPPLIER(String message) {
		Long ret = 1L;
		log.info("MessageProducerService pushMessage2CHANNEL_ACCOUNTING_UNIFIED_SUPPLIER {}", message);
//		return stringRedisTemplate.opsForList().leftPush(RedisQueueChannelConstants.CHANNEL_ACCOUNTING_UNIFIED_SUPPLIER, message);

		stringRedisTemplate.convertAndSend(RedisCommonConstants.CHANNEL_ACCOUNTING_UNIFIED_SUPPLIER, message);

		return ret;
	}

	public Long pushMessage2CHANNEL_QUEUE_F(ExcelImportTaskMessage message) {
		Long ret = 1L;
		log.info("MessageProducerService pushMessage2CHANNEL_QUEUE_F {}", message);
		stringRedisTemplate.convertAndSend(RedisCommonConstants.CHANNEL_QUEUE_F, AnJsonUtils.toJson(message));
		return ret;
	}

}
