| | |
| | | package com.zy.common.model; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/6/17 |
| | | */ |
| | | @Data |
| | | public class OutLocDto { |
| | | |
| | | private String locNo; |
| | | |
| | | private List<LocDetlDto> locDetlDtos; |
| | | private List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | |
| | | public OutLocDto() { |
| | | } |
| | | |
| | | public OutLocDto(String locNo, List<LocDetlDto> locDetlDtos) { |
| | | public OutLocDto(String locNo, LocDetlDto locDetlDto) { |
| | | this.locNo = locNo; |
| | | this.locDetlDtos = locDetlDtos; |
| | | } |
| | | |
| | | public String getLocNo() { |
| | | return locNo; |
| | | } |
| | | |
| | | public void setLocNo(String locNo) { |
| | | this.locNo = locNo; |
| | | } |
| | | |
| | | public List<LocDetlDto> getLocDetlDtos() { |
| | | return locDetlDtos; |
| | | } |
| | | |
| | | public void setLocDetlDtos(List<LocDetlDto> locDetlDtos) { |
| | | this.locDetlDtos = locDetlDtos; |
| | | this.locDetlDtos.add(locDetlDto); |
| | | } |
| | | |
| | | public boolean isAll(){ |
| | | List<LocDetlDto> locDetlDtosCp = new ArrayList<>(this.locDetlDtos); |
| | | // 查询当前库位号所有的库存明细 |
| | | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", this.locNo)); |
| | | if (locDetls == null || locDetls.isEmpty()){ |
| | | return true; |
| | | throw new CoolException("检索库存明细失败,库位号=" + this.locNo); |
| | | } |
| | | int sameNumber = 0; |
| | | for (LocDetl locDetl : locDetls) { |
| | | for (LocDetlDto dto : this.locDetlDtos) { |
| | | if (dto.getLocDetl().getMatnr().equals(locDetl.getMatnr()) && dto.getCount().equals(locDetl.getAnfme())) { |
| | | Iterator<LocDetlDto> 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(!Cools.eq(next.getLocDetl().getSuppCode(),locDetl.getSuppCode())){ |
| | | continue; |
| | | } |
| | | if(!Cools.eq(next.getLocDetl().getThreeCode(),locDetl.getThreeCode())){ |
| | | continue; |
| | | } |
| | | if(!Cools.eq(next.getLocDetl().getDeadTime(),locDetl.getDeadTime())){ |
| | | continue; |
| | | } |
| | | if (next.getCount() > locDetl.getAnfme()) { |
| | | throw new CoolException("服务器内部错误"); |
| | | } |
| | | if (next.getCount().equals(locDetl.getAnfme())) { |
| | | sameNumber++; |
| | | iterator.remove(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | return sameNumber == locDetls.size(); |
| | | } |
| | | |
| | | public void sortLocDetlDtos() { |
| | | ArrayList<LocDetlDto> list = new ArrayList<>(); |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_no", locNo); |
| | | LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | List<LocDetl> locDetls = locDetlService.selectList(wrapper); |
| | | for (LocDetl locDetl : locDetls) { |
| | | boolean flag = true; |
| | | for (LocDetlDto locDetlDto : locDetlDtos) { |
| | | LocDetl detl = locDetlDto.getLocDetl(); |
| | | if (!Cools.isEmpty(locDetl.getMatnr())) { |
| | | if (!locDetl.getMatnr().equals(detl.getMatnr())) { |
| | | continue; |
| | | } |
| | | } |
| | | if (!Cools.isEmpty(locDetl.getBatch())) { |
| | | if (!locDetl.getBatch().equals(detl.getBatch())) { |
| | | continue; |
| | | } |
| | | } |
| | | if (!Cools.isEmpty(locDetl.getSuppCode())) { |
| | | if (!locDetl.getSuppCode().equals(detl.getSuppCode())) { |
| | | continue; |
| | | } |
| | | } |
| | | flag = false; |
| | | break; |
| | | } |
| | | |
| | | if (flag) { |
| | | LocDetlDto dto = new LocDetlDto(locDetl, 0D); |
| | | list.add(dto); |
| | | } |
| | | } |
| | | |
| | | locDetlDtos.addAll(list); |
| | | // ArrayList<String> matnr = new ArrayList<>(); |
| | | // ArrayList<String> batch = new ArrayList<>(); |
| | | // ArrayList<String> suppCode = new ArrayList<>(); |
| | | // for (LocDetlDto locDetlDto : locDetlDtos) { |
| | | // LocDetl locDetl = locDetlDto.getLocDetl(); |
| | | // if (!Cools.isEmpty(locDetl.getMatnr())) { |
| | | // matnr.add(locDetl.getMatnr()); |
| | | // } |
| | | // if (!Cools.isEmpty(locDetl.getBatch())) { |
| | | // batch.add(locDetl.getBatch()); |
| | | // } |
| | | // if (!Cools.isEmpty(locDetl.getSuppCode())) { |
| | | // suppCode.add(locDetl.getSuppCode()); |
| | | // } |
| | | // } |
| | | // |
| | | // EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | // wrapper.eq("loc_no", locNo); |
| | | // wrapper.notIn("matnr", matnr); |
| | | // wrapper.notIn("batch", batch); |
| | | // wrapper.notIn("supp_code", suppCode); |
| | | // LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class); |
| | | // List<LocDetl> locDetls = locDetlService.selectList(wrapper); |
| | | // for (LocDetl locDetl : locDetls) { |
| | | // LocDetlDto dto = new LocDetlDto(locDetl, 0D); |
| | | // locDetlDtos.add(dto); |
| | | // } |
| | | } |
| | | |
| | | } |