huminmin
3 天以前 13afb7eafeffac6ecccc7c66d36974c54c5172d4
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.stock.enums.StockInventorySourceEnum;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.domain.R;
@@ -68,7 +69,25 @@
    @Override
    public IPage<StockInventoryDto> pageListCombinedStockInventory(Page page, StockInventoryDto stockInventoryDto) {
        return stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto);
        IPage<StockInventoryDto> result = stockInventoryMapper.pageListCombinedStockInventory(page, stockInventoryDto);
        // 转换来源编码为来源名称
        for (StockInventoryDto dto : result.getRecords()) {
            // 合格库存来源
            if (StringUtils.isNotBlank(dto.getQualifiedSource())) {
                StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource());
                if (qualifiedSourceEnum != null) {
                    dto.setQualifiedSourceText(qualifiedSourceEnum.getValue());
                }
            }
            // 不合格库存来源
            if (StringUtils.isNotBlank(dto.getUnQualifiedSource())) {
                StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource());
                if (unQualifiedSourceEnum != null) {
                    dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue());
                }
            }
        }
        return result;
    }
    //入库调用
@@ -170,6 +189,7 @@
        stockInRecordDto.setRemark(stockInventoryDto.getRemark());
        stockInRecordDto.setWarnNum(stockInventoryDto.getWarnNum());
        stockInRecordDto.setManufacturerId(stockInventoryDto.getManufacturerId());
        stockInRecordDto.setSource(stockInventoryDto.getSource());
        stockInRecordService.add(stockInRecordDto);
        return true;
    }
@@ -439,6 +459,29 @@
    @Override
    public IPage<StockInventoryDto> getBatchNoQty(Page page, StockInventoryDto stockInventoryDto) {
        return stockInventoryMapper.getBatchNoQty(page, stockInventoryDto);
        IPage<StockInventoryDto> resultPage = stockInventoryMapper.getBatchNoQty(page, stockInventoryDto);
        // 遍历结果,设置来源中文名
        resultPage.getRecords().forEach(dto -> {
            // 设置合格库存来源中文名
            if (StringUtils.isNotEmpty(dto.getQualifiedSource())) {
                System.out.println("合格库存来源:" + dto.getQualifiedSource());
                StockInventorySourceEnum qualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getQualifiedSource());
                if (qualifiedSourceEnum != null) {
                    dto.setQualifiedSourceText(qualifiedSourceEnum.getValue());
                    System.out.println("合格库存来源值:" + qualifiedSourceEnum.getValue());
                }
            }
            // 设置不合格库存来源中文名
            if (StringUtils.isNotEmpty(dto.getUnQualifiedSource())) {
                StockInventorySourceEnum unQualifiedSourceEnum = StockInventorySourceEnum.fromCode(dto.getUnQualifiedSource());
                if (unQualifiedSourceEnum != null) {
                    dto.setUnQualifiedSourceText(unQualifiedSourceEnum.getValue());
                }
            }
        });
        return resultPage;
    }
}