package com.hys.app.model.erp.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hys.app.framework.exception.ServiceException;
import com.hys.app.model.erp.dos.WarehouseDO;
import com.hys.app.model.erp.dos.WarehouseEntryBatchDO;
import com.hys.app.model.system.dos.AdminUser;
import com.hys.app.model.system.dos.DeptDO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.AssertFalse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 库存调拨新增/编辑DTO
 *
 * @author 张崧
 * @since 2023-12-12 11:59:06
 */
@Data
public class StockTransferDTO {

    @ApiModelProperty(hidden = true)
    private String id;

    @ApiModelProperty(name = "out_warehouse_id", value = "调出方仓库id")
    @NotNull(message = "调出方仓库id不能为空")
    private Long outWarehouseId;

    @ApiModelProperty(name = "in_warehouse_id", value = "调入方仓库id")
    @NotNull(message = "调入方仓库id不能为空")
    private Long inWarehouseId;

    @ApiModelProperty(name = "attachment", value = "附件")
    private String attachment;

    @ApiModelProperty(name = "transfer_time", value = "调拨时间")
    @NotNull(message = "调拨时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date transferTime;

    @ApiModelProperty(name = "product_list", value = "商品列表")
    @NotEmpty(message = "商品列表不能为空")
    @Valid
    private List<StockTransferProductDTO> productList;

    @AssertFalse(message = "调出方仓库和调入方仓库不能相同")
    public   Boolean isSameWarehouse() {
        if (outWarehouseId.equals(inWarehouseId)){
            throw new ServiceException("调出方仓库和调入方仓库不能相同");
        }
        return true;

    }
    @ApiModelProperty(name = "备注", value = "remark")
    private String  remark;

    @ApiModelProperty(name = "配送方式", value = "send_type")
    private Long  sendType;

}

