package com.sysu.admin.controller.crop;

import com.alibaba.fastjson.annotation.JSONField;
import com.sysu.admin.controller.crop.images.CropImage;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.Point;

import javax.persistence.*;
import java.util.Date;

@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@FieldNameConstants(innerTypeName = "FIELDS")
@Table(name = "p_crop")
@Entity
@DynamicInsert
@DynamicUpdate
public class CropLand {

    public CropLand(){
    }

    public CropLand(Long id, Integer cropType, Integer growingPeriod, Integer confirm, Integer district, String name, String address, String desc) {
        this.id = id;
        this.cropType = cropType;
        this.growingPeriod = growingPeriod;
        this.confirm = confirm;
        this.district = district;
        this.name = name;
        this.address = address;
        this.desc = desc;
    }

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "gridcode")
    private Long gridcode;

    @JSONField(serialize = false)
    @Column(columnDefinition = "geom")
    private MultiPolygon geom;

    @JSONField(serialize = false)
    @Column(columnDefinition = "center_point")
    private Point centerPoint;

    @Transient
    private String wkt;
    @Transient
    private String geojson;
    /**
     * 耕地类型
     */
    @Column
    private Integer cropType;
    /**
     * 生长期
     */
    @Column
    private Integer growingPeriod;


    /**
     * 采集经度
     */
    @Column
    private Double pickLongitude;

    /**
     * 采集纬度
     */
    @Column
    private Double pickLatitude;

    /**
     * 产量
     */
    @Column
    private Integer yield;

    @Column(nullable = false)
    private Date createDate;

    @Column(nullable = false)
    private Date updateDate;

    @Column(nullable = false)
    private Date receiveDate;

    @Column(nullable = false)
    private Long receiver;

    @Column(nullable = false)
    private Date pickDate;

    /**
     * 创建人
     */
    @Column( nullable = false)
    private Long creator;

    /**
     */
    @Column(nullable = false)
    private Long executor;

    /**
     * 状态
     */
    @Column
    private Integer status;

    @Column
    private Integer confirm;

    /**
     * 描述
     */
    @Column(name = "\"desc\"")
    private String desc;

    @Transient
    private CropImage fay;
    @Transient
    private CropImage center;
    @Transient
    private CropImage near;

    @Column
    private Integer province;
    @Column
    private Integer city;
    @Column
    private Integer district;
    @Column
    private String name;
    @Column
    private String address;


}
