package cn.amq.traffic;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import cn.amq.basis.AmqConst;
import cn.amq.business.AmqMainPoint;
import cn.amq.peas.TrafficEventAlarmHolder;
import cn.amq.peas.TrafficEventAlarmPeas;
import cn.amq.peas.VdLinkageRecordHolder;
import cn.amq.peas.VdLinkageRecordPeas;

/**
 * 发送视频设备联动录像信息amq
 * */
public class AmqVdLinkageRecordService {

	static Logger logger = Logger.getLogger(AmqVdLinkageRecordService.class);
	
	/**
	 * 发送视频设备联动录像信息amq
	 * @param gjxh
	 * @param gjsj
	 * @param sbbh
	 * @param tdbh
	 * @param sjlx
	 * @return  msg 0：AMQ发送失败；1：AMQ发送成功。
	 */
	public String publishVdLinkageRecordAction(String gjxh,String gjsj,String sbbh,String tdbh,String gjlx) {
		String msg = "1";
		//step1：视频设备联动录像信息amq
		try {
			VdLinkageRecordHolder holder = new VdLinkageRecordHolder();
			List<VdLinkageRecordPeas> list = new ArrayList<VdLinkageRecordPeas>();
			VdLinkageRecordPeas action = new VdLinkageRecordPeas();
			action.setSbbh(sbbh);
			int i_tdbh = 0;
			try {
				i_tdbh = Integer.parseInt(tdbh);
			}catch(Exception ex) {
				i_tdbh = 0;
			}
			action.setTdbh(i_tdbh);
			action.setFsmkmc("");
			list.add(action);
			holder.setGjxh(gjxh);
			holder.setGjlx(gjlx);
			holder.setGjsj(gjsj);
			holder.setTdbh(i_tdbh);
			holder.setSbbh(sbbh);
			holder.setList(list);
			AmqMainPoint.publishJob.publishGeneralEvent(holder, AmqConst.AMQ_SUBJECT_vdLinkageRecord);//
			logger.info("******发送AMQ消息******【视频设备联动录像AMQ】，发送内容为：事件编号："+gjxh+"，设备编号："+sbbh+"，通道编号："+tdbh);
			System.out.println("******发送AMQ消息******【视频设备联动录像AMQ】，发送内容为：事件编号："+gjxh+"，设备编号："+sbbh+"，通道编号："+tdbh);
		}catch(Exception e) {
			e.printStackTrace();
			msg = "0";
			logger.error("******发送AMQ消息error******【视频设备联动录像AMQ出现异常】，发送内容为：事件编号："+gjxh+"，设备编号："+sbbh+"，通道编号："+tdbh);
		}
		return msg;
	}
	
}
