新火炬后端单体项目初始化代码
zhangherong
13 小时以前 399e7d565f19f59a8da82277da8f3eab527c2c56
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package org.jeecg.modules.lsw.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.Factory;
import org.jeecg.modules.base.entity.LineSideWarehouse;
import org.jeecg.modules.base.enums.ProductionTypeEnum;
import org.jeecg.modules.base.service.IFactoryService;
import org.jeecg.modules.base.service.ILineSideWarehouseService;
import org.jeecg.modules.lsw.entity.LswMaterial;
import org.jeecg.modules.lsw.entity.LswMaterialInventory;
import org.jeecg.modules.lsw.enums.MaterialCategoryEnum;
import org.jeecg.modules.lsw.enums.MaterialInventoryStatusEnum;
import org.jeecg.modules.lsw.mapper.LswMaterialInventoryMapper;
import org.jeecg.modules.lsw.service.ILswMaterialInventoryService;
import org.jeecg.modules.lsw.service.ILswMaterialService;
import org.jeecg.modules.lsw.vo.LswMaterialInventoryVo;
import org.jeecg.modules.lsw.vo.MaterialInventoryStatisticsVO;
import org.jeecg.modules.lsw.vo.MaterialInventoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
/**
 * @Description: 物料库存信息
 * @Author: jeecg-boot
 * @Date: 2025-06-30
 * @Version: V1.0
 */
@Service
public class LswMaterialInventoryServiceImpl extends ServiceImpl<LswMaterialInventoryMapper, LswMaterialInventory> implements ILswMaterialInventoryService {
 
    @Autowired
    private LswMaterialInventoryMapper lswMaterialInventoryMapper;
    @Autowired
    private ILswMaterialService materialService;
    @Autowired
    private ILineSideWarehouseService lineSideWarehouseService;
    @Autowired
    private IFactoryService factoryService;
 
    @Override
    public List<LswMaterialInventoryVo> selectLineSideMaterialInventoryByMaterialNumber(List<String> bomMaterialNumberList, String factoryId) {
        return lswMaterialInventoryMapper.selectLineSideMaterialInventoryByMaterialNumber(bomMaterialNumberList, factoryId);
    }
 
    @Override
    public List<MaterialInventoryStatisticsVO> statisticsInventory(String materialId) {
        return lswMaterialInventoryMapper.statisticsInventory(materialId);
    }
 
    @Override
    public LswMaterialInventory queryByMaterialNumberAndBatchNumber(String materialNumber, String batchNumber, String warehouseId) {
        LswMaterial material = materialService.queryByMaterialNumber(materialNumber);
        if (material == null) {
            return null;
        }
        LambdaQueryWrapper<LswMaterialInventory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(LswMaterialInventory::getWarehouseId, warehouseId);
        queryWrapper.eq(LswMaterialInventory::getMaterialId, material.getId());
        queryWrapper.eq(LswMaterialInventory::getBatchNumber, batchNumber);
        queryWrapper.eq(LswMaterialInventory::getInventoryStatus, MaterialInventoryStatusEnum.NORMAL.name());
        return lswMaterialInventoryMapper.selectOne(queryWrapper);
    }
 
    @Override
    public List<MaterialInventoryVO> queryMaterialInventory(String factoryId) {
        Factory factory = factoryService.getById(factoryId);
        if (factory == null) {
            return Collections.emptyList();
        }
        LineSideWarehouse warehouse = lineSideWarehouseService.queryByFactoryId(factoryId);
        if (warehouse == null) {
            return Collections.emptyList();
        }
        List<String> materialCategory = new ArrayList<>();
        if (ProductionTypeEnum.ASSEMBLE.name().equals(factory.getProductionType())) {
            materialCategory.add(MaterialCategoryEnum.OUTER_FLANGE.name());
            materialCategory.add(MaterialCategoryEnum.INNER_FLANGE.name());
            materialCategory.add(MaterialCategoryEnum.SMALL_INNER_RING.name());
            materialCategory.add(MaterialCategoryEnum.STEEL_BALL.name());
            materialCategory.add(MaterialCategoryEnum.COMPONENTS.name());
        } else if (ProductionTypeEnum.INNERFLANGE.name().equals(factory.getProductionType())) {
            materialCategory.add(MaterialCategoryEnum.BLANK.name());
        } else if (ProductionTypeEnum.OUTERFLANGE.name().equals(factory.getProductionType())) {
            materialCategory.add(MaterialCategoryEnum.BLANK.name());
        } else if (ProductionTypeEnum.HEATTREATMENT.name().equals(factory.getProductionType())) {
            materialCategory.add(MaterialCategoryEnum.BLANK.name());
        }
        return lswMaterialInventoryMapper.queryMaterialInventory(warehouse.getId(), materialCategory);
    }
}