zss
2023-09-13 2d6a0cdcb1e31510a6f7776abab17cc5cb82fdcb
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
134
135
136
137
package com.yuanchu.mom.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.mom.mapper.TechniqueMapper;
import com.yuanchu.mom.mapper.TechnologyMapper;
import com.yuanchu.mom.pojo.Product;
import com.yuanchu.mom.pojo.dto.ProductDto;
import com.yuanchu.mom.service.ProductService;
import com.yuanchu.mom.mapper.ProductMapper;
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;
 
/**
 * @author Administrator
 * @description 针对表【product】的数据库操作Service实现
 * @createDate 2023-07-26 16:00:44
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
 
    @Resource
    private ProductMapper productMapper;
 
    @Resource
    TechnologyMapper technologyMapper;
 
    @Resource
    TechniqueMapper techniqueMapper;
 
    //根据型号id查询项目(技术指标)
    @Override
    public List<Map<String, Object>> selectProductList(Integer specificationsId) {
        return productMapper.selectProductList(specificationsId);
    }
 
    //根据型号id查询所有版本
    @Override
    public List<Integer> selectVerByPro(Integer specificationsId) {
        return productMapper.selectVerByPro(specificationsId);
    }
 
    //右侧数据展示-->技术指标(检验项目)
    @Override
    public List<Map<String, Object>> selectAllPro(Integer specificationsId, Integer version, String message) {
        return productMapper.selectAllPro(specificationsId, version, message);
    }
 
    //右上角新增-->技术指标-->选择工序,工艺
    @Override
    public List<Map<String, Object>> chooseTech(Integer specificationsId) {
        return technologyMapper.chooseTech(specificationsId);
    }
 
    //右上角新增-->技术指标-->选择项目父类
    @Override
    public List<Map<String, Object>> chooseFather(Integer technologyId) {
        return productMapper.chooseFather(technologyId);
    }
 
    //右上角新增-->技术指标
    @Override
    public String addProduct(ProductDto productDto) {
        Product product = new Product();
        String required = productDto.getRequired();
        String internal = productDto.getInternal();
        if (ObjectUtils.isNotEmpty(required)){
            char requ = required.charAt(0);
            if (requ != '>' && requ != '<' && requ != '=') {
                return "标准值输入格式有问题!";
            }
        }
        if (ObjectUtils.isNotEmpty(internal)){
            char inter = internal.charAt(0);
            if (inter != '>' && inter != '<' && inter != '=') {
                return "内控值输入格式有问题!";
            }
        }
        BeanUtils.copyProperties(productDto, product);
        productMapper.insert(product);
        return "新增成功!";
    }
 
    //填写标准值与内控值,鼠标移开保存
    @Override
    public String write(Integer id, String required, String internal) {
        //校验标准值,内控值格式
            char inter = internal.charAt(0);
            char requ = required.charAt(0);
            if (inter != '>' && inter != '<' && inter != '=') {
                return "内控值输入格式有问题!";
            }
            if (requ != '>' && requ != '<' && requ != '=') {
                return "标准值输入格式有问题!";
            }
        Product product = new Product();
        product.setId(id);
        product.setRequired(required);
        product.setInternal(internal);
        productMapper.updateById(product);
        return "保存成功!";
    }
 
    //删除
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delProById(Integer id) {
        //删除技术指标
        Product product = new Product();
        product.setId(id);
        product.setState(0);
        productMapper.updateById(product);
        //删除生产工艺
        techniqueMapper.delByProId(id);
    }
 
    //批量删除
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delAllPro(String ids) {
        //批量删除技术指标
        productMapper.delAllPro(ids);
        //删除生产工艺
        techniqueMapper.delAll(ids);
    }
 
    //查询标准BOM技术指标中该型号工艺下最新版本的检验项目
    @Override
    public List<Product> selProByVerSpe(Integer technologyId) {
        return productMapper.selProByVerSpe(technologyId);
    }
}