package com.bonus.canteen.core.device.vo;

import cn.hutool.core.collection.ListUtil;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Data
public class DeviceFullInfoVO {
   @ApiModelProperty("主键id")
   private Long deviceId;
   @ApiModelProperty("生效范围id")
   private Long effId;
   @ApiModelProperty("设备sn码")
   private String deviceSn;
   @ApiModelProperty("设备名称")
   private String deviceName;
   @ApiModelProperty("设备编号")
   private String deviceNum;
   @ApiModelProperty("设备型号")
   private String deviceModel;
   @ApiModelProperty("通信协议")
   private Integer deviceAgreement;
   @ApiModelProperty("设备类型")
   private Integer deviceType;
   @ApiModelProperty("设备密码")
   private String devicePwd;
   @ApiModelProperty("设备安装地址")
   private String deviceAddr;
   @ApiModelProperty("设备key")
   private String deviceKey;
   @ApiModelProperty("关联设备id")
   private Long deviceParentId;
   @ApiModelProperty("关联父设备类型")
   private String deviceParentType;
   @ApiModelProperty("服务器ip/域名")
   private String deviceServiceIp;
   @ApiModelProperty("服务器端口")
   private String deviceServicePort;
   @ApiModelProperty("版本号（MQTT上报）")
   private Integer versionCode;
   @ApiModelProperty("版本名称（MQTT上报）")
   private String versionName;
   @ApiModelProperty("设备在线状态 1在线 2离线（MQTT上报）")
   private Integer onlineState;
   @ApiModelProperty("消费模式(扣费模式)")
   private Integer consumMode;
   @ApiModelProperty("通讯模式")
   private Integer commMode;
   @ApiModelProperty("设备ip")
   private String deviceIp;
   @ApiModelProperty("子网掩码")
   private String deviceMask;
   @ApiModelProperty("设备mac")
   private String deviceMac;
   @ApiModelProperty("网关")
   private String deviceGateway;
   @ApiModelProperty("首选dns")
   private String firstDns;
   @ApiModelProperty("备选dns")
   private String nextDns;
   @ApiModelProperty("是否限额")
   private Integer ifQuotaLimit;
   @ApiModelProperty("是否打折")
   private Integer ifDiscount;
   @ApiModelProperty("是否限次")
   private Integer ifTimeLimit;
   @ApiModelProperty("是否启用叫号")
   private Integer ifUseCallNum;
   @ApiModelProperty("设备是否启用 1-是 2-否")
   private Integer ifEnable;
   @ApiModelProperty("图片地址（当mch_type为40 时，该字段表示背景图）")
   private String imgUrl;
   @ApiModelProperty("账户余额不足多少提醒")
   private Integer amountNotify;
   @ApiModelProperty("餐盘绑定有效时间")
   private Integer bindingValidTime;
   @ApiModelProperty("订单自动结算时间")
   private Integer ordAutomaticPay;
   @ApiModelProperty("是否允许离线消费")
   private Integer ifOffLinePay;
   @ApiModelProperty("报警时长")
   private Integer alarmTime;
   @ApiModelProperty("勺子重量")
   private Integer spoonWeight;
   @ApiModelProperty("心跳包时间(电子菜排)")
   private Long heartBeatTime;
   @ApiModelProperty("轮播播放时间(电子菜排)")
   private Long carouselTime;
   @ApiModelProperty("字幕标语(电子菜排)")
   private String titleSlogan;
   @ApiModelProperty("字体大小(电子菜排)")
   private Integer fontSize;
   @ApiModelProperty("界面样式(电子菜排)")
   private Integer guiStyle;
   @ApiModelProperty("设备背景或轮播图片")
   private JsonNode imageMap;
   @ApiModelProperty("字体颜色，默认黑色")
   private String fontColor;
   @ApiModelProperty("字体行数")
   private Integer lineNum;
   @ApiModelProperty("刷脸设备单次扣款金额")
   private Integer oncePayAmount;
   @ApiModelProperty("设备数据传输状态，1-传输完毕， 0-传输中")
   private Integer dataStatus;
   @ApiModelProperty("单笔订单开门数量")
   private Integer ordOpenLimit;
   @ApiModelProperty("单个柜门存单上限")
   private Integer detailNumLimit;
   @ApiModelProperty("第三方终端sn")
   private String terminalSn;
   @ApiModelProperty("第三方终端秘钥")
   private String terminalKey;
   @ApiModelProperty("打印机状态 1、离线。rn   * 2、在线，工作状态正常。rn   * 3、在线，工作状态不正常。")
   private Integer priStatus;
   @ApiModelProperty("打印机key")
   private String priKey;
   @ApiModelProperty("闸机默认消费金额")
   private Integer gateDefaultAmount;
   @ApiModelProperty("设备状态")
   private String deviceState;
   private String recipeName;
   private String areaName;
   private String areaId;
   private String canteenName;
   private String canteenId;
   private String stallName;
   private String stallId;
   @ApiModelProperty("绑定关系")
   private List<DeviceBindVO> bindList;
   @ApiModelProperty("菜谱信息")
   private List<DeviceRecipeVO> recipeList;
   @ApiModelProperty("菜品信息")
   private List<DeviceDishesVO> dishesList;
   @ApiModelProperty("设备基础设置")
   private Map deviceMetadata;
   @ApiModelProperty("范围名称")
   private String effName;
   @ApiModelProperty("取餐柜柜子列表")
   private List<DeviceLockerCabinetVO> lockerCabinetList;
   @ApiModelProperty("关联设备表")
   private List<DeviceControlRelationVO> relationDeviceList;
   public Long getFirstCanteenId() {
      return (Long) ListUtil.toList(this.bindList).stream().map(DeviceBindVO::getCanteenId).filter(Objects::nonNull).findFirst().orElse((Long) null);
   }

   public String getFirstCanteenName() {
      return (String)ListUtil.toList(this.bindList).stream().map(DeviceBindVO::getCanteenName).filter(Objects::nonNull).findFirst().orElse((String) null);
   }

   public Long getFirstShopstallId() {
      return (Long)ListUtil.toList(this.bindList).stream().map(DeviceBindVO::getStallId).filter(Objects::nonNull).findFirst().orElse((Long) null);
   }

   public String getFirstShopstallName() {
      return (String)ListUtil.toList(this.bindList).stream().map(DeviceBindVO::getStallName).filter(Objects::nonNull).findFirst().orElse((String) null);
   }

   public Long getFirstRecipeId() {
      return (Long)ListUtil.toList(this.getRecipeList()).stream().map(DeviceRecipeVO::getRecipeId).filter(Objects::nonNull).findFirst().orElse((Long) null);
   }

   public String getFirstRecipeName() {
      return (String)ListUtil.toList(this.getRecipeList()).stream().map(DeviceRecipeVO::getRecipeName).filter(Objects::nonNull).findFirst().orElse((String) null);
   }

   public String getFirstMealLineName() {
      return (String)ListUtil.toList(this.bindList).stream().map(DeviceBindVO::getMealLineName).filter(Objects::nonNull).findFirst().orElse((String) null);
   }

}
