zss
2023-08-21 aacbd7e7bfee3604d22388801b45955a26f746fa
standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductModelServiceImpl.java
@@ -1,5 +1,6 @@
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;
@@ -45,12 +46,21 @@
    //添加标准
    @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);
        }
        //添加物料产品库
        Material material = new Material();
        material.setName(productModelDto.getName()).setCode(MyUtil.getTimeSixNumberCode("CP","CP"));
        material.setName(productModelDto.getMaterial()).setCode(MyUtil.getTimeSixNumberCode("CP", "CP"));
        materialMapper.insert(material);
    }