From 530b456eded06e0692e1d8bd5891069439c8f8f8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期五, 17 四月 2026 15:10:56 +0800
Subject: [PATCH] fix: 1.已发货的销售台账对应的出入库记录做限制不能删除;2.销售台账入库操作后,点击删除,对应的销售入库记录未一并删除;3.销售台账入库状态新增部分入库
---
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
index 5cb6dda..d98bc5a 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -7,6 +7,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
+import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
@@ -42,10 +43,11 @@
@AllArgsConstructor
public class StockInventoryServiceImpl extends ServiceImpl<StockInventoryMapper, StockInventory> implements StockInventoryService {
- private StockInventoryMapper stockInventoryMapper;
+ private StockInventoryMapper stockInventoryMapper;
private StockInRecordService stockInRecordService;
private StockOutRecordService stockOutRecordService;
private SalesLedgerProductMapper salesLedgerProductMapper;
+
@Override
public IPage<StockInventoryDto> pagestockInventory(Page page, StockInventoryDto stockInventoryDto) {
return stockInventoryMapper.pagestockInventory(page, stockInventoryDto);
@@ -56,12 +58,22 @@
@Transactional(rollbackFor = Exception.class)
public Boolean addstockInventory(StockInventoryDto stockInventoryDto) {
//鏂板鍏ュ簱璁板綍鍐嶆坊鍔犲簱瀛�
+ // 鏇存柊浜у搧鍏ュ簱鐘舵��
+ SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(stockInventoryDto.getSalesLedgerProductId());
+ if (salesLedgerProduct == null) {
+ throw new ServiceException("鍏ュ簱澶辫触,閿�鍞骇鍝佷笉瀛樺湪");
+ }
+ salesLedgerProduct.setProductStockStatus(1);
+ salesLedgerProductMapper.updateById(salesLedgerProduct);
+
StockInRecordDto stockInRecordDto = new StockInRecordDto();
stockInRecordDto.setRecordId(stockInventoryDto.getRecordId());
stockInRecordDto.setRecordType(stockInventoryDto.getRecordType());
stockInRecordDto.setStockInNum(stockInventoryDto.getQualitity());
stockInRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
stockInRecordDto.setType("0");
+ stockInRecordDto.setSalesLedgerId(stockInventoryDto.getSalesLedgerId());
+ stockInRecordDto.setSalesLedgerProductId(stockInventoryDto.getSalesLedgerProductId());
stockInRecordService.add(stockInRecordDto);
//鍐嶈繘琛屾柊澧炲簱瀛樻暟閲忓簱瀛�
//鍏堟煡璇㈠簱瀛樿〃涓殑浜у搧鏄惁瀛樺湪锛屼笉瀛樺湪鏂板锛屽瓨鍦ㄦ洿鏂�
@@ -75,8 +87,8 @@
newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
stockInventoryMapper.insert(newStockInventory);
- }else {
- stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
+ } else {
+ stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
}
return true;
}
@@ -92,6 +104,8 @@
stockOutRecordDto.setStockOutNum(stockInventoryDto.getQualitity());
stockOutRecordDto.setProductModelId(stockInventoryDto.getProductModelId());
stockOutRecordDto.setType("0");
+ stockOutRecordDto.setSalesLedgerId(stockInventoryDto.getSalesLedgerId());
+ stockOutRecordDto.setSalesLedgerProductId(stockInventoryDto.getSalesLedgerProductId());
stockOutRecordService.add(stockOutRecordDto);
StockInventory oldStockInventory = stockInventoryMapper.selectOne(new QueryWrapper<StockInventory>().lambda().eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId()));
if (ObjectUtils.isEmpty(oldStockInventory)) {
@@ -132,7 +146,7 @@
stockInventoryDto.setQualitity(dto.getQualitity());
stockInventoryDto.setRemark(dto.getRemark());
stockInventoryDto.setWarnNum(dto.getWarnNum());
- if (ObjectUtils.isNotEmpty(dto.getLockedQuantity())&&dto.getLockedQuantity().compareTo(dto.getQualitity())>0) {
+ if (ObjectUtils.isNotEmpty(dto.getLockedQuantity()) && dto.getLockedQuantity().compareTo(dto.getQualitity()) > 0) {
throw new RuntimeException("鍐荤粨鏁伴噺涓嶈兘瓒呰繃鏈瀵煎叆鐨勫簱瀛樻暟閲�");
}
stockInventoryDto.setLockedQuantity(dto.getLockedQuantity());
@@ -171,28 +185,28 @@
List<StockInventoryExportData> list = stockInventoryMapper.listStockInventoryExportData(stockInventoryDto);
ExcelUtil<StockInventoryExportData> util = new ExcelUtil<>(StockInventoryExportData.class);
- util.exportExcel(response,list, "搴撳瓨淇℃伅");
+ util.exportExcel(response, list, "搴撳瓨淇℃伅");
}
@Override
public IPage<StockInRecordDto> stockInventoryPage(StockInventoryDto stockInventoryDto, Page page) {
- return stockInventoryMapper.stockInventoryPage(stockInventoryDto,page);
+ return stockInventoryMapper.stockInventoryPage(stockInventoryDto, page);
}
@Override
public IPage<StockInventoryDto> stockInAndOutRecord(StockInventoryDto stockInventoryDto, Page page) {
- return stockInventoryMapper.stockInAndOutRecord(stockInventoryDto,page);
+ return stockInventoryMapper.stockInAndOutRecord(stockInventoryDto, page);
}
@Override
public Boolean frozenStock(StockInventoryDto stockInventoryDto) {
StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId());
- if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity())<0) {
+ if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
throw new RuntimeException("鍐荤粨鏁伴噺涓嶈兘瓒呰繃搴撳瓨鏁伴噺");
}
if (ObjectUtils.isEmpty(stockInventory.getLockedQuantity())) {
stockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
- }else {
+ } else {
stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().add(stockInventoryDto.getLockedQuantity()));
}
return this.updateById(stockInventory);
@@ -201,7 +215,7 @@
@Override
public Boolean thawStock(StockInventoryDto stockInventoryDto) {
StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId());
- if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity())<0) {
+ if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
throw new RuntimeException("瑙e喕鏁伴噺涓嶈兘瓒呰繃鍐荤粨鏁伴噺");
}
stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().subtract(stockInventoryDto.getLockedQuantity()));
--
Gitblit v1.9.3