zhanghl
2025-05-09 e09e5a4e03338f21e389ce4604462b3d953699cd
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.aps.core.service.impl;
 
import java.util.*;
 
import com.aps.common.core.utils.DateUtils;
import com.aps.core.domain.ApsBomHeader;
import com.aps.core.mapper.ApsBomHeaderMapper;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.core.mapper.ApsBomMapper;
import com.aps.core.domain.ApsBom;
import com.aps.core.service.IApsBomService;
 
/**
 * BOM数据管理Service业务层处理
 * 
 * @author zhl
 * @date 2025-04-22
 */
@Service
public class ApsBomServiceImpl implements IApsBomService 
{
    @Autowired
    private ApsBomMapper apsBomMapper;
 
    @Resource
    private ApsBomHeaderMapper bomHeaderMapper;
    /**
     * 查询BOM数据管理
     * 
     * @param id BOM数据管理主键
     * @return BOM数据管理
     */
    @Override
    public ApsBom selectApsBomById(Long id)
    {
        return apsBomMapper.selectApsBomById(id);
    }
 
    /**
     * 新增BOM数据管理
     * 
     * @param apsBom BOM数据管理
     * @return 结果
     */
    @Override
    public int insertApsBom(ApsBom apsBom)
    {
        apsBom.setCreateTime(DateUtils.getNowDate());
        return apsBomMapper.insertApsBom(apsBom);
    }
 
    /**
     * 修改BOM数据管理
     * 
     * @param apsBom BOM数据管理
     * @return 结果
     */
    @Override
    public int updateApsBom(ApsBom apsBom)
    {
        apsBom.setUpdateTime(DateUtils.getNowDate());
        return apsBomMapper.updateApsBom(apsBom);
    }
 
    /**
     * 批量删除BOM数据管理
     * 
     * @param ids 需要删除的BOM数据管理主键
     * @return 结果
     */
    @Override
    public int deleteApsBomByIds(Long[] ids)
    {
        return apsBomMapper.deleteApsBomByIds(ids);
    }
 
    /**
     * 删除BOM数据管理信息
     * 
     * @param id BOM数据管理主键
     * @return 结果
     */
    @Override
    public int deleteApsBomById(Long id)
    {
        return apsBomMapper.deleteApsBomById(id);
    }
 
    /*-----*/
 
    /**
     * 查询BOM数据管理列表
     *
     * @param apsBom BOM数据管理
     * @return BOM数据管理
     */
    @Override
    public List<ApsBom> selectApsBomList(ApsBom apsBom)
    {
        return apsBomMapper.selectApsBomList(apsBom);
    }
    /**
     * 通过料号、工厂查询BOMLine数据列表
     * */
    @Override
    public List<ApsBom> selectApsBomLineList(String plant, String itemNumber)
    {
        List<ApsBom> bomLineList =new ArrayList<>();
        ApsBomHeader headerParam = ApsBomHeader.builder().itemCode(itemNumber).orgCode(plant).build();
        Optional<ApsBomHeader> first = bomHeaderMapper.selectApsBomHeaderList(headerParam).stream().findFirst();
        if (first.isPresent()){
            ApsBomHeader apsBomHeader = first.get();
            ApsBom build = new  ApsBom();
            build.setBomHeaderId(apsBomHeader.getBomHeaderId());
            build.setOrgCode(apsBomHeader.getOrgCode());
            bomLineList = apsBomMapper.selectApsBomList(build);
        }
        return bomLineList;
    }
}