package com.zksy.dispatch.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 应急事件统一档案（全生命周期主表）
 * 状态机：待受理 -> 待核实 -> 已核实 -> 处置中 -> 已解除 -> 已关闭；不实事件为终止态
 * 各环节业务表（接报/核实/转接/催办/跟踪）通过 eventId 挂靠本表，形成业务闭环
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "dis_event", schema = "app_user")
public class DisEvent {

    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty("主键ID")
    private Long id;

    @ApiModelProperty("事件编号（SJ+yyyyMMddHHmmss 自动生成，全局唯一）")
    private String eventNo;

    @ApiModelProperty("事件名称")
    private String eventName;

    @ApiModelProperty("事件类型：排水/供水/燃气/其他")
    private String eventType;

    @ApiModelProperty("事件类别：管道泄漏/塌陷/积水/设备故障")
    private String category;

    @ApiModelProperty("事件等级：一般/较大/重大/特别重大")
    @TableField("\"level\"")
    private String level;

    @ApiModelProperty("发生地点")
    private String location;

    @ApiModelProperty("发生区域：城南/城北/太常")
    private String region;

    @ApiModelProperty("事件描述")
    private String description;

    @ApiModelProperty("事件来源：巡查上报/呼叫中心/视频监控/上级下达")
    private String source;

    @ApiModelProperty("来源渠道")
    private String channel;

    @ApiModelProperty("接报人")
    private String reporter;

    @ApiModelProperty("接报时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime reportTime;

    @ApiModelProperty("发生时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime happenTime;

    @ApiModelProperty("初判时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime judgeTime;

    @ApiModelProperty("核实人")
    private String verifier;

    @ApiModelProperty("核实时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime verifyTime;

    @ApiModelProperty("核实意见")
    private String verifyOpinion;

    @ApiModelProperty("责任单位（转接部门/责任部门）")
    private String department;

    @ApiModelProperty("处置负责人")
    private String handler;

    @ApiModelProperty("应用预案ID（关联 dis_plan_library）")
    private Long planId;

    @ApiModelProperty("应用预案名称")
    private String planName;

    @ApiModelProperty("直接经济损失(万元)")
    private BigDecimal lossAmount;

    @ApiModelProperty("事件状态：待受理/待核实/已核实/处置中/已解除/已关闭/不实事件")
    private String status;

    @ApiModelProperty("关闭原因：事件不存在/处置完成/误报")
    private String closeReason;

    @ApiModelProperty("关闭说明")
    private String closeRemark;

    @ApiModelProperty("关闭时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime closeTime;

    @TableField(exist = false)
    @ApiModelProperty("是否真实（核实入参：真实/不实，不落库）")
    private String isReal;

    @ApiModelProperty("创建人")
    private String createBy;

    @ApiModelProperty("更新人")
    private String updateBy;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;

    @TableLogic(value = "0", delval = "2")
    @ApiModelProperty("删除标志（0=正常 2=删除）")
    private String delFlag;
}
