Explorar o código

1.出库完成融资单返回出库数量bug修改

纪新园 hai 5 días
pai
achega
5eb6fe615c

+ 21 - 3
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/ship/service/impl/ShipServiceImpl.java

@@ -820,7 +820,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 		List<ReservoirAreaRecord> reservoirAreaRecordListUpdate = new ArrayList<>();
 		String status = sysClient.getParamService("whether.financing");
 		if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
-			List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
 			List<Long> itemIdList = ship.getShipItemsList().stream().map(PjShipItems::getId).distinct().collect(Collectors.toList());
 			String reservoirArea = sysClient.getParamServiceDWT("reservoir.area", AuthUtil.getTenantId());
 			List<PjHistory> historyList = new ArrayList<>();
@@ -849,6 +848,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					}
 				}
 			}
+			List<Long> goodIds = ship.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
 			List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
 				.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
 				.eq(PjGoodsDesc::getIsDeleted, 0)
@@ -1155,6 +1155,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					}
 					List<Long> ordIds = orderList.stream().map(PjOrder::getId).collect(Collectors.toList());
 					List<Long> goodsList = shipItemsList.stream().map(PjShipItems::getGoodsId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
+					List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
+						.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
+						.eq(PjGoodsDesc::getIsDeleted, 0)
+						.in(PjGoodsDesc::getId, goodsList));
 					//获取融资采购单明细数据
 					List<PjOrderItems> orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
 						.eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
@@ -1167,6 +1171,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 					);
 					BigDecimal amountSum = new BigDecimal("0.00");
 					for (PjShipItems item : shipItemsList) {
+						PjGoodsDesc goodsDesc = pjGoodsDescList.stream().filter(e -> e.getId().equals(item.getGoodsId())).findFirst().orElse(null);
+						if (ObjectUtil.isEmpty(goodsDesc)) {
+							throw new RuntimeException("商品数据异常");
+						}
+						if ("1".equals(goodsDesc.getWhether()) && ObjectUtils.isNull(item.getDot())) {
+							throw new RuntimeException("商品:" + goodsDesc.getCname() + ",请选择批次号");
+						}
 						if (new BigDecimal("0").compareTo(item.getSendNumFinancing()) != 0) {
 							BigDecimal costprie = item.getSendNumFinancing().multiply(item.getCostpriePrice());
 							amountSum = amountSum.add(costprie);
@@ -1196,8 +1207,15 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
 							if (new BigDecimal("0").compareTo(shipItems.getSendNumFinancing()) == 0) {
 								continue;
 							}
-							List<PjOrderItems> orderItemList = orderItemsList.stream().filter(e -> e.getGoodsId().equals(shipItems.getGoodsId()))
-								.sorted(Comparator.comparing(PjOrderItems::getCreateTime)).collect(Collectors.toList());
+							List<PjOrderItems> orderItemList = new ArrayList<>();
+							if(ObjectUtils.isNotNull(shipItems.getDot())){
+								orderItemList= orderItemsList.stream().filter(e -> e.getGoodsId().equals(shipItems.getGoodsId()) &&
+										e.getDot().equals(shipItems.getDot())).sorted(Comparator.comparing(PjOrderItems::getCreateTime))
+									.collect(Collectors.toList());
+							}else{
+								orderItemList= orderItemsList.stream().filter(e -> e.getGoodsId().equals(shipItems.getGoodsId()))
+									.sorted(Comparator.comparing(PjOrderItems::getCreateTime)).collect(Collectors.toList());
+							}
 							if (orderItemList.isEmpty()) {
 								throw new RuntimeException("商品:" + shipItems.getGoodsName() + "超过" + days + "天未赎回,请确认在出库");
 							}