chenhj
23 小时以前 d9b764868dbfa79aa79d79f676f60a28c4055b06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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;
 
/**
 * <p>
 * 出库记录表 服务实现类
 * </p>
 *
 * @author chenhj
 * @since 2025-06-14
 */
@Service
@RequiredArgsConstructor
public class OutputInventoryRecordServiceImpl extends ServiceImpl<OutputInventoryRecordMapper, OutputInventoryRecord> 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);
    }
}