package com.bonus.core.device.android.constant;

import com.bonus.constant.LeConstants;
import com.bonus.core.common.constant.LeMqConstant;
import com.bonus.core.device.android.common.dto.DeviceMqSendUpdateConfigDto;
import com.bonus.core.device.android.common.vo.DeviceMQOnlineConfigDto;
import com.bonus.core.device.android.common.vo.MQIntervalConfigVO;
import com.bonus.core.device.manage.controller.deprecated.vo.DeviceHeartBeatMqRemVo;
import com.bonus.core.device.manage.dto.*;
import com.bonus.core.device.manage.vo.DeviceInfoVO;
import com.bonus.core.device.mettadata.model.DeviceMetadataModel;
import com.bonus.core.device.mq.MacMessage;
import com.bonus.core.order.mq.MqUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DeviceMqMessage {
   private static final Logger log = LoggerFactory.getLogger(DeviceMqMessage.class);

   public static <T> void deviceTimeCalibrationV4(T payload, String machineSn) {
      MqUtil.pushToSingleDevice(payload, LeMqConstant.Topic.DEVICE_TIME_CALIBRATION_V4, machineSn);
   }

   public static <T> void timeCalibrationV4(T payload) {
      MqUtil.pushToAllDevice(payload, LeMqConstant.Topic.DEVICE_TIME_CALIBRATION_V4);
   }

   public static <T> void deviceUpdatePersonalConfigV4() {
      MqUtil.pushToTenantAllDevice((new DeviceMqPersonalUpdateMessageDTO()).setUpdatePerson(1), LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
   }

   public static <T> void deviceUpdatePersonalFeatureConfigV4() {
      MqUtil.pushToTenantAllDevice((new DeviceMqPersonalUpdateMessageDTO()).setUpdatePersonPhoto(1), LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
   }

   public static <T> void deviceUpdateCardStatusConfigV4() {
      MqUtil.pushToTenantAllDevice((new DeviceMqPersonalUpdateMessageDTO()).setUpdateCardStatus(1), LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
   }

   public static <T> void deviceUpdatePersonalValidityConfigV4() {
      MqUtil.pushToTenantAllDevice((new DeviceMqPersonalUpdateMessageDTO()).setUpdateValidityPhoto(1), LeMqConstant.Topic.DEVICE_UPDATE_PERSONAL_CONFIG_V4);
   }

   public static <T> void deviceUpdateMenuConfigV4(String machineSn) {
      log.info("deviceUpdateMenuConfigV4 machineSn:{}", machineSn);
      MqUtil.pushToSingleTxDevice((new DeviceMqSendUpdateConfigDto()).setNeedupdate(LeConstants.COMMON_YES), LeMqConstant.Topic.DEVICE_UPDATE_MENU_CONFIG_V4, machineSn);
   }

   public static <T> void deviceUpdateIntervalConfigV4(MQIntervalConfigVO mqIntervalConfigVO) {
      MqUtil.pushToTenantAllDevice(mqIntervalConfigVO, LeMqConstant.Topic.DEVICE_UPDATE_INTERVAL_CONFIG_V4);
   }

   public static <T> void deviceUpdateSystemCardV4(T payload) {
      MqUtil.pushToTenantAllDevice(payload, LeMqConstant.Topic.DEVICE_UPDATE_SYSTEM_CARD_V4);
   }

   public static <T> void deviceUpdateInfoV4(DeviceInfoVO payload, String machineSn) {
      MqUtil.pushToSingleDevice(payload, (LeMqConstant.Topic)LeMqConstant.Topic.DEVICE_UPDATE_INFO_V4, machineSn);
   }

   public static <T> void DEVICE_ONLINE_REPORT_V4(DeviceMQOnlineConfigDto payload) {
      MqUtil.pushToTenantAllDevice(payload, LeMqConstant.Topic.DEVICE_ONLINE_REPORT_V4);
   }

   public static <T> void deviceUpdateBuffetMerchantV4(DeviceMetadataModel payload) {
      MqUtil.pushToTenantAllDevice(payload, LeMqConstant.Topic.DEVICE_UPDATE_BUFFET_MERCHANT_V4);
   }

   public static <T> void deviceStallUpdateWeightinfoV4(DeviceHeartBeatMqRemVo deviceHeartBeatMqRemVo, String machineSn) {
      MacMessage.sendToClient(deviceHeartBeatMqRemVo, LeMqConstant.Topic.DEVICE_STALL_UPDATE_WEIGHTINFO_V4, machineSn);
   }

   public static <T> void deviceSwitchDeviceMenuV4(SwitchDeviceMenuDto switchDeviceMenuDto, String machineSn) {
      MacMessage.sendToClient(switchDeviceMenuDto, LeMqConstant.Topic.DEVICE_SWITCH_DEVICE_MENU_V4, machineSn);
   }

   public static <T> void deviceSwitchDeviceMenuPriceV4(SwitchDeviceMenuPriceMenuDto switchDeviceMenuPriceMenuDto, String machineSn) {
      MacMessage.sendToClient(switchDeviceMenuPriceMenuDto, LeMqConstant.Topic.DEVICE_SWITCH_DEVICE_MENU_PRICE_V4, machineSn);
   }

   public static <T> void devicePullLogNoticeV4(DeviceSendLogNoticeDTO deviceSendLogNoticeDTO, String machineSn, Long merchantId) {
      MacMessage.sendToClient(deviceSendLogNoticeDTO, LeMqConstant.Topic.DEVICE_PULL_LOG_NOTICE_V4, machineSn, merchantId);
   }

   public static <T> void deviceUpdateApkconfigv4(DeviceUpdateInSystemDto deviceUpdateInSystemDto, String machineSn, Long merchantId) {
      MacMessage.sendToClient(deviceUpdateInSystemDto, LeMqConstant.Topic.DEVICE_UPDATE_APK_V4, machineSn, merchantId);
   }
}
