| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | * 查询物料规格列表 |
| | | */ |
| | | @Override |
| | | public List<ProductMaterialSkuDto> productMaterialSkuList(Long materialId) { |
| | | |
| | | if (materialId == null) { |
| | | return Collections.emptyList(); |
| | | public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSku> page, ProductMaterialSkuDto dto) { |
| | | if (dto == null || dto.getMaterialId() == null) { |
| | | return new Page<>(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId) |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, dto.getMaterialId()) |
| | | .like(StringUtils.isNotBlank(dto.getSpecification()), |
| | | ProductMaterialSku::getSpecification, dto.getSpecification()) |
| | | .like(StringUtils.isNotBlank(dto.getMaterialCode()), |
| | | ProductMaterialSku::getMaterialCode, dto.getMaterialCode()) |
| | | .orderByAsc(ProductMaterialSku::getId); |
| | | List<ProductMaterialSku> skuList = this.list(queryWrapper); |
| | | if (skuList == null || skuList.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // 查询物料信息 |
| | | ProductMaterial material = productMaterialMapper.selectById(materialId); |
| | | |
| | | Page<ProductMaterialSku> skuPage = this.page(page, queryWrapper); |
| | | List<ProductMaterialSku> skuList = skuPage.getRecords(); |
| | | if (skuList == null || skuList.isEmpty()) { |
| | | return new Page<>(); |
| | | } |
| | | |
| | | ProductMaterial material = productMaterialMapper.selectById(dto.getMaterialId()); |
| | | String materialName = material != null ? material.getMaterialName() : null; |
| | | String baseUnit = material != null ? material.getBaseUnit() : null; |
| | | List<ProductMaterialSkuDto> result = new ArrayList<>(skuList.size()); |
| | | for (ProductMaterialSku sku : skuList) { |
| | | ProductMaterialSkuDto dto = new ProductMaterialSkuDto(); |
| | | dto.setMaterialId(materialId); |
| | | dto.setMaterialName(materialName); |
| | | dto.setBaseUnit(baseUnit); |
| | | dto.setSkuId(sku.getId()); |
| | | dto.setSpecification(sku.getSpecification()); |
| | | dto.setSupplyType(sku.getSupplyType()); |
| | | result.add(dto); |
| | | ProductMaterialSkuDto productMaterialSkuDto = new ProductMaterialSkuDto(); |
| | | productMaterialSkuDto.setMaterialId(dto.getMaterialId()); |
| | | productMaterialSkuDto.setMaterialName(materialName); |
| | | productMaterialSkuDto.setMaterialCode(sku.getMaterialCode()); |
| | | productMaterialSkuDto.setBaseUnit(baseUnit); |
| | | productMaterialSkuDto.setSkuId(sku.getId()); |
| | | productMaterialSkuDto.setSpecification(sku.getSpecification()); |
| | | productMaterialSkuDto.setSupplyType(sku.getSupplyType()); |
| | | result.add(productMaterialSkuDto); |
| | | } |
| | | |
| | | return result; |
| | | Page<ProductMaterialSkuDto> dtoPage = new Page<>(); |
| | | dtoPage.setCurrent(skuPage.getCurrent()); |
| | | dtoPage.setSize(skuPage.getSize()); |
| | | dtoPage.setTotal(skuPage.getTotal()); |
| | | dtoPage.setRecords(result); |
| | | return dtoPage; |
| | | } |
| | | |
| | | /** |