package com.ruoyi.business.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.business.dto.OfficialInventoryDto; import com.ruoyi.business.dto.PendingInventoryDto; import com.ruoyi.business.entity.OutputInventoryRecord; import com.ruoyi.business.mapper.OutputInventoryRecordMapper; import com.ruoyi.business.service.InventorySummaryService; import com.ruoyi.business.service.OutputInventoryRecordService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import java.math.BigDecimal; import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY; import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY; /** *

* 出库记录表 服务实现类 *

* * @author chenhj * @since 2025-06-14 */ @Service @RequiredArgsConstructor public class OutputInventoryRecordServiceImpl extends ServiceImpl implements OutputInventoryRecordService { private final OutputInventoryRecordMapper outputInventoryRecordMapper; private final InventorySummaryService inventorySummaryService; @Override public int insertOutputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity) { if ((pendingInventoryDto != null && officialInventoryDto != null) || (pendingInventoryDto == null && officialInventoryDto == null)) { throw new RuntimeException("库存记录异常"); } OutputInventoryRecord outputInventoryRecord = new OutputInventoryRecord(); if (officialInventoryDto != null) { outputInventoryRecord.setInventoryType(OFFICIAL_INVENTORY); outputInventoryRecord.setId(officialInventoryDto.getId()); } else { outputInventoryRecord.setInventoryType(PENDING_INVENTORY); outputInventoryRecord.setId(pendingInventoryDto.getId()); } outputInventoryRecord.setQuantity(quantity); outputInventoryRecordMapper.insert(outputInventoryRecord); // 变更原库存信息 return inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto); } }