huminmin
3 天以前 13afb7eafeffac6ecccc7c66d36974c54c5172d4
src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -30,6 +30,7 @@
import com.ruoyi.stock.service.StockInRecordService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.jspecify.annotations.NonNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@@ -235,12 +236,7 @@
                if ("0".equals(stockInRecord.getType())) {
                    // 合格入库 -> 先查库存,存在则更新,不存在则新增
                    StockInventory stockInventory = getStockInventory(stockInRecord.getProductModelId(), stockInRecord.getBatchNo());
                    StockInventoryDto stockInventoryDto = new StockInventoryDto();
                    stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
                    stockInventoryDto.setBatchNo(stockInRecord.getBatchNo());
                    stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
                    stockInventoryDto.setRemark(stockInRecord.getRemark());
                    stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
                    StockInventoryDto stockInventoryDto = getStockInventoryDto(stockInRecord);
                    if (stockInventory == null) {
                        stockInventoryMapper.insert(new StockInventory() {{
                            setProductModelId(stockInRecord.getProductModelId());
@@ -249,6 +245,7 @@
                            setRemark(stockInRecord.getRemark());
                            setWarnNum(stockInRecord.getWarnNum());
                            setManufacturerId(stockInRecord.getManufacturerId());
                            setSource(stockInRecord.getSource());
                            setVersion(1);
                        }});
                    } else {
@@ -263,6 +260,7 @@
                    stockUninventoryDto.setQualitity(stockInRecord.getStockInNum());
                    stockUninventoryDto.setRemark(stockInRecord.getRemark());
                    stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
                    stockUninventoryDto.setSource(stockInRecord.getSource());
                    if (stockUninventory == null) {
                        stockUninventoryMapper.insert(new StockUninventory() {{
                            setProductModelId(stockInRecord.getProductModelId());
@@ -270,6 +268,7 @@
                            setBatchNo(stockInRecord.getBatchNo());
                            setRemark(stockInRecord.getRemark());
                            setManufacturerId(stockInRecord.getManufacturerId());
                            setSource(stockInRecord.getSource());
                            setVersion(1);
                        }});
                    } else {
@@ -281,6 +280,17 @@
        return ids.size();
    }
    private static @NonNull StockInventoryDto getStockInventoryDto(StockInRecord stockInRecord) {
        StockInventoryDto stockInventoryDto = new StockInventoryDto();
        stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
        stockInventoryDto.setBatchNo(stockInRecord.getBatchNo());
        stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
        stockInventoryDto.setRemark(stockInRecord.getRemark());
        stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
        stockInventoryDto.setSource(stockInRecord.getSource());
        return stockInventoryDto;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int batchReAudit(List<Long> ids) {