zss
2023-08-22 affabbd21802dacbf943692912a83e63106670e4
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
package com.yuanchu.limslaboratory.service.impl;
 
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.limslaboratory.mapper.MaterialMapper;
import com.yuanchu.limslaboratory.mapper.ProductModelMapper;
import com.yuanchu.limslaboratory.pojo.Material;
import com.yuanchu.limslaboratory.pojo.ProductModel;
import com.yuanchu.limslaboratory.pojo.dto.ProductModelDto;
import com.yuanchu.limslaboratory.service.ProductModelService;
import com.yuanchu.limslaboratory.utils.MyUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
 
/**
 * 基础项目模版表(ProductModel)表服务实现类
 *
 * @author zss
 * @since 2023-08-19 11:00:40
 */
@Service
public class ProductModelServiceImpl extends ServiceImpl<ProductModelMapper, ProductModel> implements ProductModelService {
 
    @Resource
    ProductModelMapper productModelMapper;
 
    //选择样品
    @Override
    public List<String> selectmater() {
        return productModelMapper.selectmater();
    }
 
    //添加标准-->选择项目分组
    @Override
    public List<String> selectfather() {
        return productModelMapper.selectfather();
    }
 
    //添加标准
    @Override
    public void addproductModel(ProductModelDto productModelDto) {
        if (ObjectUtils.isEmpty(productModelDto.getFather())) {
            ProductModel productModel = ProductModel.builder()
                    .name(productModelDto.getName())
                    .material(productModelDto.getMaterial())
                    .unit(productModelDto.getUnit())
                    .build();
            productModelMapper.insert(productModel);
        } else {
            ProductModel productModel = new ProductModel();
            BeanUtils.copyProperties(productModelDto, productModel);
            productModelMapper.insert(productModel);
        }
    }
 
    //查询标准模版列表
    @Override
    public List<Map<String, Object>> selectproductModel(String name, String father, String material) {
        return productModelMapper.selectproductModel(name, father, material);
    }
 
    //根据id查询详情
    @Override
    public ProductModelDto selectproductModelById(Integer id) {
        ProductModel productModel = productModelMapper.selectById(id);
        ProductModelDto productModelDto = new ProductModelDto();
        BeanUtils.copyProperties(productModel, productModelDto);
        return productModelDto;
    }
 
    //编辑
    @Override
    public void writeproductModel(Integer id, ProductModelDto productModelDto) {
        ProductModel productModel = new ProductModel();
        BeanUtils.copyProperties(productModelDto, productModel);
        productModel.setId(id);
        productModelMapper.updateById(productModel);
    }
 
    //删除
    @Override
    public void delproductModel(Integer id) {
        ProductModel productModel = new ProductModel();
        productModel.setId(id).setState(0);
        productModelMapper.updateById(productModel);
    }
 
    //批量删除
    @Override
    public void delAllproductModel(String ids) {
        productModelMapper.delAllproductModel(ids);
    }
}