package com.zy.asrs.common.domain.dto; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.common.wms.entity.LocDetl; import com.zy.asrs.common.wms.service.LocDetlService; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.common.SpringUtils; import com.zy.asrs.framework.exception.CoolException; import lombok.Data; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Created by vincent on 2020/6/17 */ @Data public class OutLocDto { private String locNo; private Long hostId; private List locDetlDtos = new ArrayList<>(); public OutLocDto() { } public OutLocDto(String locNo, LocDetlDto locDetlDto, Long hostId) { this.locNo = locNo; this.locDetlDtos.add(locDetlDto); this.hostId = hostId; } public boolean isAll(){ List locDetlDtosCp = new ArrayList<>(this.locDetlDtos); // 查询当前库位号所有的库存明细 LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); List locDetls = locDetlService.list(new LambdaQueryWrapper().eq(LocDetl::getLocNo, this.locNo).eq(LocDetl::getHostId, this.hostId)); if (locDetls == null || locDetls.isEmpty()){ throw new CoolException("检索库存明细失败,库位号=" + this.locNo); } int sameNumber = 0; for (LocDetl locDetl : locDetls) { Iterator iterator = locDetlDtosCp.iterator(); while (iterator.hasNext()) { LocDetlDto next = iterator.next(); if (!next.getLocDetl().getMatnr().equals(locDetl.getMatnr())) { continue; } if (!Cools.eq(next.getLocDetl().getBatch(), locDetl.getBatch())) { continue; } if (next.getCount() > locDetl.getAnfme()) { throw new CoolException("服务器内部错误"); } if (next.getCount().equals(locDetl.getAnfme())) { sameNumber++; iterator.remove(); break; } } } return sameNumber == locDetls.size(); } }