/**
 * @ProjectName: 智慧评标-主观分助手
 * @Package: com.zhpb.gdyd_zhpb_zgf.dto
 * @ClassName: FileUploadResponse
 * @Description: 文件上传响应DTO，包含上传结果、文件路径列表和按公司、文件类型整理后的文件列表
 * @Author: 张志锋
 * @Date: 2025-10-31
 * @Version: 1.0
 * @Copyright: © 2025 智慧评标-主观分助手
 */
package com.zhpb.gdyd_zhpb_zgf.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

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

/**
 * 文件上传响应DTO
 */
@Data
@Schema(description = "文件上传响应")
public class FileUploadResponse {

    @Schema(description = "响应状态码，0表示成功", example = "0")
    private Integer code;

    @Schema(description = "响应消息", example = "上传成功")
    private String message;

    @Schema(description = "响应数据")
    private FileUploadData data;

    @Data
    @Schema(description = "文件上传响应数据")
    public static class FileUploadData {
        @Schema(description = "项目ID", example = "project-001")
        private String projectId;

        @Schema(description = "原始ZIP文件路径", example = "./uploads/project-001/file.zip")
        private String zipFilePath;

        @Schema(description = "解压路径", example = "./extracts/project-001/")
        private String extractPath;

        @Schema(description = "解压后的文件路径列表", example = "[\"./extracts/project-001/file1.pdf\", \"./extracts/project-001/file2.doc\"]")
        private List<String> extractedFilePaths;

        @Schema(description = "文件数量", example = "5")
        private Integer fileCount;

        @Schema(description = "按公司和文件类型整理后的文件列表", example = "{\"公司1\": {\"技术文件\": [\"...\"], \"商务文件\": [...]}}")
        private Map<String, Map<String, List<String>>> organizedFiles;
    }

    /**
     * 文件向量化状态
     */
    @Data
    @Schema(description = "文件向量化状态信息")
    public static class VectorizationStatus {
        @Schema(description = "文件ID", example = "550e8400-e29b-41d4-a716-446655440000")
        private String fileId;

        @Schema(description = "文件名", example = "技术方案.pdf")
        private String fileName;

        @Schema(description = "项目ID", example = "project-001")
        private String projectId;

        @Schema(description = "向量化状态", example = "completed", allowableValues = {"not_started", "processing", "completed", "failed"})
        private String vectorizationStatus;

        @Schema(description = "是否已向量化", example = "true")
        private Boolean isVectorized;

        @Schema(description = "向量化数据条数", example = "150")
        private Integer vectorizationCount;

        @Schema(description = "向量化完成时间", example = "2025-11-03T15:30:00")
        private LocalDateTime vectorizedTime;

        @Schema(description = "文件扩展名", example = "pdf")
        private String fileExtension;

        @Schema(description = "文件大小（字节）", example = "2048576")
        private Long fileSize;
    }

    /**
     * 向量化状态统计
     */
    @Data
    @Schema(description = "向量化状态统计信息")
    public static class VectorizationStats {
        @Schema(description = "总文件数", example = "25")
        private int totalFiles;

        @Schema(description = "已完成向量化文件数", example = "20")
        private int completedFiles;

        @Schema(description = "正在处理的文件数", example = "2")
        private int processingFiles;

        @Schema(description = "向量化失败的文件数", example = "1")
        private int failedFiles;

        @Schema(description = "未开始向化的文件数", example = "2")
        private int notStartedFiles;

        @Schema(description = "向量化完成率", example = "0.8")
        private double completionRate;

        @Schema(description = "最近的文件列表")
        private List<VectorizationStatus> recentFiles;
    }

    /**
     * 供应商信息
     */
    @Data
    @Schema(description = "供应商基本信息")
    public static class SupplierInfo {
        @Schema(description = "供应商ID", example = "supplier-001")
        private String supplierId;

        @Schema(description = "供应商名称", example = "彩讯科技股份有限公司")
        private String supplierName;

        @Schema(description = "供应商代码", example = "CXKJ")
        private String supplierCode;

        @Schema(description = "供应商类型", example = "企业")
        private String supplierType;

        @Schema(description = "联系人", example = "张三")
        private String contactPerson;

        @Schema(description = "联系电话", example = "13800138000")
        private String contactPhone;

        @Schema(description = "联系邮箱", example = "contact@company.com")
        private String contactEmail;

        @Schema(description = "供应商地址", example = "北京市朝阳区")
        private String address;

        @Schema(description = "供应商状态", example = "active")
        private String status;
    }

    /**
     * 项目供应商和文件信息（简化格式）
     */
    @Data
    @Schema(description = "项目供应商和文件信息（供应商为键，文件列表为值）")
    public static class ProjectSuppliersAndFilesSimple {
        @Schema(description = "供应商列表")
        private List<SupplierInfo> 供应商;

        // 动态字段：供应商名称 -> 文件列表
        // 使用Map来存储供应商名称和对应的文件列表
    }

    /**
     * 项目供应商和文件信息（完整格式）
     */
    @Data
    @Schema(description = "项目供应商和文件信息")
    public static class ProjectSuppliersAndFiles {
        @Schema(description = "项目ID", example = "project-001")
        private String projectId;

        @Schema(description = "项目名称", example = "智慧评标系统项目")
        private String projectName;

        @Schema(description = "供应商列表")
        private List<SupplierInfo> suppliers;

        @Schema(description = "文件列表")
        private List<VectorizationStatus> files;

        @Schema(description = "供应商文件分组")
        private Map<String, List<VectorizationStatus>> supplierFiles;
    }
}

