2026-05-11 6d5ce70c3e2b536c8e4b74269be70029a57cb1cc
src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -17,6 +17,8 @@
import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class StockUtils {
@@ -126,12 +128,15 @@
     * @param recordType
     * @param recordId
     */
    public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId) {
    public void substractStock(Long productModelId, BigDecimal quantity, String recordType, Long recordId,String batchNo) {
        StockInventoryDto stockInventoryDto = new StockInventoryDto();
        stockInventoryDto.setRecordId(recordId);
        stockInventoryDto.setRecordType(String.valueOf(recordType));
        stockInventoryDto.setQualitity(quantity);
        stockInventoryDto.setProductModelId(productModelId);
        if (batchNo !=null && !batchNo.isEmpty()) {
            stockInventoryDto.setBatchNo(batchNo);
        }
        stockInventoryService.subtractStockInventory(stockInventoryDto);
    }
@@ -146,11 +151,14 @@
    }
    public void deleteStockOutRecord(Long recordId, String recordType) {
        StockOutRecord one = stockOutRecordService.getOne(new QueryWrapper<StockOutRecord>()
        List<StockOutRecord> one = stockOutRecordService.list(new QueryWrapper<StockOutRecord>()
                .lambda().eq(StockOutRecord::getRecordId, recordId)
                .eq(StockOutRecord::getRecordType, recordType));
        if (ObjectUtils.isNotEmpty(one)) {
            stockOutRecordService.batchDelete(Collections.singletonList(one.getId()));
            List<Long> idList = one.stream()
                    .map(StockOutRecord::getId)
                    .collect(Collectors.toList());
            stockOutRecordService.batchDelete(idList);
        }
    }
}