package cn.com.taiji.track.entity;

import cn.com.taiji.track.constants.WarningCodeConstants;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @Author CHEN
 * @Date 2022/11/9 18:00
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("ax_beidou_ship_status")
public class ShipStatusEntity{
    /**
     * 重点关注id
     */
    @TableId
    private String deviceId;
    /**
     *  在线状态
     */
    private OnlineStatus isOnline;
    /**
     * 在线状态变更时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date onlineChangeTime;
    /**  0否 1是 */
    private InportStatus isInport;
    /** 在港状态变更时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date inportChangeTime;
    /**  0否 1是 */
    private AnchorStatus isAnchor;
    /** 在港状态变更时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date anchorChangeTime;

    public enum OnlineStatus {
        ONLINE("1","在线"),
        OFFLINE("2","离线"),
        MARK("3","标记");
        @EnumValue
        private final String value;
        @JsonValue    //需要在前端展示哪个值就在哪个属性上加上该注解
        private String text;

        public static OnlineStatus getStatus(String start) {
            if("true".equals(start)){
                return ONLINE;
            }else{
                return OFFLINE;
            }
        }

        public String getValue() {
            return value;
        }

        private OnlineStatus(String value,String text) {
            this.value = value;
            this.text = text;
        }
    }
    public enum InportStatus {
        FALSE("0","否"),
        TRUE("1","是");
        @EnumValue
        private final String value;
        @JsonValue    //需要在前端展示哪个值就在哪个属性上加上该注解
        private String text;

        public static InportStatus getStatus(String inportCode) {
            switch (inportCode) {
                case WarningCodeConstants.INPORT_WARNING:
                    return TRUE;
                default:
                    return FALSE;
            }
        }

        public String getValue() {
            return value;
        }

        private InportStatus(String value,String text) {
            this.value = value;
            this.text = text;
        }
    }
    public enum AnchorStatus {
        FALSE("0","否"),
        TRUE("1","是");
        @EnumValue
        private final String value;
        @JsonValue    //需要在前端展示哪个值就在哪个属性上加上该注解
        private String text;

        public String getValue() {
            return value;
        }

        public static AnchorStatus getStatus(String start) {
            if("true".equals(start)){
                return TRUE;
            }else{
                return FALSE;
            }
        }

        private AnchorStatus(String value,String text) {
            this.value = value;
            this.text = text;
        }
    }
}
