package com.casic.missiles.modular.system.model;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.alibaba.excel.enums.poi.BorderStyleEnum;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Digits;
import java.util.Date;

/**
 * <p>
 * 集中器信息表
 * </p>
 *
 * @author stylefeng123
 * @since 2019-06-03
 */
@ColumnWidth(30)
@HeadRowHeight(15)
@ContentRowHeight(20)
@ExcelIgnoreUnannotated
@ContentStyle(borderLeft = BorderStyleEnum.THIN,borderBottom =BorderStyleEnum.THIN,borderTop = BorderStyleEnum.THIN,borderRight = BorderStyleEnum.THIN)
@TableName("bus_concentrator")
@Data
public class BusConcentrator extends Model<BusConcentrator> {
    private static final long serialVersionUID = 1L;
    //设置表头与字段映射,可通过反射获取
    //判断唯一
//        mapper.put("集中器编号", "concencode");
//        mapper.put("集中器SIM卡号", "simid");
//        mapper.put("安装位置", "position");
//        mapper.put("权属单位", "deptid");
//    //需要转换
//        mapper.put("纬度", "lat");
//        mapper.put("经度", "lng");
//        mapper.put("安装时间", "setupdateFormat");
    /**
     * 主键
     */
    @TableId(value = "ID")
    private Long id;
    /**
     * 集中器编码
     */
    @ExcelProperty("集中器编号")
    @NotEmpty(message = "集中器编码不能为空")
    @TableField("CONCENCODE")
    private String concencode;
    /**
     * SIM卡号
     */
    @ExcelProperty("集中器SIM卡号")
    @NotEmpty
    @Digits(integer = 14, fraction = 0, message = "SIM卡号为14位")
    @TableField("SIMID")
    private String simid;

    @ExcelProperty("权属单位")
    @TableField(exist = false)
    private String deptName;

    /**
     * 部门
     */
    @TableField("DEPTID")
    private Long deptid;
    /**
     * 集中器位置
     */
    @ExcelProperty("安装位置")
    @TableField("POSITION")
    private String position;

    @ExcelProperty("在线状态")
    @TableField(exist = false)
    private String statusName;


    /**
     * 纬度
     */
//    @Digits(integer = 3,fraction = 14,message = "经度必须为正数且最多14位小数")
//    @ExcelProperty("纬度")
    @TableField("LAT")
    private String lat;
    /**
     * 经度
     */
//    @Digits(integer = 3,fraction = 14,message = "纬度必须为正数且最多14位小数")
//    @ExcelProperty("经度")
    @TableField("LNG")
    private String lng;
    /**
     * 百度地图纬度
     */
    @TableField("LAT_BAIDU")
    private String latBaidu;
    /**
     * 百度地图经度
     */
    @TableField("LNG_BAIDU")
    private String lngBaidu;
    /**
     * 高德地图纬度
     */
    @TableField("LAT_GAODE")
    private String latGaode;
    /**
     * 高德地图经度
     */
    @TableField("LNG_GAODE")
    private String lngGaode;
    /**
     * 照片路径
     */
    @TableField("PHOTOS")
    private String photos;
    /**
     * 状态
     */
    @TableField("STATUS")
    private String status;

    /**
     * 是否有效
     */
    @TableField("VALID")
    private String valid;
    /**
     * 启用时间
     */
    @TableField("SETUPDATE")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date setupdate;
    /**
     * 时间戳
     */
    @TableField("TS")
    private Date ts;

    @ExcelProperty("设备数量")
    @TableField(exist = false)
    private int devices;



    @TableField(exist = false)
    private String lasttimeFormat;

    /**
     * 最后上传时间
     */
    @ExcelProperty("最新在线时间")
    @TableField("LASTTIME")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date lasttime;

    @ExcelProperty("安装日期")
    @TableField(exist = false)
    private String setupdateFormat;


    @Override
    public String toString() {
        return "BusConcentrator{" +
                "id=" + id +
                ", concencode=" + concencode +
                ", simid=" + simid +
                ", deptid=" + deptid +
                ", position=" + position +
                ", lat=" + lat +
                ", lng=" + lng +
                ", latBaidu=" + latBaidu +
                ", lngBaidu=" + lngBaidu +
                ", latGaode=" + latGaode +
                ", lngGaode=" + lngGaode +
                ", photo=" + photos +
                ", status=" + status +
                ", lasttime=" + lasttime +
                ", valid=" + valid +
                ", ts=" + ts +
                "}";
    }
}
