diff --git a/src/main/java/kz/konturai/parser/service/MarketingStrategyV3Service.java b/src/main/java/kz/konturai/parser/service/MarketingStrategyV3Service.java index 28316b2..349a190 100644 --- a/src/main/java/kz/konturai/parser/service/MarketingStrategyV3Service.java +++ b/src/main/java/kz/konturai/parser/service/MarketingStrategyV3Service.java @@ -13,6 +13,8 @@ import kz.konturai.parser.repository.MarketingAnalysisV3Repository; import kz.konturai.parser.repository.MarketingStrategyRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.scheduling.annotation.Async; @@ -36,6 +38,11 @@ public class MarketingStrategyV3Service { private final PostingTaskService postingTaskService; private final MinIOService minIOService; + // Решение проблемы с @Async (Self-Injection) + @Autowired + @Lazy + private MarketingStrategyV3Service self; + private final ObjectMapper objectMapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); @@ -76,7 +83,9 @@ public class MarketingStrategyV3Service { addStatusHistoryEntry(strategy, "queued", "Запуск генерации. ИИ проектирует массированный контент-план..."); strategy = repository.save(strategy); - processStrategyGenerationAsync(strategy.getId(), analysisDoc, strategy); + + // Вызов через прокси для корректной работы @Async + self.processStrategyGenerationAsync(strategy.getId(), analysisDoc, strategy); return strategy; }