package org.dromara.ems.info.domain;

import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.format.DateTimeFormat;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 日常故障记录对象 daily_fault_record
 * 
 * @author Yinq
 * @date 2025-06-05
 */
@ExcelIgnoreUnannotated
public class DailyFaultRecord extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键，自增ID */
    private Long id;

    /** 日期 */
    @DateTimeFormat("yyyy/MM/dd")
    @ExcelProperty(value = "日期")
    private String date;

    /** 位置 */
    @ExcelProperty(value = "位置")
    private String location;

    /** 科室值班 */
    @ExcelProperty(value = "科室值班")
    private String dailyDutySupervisor;

    /** 外包值班 */
    @ExcelProperty(value = "外包值班")
    private String tendaDailyDutySupervisor;

    /** 故障情况 */
    @ExcelProperty(value = "故障情况")
    private String faultSituation;

    /** 处置措施 */
    @ExcelProperty(value = "处置措施")
    private String handlingMeasures;

    /** 故障类型 */
    @ExcelProperty(value = "故障类型")
    private String faultType;

    /** 故障发生时间 */
    @DateTimeFormat("HH:mm:ss")
    @ExcelProperty(value = "故障发生时间")
    private String faultOccurrenceTime;

    /** 处置完毕时间 */
    @DateTimeFormat("HH:mm:ss")
    @ExcelProperty(value = "处置完毕时间")
    private String handlingCompletionTime;

    /** 处置时长 */
    private Long handlingDuration;

    /** 处置时长格式化显示 (HH:mm:ss) */
    @ExcelProperty(value = "处置时长")
    private String handlingDurationFormatted;

    /** 备注 */
    @ExcelProperty(value = "备注")
    private String remarks;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setDate(String date) 
    {
        this.date = date;
    }

    public String getDate() 
    {
        return date;
    }
    public void setLocation(String location) 
    {
        this.location = location;
    }

    public String getLocation() 
    {
        return location;
    }
    public void setDailyDutySupervisor(String dailyDutySupervisor) 
    {
        this.dailyDutySupervisor = dailyDutySupervisor;
    }

    public String getDailyDutySupervisor() 
    {
        return dailyDutySupervisor;
    }
    public void setTendaDailyDutySupervisor(String tendaDailyDutySupervisor) 
    {
        this.tendaDailyDutySupervisor = tendaDailyDutySupervisor;
    }

    public String getTendaDailyDutySupervisor() 
    {
        return tendaDailyDutySupervisor;
    }
    public void setFaultSituation(String faultSituation) 
    {
        this.faultSituation = faultSituation;
    }

    public String getFaultSituation() 
    {
        return faultSituation;
    }
    public void setHandlingMeasures(String handlingMeasures) 
    {
        this.handlingMeasures = handlingMeasures;
    }

    public String getHandlingMeasures() 
    {
        return handlingMeasures;
    }
    public void setFaultType(String faultType) 
    {
        this.faultType = faultType;
    }

    public String getFaultType() 
    {
        return faultType;
    }
    public void setFaultOccurrenceTime(String faultOccurrenceTime) 
    {
        this.faultOccurrenceTime = faultOccurrenceTime;
    }

    public String getFaultOccurrenceTime() 
    {
        return faultOccurrenceTime;
    }
    public void setHandlingCompletionTime(String handlingCompletionTime) 
    {
        this.handlingCompletionTime = handlingCompletionTime;
    }

    public String getHandlingCompletionTime() 
    {
        return handlingCompletionTime;
    }
    public void setHandlingDuration(Long handlingDuration) 
    {
        this.handlingDuration = handlingDuration;
        // 自动格式化处置时长
        this.handlingDurationFormatted = formatDuration(handlingDuration);
    }

    public Long getHandlingDuration() 
    {
        return handlingDuration;
    }

    public void setHandlingDurationFormatted(String handlingDurationFormatted) 
    {
        this.handlingDurationFormatted = handlingDurationFormatted;
    }

    public String getHandlingDurationFormatted() 
    {
        return handlingDurationFormatted;
    }

    /**
     * 格式化处置时长为HH:mm:ss格式
     * @param seconds 秒数
     * @return 格式化后的时间字符串
     */
    private String formatDuration(Long seconds) {
        if (seconds == null || seconds <= 0) {
            return "00:00:00";
        }
        
        long hours = seconds / 3600;
        long minutes = (seconds % 3600) / 60;
        long secs = seconds % 60;
        
        return String.format("%02d:%02d:%02d", hours, minutes, secs);
    }

    public void setRemarks(String remarks) 
    {
        this.remarks = remarks;
    }

    public String getRemarks() 
    {
        return remarks;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("date", getDate())
            .append("location", getLocation())
            .append("dailyDutySupervisor", getDailyDutySupervisor())
            .append("tendaDailyDutySupervisor", getTendaDailyDutySupervisor())
            .append("faultSituation", getFaultSituation())
            .append("handlingMeasures", getHandlingMeasures())
            .append("faultType", getFaultType())
            .append("faultOccurrenceTime", getFaultOccurrenceTime())
            .append("handlingCompletionTime", getHandlingCompletionTime())
            .append("handlingDuration", getHandlingDuration())
            .append("handlingDurationFormatted", getHandlingDurationFormatted())
            .append("remarks", getRemarks())
            .toString();
    }
}
