| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.yuanchu.limslaboratory.pojo.Product; |
| | | import com.yuanchu.limslaboratory.mapper.ProductMapper; |
| | | import com.yuanchu.limslaboratory.service.ProductService; |
| | |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | | * 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 江苏鵷雏网络科技有限公司 |
| | |
| | | private ProductMapper productMapper; |
| | | |
| | | @Override |
| | | public List<Product> selectProductByMaterialId(int materialId) { |
| | | public List<Product> selectProductByMaterialId(String materialId) { |
| | | return productMapper.selectProductByMaterialId(materialId); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getListProductInformation(Integer materialId) { |
| | | public List<Map<String, Object>> getListProductInformation(String materialId) { |
| | | LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Product::getMaterialId, materialId); |
| | | wrapper.select(Product::getId, Product::getName, Product::getFather); |
| | | wrapper.groupBy(Product::getFather); |
| | | List<Map<String, Object>> products = productMapper.selectMaps(wrapper); |
| | | for (Map<String, Object> product:products){ |
| | | if (!ObjectUtils.isEmpty(product.get("father"))){ |
| | | for (Map<String, Object> product : products) { |
| | | if (!ObjectUtils.isEmpty(product.get("father"))) { |
| | | product.remove("name"); |
| | | product.remove("id"); |
| | | LambdaQueryWrapper<Product> wrapper1 = new LambdaQueryWrapper<>(); |
| | |
| | | product.put("sonProduct", maps); |
| | | } |
| | | } |
| | | for (Map<String, Object> product:products){ |
| | | for (Map<String, Object> product : products) { |
| | | System.out.println(product); |
| | | } |
| | | return products; |
| | |
| | | |
| | | @Override |
| | | public Integer deleteProductInformation(Integer productId) { |
| | | LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>(); |
| | | LambdaUpdateWrapper<Product> wrapper = new LambdaUpdateWrapper<>(); |
| | | wrapper.eq(Product::getId, productId); |
| | | return productMapper.delete(wrapper); |
| | | wrapper.set(Product::getState, 0); |
| | | return productMapper.update(new Product(), wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteProductEqMaterialId(List<String> materialListId) { |
| | | for (String materialId : materialListId){ |
| | | LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>(); |
| | | public void MaterialIdDeleteProduct(List<String> deleteMaterialId) { |
| | | for (String materialId : deleteMaterialId) { |
| | | LambdaUpdateWrapper<Product> wrapper = new LambdaUpdateWrapper<>(); |
| | | wrapper.eq(Product::getMaterialId, materialId); |
| | | wrapper.select(Product::getId); |
| | | List<Product> products = productMapper.selectList(wrapper); |
| | | List<Integer> productDeleteId = new ArrayList<>(); |
| | | for (Product product : products){ |
| | | productDeleteId.add(product.getId()); |
| | | } |
| | | productMapper.deleteBatchIds(productDeleteId); |
| | | wrapper.set(Product::getState, 0); |
| | | productMapper.update(new Product(), wrapper); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Integer updateMaterialInformation(Product product) { |
| | | LambdaUpdateWrapper<Product> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(Product::getId, product.getId()); |
| | | return productMapper.update(product, updateWrapper); |
| | | } |
| | | |
| | | //通过项目名查询项目的试验方法 |
| | | @Override |
| | | public List<Map> selectInstrumentByProname(String name) { |
| | | return productMapper.selectInstrumentByProname(name); |
| | | } |
| | | } |