package com.qqchen.deploy.backend.deploy.dto;

import com.qqchen.deploy.backend.deploy.enums.DeployRecordStatusEnums;
import com.qqchen.deploy.backend.workflow.dto.WorkflowNodeInstanceDTO;
import com.qqchen.deploy.backend.workflow.dto.definition.workflow.WorkflowDefinitionGraph;
import com.qqchen.deploy.backend.workflow.enums.WorkflowInstanceStatusEnums;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 部署记录流程图DTO
 * 用于前端展示部署工作流的流程图和节点状态
 *
 * @author qqchen
 * @since 2025-11-04
 */
@Data
@Schema(description = "部署记录流程图信息")
public class DeployRecordFlowGraphDTO {

    // ============ 部署记录基本信息 ============
    
    @Schema(description = "部署记录ID")
    private Long deployRecordId;

    @Schema(description = "业务标识（UUID）")
    private String businessKey;

    @Schema(description = "部署状态")
    private DeployRecordStatusEnums deployStatus;

    @Schema(description = "部署人")
    private String deployBy;

    @Schema(description = "部署备注")
    private String deployRemark;

    @Schema(description = "部署开始时间")
    private LocalDateTime deployStartTime;

    @Schema(description = "部署结束时间")
    private LocalDateTime deployEndTime;

    @Schema(description = "部署总时长（毫秒）")
    private Long deployDuration;

    // ============ 业务上下文信息 ============

    @Schema(description = "应用名称")
    private String applicationName;

    @Schema(description = "应用编码")
    private String applicationCode;

    @Schema(description = "环境名称")
    private String environmentName;

    @Schema(description = "团队名称")
    private String teamName;

    // ============ 工作流实例信息 ============

    @Schema(description = "工作流实例ID")
    private Long workflowInstanceId;

    @Schema(description = "流程实例ID（Flowable）")
    private String processInstanceId;

    @Schema(description = "工作流实例状态")
    private WorkflowInstanceStatusEnums workflowStatus;

    @Schema(description = "工作流开始时间")
    private LocalDateTime workflowStartTime;

    @Schema(description = "工作流结束时间")
    private LocalDateTime workflowEndTime;

    @Schema(description = "工作流总时长（毫秒）")
    private Long workflowDuration;

    // ============ 执行统计信息 ============

    @Schema(description = "总节点数")
    private Integer totalNodeCount;

    @Schema(description = "已执行节点数")
    private Integer executedNodeCount;

    @Schema(description = "成功节点数")
    private Integer successNodeCount;

    @Schema(description = "失败节点数")
    private Integer failedNodeCount;

    @Schema(description = "运行中节点数")
    private Integer runningNodeCount;

    // ============ 流程图数据 ============

    @Schema(description = "流程图数据（画布快照，包含节点和边的位置信息）")
    private WorkflowDefinitionGraph graph;

    @Schema(description = "节点执行状态列表（用于标记每个节点的执行状态，包含已执行和未执行节点）")
    private List<WorkflowNodeInstanceDTO> nodeInstances;

}

