package com.evobms.project.iot.domain.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@ApiModel(value = "OtaProgressResultDTO", description = "OTA进度查询结果（用于进度条）")
@Data
public class OtaProgressResultDTO {

    @ApiModelProperty(value = "状态码", example = "200")
    private Integer code;

    @ApiModelProperty(value = "是否成功，1成功/0失败", example = "1")
    private String success;

    @ApiModelProperty(value = "提示信息", example = "success")
    private String msg;

    @ApiModelProperty(value = "设备SN", example = "137PBP1M11001AFCF0000007")
    private String sn;

    @ApiModelProperty(value = "设备ID（平台侧deviceId）", example = "BAT_001")
    private String deviceId;

    @ApiModelProperty(value = "目标固件版本", example = "v1.0.3")
    private String firmwareVersion;

    @ApiModelProperty(value = "任务状态", example = "IN_PROGRESS")
    private String status;

    @ApiModelProperty(value = "进度(0-100)", example = "30")
    private Long progress;

    /** 与设备登录接口返回的 count、GET /iot/ota/meta 的 chunks 同一口径（按固件字节与 ota.chunk-size 计算） */
    @ApiModelProperty(value = "OTA 分片总数（与设备侧 count 对齐；服务端根据仓库内固件计算，缺文件时为 null）", example = "120")
    private Integer totalChunks;

    /**
     * 基于当前任务的 progress 与 totalChunks 推算的已拉取分片数（与 downloadOtaChunk 中按片更新 progress 的规则一致；取整误差 ±1 片属正常）。
     * 任务状态为 DONE 等终态成功时置为 totalChunks。
     */
    @ApiModelProperty(value = "推算的已下载分片数（来自 progress×totalChunks，仅供展示；无 totalChunks 时为 null）", example = "54")
    private Integer downloadedChunks;

    @ApiModelProperty(value = "单分片字节数（与 ota.chunk-size 一致）", example = "1024")
    private Integer chunkSize;

    @ApiModelProperty(value = "开始时间")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    private Date endTime;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
}
