package com.huatek.busi.dto.cable;

import com.huatek.torch.sql.beans.PageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * 电缆环流日统计
 *
 * @author Bobi_huo
 * @date 2020-09-16 14:49
 */
@ApiModel(value = "BusiCableCirculationStatisticsDto", description = "电缆环流日统计 Dto", parent = PageBean.class)
@Data
@EqualsAndHashCode(callSuper = false)
public class BusiCableCirculationStatisticsDto extends PageBean implements Serializable {

    private static final long serialVersionUID = 4931736474235912184L;


    @ApiModelProperty(hidden = true)
    private final int DEFAULT_DAYS = 15;
    /**
     * 主键ID
     */
    @ApiModelProperty(name = "id", value = "主键ID")
    private String id;

    /**
     * 站点ID
     */
    @ApiModelProperty(name = "siteId", value = "站点ID")
    private String siteId;

    /**
     * 外挂设备ID
     */
    @ApiModelProperty(name = "subEquipmentId", value = "外挂设备ID")
    private String subEquipmentId;

    /**
     * 主设备ID
     */
    @ApiModelProperty(name = "subEquipmentId", value = "主设备ID")
    private String mainEquipmentId;

    /**
     * 统计时间
     */
    @ApiModelProperty(name = "dTime", value = "统计时间")
    private String dTime;

    /**
     * 电流(A)
     */
    @ApiModelProperty(name = "totalCoreCurrent", value = "电流(A)")
    private String totalCoreCurrent;

    /**
     * 创建时间
     */
    @ApiModelProperty(name = "createTime", value = "创建时间")
    private String createTime;

    /**
     * 传感器编码
     */
    @ApiModelProperty(name = "sensorCode", value = "传感器编码")
    private String sensorCode;

    /**
     * 开始日期
     */
    @ApiModelProperty(value = "开始日期", name = "startTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate startTime;

    /**
     * 终止日期
     */
    @ApiModelProperty(value = "终止日期", name = "endTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate endTime;

    private String cacMonitorTypeCode;

    public BusiCableCirculationStatisticsDto check() {
        if (this.getStartTime() == null && this.getEndTime() == null) {
            this.setEndTime(LocalDate.now());
            this.setStartTime(this.getEndTime().minusDays(DEFAULT_DAYS));
        }
//        if(StringUtils.isEmpty(this.sensorId)) {
//            this.sensorId = this.mainTreeId;
//        }
        return this;
    }
}
