package com.centreproject.system.domain.kpi.park;

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 com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.Getter;

import java.time.LocalDateTime;

/**
 * 园区中心展示信息实体类
 * @author zhonglei.xu
 */
@Data
@TableName("map_center")
public class MapCenter {

    @TableId(type = IdType.AUTO)
    private Integer id;

    @TableField("park_code")
    private String parkCode;

    @TableField("analysis_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String analysisDate;

    @TableField("business_start_time")
    private String businessStartTime;

    @TableField("business_end_time")
    private String businessEndTime;

    @TableField("facility_name")
    private String facilityName;

    @TableField("facility_status")
    private FacilityStatus facilityStatus;

    @TableField("display_order")
    private Integer displayOrder;

    @TableField("synch_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime synchTime;

    @TableField("sync_trace_id")
    private String syncTraceId;

    /**
     * 设施状态枚举
     */
    @Getter
    public enum FacilityStatus {
        OPEN("OPEN"),
        CLOSED("CLOSED"),
        MAINTENANCE("MAINTENANCE"),
        SCHEDULED("SCHEDULED");

        private final String description;

        FacilityStatus(String description) {
            this.description = description;
        }

    }
    /**
     * 判断是否是营业时间记录
     */
    public boolean isBusinessHours() {
        return "Business Hours".equals(this.facilityName);
    }

    /**
     * 获取营业时间文本（如：10:00-20:00）
     */
    public String getBusinessHoursText() {
        if (businessStartTime == null || businessEndTime == null) {
            return null;
        }
        return businessStartTime + "-" + businessEndTime;
    }

    /**
     * 获取状态中文描述
     */
    public String getStatusDescription() {
        return facilityStatus != null ? facilityStatus.getDescription() : null;
    }
}