package com.bonus.canteen.core.cook.enums;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public enum CookRecipeSortEnum {
   MEALLINE(1, "自助餐线/小碗菜餐线", CookBindTypeEnum.MEAL_LINE.key(), Arrays.asList(35, 32, 44, 30, 55, 58)),
   TABLE(2, "智慧餐台/消费机", CookBindTypeEnum.TABLE.key(), Arrays.asList(20, 23, 41, 47, 21, 34)),
   BUFFET(3, "点餐机/手持机/平板", CookBindTypeEnum.PAD.key(), Arrays.asList(41, 22, 36, 46, 63)),
   ISSUE(4, "信息发布屏", CookBindTypeEnum.SCREEN.key(), Arrays.asList(40, 45)),
   ANDROID_SELF_RECHARGE(5, "自助终端菜谱公示", CookBindTypeEnum.SELF_MACHINE.key(), Collections.singletonList(25)),
   MOBILE_CURRENT(6, "移动端当餐点餐", CookBindTypeEnum.CURRENT.key(), new ArrayList()),
   MOBILE_RESERVE(7, "移动端预订餐", CookBindTypeEnum.RESERVE.key(), new ArrayList()),
   MOBILE_WEEK(8, "移动端一周菜谱", CookBindTypeEnum.WEEK.key(), new ArrayList()),
   DISHES_IDENTIFY(9, "菜品识别", CookBindTypeEnum.DISHES_IDENTIFY.key(), Arrays.asList(50, 51)),
   NUTRITIONAL_PRICE_TAG(10, "营养价签", CookBindTypeEnum.NUTRITIONAL_PRICE_TAG.key(), Collections.singletonList(57));

   private final Integer key;
   private final String name;
   private final Integer bindType;
   private final List<Integer> deviceType;

   private CookRecipeSortEnum(Integer key, String name, Integer bindType, List deviceType) {
      this.key = key;
      this.name = name;
      this.bindType = bindType;
      this.deviceType = deviceType;
   }

   public static Map<Integer, CookRecipeSortEnum> getKeyMap() {
      return Arrays.stream(values()).collect(Collectors.toMap(CookRecipeSortEnum::getKey, Function.identity()));
   }

   public static Map<Integer, CookRecipeSortEnum> getBindTypeMap() {
      return Arrays.stream(values()).collect(Collectors.toMap(CookRecipeSortEnum::getBindType, Function.identity()));
   }

   public static CookRecipeSortEnum getByKey(Integer key) {
      return (CookRecipeSortEnum)getKeyMap().get(key);
   }

   public Integer getKey() {
      return this.key;
   }

   public String getName() {
      return this.name;
   }

   public Integer getBindType() {
      return this.bindType;
   }

   public List<Integer> getDeviceType() {
      return this.deviceType;
   }

   public static List<Integer> getDeviceBindTypes() {
      return Arrays.asList(MEALLINE.getBindType(), TABLE.getBindType(), BUFFET.getBindType(), ISSUE.getBindType(), ANDROID_SELF_RECHARGE.getBindType(), NUTRITIONAL_PRICE_TAG.getBindType());
   }
}
