zss
2023-08-22 59ae18f04a602bdfdc91299bbe2ff74a2ae1d215
standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/SpecificationsServiceImpl.java
@@ -2,20 +2,25 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yuanchu.limslaboratory.mapper.ProductModelMapper;
import com.yuanchu.limslaboratory.pojo.Product;
import com.yuanchu.limslaboratory.pojo.Specifications;
import com.yuanchu.limslaboratory.mapper.SpecificationsMapper;
import com.yuanchu.limslaboratory.pojo.dto.AddSpecifications;
import com.yuanchu.limslaboratory.pojo.dto.AddStandardDto;
import com.yuanchu.limslaboratory.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * <p>
@@ -33,6 +38,9 @@
    @Autowired
    private ProductService productService;
    @Resource
    ProductModelMapper productModelMapper;
    @Override
    public Integer deleteSpecifications(Integer specificationsId) {
@@ -73,6 +81,22 @@
        Specifications specifications = new Specifications()
                .setName(addStandardDto.getSpecificationsName())
                .setStandardId(addStandardDto.getStandardId());
        return specificationsMapper.insert(specifications);
         specificationsMapper.insert(specifications);
        //添加型号之后添加项目
        List<Map<String, Object>> productModel=productModelMapper.seleMode(specificationsMapper.selMateName(addStandardDto.getStandardId()));
        List<Product> productList = productModel.stream().map(stringObjectMap -> {
            Product product = new Product();
            product.setName(stringObjectMap.get("name").toString());
            if (ObjectUtils.isNotEmpty(stringObjectMap.get("father"))) {
                product.setFather(stringObjectMap.get("father").toString());
            }
            if (ObjectUtils.isNotEmpty(stringObjectMap.get("unit"))) {
                product.setUnit(stringObjectMap.get("unit").toString());
            }
            product.setSpecifications_id(specifications.getId());
            return product;
        }).collect(Collectors.toList());
        productService.saveBatch(productList);
        return 1;
    }
}