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

import cn.hutool.core.bean.BeanUtil;
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.Instant;
import java.util.List;
import java.util.Map;

@ApiModel("设备基础返回")
public class DeviceInfoVO {
   @ApiModelProperty("食堂ID")
   Long canteenId;
   @ApiModelProperty("店铺档口id")
   Long shopstallId;
   @ApiModelProperty("食堂名称")
   String canteenName;
   @ApiModelProperty("档口名称")
   String shopstallName;
   @ApiModelProperty("菜谱Id（只限单食堂当口设备使用）")
   Long recipeId;
   @ApiModelProperty("设备密码")
   String devicePwd;
   @ApiModelProperty("设备编号")
   String deviceNum;
   @ApiModelProperty("设备名称")
   String deviceName;
   @ApiModelProperty("设备自定义")
   Map deviceMetadata;
   @ApiModelProperty("菜谱信息")
   private List<DeviceBaseRecipeVO> recipeList;
   @ApiModelProperty("消息生成时间只在mqtt推送时使用，其余场景忽略")
   private Long time;

   public Long getTime() {
      return Instant.now().toEpochMilli();
   }

   public static DeviceInfoVO of(DeviceFullInfoVO deviceFullInfoVO) {
      DeviceInfoVO deviceInfoVO = new DeviceInfoVO();
      deviceInfoVO.setCanteenId(deviceFullInfoVO.getFirstCanteenId());
      deviceInfoVO.setCanteenName(deviceFullInfoVO.getFirstCanteenName());
      deviceInfoVO.setDeviceName(deviceFullInfoVO.getDeviceName());
      deviceInfoVO.setDeviceNum(deviceFullInfoVO.getDeviceNum());
      deviceInfoVO.setDevicePwd(deviceFullInfoVO.getDevicePwd());
      deviceInfoVO.setShopstallId(deviceFullInfoVO.getFirstShopstallId());
      deviceInfoVO.setShopstallName(deviceFullInfoVO.getFirstShopstallName());
      deviceInfoVO.setDeviceMetadata(deviceFullInfoVO.getDeviceMetadata());
      deviceInfoVO.setRecipeId(deviceFullInfoVO.getFirstRecipeId());
      deviceInfoVO.setRecipeList(BeanUtil.copyToList(deviceFullInfoVO.getRecipeList(), DeviceBaseRecipeVO.class));
      return deviceInfoVO;
   }

   public Long getCanteenId() {
      return this.canteenId;
   }

   public Long getShopstallId() {
      return this.shopstallId;
   }

   public String getCanteenName() {
      return this.canteenName;
   }

   public String getShopstallName() {
      return this.shopstallName;
   }

   public Long getRecipeId() {
      return this.recipeId;
   }

   public String getDevicePwd() {
      return this.devicePwd;
   }

   public String getDeviceNum() {
      return this.deviceNum;
   }

   public String getDeviceName() {
      return this.deviceName;
   }

   public Map getDeviceMetadata() {
      return this.deviceMetadata;
   }

   public List<DeviceBaseRecipeVO> getRecipeList() {
      return this.recipeList;
   }

   public void setCanteenId(final Long canteenId) {
      this.canteenId = canteenId;
   }

   public void setShopstallId(final Long shopstallId) {
      this.shopstallId = shopstallId;
   }

   public void setCanteenName(final String canteenName) {
      this.canteenName = canteenName;
   }

   public void setShopstallName(final String shopstallName) {
      this.shopstallName = shopstallName;
   }

   public void setRecipeId(final Long recipeId) {
      this.recipeId = recipeId;
   }

   public void setDevicePwd(final String devicePwd) {
      this.devicePwd = devicePwd;
   }

   public void setDeviceNum(final String deviceNum) {
      this.deviceNum = deviceNum;
   }

   public void setDeviceName(final String deviceName) {
      this.deviceName = deviceName;
   }

   public void setDeviceMetadata(final Map deviceMetadata) {
      this.deviceMetadata = deviceMetadata;
   }

   public void setRecipeList(final List<DeviceBaseRecipeVO> recipeList) {
      this.recipeList = recipeList;
   }

   public void setTime(final Long time) {
      this.time = time;
   }

}
