zss
2023-09-01 6a19365f5dea396622b32afe28b3e4b9b067e0e1
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
123
124
125
126
127
128
129
130
131
132
133
package com.yuanchu.mom.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yuanchu.mom.mapper.*;
import com.yuanchu.mom.pojo.Technology;
import com.yuanchu.mom.pojo.dto.TechnologyDto;
import com.yuanchu.mom.service.TechnologyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 江苏鵷雏网络科技有限公司
 * @since 2023-07-31
 */
@Service
public class TechnologyServiceImpl extends ServiceImpl<TechnologyMapper, Technology> implements TechnologyService {
 
    @Resource
    TechnologyMapper technologyMapper;
 
    @Resource
    DeviceMapper deviceMapper;
 
    @Resource
    ProductMapper productMapper;
 
    @Resource
    MbomMapper mbomMapper;
 
    @Resource
    TechniqueMapper techniqueMapper;
 
 
    //根据型号id查询版本
    @Override
    public List<Integer> selectVerByTec(Integer specificationsId) {
        return technologyMapper.selectVerByTec(specificationsId);
    }
 
    //右侧数据展示-->工艺路线
    @Override
    public List<Map<String, Object>> selectAllTec(Integer specificationsId, Integer version, String message) {
        return technologyMapper.selectAllTec(specificationsId, version, message);
    }
 
    //右上角新增-->工艺路线-->选择设备组
    @Override
    public List<Map<String, Object>> chooseDevice() {
        return deviceMapper.chooseDevGroup();
    }
 
    //右上角新增-->工艺路线-->选择工序
    @Override
    public List<Map<String, Object>> chooseFather(Integer specificationsId) {
        return technologyMapper.chooseFather(specificationsId);
    }
 
    //右上角新增-->工艺路线
    @Override
    public void addTechnology(Integer specificationsId, TechnologyDto technologyDto) {
        Technology technology = new Technology();
        BeanUtils.copyProperties(technologyDto, technology);
        technology.setSpecificationsId(specificationsId);
        technologyMapper.insert(technology);
    }
 
    //填写生产定额,鼠标移开保存
    @Override
    public Integer write(Integer id, Integer productionQuota) {
        Technology technology = new Technology();
        technology.setId(id);
        technology.setProductionQuota(productionQuota);
        return technologyMapper.updateById(technology);
    }
 
    //添加同一个型号工艺路线的版本
    @Override
    public Integer addVersion(Integer specificationsId, Integer version) {
        List<Technology> technologyList = technologyMapper.selectList(Wrappers.<Technology>query()
                .eq("specifications_id", specificationsId)
                .eq("version", version));
        for (Technology technology : technologyList) {
            technology.setId(null);
            //最新版本+!
            technology.setVersion(technologyMapper.selectVerByTec(specificationsId).get(0) + 1);
        }
        saveBatch(technologyList);
        return technologyList.get(0).getVersion();
    }
 
    //删除
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delTechById(Integer id) {
        //删除工艺路线表
        Technology technology = new Technology();
        technology.setId(id);
        technology.setState(0);
        technologyMapper.updateById(technology);
        //删除技术指标表
        productMapper.delProByTecId(id);
        //删除物料清单表
        mbomMapper.delMbomByTecId(id);
        //删除生产工艺表
        techniqueMapper.delTeqByTecId(id);
    }
 
    //批量删除
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delAllTech(String ids) {
        //批量删除工艺路线表
        technologyMapper.delAllTech(ids);
        //批量删除技术指标表
        productMapper.delAllByTechId(ids);
        //批量删除物料清单表
        mbomMapper.delAllByTecId(ids);
        //批量删除生产工艺表
        techniqueMapper.delAllByTecId(ids);
    }
}