package com.persagy.dmp.digital.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.persagy.dmp.common.model.entity.AuditableEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Set;

/**
 * 对象数据
 * @author Charlie Yu
 * @date 2021-06-25
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "dt_object",autoResultMap = true)
@NoArgsConstructor
@AllArgsConstructor
public class ObjectDigital extends AuditableEntity {

    /** 扩展属性列 */
    public static final String EXTRA_COLUMN = "infos";
    /** 扩展属性列 */
    public static final String OBJ_TYPE = "obj_type";
    /** 扩展属性列 */
    public static final String OBJ_TYPE_HUM = "objType";
    /** 对象类型 */
    public static final String CLASS_CODE = "class_code";
    /** 对象类型 */
    public static final String CLASS_CODE_HUM = "classCode";
    /** 对象本地名称 */
    public static final String LOCAL_NAME_HUM = "localName";
    /** 对象本地名称 */
    public static final String LOCAL_NAME = "local_name";
    /** 对象本地编码 */
    public static final String LOCAL_ID = "local_id";
    /** 对象名称 */
    public static final String NAME = "name";

    /** 项目ID */
    private String projectId;
    /** 名称 */
    @NotNull(message = "名称不允许为空")
    @Length(max = 200)
    private String name;
    /** 本地编码 */
    private String localId;
    /** 本地名称 */
    private String localName;
    /** 对象分类 */
    private String objType;
    /** 类型编码 */
    @NotNull(message = "类型编码不允许为空")
    @Length(max = 40)
    private String classCode;
    /** 集团编码 */
    private String groupCode;
    /** 组标识 mysql8中grouping是关键字，必须标识 */
    @TableField(value = "`grouping`")
    private Integer grouping;
    /** 边类型编码 */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private ObjectNode infos;
    /** 虚点清单 */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> virtualCodes;
    /** 创建应用 */
    private String createApp;
    /** 最后修改应用 */
    private String updateApp;
    /** 符合查询条件的数据总条数 */
    @TableField(exist = false)
    private Integer totalCount;
    /** 来源的对象id集合 */
    @TableField(exist = false)
    private Set<String> objFromIds;
    /** 去向的对象id集合 */
    @TableField(exist = false)
    private Set<String> objToIds;
    /** 主从对象标记,true-主对象,false-从对象 */
    @TableField(exist = false)
    private Boolean mainFlag;
    /** CADID */
    @TableField(exist = false)
    private String cadId;
    /** 模型id */
    @TableField(exist = false)
    private String modelId;
    /** 序号 */
    @TableField(exist = false)
    private Integer sequenceId;
    /** 是否使用的标记 */
    @TableField(exist = false)
    private Boolean usedFlag;
    /** 关联的对象列表 */
    @TableField(exist = false,typeHandler = JacksonTypeHandler.class)
    private List<ObjectDigital> relObjs;
    /** 对象的bim点坐标 */
    @TableField(exist = false,typeHandler = JacksonTypeHandler.class,value = "bimLocation")
    private ObjectNode bimLocation;
    /** 对象的outline平面坐标 */
    @TableField(exist = false,typeHandler = JacksonTypeHandler.class,value = "outLines")
    private List<LinkedHashMap<String,Object>> outLines;
    /** 该对象的对象分类所拥有的classCode集合 */
    @TableField(exist = false,typeHandler = JacksonTypeHandler.class,value = "objTypeClassCodes")
    private Set<String> objTypeClassCodes;
}
