package cn.estsh.i3plus.ext.mes.pcn.pojo.model;

import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import io.swagger.annotations.ApiParam;
import lombok.Data;

import java.util.List;
import java.util.Objects;

/**
 * @Description :
 * @Reference :
 * @Author :
 * @CreateDate : 2024-04-26 15:44
 * @Modify:
 **/
@Data
public class MesSortShippingCheckModel {

    @ApiParam("操作人")
    private String userInfo;

    @ApiParam("组织代码")
    private String organizeCode;

    @ApiParam("发运单号")
    private String shippingCode;
    @ApiParam("最近扫描完成的装车单号")
    private String recentlyScanShippingCode;
    @ApiParam("条码")
    private String sn;
    @ApiParam("位置码")
    private String locationCode;
    @ApiParam("跳过")
    private Integer isPass;

    @ApiParam("已扫描数量")
    private Integer isScanCount = 0;

    @ApiParam("是否需要扫描槽位码")
    private Boolean isScanLocationCode = false;

    @ApiParam("发运组明细数据")
    private List<MesShippingOrderManagementDetail> detailList;

    @ApiParam("发运组")
    private MesPartShippingGroup mesPartShippingGroup;

    @ApiParam("最后扫描的发运单明细ID")
    private Long lastShippingDetailId;

    @ApiParam("提示引导信息")
    private String msg;

    @ApiParam("发运单顺序号")
    private Long shippingSeq;

    @ApiParam("料架条码")
    private String volvoRackNo;

    @ApiParam("待发运列表")
    private List<MesSortShippingListModel> sortShippingListModelList;

    @ApiParam("是否为二次发运")
    private Boolean secondShipping;

    public void setDetailList(List<MesShippingOrderManagementDetail> detailList) {
        this.detailList = detailList;
        this.isScanCount = (int) detailList.stream().filter(k -> Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).count();
    }

    public MesSortShippingCheckModel() {}

    public MesSortShippingCheckModel(String organizeCode) {
        this.organizeCode = organizeCode;
    }
}
