package com.oqpo.api.web.dto.request.inoutmng;

import com.oqpo.api.entity.rtnmng.RtnProcInfoPtclEntity;
import com.oqpo.api.entity.stockmng.WhsProcInfoPtclEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class SaveRtnStockProcRequest {
    @NotBlank
    @ApiModelProperty(value = "CRUD")
    private String viewCd;

    @NotBlank
    @ApiModelProperty(value = "브랜드아이디") private String brandId;

    @NotBlank
    @ApiModelProperty(value = "반품창고아이디") private String rtnWhsId;

    @ApiModelProperty(value = "입고창고아이디") private String whsId;

    @ApiModelProperty(value = "매장창고 반품처리시 필수") private String storeId;
    //colCnfmDocFileNo
    @ApiModelProperty(value = "반품처리대상 리스트")
    private List<RtnStockProcDataList> gridInsertData;


    public List<RtnProcInfoPtclEntity> toCodeEntities(List<RtnStockProcDataList> gridData) {
        List<RtnProcInfoPtclEntity> entities = new ArrayList<>();
        if (gridData == null || gridData.size() == 0)
            return entities;

        gridData.forEach(x -> {
            RtnProcInfoPtclEntity entity = new RtnProcInfoPtclEntity();
            entity.setColPickUnqNo(x.getColPickUnqNo());
            entity.setColPickDtlNo(x.getColPickDtlNo());
            entity.setItemId(x.getItemId());
            entity.setColQty(x.getColQty());
            entities.add(entity);
        });
        return entities;
    }

    @Getter
    @Builder
    @AllArgsConstructor(access = AccessLevel.PROTECTED)
    static class RtnStockProcDataList {

        @NotBlank
        @ApiModelProperty(value = "수거서번호") private String colPickUnqNo;

        @NotBlank
        @ApiModelProperty(value = "수거서항번") private String colPickDtlNo;

        @ApiModelProperty(value = "품목아이디") private String itemId;

        @NotBlank
        @ApiModelProperty(value = "수거수량") private Integer colQty;


    }
}
