package com.bonus.canteen.core.device.manage.dto;

import cn.hutool.core.bean.BeanUtil;
import com.bonus.canteen.core.common.utils.SysUtil;
import com.bonus.canteen.core.device.door.dto.door.BindDto;
import com.bonus.canteen.core.device.manage.model.DeviceInfo;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import io.swagger.annotations.ApiModelProperty;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class DeviceDTO {
   @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 deviceType;
   @ApiModelProperty("设备密码")
   private String devicePwd;
   @ApiModelProperty("设备安装地址")
   private String deviceAddr;
   @ApiModelProperty("设备key")
   private String deviceKey;
   @ApiModelProperty("餐线id")
   private Long mealLineId;
   @ApiModelProperty("版本号（上报）")
   private Integer versionCode;
   @ApiModelProperty("版本名称（上报）")
   private String versionName;
   @ApiModelProperty("设备在线状态 1在线 2离线（上报）")
   private Integer onlineState;
   @ApiModelProperty("消费模式(扣费模式)")
   private Integer consumMode;
   @ApiModelProperty("通讯模式")
   private Integer commMode;
   @ApiModelProperty("设备ip")
   private String deviceIp;
   @ApiModelProperty("设备ip")
   private String ipPort;
   @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 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("关联设备id")
   private Long deviceParentId;
   @ApiModelProperty("关联父设备类型")
   private String deviceParentType;
   @ApiModelProperty("服务器ip/域名")
   private String deviceServiceIp;
   @ApiModelProperty("服务器端口")
   private String deviceServicePort;
   @ApiModelProperty("楼宇id 门禁专用")
   private Integer buildId;
   @ApiModelProperty("备注 门禁专用")
   private String note;
   @ApiModelProperty("绑定的门信息 门禁专用")
   private List<BindDto> doors;
   @ApiModelProperty("门全称 门禁专用")
   private String doorFullName;
   @ApiModelProperty("是否显示日志 门禁专用")
   private Integer displayLog;
   @ApiModelProperty("设备类型 1 门禁 2 考勤")
   private String deviceCategory;
   @ApiModelProperty("通信协议")
   private Integer deviceAgreement;
   @ApiModelProperty("是否开启定额支付")
   private Integer ifOpenPay;
   @ApiModelProperty("序列号")
   private String serialNo;
   @ApiModelProperty("设备绑定信息")
   private List<DeviceBindDTO> binds;
   @ApiModelProperty("菜谱信息")
   private List<DeviceRecipeDTO> recipeList;
   @ApiModelProperty("菜品信息")
   private List<DeviceDishesDTO> dishes;
   @ApiModelProperty("控制关联设备信息")
   private List<DeviceControlRelationDTO> controlRelations;
   @ApiModelProperty("取餐柜（柜子）")
   private List<DeviceLockerCabinetDTO> cabinets;
   @ApiModelProperty("设备设置参数")
   private Map<String, Object> metadata;
   @ApiModelProperty("线路id")
   private Long lineId;
   @ApiModelProperty("使用场景 1、固定计费2、上车使用3、下车使用")
   private Integer useScene;

   public List<DeviceControlRelationDTO> getControlRelations() {
      if (this.controlRelations == null) {
         return Collections.emptyList();
      } else {
         this.controlRelations.forEach((s) -> {
            s.setControlDeviceId(this.deviceId);
         });
         return this.controlRelations;
      }
   }

   public List<DeviceLockerCabinetDTO> getCabinets() {
      if (this.cabinets == null) {
         return Collections.emptyList();
      } else {
         this.cabinets.forEach((s) -> {
            s.setDeviceId(this.deviceId);
         });
         return this.cabinets;
      }
   }

   public List<DeviceBindDTO> getBinds() {
      if (this.binds == null) {
         return Collections.emptyList();
      } else {
         this.binds.forEach((s) -> {
            s.setDeviceId(this.deviceId);
         });
         return this.binds;
      }
   }

   public List<DeviceRecipeDTO> getRecipeList() {
      if (this.recipeList == null) {
         return Collections.emptyList();
      } else {
         this.recipeList.forEach((s) -> {
            s.setDeviceId(this.deviceId);
         });
         return this.recipeList;
      }
   }

   public List<DeviceDishesDTO> getDishes() {
      if (this.dishes == null) {
         return Collections.emptyList();
      } else {
         this.dishes.forEach((s) -> {
            s.setDeviceId(this.deviceId);
         });
         return this.dishes;
      }
   }

   public DeviceInfo convertToInfoEntity() {
      DeviceInfo entity = new DeviceInfo();
      BeanUtil.copyProperties(this, entity, new String[0]);
      if (this.imageMap != null && this.imageMap.isArray()) {
         ArrayNode arrayNode = (ArrayNode)this.imageMap;
         ArrayNode arrayNodenew = new ArrayNode((JsonNodeFactory)null);
         arrayNode.forEach((s) -> {
            arrayNodenew.add(SysUtil.getCutPath(s.toString()));
         });
         entity.setImageMap(arrayNodenew);
      }

      return entity;
   }

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

   public Long getEffId() {
      return this.effId;
   }

   public String getDeviceSn() {
      return this.deviceSn;
   }

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

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

   public String getDeviceModel() {
      return this.deviceModel;
   }

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

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

   public String getDeviceAddr() {
      return this.deviceAddr;
   }

   public String getDeviceKey() {
      return this.deviceKey;
   }

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

   public Integer getVersionCode() {
      return this.versionCode;
   }

   public String getVersionName() {
      return this.versionName;
   }

   public Integer getOnlineState() {
      return this.onlineState;
   }

   public Integer getConsumMode() {
      return this.consumMode;
   }

   public Integer getCommMode() {
      return this.commMode;
   }

   public String getDeviceIp() {
      return this.deviceIp;
   }

   public String getIpPort() {
      return this.ipPort;
   }

   public String getDeviceMask() {
      return this.deviceMask;
   }

   public String getDeviceMac() {
      return this.deviceMac;
   }

   public String getDeviceGateway() {
      return this.deviceGateway;
   }

   public String getFirstDns() {
      return this.firstDns;
   }

   public String getNextDns() {
      return this.nextDns;
   }

   public Integer getIfQuotaLimit() {
      return this.ifQuotaLimit;
   }

   public Integer getIfDiscount() {
      return this.ifDiscount;
   }

   public Integer getIfTimeLimit() {
      return this.ifTimeLimit;
   }

   public Integer getIfUseCallNum() {
      return this.ifUseCallNum;
   }

   public Integer getIfEnable() {
      return this.ifEnable;
   }

   public String getImgUrl() {
      return this.imgUrl;
   }

   public Long getHeartBeatTime() {
      return this.heartBeatTime;
   }

   public Long getCarouselTime() {
      return this.carouselTime;
   }

   public String getTitleSlogan() {
      return this.titleSlogan;
   }

   public Integer getFontSize() {
      return this.fontSize;
   }

   public Integer getGuiStyle() {
      return this.guiStyle;
   }

   public JsonNode getImageMap() {
      return this.imageMap;
   }

   public String getFontColor() {
      return this.fontColor;
   }

   public Integer getLineNum() {
      return this.lineNum;
   }

   public Integer getOncePayAmount() {
      return this.oncePayAmount;
   }

   public Integer getDataStatus() {
      return this.dataStatus;
   }

   public Integer getOrdOpenLimit() {
      return this.ordOpenLimit;
   }

   public Integer getDetailNumLimit() {
      return this.detailNumLimit;
   }

   public String getTerminalSn() {
      return this.terminalSn;
   }

   public String getTerminalKey() {
      return this.terminalKey;
   }

   public Integer getPriStatus() {
      return this.priStatus;
   }

   public String getPriKey() {
      return this.priKey;
   }

   public Integer getGateDefaultAmount() {
      return this.gateDefaultAmount;
   }

   public Long getDeviceParentId() {
      return this.deviceParentId;
   }

   public String getDeviceParentType() {
      return this.deviceParentType;
   }

   public String getDeviceServiceIp() {
      return this.deviceServiceIp;
   }

   public String getDeviceServicePort() {
      return this.deviceServicePort;
   }

   public Integer getBuildId() {
      return this.buildId;
   }

   public String getNote() {
      return this.note;
   }

   public List<BindDto> getDoors() {
      return this.doors;
   }

   public String getDoorFullName() {
      return this.doorFullName;
   }

   public Integer getDisplayLog() {
      return this.displayLog;
   }

   public String getDeviceCategory() {
      return this.deviceCategory;
   }

   public Integer getDeviceAgreement() {
      return this.deviceAgreement;
   }

   public Integer getIfOpenPay() {
      return this.ifOpenPay;
   }

   public String getSerialNo() {
      return this.serialNo;
   }

   public Map<String, Object> getMetadata() {
      return this.metadata;
   }

   public Long getLineId() {
      return this.lineId;
   }

   public Integer getUseScene() {
      return this.useScene;
   }

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

   public void setEffId(final Long effId) {
      this.effId = effId;
   }

   public void setDeviceSn(final String deviceSn) {
      this.deviceSn = deviceSn;
   }

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

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

   public void setDeviceModel(final String deviceModel) {
      this.deviceModel = deviceModel;
   }

   public void setDeviceType(final Integer deviceType) {
      this.deviceType = deviceType;
   }

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

   public void setDeviceAddr(final String deviceAddr) {
      this.deviceAddr = deviceAddr;
   }

   public void setDeviceKey(final String deviceKey) {
      this.deviceKey = deviceKey;
   }

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

   public void setVersionCode(final Integer versionCode) {
      this.versionCode = versionCode;
   }

   public void setVersionName(final String versionName) {
      this.versionName = versionName;
   }

   public void setOnlineState(final Integer onlineState) {
      this.onlineState = onlineState;
   }

   public void setConsumMode(final Integer consumMode) {
      this.consumMode = consumMode;
   }

   public void setCommMode(final Integer commMode) {
      this.commMode = commMode;
   }

   public void setDeviceIp(final String deviceIp) {
      this.deviceIp = deviceIp;
   }

   public void setIpPort(final String ipPort) {
      this.ipPort = ipPort;
   }

   public void setDeviceMask(final String deviceMask) {
      this.deviceMask = deviceMask;
   }

   public void setDeviceMac(final String deviceMac) {
      this.deviceMac = deviceMac;
   }

   public void setDeviceGateway(final String deviceGateway) {
      this.deviceGateway = deviceGateway;
   }

   public void setFirstDns(final String firstDns) {
      this.firstDns = firstDns;
   }

   public void setNextDns(final String nextDns) {
      this.nextDns = nextDns;
   }

   public void setIfQuotaLimit(final Integer ifQuotaLimit) {
      this.ifQuotaLimit = ifQuotaLimit;
   }

   public void setIfDiscount(final Integer ifDiscount) {
      this.ifDiscount = ifDiscount;
   }

   public void setIfTimeLimit(final Integer ifTimeLimit) {
      this.ifTimeLimit = ifTimeLimit;
   }

   public void setIfUseCallNum(final Integer ifUseCallNum) {
      this.ifUseCallNum = ifUseCallNum;
   }

   public void setIfEnable(final Integer ifEnable) {
      this.ifEnable = ifEnable;
   }

   public void setImgUrl(final String imgUrl) {
      this.imgUrl = imgUrl;
   }

   public void setHeartBeatTime(final Long heartBeatTime) {
      this.heartBeatTime = heartBeatTime;
   }

   public void setCarouselTime(final Long carouselTime) {
      this.carouselTime = carouselTime;
   }

   public void setTitleSlogan(final String titleSlogan) {
      this.titleSlogan = titleSlogan;
   }

   public void setFontSize(final Integer fontSize) {
      this.fontSize = fontSize;
   }

   public void setGuiStyle(final Integer guiStyle) {
      this.guiStyle = guiStyle;
   }

   public void setImageMap(final JsonNode imageMap) {
      this.imageMap = imageMap;
   }

   public void setFontColor(final String fontColor) {
      this.fontColor = fontColor;
   }

   public void setLineNum(final Integer lineNum) {
      this.lineNum = lineNum;
   }

   public void setOncePayAmount(final Integer oncePayAmount) {
      this.oncePayAmount = oncePayAmount;
   }

   public void setDataStatus(final Integer dataStatus) {
      this.dataStatus = dataStatus;
   }

   public void setOrdOpenLimit(final Integer ordOpenLimit) {
      this.ordOpenLimit = ordOpenLimit;
   }

   public void setDetailNumLimit(final Integer detailNumLimit) {
      this.detailNumLimit = detailNumLimit;
   }

   public void setTerminalSn(final String terminalSn) {
      this.terminalSn = terminalSn;
   }

   public void setTerminalKey(final String terminalKey) {
      this.terminalKey = terminalKey;
   }

   public void setPriStatus(final Integer priStatus) {
      this.priStatus = priStatus;
   }

   public void setPriKey(final String priKey) {
      this.priKey = priKey;
   }

   public void setGateDefaultAmount(final Integer gateDefaultAmount) {
      this.gateDefaultAmount = gateDefaultAmount;
   }

   public void setDeviceParentId(final Long deviceParentId) {
      this.deviceParentId = deviceParentId;
   }

   public void setDeviceParentType(final String deviceParentType) {
      this.deviceParentType = deviceParentType;
   }

   public void setDeviceServiceIp(final String deviceServiceIp) {
      this.deviceServiceIp = deviceServiceIp;
   }

   public void setDeviceServicePort(final String deviceServicePort) {
      this.deviceServicePort = deviceServicePort;
   }

   public void setBuildId(final Integer buildId) {
      this.buildId = buildId;
   }

   public void setNote(final String note) {
      this.note = note;
   }

   public void setDoors(final List<BindDto> doors) {
      this.doors = doors;
   }

   public void setDoorFullName(final String doorFullName) {
      this.doorFullName = doorFullName;
   }

   public void setDisplayLog(final Integer displayLog) {
      this.displayLog = displayLog;
   }

   public void setDeviceCategory(final String deviceCategory) {
      this.deviceCategory = deviceCategory;
   }

   public void setDeviceAgreement(final Integer deviceAgreement) {
      this.deviceAgreement = deviceAgreement;
   }

   public void setIfOpenPay(final Integer ifOpenPay) {
      this.ifOpenPay = ifOpenPay;
   }

   public void setSerialNo(final String serialNo) {
      this.serialNo = serialNo;
   }

   public void setBinds(final List<DeviceBindDTO> binds) {
      this.binds = binds;
   }

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

   public void setDishes(final List<DeviceDishesDTO> dishes) {
      this.dishes = dishes;
   }

   public void setControlRelations(final List<DeviceControlRelationDTO> controlRelations) {
      this.controlRelations = controlRelations;
   }

   public void setCabinets(final List<DeviceLockerCabinetDTO> cabinets) {
      this.cabinets = cabinets;
   }

   public void setMetadata(final Map<String, Object> metadata) {
      this.metadata = metadata;
   }

   public void setLineId(final Long lineId) {
      this.lineId = lineId;
   }

   public void setUseScene(final Integer useScene) {
      this.useScene = useScene;
   }

}
