From 3ad5b828240db97470c9a08b247b1f6f5cdc0dd7 Mon Sep 17 00:00:00 2001 From: XiaoRuby <3114200645@qq.com> Date: 星期五, 04 八月 2023 11:30:33 +0800 Subject: [PATCH] LIMS管理系统框架-开发8-4 --- standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java | 78 +++++++++++++++++++++++++++------------ 1 files changed, 54 insertions(+), 24 deletions(-) diff --git a/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java b/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java index 02ac399..62db781 100644 --- a/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java +++ b/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java @@ -2,16 +2,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.yuanchu.limslaboratory.pojo.Material; import com.yuanchu.limslaboratory.mapper.MaterialMapper; +import com.yuanchu.limslaboratory.pojo.Specifications; +import com.yuanchu.limslaboratory.pojo.Standard; +import com.yuanchu.limslaboratory.pojo.dto.AddMaterialDto; import com.yuanchu.limslaboratory.service.MaterialService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yuanchu.limslaboratory.service.ProductService; +import com.yuanchu.limslaboratory.service.SpecificationsService; +import com.yuanchu.limslaboratory.service.StandardService; +import com.yuanchu.limslaboratory.utils.MyUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -27,51 +34,74 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> implements MaterialService { @Resource - MaterialMapper materialMapper; + private MaterialMapper materialMapper; + @Autowired + private StandardService standardService; + + @Autowired + private SpecificationsService specificationsService; + + @Autowired + private ProductService productService; + + //鏌ヨ鐗╂枡淇℃伅 @Override - public List<Material> selectMaterialLimit(int pageSize, int countSize) { - return materialMapper.selectMaterialLimit((pageSize - 1) * countSize,pageSize * countSize); + public List<Map> selectMaterialLimit(int pageSize, int countSize, int type) { + return materialMapper.selectMaterialLimit((pageSize - 1) * countSize,pageSize * countSize, type); } + //鏍规嵁鐗╂枡id鏌ヨ鐗╂枡淇℃伅 @Override public Map selectMaterialById(String materialId) { return materialMapper.selectMaterialById(materialId); } - @Autowired - private ProductService productService; - @Override - public Integer deleteMaterialInformation(String materialId) { + public Integer deleteMaterialInformation(Integer materialId) { LambdaUpdateWrapper<Material> updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(Material::getId, materialId); updateWrapper.set(Material::getState, 0); - List<String> list = new ArrayList<>(); - list.add(materialId); int isDeleteSuccess = materialMapper.update(new Material(), updateWrapper); if (isDeleteSuccess == 1){ - productService.MaterialIdDeleteProduct(list); + List<Integer> isDeleteStandard = standardService.deleteStandardsInformation(materialId); + if (!ObjectUtils.isEmpty(isDeleteStandard)){ + List<Integer> idDeleteSpecifications = specificationsService.StandardIdDeleteSpecifications(isDeleteStandard); + if (!ObjectUtils.isEmpty(idDeleteSpecifications)){ + productService.deleteProductInformation(idDeleteSpecifications); + } + } return 1; } return 0; } @Override - public List<String> specificationsIdDeleteMaterial(List<Integer> deleteSpecificationsId) { - List<String> list = new ArrayList<>(); - for (Integer serialNumberId:deleteSpecificationsId){ - LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>(); - wrapper.select(Material::getId); - List<Material> maps1 = materialMapper.selectList(wrapper); - for (Material material:maps1){ - LambdaUpdateWrapper<Material> updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(Material::getId, material.getId()); - updateWrapper.set(Material::getState, 0); - materialMapper.update(new Material(), updateWrapper); - list.add(material.getId()); + public Integer addMaterialInformation(AddMaterialDto addMaterialDto) { + Material material = new Material() + .setCode("BZ" + IdWorker.getIdStr()) + .setName(addMaterialDto.getMaterialName()) + .setType(addMaterialDto.getType()); + int isInsertSuccess = materialMapper.insert(material); + if (isInsertSuccess > 0){ + Standard standard = new Standard() + .setMaterialId(material.getId()) + .setName(addMaterialDto.getStandardName()); + boolean save = standardService.save(standard); + if (save){ + Specifications specifications = new Specifications() + .setName(addMaterialDto.getSpecificationsName()) + .setStandardId(standard.getId()); + boolean save1 = specificationsService.save(specifications); + if (save1) + return 1; } } - return list; + return 0; + } + + @Override + public List<Map<String, Object>> getFourLevelInformation(String specificationName) { + return materialMapper.FourTree(specificationName); } } -- Gitblit v1.9.3