| | |
| | | |
| | | for (ProductMaterialSku sku : list) { |
| | | |
| | | ProductMaterialSku exist = |
| | | productMaterialSkuService.getOne(new LambdaQueryWrapper<ProductMaterialSku>() |
| | | .eq(ProductMaterialSku::getMaterialId, sku.getMaterialId()) |
| | | .eq(ProductMaterialSku::getSpecification, sku.getSpecification())); |
| | | LambdaQueryWrapper<ProductMaterialSku> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterialSku::getMaterialId, sku.getMaterialId()) |
| | | .eq(ProductMaterialSku::getSpecification, sku.getSpecification()); |
| | | |
| | | if (StringUtils.isNotEmpty(sku.getMaterialCode())) { |
| | | wrapper.eq(ProductMaterialSku::getMaterialCode, sku.getMaterialCode()); |
| | | } else { |
| | | wrapper.isNull(ProductMaterialSku::getMaterialCode); |
| | | } |
| | | |
| | | ProductMaterialSku exist = productMaterialSkuService.getOne(wrapper); |
| | | if (exist == null) { |
| | | productMaterialSkuService.save(sku); |
| | | affected++; |
| | |
| | | for (ProductMaterialConfig materialConfig : materialConfigList) { |
| | | LambdaQueryWrapper<ProductMaterial> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterial::getMaterialTypeId, materialConfig.getId()) |
| | | .select(ProductMaterial::getId, ProductMaterial::getMaterialName) |
| | | .like(materialName != null && !materialName.isEmpty(), ProductMaterial::getMaterialName, materialName); |
| | | List<ProductMaterial> productMaterialList = list(wrapper); |
| | | |
| | | if (productMaterialList != null && !productMaterialList.isEmpty()) { |
| | | ProductMaterialGroupDto dto = new ProductMaterialGroupDto(); |
| | | dto.setConfigId(materialConfig.getId()); |
| | | dto.setConfigName(materialConfig.getConfigName()); |
| | | dto.setMaterialList(productMaterialList); |
| | | productMaterialMap.add(dto); |
| | | } |
| | | ProductMaterialGroupDto dto = new ProductMaterialGroupDto(); |
| | | dto.setConfigId(materialConfig.getId()); |
| | | dto.setConfigName(materialConfig.getConfigName()); |
| | | dto.setMaterialList(productMaterialList); |
| | | productMaterialMap.add(dto); |
| | | } |
| | | return productMaterialMap; |
| | | } |