|
@ -1,34 +1,34 @@ |
|
|
package org.nl.wms.database.eas.service.impl; |
|
|
package org.nl.wms.database.eas.service.impl; |
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.nl.common.base.CommonPage; |
|
|
import org.nl.common.exception.BadRequestException; |
|
|
import org.nl.common.exception.BadRequestException; |
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
import org.nl.wms.database.eas.dao.*; |
|
|
import org.nl.wms.database.eas.dao.EasOutInBillDetail; |
|
|
import org.nl.wms.database.eas.dto.*; |
|
|
import org.nl.wms.database.eas.dao.InventoryInfo; |
|
|
import org.nl.wms.database.eas.dao.mapper.EasOutInBillDetailMapper; |
|
|
import org.nl.wms.database.eas.dao.mapper.EasOutInBillDetailMapper; |
|
|
|
|
|
import org.nl.wms.database.eas.dto.EasOutInBillDetailVO; |
|
|
import org.nl.wms.database.eas.service.IeasOutInBillDetailService; |
|
|
import org.nl.wms.database.eas.service.IeasOutInBillDetailService; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
import org.nl.wms.database.eas.service.IeasOutInBillService; |
|
|
import org.nl.wms.database.eas.service.IeasOutInBillService; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
|
|
|
|
import org.nl.common.base.CommonPage; |
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.*; |
|
|
import java.util.List; |
|
|
import java.util.concurrent.CompletableFuture; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
import java.util.Set; |
|
|
import java.util.function.Function; |
|
|
import java.util.function.Function; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -64,53 +64,64 @@ public class EasOutInBillDetailServiceImpl extends ServiceImpl<EasOutInBillDetai |
|
|
.eq(ObjectUtil.isNotEmpty(params), EasOutInBillDetail::getDjid, params.getDjid()) |
|
|
.eq(ObjectUtil.isNotEmpty(params), EasOutInBillDetail::getDjid, params.getDjid()) |
|
|
); |
|
|
); |
|
|
List<EasOutInBillDetail> easOutInBillDetailList = result.getRecords(); |
|
|
List<EasOutInBillDetail> easOutInBillDetailList = result.getRecords(); |
|
|
List<InventoryInfo> inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList); |
|
|
for (int i = 0; i < easOutInBillDetailList.size(); i++) { |
|
|
|
|
|
long se = 10L; |
|
|
|
|
|
easOutInBillDetailList.get(i).setKcsl(BigDecimal.valueOf(se + i * 10L)); |
|
|
|
|
|
} |
|
|
|
|
|
//计算相同物料编码的总数
|
|
|
|
|
|
Map<String, Double> totalQty = easOutInBillDetailList.stream() |
|
|
|
|
|
.collect(Collectors.groupingBy(EasOutInBillDetail::getWlbm, Collectors.summingDouble(bill -> bill.getSl().doubleValue()))); |
|
|
easOutInBillDetailList.forEach(bill -> { |
|
|
easOutInBillDetailList.forEach(bill -> { |
|
|
//查询库存信息
|
|
|
//设置物料总数
|
|
|
List<InventoryInfo> matchedInventory = inventoryInfoList.stream() |
|
|
bill.setWlzs(totalQty.get(bill.getWlbm())); |
|
|
.filter(inventory -> { |
|
|
|
|
|
boolean isMatched = true; |
|
|
|
|
|
//去向部门
|
|
|
|
|
|
if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) { |
|
|
|
|
|
isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm()); |
|
|
|
|
|
} |
|
|
|
|
|
//仓库编码
|
|
|
|
|
|
if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) { |
|
|
|
|
|
isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm()); |
|
|
|
|
|
} |
|
|
|
|
|
//库位编码
|
|
|
|
|
|
if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) { |
|
|
|
|
|
isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//物料编码
|
|
|
|
|
|
if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) { |
|
|
|
|
|
isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm()); |
|
|
|
|
|
} |
|
|
|
|
|
// 批次
|
|
|
|
|
|
if (bill.getPc() != null && !bill.getPc().isEmpty()) { |
|
|
|
|
|
isMatched = Objects.equals(inventory.getPc(), bill.getPc()); |
|
|
|
|
|
} |
|
|
|
|
|
// 跟踪号
|
|
|
|
|
|
if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) { |
|
|
|
|
|
isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno()); |
|
|
|
|
|
} |
|
|
|
|
|
return isMatched; |
|
|
|
|
|
}) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
// List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
|
|
|
|
|
|
// .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm())
|
|
|
|
|
|
// && Objects.equals(inventory.getCkbm(), bill.getCkbm())
|
|
|
|
|
|
// && Objects.equals(inventory.getWlbm(), bill.getWlbm())
|
|
|
|
|
|
// && Objects.equals(inventory.getPc(), bill.getPc())
|
|
|
|
|
|
// && Objects.equals(inventory.getTrackno(), bill.getTrackno())
|
|
|
|
|
|
// && Objects.equals(inventory.getKwbm(), bill.getKwbm()))
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
Optional<InventoryInfo> minKcsl = matchedInventory.stream() |
|
|
|
|
|
.filter(r -> r.getUnitno().equals(bill.getJldw())) |
|
|
|
|
|
.min(Comparator.comparing(InventoryInfo::getKcsl)); |
|
|
|
|
|
minKcsl.ifPresent(m -> bill.setKcsl(m.getKcsl())); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
// List<InventoryInfo> inventoryInfoList = queryInventoryInfoList(easOutInBillDetailList);
|
|
|
|
|
|
// easOutInBillDetailList.forEach(bill -> {
|
|
|
|
|
|
// //查询库存信息
|
|
|
|
|
|
// List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
|
|
|
|
|
|
// .filter(inventory -> {
|
|
|
|
|
|
// boolean isMatched = true;
|
|
|
|
|
|
// //去向部门
|
|
|
|
|
|
// if (bill.getZzbm() != null && !bill.getZzbm().isEmpty()) {
|
|
|
|
|
|
// isMatched = Objects.equals(inventory.getZzbm(), bill.getZzbm());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// //仓库编码
|
|
|
|
|
|
// if (bill.getCkbm() != null && !bill.getCkbm().isEmpty()) {
|
|
|
|
|
|
// isMatched = Objects.equals(inventory.getCkbm(), bill.getCkbm());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// //库位编码
|
|
|
|
|
|
// if (bill.getTjkwbm() != null && !bill.getTjkwbm().isEmpty()) {
|
|
|
|
|
|
// isMatched = Objects.equals(inventory.getTjkwbm(), bill.getTjkwbm());
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// //物料编码
|
|
|
|
|
|
// if (bill.getWlbm() != null && !bill.getWlbm().isEmpty()) {
|
|
|
|
|
|
// isMatched = Objects.equals(inventory.getWlbm(), bill.getWlbm());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 批次
|
|
|
|
|
|
// if (bill.getPc() != null && !bill.getPc().isEmpty()) {
|
|
|
|
|
|
// isMatched = Objects.equals(inventory.getPc(), bill.getPc());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 跟踪号
|
|
|
|
|
|
// if (bill.getTrackno() != null && !bill.getTrackno().isEmpty()) {
|
|
|
|
|
|
// isMatched = Objects.equals(inventory.getTrackno(), bill.getTrackno());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return isMatched;
|
|
|
|
|
|
// })
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
// List<InventoryInfo> matchedInventory = inventoryInfoList.stream()
|
|
|
|
|
|
// .filter(inventory -> Objects.equals(inventory.getZzbm(), bill.getZzbm())
|
|
|
|
|
|
// && Objects.equals(inventory.getCkbm(), bill.getCkbm())
|
|
|
|
|
|
// && Objects.equals(inventory.getWlbm(), bill.getWlbm())
|
|
|
|
|
|
// && Objects.equals(inventory.getPc(), bill.getPc())
|
|
|
|
|
|
// && Objects.equals(inventory.getTrackno(), bill.getTrackno())
|
|
|
|
|
|
// && Objects.equals(inventory.getKwbm(), bill.getKwbm()))
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
// Optional<InventoryInfo> minKcsl = matchedInventory.stream()
|
|
|
|
|
|
// .filter(r -> r.getUnitno().equals(bill.getJldw()))
|
|
|
|
|
|
// .min(Comparator.comparing(InventoryInfo::getKcsl));
|
|
|
|
|
|
// minKcsl.ifPresent(m -> bill.setKcsl(m.getKcsl()));
|
|
|
|
|
|
// });
|
|
|
result.setRecords(easOutInBillDetailList); |
|
|
result.setRecords(easOutInBillDetailList); |
|
|
return CommonPage.getPage(result); |
|
|
return CommonPage.getPage(result); |
|
|
} |
|
|
} |
|
|