package com.cim.idm.service.impl;


import com.cim.idm.framework.esb.amqp.RabbitSender;
import com.cim.idm.service.PdaService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.text.SimpleDateFormat;
import java.util.Date;


public class PdaServiceImpl implements PdaService{
	@Autowired
	@Qualifier("pdaSender")
	private RabbitSender rabbitSender ;
	private static  Log Log = LogFactory.getLog(PdaServiceImpl.class);

	public String sendMessage(String message)
			throws Exception
	{
		System.out.println("-----PdaService-----");
		Log.info("-----PdaService-----");
		String currentTime1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
		System.out.println("Start time：" + currentTime1);
		System.out.println(message);
		Log.info("-----pda message-----");
		Log.info(message);
		String returnMsg = (String) this.rabbitSender.sendRequest(message);
		System.out.println(returnMsg);
		Log.info("-----pda returnMsg-----");
		Log.info(returnMsg);
		String currentTime2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
		System.out.println("End time：" + currentTime2);
		return returnMsg;
	}
}
