zss
2023-08-19 e6ffa9fcebef022be1e8e8162c65f52754f9081e
standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/SpecificationsServiceImpl.java
@@ -2,12 +2,15 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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;
@@ -16,6 +19,8 @@
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,18 @@
        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());
            product.setFather(stringObjectMap.get("father").toString());
            product.setUnit(stringObjectMap.get("unit").toString());
            product.setSpecifications_id(specifications.getId());
            return product;
        }).collect(Collectors.toList());
        productService.saveBatch(productList);
        return 1;
    }
}