package org.springblade.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.EnumUtils;

import java.util.List;

/**
 * Created By lidexi in 2021/4/27
 **/
@Getter
@AllArgsConstructor
public enum  Instruct {

	/**
	 * 添加用户
	 */
	ADD_USER("add_user", Instruct.REPEATER_EXCHANGE, "添加人员名单"),
	JVT_ADD_USER("add_user_face", Instruct.PERSISTENT_EXCHANGE, "添加人脸"),
	JVT_OPEN_DOOR("open_door", Instruct.PERSISTENT_EXCHANGE, "远程开门"),

	//  临时指令：消息在指定时间内没有被消费,将自动清除
	/* ############################################################################################################## */

	open_door("open_door", Instruct.TRANSIENT_EXCHANGE,"远程开门"),
	restart("restart", Instruct.TRANSIENT_EXCHANGE,"重启设备"),
	check_online("check_online", Instruct.TRANSIENT_EXCHANGE,"检测设备在线"),

	//  持久指令：消息在队列中存储,等待客户端消费后清除
	/* ############################################################################################################## */

	pull_data("pull_data", Instruct.PERSISTENT_EXCHANGE,"重新拉取数据"),
	add_open_door_pwd("add_open_door_pwd", Instruct.PERSISTENT_EXCHANGE,"添加开门密码"),
	del_open_door_pwd("del_open_door_pwd", Instruct.PERSISTENT_EXCHANGE,"删除开门密码"),
	add_user_face("add_user_face", Instruct.PERSISTENT_EXCHANGE,"设置用户人脸"),
	delete_user_face("delete_user_face", Instruct.PERSISTENT_EXCHANGE,"删除用户人脸"),
	delete_user("delete_user", Instruct.PERSISTENT_EXCHANGE,"删除用户"),
	add_user_face_batch("add_user_face_batch", Instruct.PERSISTENT_EXCHANGE,"批量设置人脸"),
	delete_user_face_batch("delete_user_face_batch", Instruct.PERSISTENT_EXCHANGE,"批量删除人脸"),
	add_open_door_card("add_open_door_card", Instruct.PERSISTENT_EXCHANGE,"添加门禁卡"),
	del_open_door_card("del_open_door_card", Instruct.PERSISTENT_EXCHANGE,"删除门禁卡"),
	add_open_door_card_batch("add_open_door_card_batch", Instruct.PERSISTENT_EXCHANGE,"批量添加门禁卡"),
	delete_open_door_card_batch("del_open_door_card_batch", Instruct.PERSISTENT_EXCHANGE,"批量删除门禁卡"),
	update_device_info("update_device_info", Instruct.PERSISTENT_EXCHANGE,"更新设备信息"),
	add_video_call_account("add_video_call_account", Instruct.PERSISTENT_EXCHANGE,"添加视频对讲账号"),
	evacuate("evacuate", Instruct.PERSISTENT_EXCHANGE,"开启紧急疏散模式"),
	cancel_evacuate("cancel_evacuate", Instruct.PERSISTENT_EXCHANGE,"解除紧急疏散模式"),
	update_app_package("update_app_package", Instruct.PERSISTENT_EXCHANGE,"更新app包"),
	update_restore_app_package("update_restore_app_package", Instruct.PERSISTENT_EXCHANGE,"更新设备恢复版app包"),
	format_data("format_data", Instruct.PERSISTENT_EXCHANGE,"格式化数据"),
	format_user_face("format_user_face", Instruct.PERSISTENT_EXCHANGE,"格式化住户人脸数据"),
	format_server_face("format_server_face", Instruct.PERSISTENT_EXCHANGE,"格式化服务人员人脸数据"),
	format_card_data("format_card_data", Instruct.PERSISTENT_EXCHANGE,"格式化门禁卡数据"),
	format_face_advert("format_face_advert", Instruct.PERSISTENT_EXCHANGE,"格式化人脸广告数据"),
	format_leisure_advert("format_leisure_advert", Instruct.PERSISTENT_EXCHANGE,"格式化轮播广告数据"),
	format_notice_data("format_notice_data", Instruct.PERSISTENT_EXCHANGE,"格式化公告数据"),
	format_open_pwd("format_open_pwd", Instruct.PERSISTENT_EXCHANGE,"格式化访客密码数据"),
	sync_face_advert("sync_face_advert", Instruct.PERSISTENT_EXCHANGE,"同步人脸广告数据"),
	sync_leisure_advert("sync_leisure_advert", Instruct.PERSISTENT_EXCHANGE,"同步轮播广告数据"),
	sync_notice_data("sync_notice_data", Instruct.PERSISTENT_EXCHANGE,"同步公告数据"),
	sync_user_face("sync_user_face", Instruct.PERSISTENT_EXCHANGE,"同步住户人脸数据"),
	sync_server_face("sync_server_face", Instruct.PERSISTENT_EXCHANGE,"同步服务人员人脸数据"),
	sync_card_data("sync_card_data", Instruct.PERSISTENT_EXCHANGE,"同步门禁卡数据"),
	sync_open_pwd("sync_open_pwd", Instruct.PERSISTENT_EXCHANGE,"同步访客密码数据"),
	add_face_advert_task("add_face_advert_task", Instruct.PERSISTENT_EXCHANGE,"添加人脸广告任务"),
	add_leisure_advert_task("add_leisure_advert_task", Instruct.PERSISTENT_EXCHANGE,"添加轮播广告任务"),
	add_notice("add_notice", Instruct.PERSISTENT_EXCHANGE,"添加设备公告"),
	delete_notice("delete_notice", Instruct.PERSISTENT_EXCHANGE,"删除设备公告"),
	add_strategy_task("add_strategy_task", Instruct.PERSISTENT_EXCHANGE,"添加策略任务"),
	delete_advert("delete_advert", Instruct.PERSISTENT_EXCHANGE,"删除设备广告"),
	restore("restore", Instruct.PERSISTENT_EXCHANGE,"远程恢复版本"),
	//    disable_device("disable_device",Instruct.PERSISTENT_EXCHANGE,"禁用设备"),
//    disable_keyboard("disable_keyboard",Instruct.PERSISTENT_EXCHANGE,"禁用设备按键"),
//    disable_face_open_door("disable_face_open_door",Instruct.PERSISTENT_EXCHANGE,"禁用刷脸开门功能"),
//    disable_card_open_door("disable_card_open_door",Instruct.PERSISTENT_EXCHANGE,"禁用刷卡开门功能"),
//    disable_pwd_open_door("disable_pwd_open_door",Instruct.PERSISTENT_EXCHANGE,"禁用密码开门功能"),
//    disable_remote_open_door("disable_remote_open_door",Instruct.PERSISTENT_EXCHANGE,"禁用远程开门功能"),
//    disable_ad_play("disable_ad_play",Instruct.PERSISTENT_EXCHANGE,"禁用广告播放功能"),
	remote_update_device_setting("remote_update_device_setting", Instruct.PERSISTENT_EXCHANGE,"远程更新配置"),
	remote_info_obtain("remote_info_obtain", Instruct.PERSISTENT_EXCHANGE,"远程信息获取"),
		;

	/**
	 * 临时交换机
	 */
	private static final String TRANSIENT_EXCHANGE = "TRANSIENT_EXCHANGE";

	/**
	 * 适配器交换机
	 */
	private static final String REPEATER_EXCHANGE = "REPEATER_EXCHANGE";

	/**
	 * 持久交换机
	 */
	private static final String PERSISTENT_EXCHANGE = "PERSISTENT_EXCHANGE";



	/**
	 * 指令
	 */
	private String code;

	/**
	 * 交换机
	 */
	private String exchangeName;

	/**
	 * 描述
	 */
	private String describe;

	public static Instruct getByCode(String code){
		List<Instruct> enumList = EnumUtils.getEnumList(Instruct.class);
		if(enumList != null){
			for (Instruct instruct : enumList){
				if(instruct.getCode().equals(code)){
					return instruct;
				}
			}
			return null;
		}else{
			return null;
		}
	}
}
