package com.wms_main.model.vo.wms;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.wms_main.model.po.TAppDbs;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * Dbs显示类
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DbsVo extends BaseImportVo {
    /**
     * 主键id
     */
    @JsonProperty(value = "dbsId")
    private String dbsId;
    /**
     * 工单
     */
    @JsonProperty(value = "workOrder")
    private String workOrder;
    /**
     * dbs原始未处理的零件号，成品号
     */
    @JsonProperty(value = "productIdOrigin")
    private String productIdOrigin;
    /**
     * 零件号，成品号
     */
    @JsonProperty(value = "productId")
    private String productId;
    /**
     * Test计划开始时间
     */
    @JsonProperty(value = "testPlanStartDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate testPlanStartDate;
    /**
     * Test计划完成时间
     */
    @JsonProperty(value = "testPlanFinishDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate testPlanFinishDate;
    /**
     * PNT计划开始时间
     */
    @JsonProperty(value = "pntPlanStartDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate pntPlanStartDate;
    /**
     * PNT计划完成时间
     */
    @JsonProperty(value = "pntPlanFinishDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate pntPlanFinishDate;
    /**
     * 计划产量/套
     */
    @JsonProperty(value = "planProduction")
    private Integer planProduction;
    /**
     * 设备名称
     */
    @JsonProperty(value = "equipmentName")
    private String equipmentName;
    /**
     * 班次
     */
    @JsonProperty(value = "workShift")
    private String workShift;
    /**
     * Family
     */
    @JsonProperty(value = "family")
    private String family;
    /**
     * Test No#
     */
    @JsonProperty(value = "testNo")
    private String testNo;
    /**
     * 状态
     */
    @JsonProperty(value = "dbsStatus")
    private Integer dbsStatus;
    /**
     * 工作站台
     */
    @JsonProperty(value = "workStand")
    private String workStand;
    /**
     * 实际工作日期
     */
    @JsonProperty(value = "realWorkDate")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate realWorkDate;
    /**
     * 完成时间
     */
    @JsonProperty(value = "finishTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime finishTime;
    /**
     * K料备注
     */
    @JsonProperty(value = "kittingRemark")
    private String kittingRemark;
    /**
     * 备注
     */
    @JsonProperty(value = "remark")
    private String remark;

    /**
     * 将PO转换为VO
     * @param po po
     * @return vo
     */
    public static DbsVo ofPo(TAppDbs po) {
        return new DbsVo(
                po.getDbsId(),
                po.getWorkOrder(),
                po.getProductIdOrigin(),
                po.getProductId(),
                po.getTestPlanStartDate(),
                po.getTestPlanFinishDate(),
                po.getPntPlanStartDate(),
                po.getPntPlanFinishDate(),
                po.getPlanProduction(),
                po.getEquipmentName(),
                po.getWorkShift(),
                po.getFamily(),
                po.getTestNo(),
                po.getDbsStatus(),
                po.getWorkStand(),
                po.getRealWorkDate(),
                po.getFinishTime(),
                po.getKittingRemark(),
                po.getRemark()
        );
    }
}
