package com.bonus.core.device.manage.strategy;

import cn.hutool.core.collection.ListUtil;
import com.bonus.constant.SourceTypeEnum;
import com.bonus.core.device.constants.PrinterModelEnum;

import java.util.List;

public class DeviceStrategy {
   public static boolean isPrinter(Integer deviceType) {
      return SourceTypeEnum.PRINTER.getKey().equals(deviceType);
   }

   public static boolean isFeiePrinter(Integer deviceType, String deviceModel) {
      if (!isPrinter(deviceType)) {
         return false;
      } else {
         return PrinterModelEnum.FEI_E.getKey().equals(deviceModel) || PrinterModelEnum.FEI_E_LABEL.getKey().equals(deviceModel);
      }
   }

   public static boolean isLocker(Integer deviceType) {
      return SourceTypeEnum.MEAL_LOCKER.getKey().equals(deviceType) || SourceTypeEnum.GOODS_LOCKER.getKey().equals(deviceType) || SourceTypeEnum.FRESH_CABINET.getKey().equals(deviceType);
   }

   public static List<Integer> paymentDeviceTypes() {
      return ListUtil.toList(new Integer[]{SourceTypeEnum.AI_DISHES_RECOGNIZER.getKey(), SourceTypeEnum.ANDROID_DINING_TABLE.getKey(), SourceTypeEnum.ANDROID_DUAL_SCREEN.getKey(), SourceTypeEnum.ANDROID_HANG_CONSUMER.getKey(), SourceTypeEnum.ANDROID_SELF_RECHARGE.getKey(), SourceTypeEnum.AUTONOMOUS_WEIGHING.getKey(), SourceTypeEnum.BUFFET.getKey(), SourceTypeEnum.UFACE_MONITOR.getKey(), SourceTypeEnum.HANDHELD.getKey(), SourceTypeEnum.PAYMENT_POS.getKey(), SourceTypeEnum.PRODUCTION.getKey(), SourceTypeEnum.PRODUCTION_TRANSFER.getKey(), SourceTypeEnum.SCAN_CODE_TOLL.getKey(), SourceTypeEnum.VERTICAL_CONSUME.getKey(), SourceTypeEnum.WRITE_OFF.getKey()});
   }

   public static boolean isPayment(Integer deviceType) {
      return paymentDeviceTypes().contains(deviceType);
   }

   public static boolean supportsMultiBind(Integer deviceType) {
      return ListUtil.toList(new Integer[]{SourceTypeEnum.AI_DISHES_TERMINAL.getKey(), SourceTypeEnum.ANDROID_SELF_RECHARGE.getKey(), SourceTypeEnum.BUFFET.getKey(), SourceTypeEnum.CALL_MACHINE.getKey(), SourceTypeEnum.PRICE_TAG.getKey(), SourceTypeEnum.WRITE_OFF.getKey()}).contains(deviceType);
   }

   public static boolean supportsMQTT(Integer deviceType, Integer versionCode) {
      if (!SourceTypeEnum.AUTONOMOUS_WEIGHING.getKey().equals(deviceType)) {
         return ListUtil.toList(new Integer[]{SourceTypeEnum.PRICE_TAG.getKey()}).contains(deviceType);
      } else {
         return versionCode != null && versionCode >= 500;
      }
   }

   public static boolean isDoorTerminal(Integer deviceType) {
      return SourceTypeEnum.DC_TERMINAL.getKey().equals(deviceType);
   }

   public static boolean isDoor(Integer deviceType) {
      return SourceTypeEnum.DC_DOOR.getKey().equals(deviceType);
   }

   public static boolean isBusDevice(Integer deviceType) {
      return SourceTypeEnum.BUS_DEVICE.getKey().equals(deviceType);
   }

   public static boolean isSmartWeightContainer(Integer deviceType) {
      return SourceTypeEnum.SMART_WEIGHT_CONTAINER.getKey().equals(deviceType);
   }
}
