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

import cn.hutool.core.bean.BeanUtil;
import com.bonus.core.allocation.canteen.model.AllocCanteen;
import com.bonus.core.allocation.canteen.model.AllocMealLine;
import com.bonus.core.allocation.canteen.model.AllocStall;
import com.bonus.core.allocation.canteen.vo.AllocAreaFullNameVO;
import com.bonus.core.device.manage.model.DeviceBind;
import com.bonus.framework.config.deserializer.TimeDeserializer;
import com.bonus.framework.config.serializer.TimeSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalTime;

public class DeviceBindVO {
   @ApiModelProperty("主键id")
   private Long id;
   @ApiModelProperty("设备id")
   private Long deviceId;
   @ApiModelProperty("区域id")
   private Long areaId;
   @ApiModelProperty("食堂id")
   private Long canteenId;
   @ApiModelProperty("店铺档口id")
   private Long stallId;
   @ApiModelProperty("包间id")
   private Long roomId;
   @ApiModelProperty("是否启用打印")
   private Integer ifUsePrint;
   @ApiModelProperty("餐线id")
   private Long mealLineId;
   @ApiModelProperty("餐线名称")
   private String mealLineName;
   @ApiModelProperty("区域名称")
   private String areaName;
   @ApiModelProperty("食堂名称")
   private String canteenName;
   @ApiModelProperty("档口名称")
   private String stallName;
   @ApiModelProperty("档口图片地址")
   private String stallImgUrl;
   @ApiModelProperty("档口是否营业")
   private Integer stallIfOpen;
   @ApiModelProperty("档口营业时间  档口是否营业")
   @JsonSerialize(
      using = TimeSerializer.HH_MM_SS.class
   )
   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   private LocalTime stallStaTime;
   @ApiModelProperty("档口营业结束时间")
   @JsonSerialize(
      using = TimeSerializer.HH_MM_SS.class
   )
   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   private LocalTime stallEndTime;

   public static DeviceBindVO of(DeviceBind deviceBind, AllocMealLine mealLine, AllocStall stall, AllocCanteen canteen, AllocAreaFullNameVO allocAreaFullNameVO) {
      DeviceBindVO vo = (DeviceBindVO)BeanUtil.toBean(deviceBind, DeviceBindVO.class);
      BeanUtil.copyProperties(deviceBind, vo, new String[0]);
      vo.setStallName(stall != null ? stall.getStallName() : "");
      vo.setStallImgUrl(stall != null ? stall.getImgUrl() : "");
      vo.setStallIfOpen(stall != null ? stall.getBusinessState() : null);
      vo.setStallStaTime(stall != null ? stall.getStartBusinessTime() : null);
      vo.setStallEndTime(stall != null ? stall.getEndBusinessTime() : null);
      vo.setMealLineName(mealLine != null ? mealLine.getMealLineName() : null);
      vo.setCanteenName(canteen != null ? canteen.getCanteenName() : "");
      vo.setAreaName(allocAreaFullNameVO != null ? allocAreaFullNameVO.getFullAreaName() : "");
      return vo;
   }

   public Long getId() {
      return this.id;
   }

   public Long getDeviceId() {
      return this.deviceId;
   }

   public Long getAreaId() {
      return this.areaId;
   }

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

   public Long getStallId() {
      return this.stallId;
   }

   public Long getRoomId() {
      return this.roomId;
   }

   public Integer getIfUsePrint() {
      return this.ifUsePrint;
   }

   public Long getMealLineId() {
      return this.mealLineId;
   }

   public String getMealLineName() {
      return this.mealLineName;
   }

   public String getAreaName() {
      return this.areaName;
   }

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

   public String getStallName() {
      return this.stallName;
   }

   public String getStallImgUrl() {
      return this.stallImgUrl;
   }

   public Integer getStallIfOpen() {
      return this.stallIfOpen;
   }

   public LocalTime getStallStaTime() {
      return this.stallStaTime;
   }

   public LocalTime getStallEndTime() {
      return this.stallEndTime;
   }

   public void setId(final Long id) {
      this.id = id;
   }

   public void setDeviceId(final Long deviceId) {
      this.deviceId = deviceId;
   }

   public void setAreaId(final Long areaId) {
      this.areaId = areaId;
   }

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

   public void setStallId(final Long stallId) {
      this.stallId = stallId;
   }

   public void setRoomId(final Long roomId) {
      this.roomId = roomId;
   }

   public void setIfUsePrint(final Integer ifUsePrint) {
      this.ifUsePrint = ifUsePrint;
   }

   public void setMealLineId(final Long mealLineId) {
      this.mealLineId = mealLineId;
   }

   public void setMealLineName(final String mealLineName) {
      this.mealLineName = mealLineName;
   }

   public void setAreaName(final String areaName) {
      this.areaName = areaName;
   }

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

   public void setStallName(final String stallName) {
      this.stallName = stallName;
   }

   public void setStallImgUrl(final String stallImgUrl) {
      this.stallImgUrl = stallImgUrl;
   }

   public void setStallIfOpen(final Integer stallIfOpen) {
      this.stallIfOpen = stallIfOpen;
   }

   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   public void setStallStaTime(final LocalTime stallStaTime) {
      this.stallStaTime = stallStaTime;
   }

   @JsonDeserialize(
      using = TimeDeserializer.class
   )
   public void setStallEndTime(final LocalTime stallEndTime) {
      this.stallEndTime = stallEndTime;
   }
}
