package com.cf.imes.module.executor.controller.admin.veneer.vo;

import cn.hutool.core.collection.CollUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * 贴皮分解请求参数。
 */
@Data
public class VeneerDecomposeCreateReqVO {

    @Schema(description = "订单ID列表；非空时按订单范围分解")
    private List<Long> orderIds;

    @Schema(description = "板材商品编码；orderIds为空时必填")
    private String goodsId;

    @Schema(description = "原板件编号列表", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "{veneer.decompose.plate.no.required}")
    private List<String> plateNos;

    @Schema(description = "A面贴皮库ID")
    @JsonProperty("aVeneerId")
    private Long aVeneerId;

    @Schema(description = "B面贴皮库ID")
    @JsonProperty("bVeneerId")
    private Long bVeneerId;

    @Schema(description = "外扩余量(mm)，默认10")
    @DecimalMin(value = "0", message = "{veneer.decompose.outer.margin.min}")
    private BigDecimal outerMargin = new BigDecimal("10");

    /**
     * 判断是否按订单入口提交。
     *
     * @return {@code true} 表示按订单范围分解，{@code false} 表示按板材范围分解
     */
    public boolean isByOrder() {
        return CollUtil.isNotEmpty(orderIds);
    }
}
