liding
昨天 17a7a0c0df3dbc3e6225dddb55f6332deccdb201
src/main/java/com/ruoyi/stock/service/impl/StockUninventoryServiceImpl.java
@@ -25,7 +25,10 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
 * <p>
@@ -60,6 +63,11 @@
        } else {
            wrapper.eq(StockUninventory::getBatchNo, stockUninventoryDto.getBatchNo());
        }
        if (ObjectUtils.isEmpty(stockUninventoryDto.getBatchNo())) {
            String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmm"));
            int suffix = ThreadLocalRandom.current().nextInt(100, 1000);
            stockUninventoryDto.setBatchNo("PY" + time + suffix);
        }
        //新增入库记录再添加库存
        StockInRecordDto stockInRecordDto = new StockInRecordDto();
        stockInRecordDto.setRecordId(stockUninventoryDto.getRecordId());
@@ -72,20 +80,20 @@
        stockInRecordService.add(stockInRecordDto);
        //再进行新增库存数量库存
        //先查询库存表中的产品是否存在,不存在新增,存在更新
        StockUninventory oldStockUnInventory = stockUninventoryMapper.selectOne(wrapper);
        if (ObjectUtils.isEmpty(oldStockUnInventory)) {
            StockUninventory newStockUnInventory = new StockUninventory();
            newStockUnInventory.setProductModelId(stockUninventoryDto.getProductModelId());
            newStockUnInventory.setQualitity(stockUninventoryDto.getQualitity());
            newStockUnInventory.setLockedQuantity(stockUninventoryDto.getLockedQuantity());
            newStockUnInventory.setBatchNo(stockUninventoryDto.getBatchNo());
            newStockUnInventory.setWarehouseInfoId(stockUninventoryDto.getWarehouseInfoId());
            newStockUnInventory.setVersion(1);
            newStockUnInventory.setRemark(stockUninventoryDto.getRemark());
            stockUninventoryMapper.insert(newStockUnInventory);
        }else {
            stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto);
        }
//        StockUninventory oldStockUnInventory = stockUninventoryMapper.selectOne(wrapper);
//        if (ObjectUtils.isEmpty(oldStockUnInventory)) {
//            StockUninventory newStockUnInventory = new StockUninventory();
//            newStockUnInventory.setProductModelId(stockUninventoryDto.getProductModelId());
//            newStockUnInventory.setQualitity(stockUninventoryDto.getQualitity());
//            newStockUnInventory.setLockedQuantity(stockUninventoryDto.getLockedQuantity());
//            newStockUnInventory.setBatchNo(stockUninventoryDto.getBatchNo());
//            newStockUnInventory.setWarehouseInfoId(stockUninventoryDto.getWarehouseInfoId());
//            newStockUnInventory.setVersion(1);
//            newStockUnInventory.setRemark(stockUninventoryDto.getRemark());
//            stockUninventoryMapper.insert(newStockUnInventory);
//        }else {
//            stockUninventoryMapper.updateAddStockUnInventory(stockUninventoryDto);
//        }
        return 1;
    }
@@ -160,6 +168,7 @@
        stockOutRecordDto.setRecordId(stockUninventoryDto.getRecordId());
        stockOutRecordDto.setRecordType(stockUninventoryDto.getRecordType());
        stockOutRecordDto.setStockOutNum(stockUninventoryDto.getQualitity());
        stockOutRecordDto.setWarehouseInfoId(stockUninventoryDto.getWarehouseInfoId());
        stockOutRecordDto.setBatchNo(stockUninventoryDto.getBatchNo());
        stockOutRecordDto.setProductModelId(stockUninventoryDto.getProductModelId());
        stockOutRecordDto.setType("1");