package com.gci.boot.modules.gis.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import com.gci.boot.common.dict.annotation.Dict;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 *
 * </p>
 *
 * @author 2464
 * @since 2023-09-01
 */
@Getter
@Setter
@TableName("tb_gis_gps")
@ApiModel(value = "TbGisGps对象", description = "")
public class TbGisGps implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @ApiModelProperty("车牌号")
    private String plateNumber;

    @ApiModelProperty("定位终端标识")
    private String gpsNo;

    @ApiModelProperty("车辆状态  1-启动  2-熄火 3-其它  -99-无效 -100：异常")
    private Integer status;

    @ApiModelProperty("gps采集时间")
    private Date gpsTime;

    @ApiModelProperty("纬度")
    private BigDecimal lat;

    @ApiModelProperty("经度")
    private BigDecimal lon;

    @ApiModelProperty("速度 单位km/h")
    private BigDecimal speed;

    @ApiModelProperty("方向角")
    private String dir;

    @ApiModelProperty("高程")
    private BigDecimal altitude;

    @ApiModelProperty("acc状态 0-熄火 1-点火")
    private Integer acc;

    @ApiModelProperty("充电状态  1-停车充电、2-行驶充电、3-未充电  4-充电完成、-99-无效、-100-异常")
    private Integer chargeStatus;

    @ApiModelProperty("运行模式 1-纯电 2-混动 3-燃油 -99-无效、-100-异常")
    private Integer operatingMode;

    @ApiModelProperty("累计里程 单位km")
    private BigDecimal totalMileage;

    @ApiModelProperty("总电压 单位V")
    private BigDecimal totalVoltage;

    @ApiModelProperty("总电流 单位A")
    private BigDecimal totalCurrent;

    @ApiModelProperty("剩余电量比例 %")
    private Integer stateOfCharge;

    @ApiModelProperty("1-工作 2-断开")
    private Integer dcStatus;

    @ApiModelProperty("挡位")
    private String gearPosition;

    @ApiModelProperty("创建时间")
    private Date createTime;

    /**
     * 是否有效  1-有效 0-无效
     */
    @Dict(dicCode = "yes_no")
    private Integer isValid;

    /**
     * 是否作业 0-否 1-是
     */
    @Dict(dicCode = "yes_no")
    private Integer isWork;

    /**
     * 来源 1-808 2-eic 3-1078
     */
    private Integer recordSource;

    /**
     * 状态
     */
    @TableField(exist = false)
    private Integer cerStatus;

    public int getCurrentStatus() {
        if (this.recordSource == null) {
            return 3;
        }
        if (this.recordSource == 2) {
            return this.status == 1 ? 1 : 0;
        } else if (this.recordSource == 1) {
            return this.acc;
        }
        return 3;
    }
}
