价格校验备份

test
anthonywj 1 year ago
parent d294d54d0c
commit c91f10609f

@ -540,9 +540,9 @@ public class IoCodeTempController extends BaseController {
if (StringUtils.isBlank(orderId) || orderEntity == null) {
String orderNo = gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix()), "yyyyMMdd"));
orderId = orderNo;
inBatch = orderNo.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length());
}
inBatch = orderId.substring((Constant.SCAN_ORDER + StrUtil.trimToEmpty(bussinessTypeEntity.getPrefix())).length());
List<IoCodeTempEntity> codeEnttitys = codeTempService.findByOrderId(orderId);
IoCodeTempEntity exitLocalEntity = null;
IoCodeTempEntity genDetaiEntity = new IoCodeTempEntity();
@ -762,7 +762,6 @@ public class IoCodeTempController extends BaseController {
return invRes;
}
}
codeEnttity.setPrice(udiRelevanceResponse.getPrice());
//是否边扫边校验
if (bussinessTypeEntity.getCheckWebNew() == 1 && bussinessTypeEntity.isCheckEnable()) {
String errMsg = ioCheckInoutService.checkCode(codeEnttity);
@ -781,22 +780,19 @@ public class IoCodeTempController extends BaseController {
codeTempService.insert(codeEnttity);
}
}
addCodeResult.setOrderId(orderId);
transInoutService.genOrderDetailCode(orderEntity, genDetaiEntity);
return ResultVOUtils.success(addCodeResult);
}
public void checkPrice(IoCodeTempEntity codeTempEntity, BasicBussinessTypeEntity bussinessTypeEntity, String inBatch, List<IoCodeTempEntity> codeTempEntities) {
// 校验价格
String priceFifo = systemParamConfigService.selectValueByParamKey("price_fifo");
if (IntUtil.value(priceFifo) > 0) {
//入库时添加入库批号
if (bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
codeTempEntity.setInBatchNo(inBatch);
codeTempService.updateById(codeTempEntity);
} else {
List<IoCodeTempEntity> filteredAndSorted = codeTempEntities.stream()
.filter(person -> IntUtil.value(person.getRelId()) == IntUtil.value(codeTempEntity.getRelId())
&& StrUtil.trimToEmpty(person.getBatchNo()).equals(StrUtil.trimToEmpty(codeTempEntity.getBatchNo()))
@ -864,7 +860,6 @@ public class IoCodeTempController extends BaseController {
}
}
public BaseResponse checkInv(BasicBussinessTypeEntity bussinessTypeEntity, IoCodeTempEntity codeTempEntity, boolean isEdit) {
if (bussinessTypeEntity.isVailInv() && bussinessTypeEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
int count = 0;

@ -372,6 +372,11 @@ public class IoAddInoutService {
List<IoOrderDetailCodeEntity> ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo", "price").eq("orderIdFk", orderEntity.getBillNo()));
UdiRelevanceResponse udiRelevanceResponse = udiRelevanceService.selectSupGroupById(codeTempEntity.getRelId(), codeTempEntity.getSupId());
if (codeTempEntity.getPrice() == null) {
codeTempEntity.setPrice(udiRelevanceResponse.getPrice());
codeTempService.updateById(codeTempEntity);
}
if (CollUtil.isEmpty(ioOrderDetailCodeEntities)) {
orderDetailCodeService.insert(buildEntity(orderEntity, codeTempEntity, udiRelevanceResponse));
ioOrderDetailCodeEntities = orderDetailCodeDao.selectList(new QueryWrapper<IoOrderDetailCodeEntity>().select("id", "count", "reCount", "bindRlFk", "batchNo", "price").eq("orderIdFk", orderEntity.getBillNo()));
@ -958,18 +963,6 @@ public class IoAddInoutService {
*/
public List<IoCodeTempEntity> checkPrice(BasicBussinessTypeEntity bussinessTypeEntity, List<IoCodeTempEntity> codeTempEntities) {
// Map<Long, IoCodeTempEntity> personMap = codeTempEntities.stream()
// .collect(Collectors.toMap(IoCodeTempEntity::getId, person -> person, (person1, person2) -> {
// if (person1.getBindRlFk().equals(person2.getBindRlFk())
// && StrUtil.emptyIfNull(person1.getBatchNo()).equals(StrUtil.emptyIfNull(person2.getBatchNo()))
// ) {
// person1.setCount(IntUtil.value(person1.getCount()) + IntUtil.value(person2.getCount()));
// person1.setCount(IntUtil.value(person1.getReCount()) + IntUtil.value(person2.getReCount()));
// return person1;
// } else {
// return person2;
// }
// }));
Map<String, List<IoCodeTempEntity>> stringListMap = codeTempEntities.stream()
.collect(Collectors.groupingBy(person -> person.getRelId() + ":" + person.getBatchNo()));
List<IoCodeTempEntity> resultList = new ArrayList<>();
@ -1097,4 +1090,77 @@ public class IoAddInoutService {
}
public List<IoCodeTempEntity> checkPrice(IoCodeTempEntity codeTempEntity, BasicBussinessTypeEntity bussinessTypeEntity, List<IoCodeTempEntity> codeTempEntities) {
List<IoCodeTempEntity> filteredAndSorted = codeTempEntities.stream()
.filter(person -> IntUtil.value(person.getRelId()) == IntUtil.value(codeTempEntity.getRelId())
&& StrUtil.trimToEmpty(person.getBatchNo()).equals(StrUtil.trimToEmpty(codeTempEntity.getBatchNo()))
)
.sorted(Comparator.comparing(IoCodeTempEntity::getInBatchNo))
.collect(Collectors.toList());
Map<String, List<IoCodeTempEntity>> stringListMap = null;
if (CollUtil.isNotEmpty(filteredAndSorted)) {
stringListMap = filteredAndSorted.stream()
.collect(Collectors.groupingBy(person -> StrUtil.trimToEmpty(person.getInBatchNo()))
);
}
List<IoCodeTempEntity> lastList = null;
if (stringListMap != null) {
lastList = stringListMap.entrySet().stream().findFirst().get().getValue();
}
int exitCount = 0;
int extiReCount = 0;
if (CollUtil.isNotEmpty(lastList)) {
for (IoCodeTempEntity ioCodeTempEntity : lastList) {
exitCount = exitCount + ioCodeTempEntity.getCount();
extiReCount = extiReCount + ioCodeTempEntity.getReCount();
}
}
//出库时填写价格与入库批次
//1.获取出库最新批次
String lastInBatch = null;
if (exitCount > 0) {
lastInBatch = lastList.get(0).getInBatchNo();
} else {
InvProductDetailEntity invProductDetailEntity = invProductDetailService.selectLastInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), codeTempEntity.getMainAction());
if (invProductDetailEntity != null)
lastInBatch = invProductDetailEntity.getInBatchNo();
}
if (lastInBatch == null && exitCount == 0) {
//首次出库,获取入库最早批次
InvProductDetailEntity inProductDetail = invProductDetailService.selectFirstInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT);
if (inProductDetail != null) {
codeTempEntity.setPrice(inProductDetail.getPrice());
codeTempEntity.setInBatchNo(inProductDetail.getInBatchNo());
}
} else {
//非首次出库
//1.获取当前批次已出库数量
Integer outCount = IntUtil.value(invProductDetailService.selectCountByInBatch(bussinessTypeEntity, lastInBatch, ConstantType.TYPE_OUT));
//2.获取当前批次入库数量
Integer inCount = IntUtil.value(invProductDetailService.selectCountByInBatch(bussinessTypeEntity, lastInBatch, ConstantType.TYPE_PUT));
//3.若数量还有剩,则此次出库为当前批次
if (inCount >= (outCount + extiReCount + codeTempEntity.getReCount())) {
codeTempEntity.setPrice(lastList.get(0).getPrice());
codeTempEntity.setInBatchNo(lastList.get(0).getInBatchNo());
} else {
// 4.若数量不足,则出下一批次
InvProductDetailEntity nextInvProduct = invProductDetailService.selectNextInBatch(bussinessTypeEntity, codeTempEntity.getRelId() + "", codeTempEntity.getBatchNo(), codeTempEntity.getInvCode(), ConstantType.TYPE_PUT, lastList.get(0).getInBatchNo());
if (nextInvProduct != null) {
codeTempEntity.setPrice(nextInvProduct.getPrice());
codeTempEntity.setInBatchNo(nextInvProduct.getInBatchNo());
}
}
}
codeTempEntities.add(codeTempEntity);
return codeTempEntities;
}
}

@ -146,7 +146,7 @@ public class BigDecimalUtil {
}
if (b1 != null && b2 == null) {
return true;
return false;
}
return 0 == b1.compareTo(b2);
}

Loading…
Cancel
Save