• 1000 code состоит из 2 карт: представлен обзор, а также их соответствующие коды:
Диаграмма Mapstruct
Mapper 1:
@Mapper(componentModel = "spring", uses={ProductionPlanDetailAutoMapper.class})
public interface SupplyPlanProjectionAutoMapper {
@Mapping(source = "material.id", target = "materialId")
public PlanningProjectionDTO convert(PlanningProjection);
public Map<PlanningProjectionDTO, List<ProductionPlanDetailDTO>> convertMapProductionPlanDetail (Map<PlanningProjection, List<ProductionPlanDetail>> map);
}
Mapper 2:
@Mapper(componentModel = "spring", uses={RecipeAutoMapper.class})
public interface ProductionPlanDetailAutoMapper {
@Mapping(source = "location.id", target = "locationId")
@Mapping(source = "receitaProducaoOperacao", target = "productionRecipeOperation")
@Mapping(source = "dataReferencia", target = "referenceDate")
@Named(value = "convertWithRecipeDetail")
public ProductionPlanDetailDTO convertWithRecipeDetail(ProductionPlanDetail);
@Mapping(source = "receitaProducaoOperacao.listaTecnica.materialOutput.id", target = "outputMaterialId")
@Mapping(source = "receitaProducaoOperacao.listaTecnica.id", target = "billOfMaterialsId")
@Mapping(source = "receitaProducaoOperacao.receitaProducaoOperacaoCompositeKey.receitaProducao.id", target = "productionRecipeId")
@Mapping(source = "receitaProducaoOperacao.recursoProdutivo.id", target = "productionResourceId")
@Mapping(source = "receitaProducaoOperacao.receitaProducaoOperacaoCompositeKey.posicaoOperacao", target = "productionRecipeOperationSequence")
@Mapping(source = "location.id", target = "locationId")
@Mapping(source = "dataReferencia", target = "referenceDate")
@Named(value = "convertWithoutRecipeDetail")
public ProductionPlanDetailDTO convertWithoutRecipeDetail(ProductionPlanDetail productionPlanDetail);
@Named(value = "convertToListWithRecipeDetail")
@IterableMapping(qualifiedByName = "convertWithRecipeDetail")
public List<ProductionPlanDetailDTO> convertToDTOListWithRecipeDetail (List<ProductionPlanDetail> productionPlanDetailList);
@Named(value = "convertToListWithoutRecipeDetail")
@IterableMapping(qualifiedByName = "convertWithoutRecipeDetail")
public List<ProductionPlanDetailDTO> convertToDTOListWithoutRecipeDetail (List<ProductionPlanDetail> productionPlanDetailList);
}
Неоднозначности между методами внутри второго сопоставителя разрешаются объединением @Name и @ IterableMapping # QualifiedByName
Мы попробовали тот же метод, добавив аннотацию ниже к методу convertMapProductionPlanDetail, но безрезультатно:
@IterableMapping(qualifiedByName = "convertToListWithRecipeDetail")