+ nlp reatech

This commit is contained in:
xds
2025-04-08 12:13:20 +03:00
parent af7577c65b
commit 5d9cc167fc
5 changed files with 58 additions and 28 deletions

View File

@@ -48,6 +48,7 @@ class FinancialService(
val transactionsMapper: TransactionsMapper,
val budgetMapper: BudgetMapper,
private val subscriptionService: SubscriptionService,
private val nlpService: NLPService
) {
private val logger = LoggerFactory.getLogger(FinancialService::class.java)
@@ -761,6 +762,37 @@ class FinancialService(
}
}
suspend fun getAllTransactions(): List<Transaction>{
// Сборка агрегации
val lookup = lookup("categories", "category.\$id", "_id", "categoryDetails")
val unwindCategory = unwind("categoryDetails")
val lookupSpaces = lookup("spaces", "space.\$id", "_id", "spaceDetails")
val unwindSpace = unwind("spaceDetails")
val lookupUsers = lookup("users", "user.\$id", "_id", "userDetails")
val unwindUser = unwind("userDetails")
val sort =
sort(Sort.by(Direction.DESC, "date").and(Sort.by(Direction.DESC, "createdAt")))
val aggregationBuilder = mutableListOf(
lookup,
unwindCategory,
lookupSpaces,
unwindSpace,
lookupUsers,
unwindUser,
sort
)
val aggregation = newAggregation(aggregationBuilder)
return reactiveMongoTemplate.aggregate(
aggregation, "transactions", Document::class.java
).collectList().awaitSingle().map { doc ->
transactionsMapper.fromDocument(doc)
}
}
suspend fun getTransactionByParentId(parentId: String): Transaction? {
// Сборка агрегации
@@ -885,6 +917,9 @@ class FinancialService(
)
)
}
scope.launch {
nlpService.reteach()
}
return savedTransaction
}