| | |
| | | import com.ruoyi.basic.pojo.ProductModel; |
| | | import com.ruoyi.basic.service.IProductService; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import lombok.AllArgsConstructor; |
| | | import com.ruoyi.consumables.mapper.ConsumablesInventoryMapper; |
| | | import com.ruoyi.consumables.pojo.ConsumablesInventory; |
| | | import com.ruoyi.stock.mapper.StockInventoryMapper; |
| | | import com.ruoyi.stock.pojo.StockInventory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService { |
| | | |
| | | @Autowired |
| | | private ProductMapper productMapper; |
| | | |
| | | @Autowired |
| | | private ProductModelMapper productModelMapper; |
| | | @Autowired |
| | | private StockInventoryMapper stockInventoryMapper; |
| | | @Autowired |
| | | private ConsumablesInventoryMapper consumablesInventoryMapper; |
| | | |
| | | @Override |
| | | public List<ProductTreeDto> selectProductList(ProductDto productDto) { |
| | |
| | | |
| | | @Override |
| | | public int delProductByIds(Long[] ids) { |
| | | |
| | | List<StockInventory> stockInventoryList = stockInventoryMapper.selectList(new LambdaQueryWrapper<StockInventory>().in(StockInventory::getProductId, Arrays.asList(ids))); |
| | | List<ConsumablesInventory> consumablesInventoryList = consumablesInventoryMapper.selectList(new LambdaQueryWrapper<ConsumablesInventory>().in(ConsumablesInventory::getProductId, Arrays.asList(ids))); |
| | | if (!stockInventoryList.isEmpty() || !consumablesInventoryList.isEmpty()) { |
| | | throw new RuntimeException("该产品存在库存关联!"); |
| | | } |
| | | |
| | | // 1. 删除子表 product_model 中关联的数据 |
| | | LambdaQueryWrapper<ProductModel> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(ProductModel::getProductId, ids); |
| | | productModelMapper.delete(queryWrapper); |
| | | |
| | | // 2. 删除主表 product 数据 |
| | | int deleteCount = productMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | |
| | | return deleteCount; |
| | | return productMapper.deleteBatchIds(Arrays.asList(ids)); |
| | | } |
| | | |
| | | } |