XiaoRuby
2023-07-27 ad7151b14f2721b0fa40a903c6e65a2c511dd4c5
standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/SpecificationsServiceImpl.java
@@ -4,9 +4,12 @@
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@@ -29,9 +32,6 @@
    private SpecificationsMapper specificationsMapper;
    @Autowired
    private MaterialService materialService;
    @Autowired
    private ProductService productService;
    @Override
@@ -43,21 +43,18 @@
        list.add(specificationsId);
        int isDeleteSuccess = specificationsMapper.update(new Specifications(), updateWrapper);
        if (isDeleteSuccess == 1){
            List<String> deleteMaterialId = materialService.specificationsIdDeleteMaterial(list);
            if (!ObjectUtils.isEmpty(deleteMaterialId)){
                productService.MaterialIdDeleteProduct(deleteMaterialId);
            }
            productService.deleteProductInformation(list);
            return 1;
        }
        return 0;
    }
    @Override
    public List<Integer> SerialNumberIdDeleteSpecifications(List<String> deleteSerialNumberId) {
    public List<Integer> StandardIdDeleteSpecifications(List<Integer> deleteStandard) {
        List<Integer> list = new ArrayList<>();
        for (String serialNumberId:deleteSerialNumberId){
        for (Integer standard : deleteStandard){
            LambdaQueryWrapper<Specifications> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(Specifications::getId, serialNumberId);
            wrapper.eq(Specifications::getStandardId, standard);
            wrapper.select(Specifications::getId);
            List<Specifications> maps1 = specificationsMapper.selectList(wrapper);
            for (Specifications specifications:maps1){
@@ -70,4 +67,12 @@
        }
        return list;
    }
    @Override
    public Integer addSpecificationsInformation(AddSpecifications addStandardDto) {
        Specifications specifications = new Specifications()
                .setName(addStandardDto.getSpecificationsName())
                .setStandardId(addStandardDto.getStandardId());
        return specificationsMapper.insert(specifications);
    }
}