|
|
@ -107,16 +107,38 @@ public class InvProductServiceImpl implements InvProductService {
|
|
|
|
relIdFkSet.add(invProductResponse.getRelIdFk());
|
|
|
|
relIdFkSet.add(invProductResponse.getRelIdFk());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//按照产品批次分组
|
|
|
|
|
|
|
|
Set<String> batchNoSet = new HashSet<>();
|
|
|
|
|
|
|
|
data.forEach(invProductResponse -> {
|
|
|
|
|
|
|
|
batchNoSet.add(invProductResponse.getBatchNo());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<InvProductResponse> result = new ArrayList<>();
|
|
|
|
List<InvProductResponse> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
for (String relIdFk : relIdFkSet) {
|
|
|
|
for (String relIdFk : relIdFkSet) {
|
|
|
|
InvProductResponse invProductResponse = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).collect(Collectors.toList()).get(0);
|
|
|
|
if (CollUtil.isNotEmpty(batchNoSet)) {
|
|
|
|
int inCount = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).mapToInt(InvProductResponse::getInCount).sum();
|
|
|
|
for (String batchNo : batchNoSet) {
|
|
|
|
int outCount = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).mapToInt(InvProductResponse::getOutCount).sum();
|
|
|
|
List<InvProductResponse> list = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).filter(product -> product.getBatchNo().equals(batchNo)).collect(Collectors.toList());
|
|
|
|
invProductResponse.setInCount(inCount);
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
invProductResponse.setOutCount(outCount);
|
|
|
|
InvProductResponse invProductResponse = list.get(0);
|
|
|
|
invProductResponse.setReCount(inCount - outCount);
|
|
|
|
int inCount = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).filter(product -> product.getBatchNo().equals(batchNo)).mapToInt(InvProductResponse::getInCount).sum();
|
|
|
|
result.add(invProductResponse);
|
|
|
|
int outCount = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).filter(product -> product.getBatchNo().equals(batchNo)).mapToInt(InvProductResponse::getOutCount).sum();
|
|
|
|
|
|
|
|
invProductResponse.setInCount(inCount);
|
|
|
|
|
|
|
|
invProductResponse.setOutCount(outCount);
|
|
|
|
|
|
|
|
invProductResponse.setReCount(inCount - outCount);
|
|
|
|
|
|
|
|
result.add(invProductResponse);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
InvProductResponse invProductResponse = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).collect(Collectors.toList()).get(0);
|
|
|
|
|
|
|
|
int inCount = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).mapToInt(InvProductResponse::getInCount).sum();
|
|
|
|
|
|
|
|
int outCount = data.stream().filter(product -> product.getRelIdFk().equals(relIdFk)).mapToInt(InvProductResponse::getOutCount).sum();
|
|
|
|
|
|
|
|
invProductResponse.setInCount(inCount);
|
|
|
|
|
|
|
|
invProductResponse.setOutCount(outCount);
|
|
|
|
|
|
|
|
invProductResponse.setReCount(inCount - outCount);
|
|
|
|
|
|
|
|
result.add(invProductResponse);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|