| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ProductMaterialSkuServiceImpl |
| | | extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku> |
| | | implements ProductMaterialSkuService { |
| | | public class ProductMaterialSkuServiceImpl extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku> implements ProductMaterialSkuService { |
| | | |
| | | @Autowired |
| | | private ProductMaterialMapper productMaterialMapper; |
| | |
| | | * 查询物料规格列表 |
| | | */ |
| | | @Override |
| | | 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, dto.getMaterialId()) |
| | | .like(StringUtils.isNotBlank(dto.getSpecification()), |
| | | ProductMaterialSku::getSpecification, dto.getSpecification()) |
| | | .like(StringUtils.isNotBlank(dto.getMaterialCode()), |
| | | ProductMaterialSku::getMaterialCode, dto.getMaterialCode()) |
| | | .orderByAsc(ProductMaterialSku::getId); |
| | | |
| | | 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 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); |
| | | } |
| | | Page<ProductMaterialSkuDto> dtoPage = new Page<>(); |
| | | dtoPage.setCurrent(skuPage.getCurrent()); |
| | | dtoPage.setSize(skuPage.getSize()); |
| | | dtoPage.setTotal(skuPage.getTotal()); |
| | | dtoPage.setRecords(result); |
| | | return dtoPage; |
| | | public Page<ProductMaterialSkuDto> productMaterialSkuList(Page<ProductMaterialSkuDto> page, ProductMaterialSkuDto dto, Integer type) { |
| | | return baseMapper.selectSkuWithMaterialPage(page, dto, type); |
| | | } |
| | | |
| | | /** |