XiaoRuby
2023-08-19 3f0e25410f5aa3f01fda3d2d6410d89dc74159f3
standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/ProductServiceImpl.java
@@ -4,14 +4,18 @@
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.mapper.ProductModelMapper;
import com.yuanchu.limslaboratory.mapper.SpecificationsMapper;
import com.yuanchu.limslaboratory.pojo.Product;
import com.yuanchu.limslaboratory.mapper.ProductMapper;
import com.yuanchu.limslaboratory.pojo.ProductModel;
import com.yuanchu.limslaboratory.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanchu.limslaboratory.utils.MyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import com.yuanchu.limslaboratory.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
@@ -34,6 +38,10 @@
    @Resource
    private ProductMapper productMapper;
    @Resource
    ProductModelMapper productModelMapper;
    @Override
    public void deleteProductInformation(List<Integer> SpecificationsId) {
        for (Integer materialId : SpecificationsId){
@@ -44,36 +52,12 @@
        }
    }
    //展示该型号下的检验项目要求
    @Override
    public IPage<Map<String, Object>> pageProductInformation(String productCodeOrName, Integer specificationsId, Page<Objects> page) {
        IPage<Map<String, Object>> iPage = productMapper.pageProductInformation(productCodeOrName, specificationsId, page);
        List<Map<String, Object>> maps = iPage.getRecords();
        maps.forEach(map -> {
            int num = Integer.parseInt(map.get("num").toString());
            boolean children = false;
            if (num > 1){
                children = true;
            } else {
                Map<String, Object> product = productMapper.selectOneChildren(map.get("father"));
                map.putAll(product);
            }
            map.put("children", children);
            map.remove("num");
        });
        return iPage;
    @Transactional(rollbackFor = Exception.class)
    public List<Map<String, Object>> pageProductInformation(Integer specificationsId) {
        return productMapper.pageProductInformation(specificationsId);
    }
    @Override
    public List<Map<String, Object>> pageFatherNameProductInformation(String fatherName) {
        LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Product::getFather, fatherName);
        wrapper.select(Product::getId, Product::getName, Product::getUnit, Product::getRequired, Product::getInternal);
        return productMapper.selectMaps(wrapper);
    }
    //通过项目名查询项目的试验方法
    @Override
    public List<Map> selectInstrumentByProname(String name) {
        return productMapper.selectInstrumentByProname(name);
    }
}