package com.yuanchu.limslaboratory.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.pojo.Product; import com.yuanchu.limslaboratory.mapper.ProductMapper; 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.util.ObjectUtils; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; /** *

* 服务实现类 *

* * @author 江苏鵷雏网络科技有限公司 * @since 2023-07-17 */ @Service public class ProductServiceImpl extends ServiceImpl implements ProductService { @Resource private ProductMapper productMapper; @Override public void deleteProductInformation(List SpecificationsId) { for (Integer materialId : SpecificationsId){ LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(Product::getSpecifications_id, materialId); wrapper.set(Product::getState, 0); productMapper.update(new Product(), wrapper); } } @Override public IPage> pageProductInformation(String productCodeOrName, Page page) { IPage> iPage = productMapper.pageProductInformation(productCodeOrName, page); List> maps = iPage.getRecords(); MyUtil.PrintLog(maps.toString()); maps.forEach(map -> { int num = Integer.parseInt(map.get("num").toString()); boolean children = false; if (num > 1){ children = true; } else { Map product = productMapper.selectOneChildren(map.get("father")); map.putAll(product); } map.put("children", children); map.remove("num"); }); return iPage; } @Override public List> pageFatherNameProductInformation(String fatherName) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(Product::getFather, fatherName); wrapper.select(Product::getId, Product::getName, Product::getUnit, Product::getRequired, Product::getInternal); return productMapper.selectMaps(wrapper); } }