From 18039c6046648d129a33059f72c9dbcbe7c71998 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 13 十月 2025 15:56:09 +0800
Subject: [PATCH] 盘点问题修改
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java | 65 ++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
index 49a3e7b..0cb18bd 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpSupplierWarehousingServiceImpl.java
@@ -89,6 +89,8 @@
if(list.isEmpty()){
return pageInfo;
}
+
+
List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList());
if(!typeIds.isEmpty()){
List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
@@ -173,6 +175,7 @@
}
tErpGoodsWarehouseLastVO.setAllNum(tErpGoodsWarehouseVOS.stream().mapToInt(TErpGoodsWarehouseVO::getNowNum).sum());
tErpGoodsWarehouseLastVO.setAllTotalPrice(tErpGoodsWarehouseVOS.stream().mapToDouble(TErpGoodsWarehouseVO::getUnitAmount).sum());
+ tErpGoodsWarehouseLastVO.setAllTotalPrice(BigDecimal.valueOf(tErpGoodsWarehouseLastVO.getAllTotalPrice()).setScale(2,RoundingMode.HALF_UP).doubleValue());
tErpGoodsWarehouseLastVO.setList(tErpGoodsWarehouseVOS);
tErpGoodsWarehouseLastVO.setWarningInventory(goods.getWarningInventory());
tErpGoodsWarehouseLastVOS.add(tErpGoodsWarehouseLastVO);
@@ -277,11 +280,14 @@
tErpSupplierWarehousing.setGoodsId(dto.getGoodsId());
TErpGoods goods = erpGoodsMapper.selectById(dto.getGoodsId());
tErpSupplierWarehousing.setGoodsName(goods.getGoodsName());
- tErpSupplierWarehousing.setGoodsCount(tErpSupplierWarehousing.getGoodsCount());
- tErpSupplierWarehousing.setUnitAmount(tErpSupplierWarehousing.getUnitAmount());
- tErpSupplierWarehousing.setTotalPrice(tErpSupplierWarehousing.getTotalPrice());
- erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
+ tErpSupplierWarehousing.setGoodsCount(dto.getWarehousingNum());
+ tErpSupplierWarehousing.setUnitAmount(dto.getPrice());
+ tErpSupplierWarehousing.setTotalPrice(dto.getTotalPrice());
List<WarehousingGoodsNextDto> warehousingGoodsNextDtos = dto.getWarehousingGoodsNextDtos();
+ int sum = warehousingGoodsNextDtos.stream().mapToInt(WarehousingGoodsNextDto::getWarehousingNum).sum();
+ tErpSupplierWarehousing.setGoodsCount( sum);
+ erpSupplierWarehousingMapper.insert(tErpSupplierWarehousing);
+
for (WarehousingGoodsNextDto warehousingGoodsNextDto : warehousingGoodsNextDtos) {
TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = new TErpSupplierWarehousingBatch();
tErpSupplierWarehousingBatch.setWarehousingId(tErpSupplierWarehousing.getId());
@@ -291,7 +297,7 @@
tErpSupplierWarehousingBatch.setExpiryDate(warehousingGoodsNextDto.getExpiryDate().atStartOfDay());
erpSupplierWarehousingBatchMapper.insert(tErpSupplierWarehousingBatch);
- if(goods.getMaintenanceInterval()!=null){
+ if(goods.getMaintenanceInterval()!=null && !goods.getMaintenanceInterval().isEmpty()){
TErpMaintenanceReminder tErpMaintenanceReminder = new TErpMaintenanceReminder();
tErpMaintenanceReminder.setClinicSupplierId(supplierClinicId);
tErpMaintenanceReminder.setMaintenanceType(1);
@@ -390,9 +396,9 @@
// List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getWarehousingId, tErpSupplierWarehousing.getId()));
// int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpSupplierWarehousingBatch::getWarehousingNumber).sum();
String goodsId = tErpSupplierWarehousing.getGoodsId();
- TErpGoods goods = erpGoodsMapper.selectById(goodsId);
+// TErpGoods goods = erpGoodsMapper.selectById(goodsId);
int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount();
- BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(count));
+ BigDecimal multiply = tErpSupplierWarehousing.getUnitAmount().multiply(new BigDecimal(count));
add = add.add(multiply);
}else {
// 盘亏 查出库
@@ -402,9 +408,9 @@
for (TErpSupplierOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierOutboundGood.getWarehousingId());
String goodsId = tErpSupplierWarehousing.getGoodsId();
- TErpGoods goods = erpGoodsMapper.selectById(goodsId);
+// TErpGoods goods = erpGoodsMapper.selectById(goodsId);
int count = tErpSupplierInventoryGoods1.getInventoryCount() - tErpSupplierInventoryGoods1.getDamagedCount();
- BigDecimal multiply = goods.getSalesAmount().multiply(new BigDecimal(count));
+ BigDecimal multiply = tErpSupplierWarehousing.getUnitAmount().multiply(new BigDecimal(count));
add = add.add(multiply);
}
// int sum = tErpSupplierOutboundGoods.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
@@ -458,6 +464,41 @@
inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
+ }else {
+ TErpSupplierOutbound tErpSupplierOutbound = erpSupplierOutboundMapper.selectById(tErpSupplierInventoryGood.getWarehousingId());
+ List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getOutboundId, tErpSupplierOutbound.getId()));
+ for (TErpSupplierOutboundGoods tErpSupplierOutboundGood : tErpSupplierOutboundGoods) {
+ String warehousingId = tErpSupplierOutboundGood.getWarehousingId();
+ TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(warehousingId);
+ String goodsId = tErpSupplierWarehousing.getGoodsId();
+ TErpGoods goods = erpGoodsMapper.selectById(goodsId);
+ inventoryDetailVo.setGoodsName(goods.getGoodsName());
+ TErpGoodsUnit tErpGoodsUnit = erpGoodsUnitMapper.selectById(goods.getPackingUnitId());
+ inventoryDetailVo.setUnitName(tErpGoodsUnit.getUnitName());
+ inventoryDetailVo.setWarehouseNo(tErpSupplierWarehousing.getWarehouseNo());
+
+ TErpSupplierOutboundGoods tErpSupplierOutboundGoods2 = erpSupplierOutboundGoodsMapper.selectById(tErpSupplierInventoryGood.getWarehousingBatchId());
+
+ TErpSupplierWarehousingBatch tErpSupplierWarehousingBatch = erpSupplierWarehousingBatchMapper.selectById(tErpSupplierOutboundGoods2.getWarehousingBatchId());
+ inventoryDetailVo.setBatchNumber(tErpSupplierWarehousingBatch.getBatchNumber());
+
+
+ List<TErpSupplierWarehousingBatch> tErpSupplierWarehousingBatches = erpSupplierWarehousingBatchMapper.selectList(new LambdaQueryWrapper<TErpSupplierWarehousingBatch>().eq(TErpSupplierWarehousingBatch::getBatchNumber, tErpSupplierWarehousingBatch.getBatchNumber()));
+ int sum = tErpSupplierWarehousingBatches.stream().mapToInt(TErpSupplierWarehousingBatch::getWarehousingNumber).sum();
+ List<String> collect = tErpSupplierWarehousingBatches.stream().map(TErpSupplierWarehousingBatch::getId).collect(Collectors.toList());
+ if(!collect.isEmpty()){
+ List<TErpSupplierOutboundGoods> tErpSupplierOutboundGoods1 = erpSupplierOutboundGoodsMapper.selectList(new LambdaQueryWrapper<TErpSupplierOutboundGoods>().eq(TErpSupplierOutboundGoods::getWarehousingBatchId, collect));
+ int sum1 = tErpSupplierOutboundGoods1.stream().mapToInt(TErpSupplierOutboundGoods::getOutboundCount).sum();
+ sum = sum-sum1;
+ }
+
+ // sum = 剩余库存
+ inventoryDetailVo.setNowCount(sum);
+ inventoryDetailVo.setInventoryCount(tErpSupplierInventoryGood.getInventoryCount());
+ inventoryDetailVo.setInventoryType(tErpSupplierInventoryGood.getInventoryType());
+ inventoryDetailVo.setDamagedCount(tErpSupplierInventoryGood.getDamagedCount());
+ }
+
}
inventoryDetailVos.add(inventoryDetailVo);
@@ -503,11 +544,11 @@
throw new ServiceException("批次号:"+tErpSupplierWarehousingBatch.getBatchNumber()+"库存不足");
}
TErpSupplierWarehousing tErpSupplierWarehousing = erpSupplierWarehousingMapper.selectById(tErpSupplierWarehousingBatch.getWarehousingId());
- TErpGoods goods = erpGoodsMapper.selectById(tErpSupplierWarehousing.getGoodsId());
- BigDecimal multiply = goods.getSalesAmount().multiply(BigDecimal.valueOf(outboundGoodsNextDto.getNum()));
+// TErpGoods goods = erpGoodsMapper.selectById(tErpSupplierWarehousing.getGoodsId());
+ BigDecimal multiply = tErpSupplierWarehousing.getUnitAmount().multiply(BigDecimal.valueOf(outboundGoodsNextDto.getNum()));
TErpSupplierOutboundGoods tErpSupplierOutboundGoods1 = new TErpSupplierOutboundGoods();
- tErpSupplierOutboundGoods1.setWarehousingId(dto.getWarehouseId());
+ tErpSupplierOutboundGoods1.setWarehousingId(tErpSupplierWarehousing.getId());
tErpSupplierOutboundGoods1.setWarehousingBatchId(outboundGoodsNextDto.getBatchId());
tErpSupplierOutboundGoods1.setOutboundCount(outboundGoodsNextDto.getNum());
tErpSupplierOutboundGoods1.setTotalPrice(multiply);
--
Gitblit v1.7.1