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.*;
|
|
/**
|
* Created by vincent on 2022/3/28
|
*/
|
@Data
|
public class TaskDto {
|
|
private String locNo;
|
|
private Integer staNo;
|
private List<LocDetlDto> locDetlDtos = new ArrayList<>();
|
|
private List<LocDto> locDtos;
|
|
{
|
locDtos = new ArrayList<>();
|
}
|
|
public TaskDto(String locNo, Integer staNo) {
|
this.locNo = locNo;
|
this.staNo = staNo;
|
}
|
|
public TaskDto(String locNo, Integer staNo, LocDto locDto) {
|
this.locNo = locNo;
|
this.staNo = staNo;
|
this.locDtos.add(locDto);
|
}
|
|
public TaskDto(String locNo, Integer staNo, List<LocDto> locDtos) {
|
this.locNo = locNo;
|
this.staNo = staNo;
|
this.locDtos = locDtos;
|
}
|
|
public static boolean has(List<TaskDto> list, TaskDto dto) {
|
if (Cools.isEmpty(list)) {
|
return false;
|
}
|
for (TaskDto taskDto : list) {
|
if (dto.getLocNo().equals(taskDto.getLocNo()) && taskDto.getStaNo().equals(dto.getStaNo())) {
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public static TaskDto find(List<TaskDto> list, TaskDto dto) {
|
if (Cools.isEmpty(list)) {
|
return null;
|
}
|
for (TaskDto taskDto : list) {
|
if (dto.getLocNo().equals(taskDto.getLocNo()) && taskDto.getStaNo().equals(dto.getStaNo())) {
|
return taskDto;
|
}
|
}
|
return null;
|
}
|
|
// public boolean isAll(){
|
// // 汇总不考虑序列码
|
// List<DetlDto> detlDtos = new ArrayList<>();
|
// for (LocDto locDto : this.getLocDtos()) {
|
// DetlDto dto = new DetlDto(locDto);
|
// if (DetlDto.has(detlDtos, dto)) {
|
// DetlDto detlDto = DetlDto.find(detlDtos, locDto);
|
// assert detlDto != null;
|
// detlDto.setAnfme(detlDto.getAnfme() + locDto.getAnfme());
|
// } else {
|
// detlDtos.add(new DetlDto(locDto));
|
// }
|
// }
|
//
|
// // 查询当前库位号所有的库存明细
|
// LocDetlService locDetlService = SpringUtils.getBean(LocDetlService.class);
|
// List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", this.locNo));
|
// if (locDetls == null || locDetls.isEmpty()){
|
// throw new CoolException("检索库存明细失败,库位号=" + this.locNo);
|
// }
|
// int sameNumber = 0;
|
// for (LocDetl locDetl : locDetls) {
|
// Iterator<DetlDto> iterator = detlDtos.iterator();
|
// while (iterator.hasNext()) {
|
// DetlDto dto = iterator.next();
|
// if (!dto.getMatnr().equals(locDetl.getMatnr())) {
|
// continue;
|
// }
|
// if (Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) {
|
// continue;
|
// }
|
// if (!Cools.isEmpty(dto.getBatch()) && Cools.isEmpty(locDetl.getBatch())) {
|
// continue;
|
// }
|
// if (!Cools.isEmpty(dto.getBatch()) && !Cools.isEmpty(locDetl.getBatch())) {
|
// if (!dto.getBatch().equals(locDetl.getBatch())) {
|
// continue;
|
// }
|
// }
|
// if (dto.getAnfme() > locDetl.getAnfme()) {
|
// throw new CoolException("服务器内部错误");
|
// }
|
// if (dto.getAnfme().equals(locDetl.getAnfme())) {
|
// sameNumber++;
|
// iterator.remove();
|
// break;
|
// }
|
// }
|
// }
|
// return sameNumber == locDetls.size();
|
// }
|
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()){
|
throw new CoolException("检索库存明细失败,库位号=" + this.locNo);
|
}
|
int sameNumber = 0;
|
for (LocDetl locDetl : locDetls) {
|
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 (next.getCount() > locDetl.getAnfme()) {
|
throw new CoolException("服务器内部错误");
|
}
|
if (next.getCount().equals(locDetl.getAnfme())) {
|
sameNumber++;
|
iterator.remove();
|
break;
|
}
|
}
|
}
|
return sameNumber == locDetls.size();
|
}
|
|
}
|