2026-09-07 15:11:33 +08:00
|
|
|
|
package com.gzzn.omms.msgexchange.delivery
|
2026-09-06 16:13:50 +08:00
|
|
|
|
|
2026-09-07 15:11:33 +08:00
|
|
|
|
import com.gzzn.omms.msgexchange.domain.MsgEvent
|
|
|
|
|
|
import com.gzzn.omms.msgexchange.domain.SchdPush
|
2026-09-06 16:13:50 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* ACMA-8 流程 3 flushSchd 聚合(纯函数,可单测):
|
|
|
|
|
|
* 按 PARTITION_KEY(=FLID) 分组、组内取 EVENT_ID 最大——v4 显式 max(EVENT_ID),
|
|
|
|
|
|
* 不依赖集合遍历序(FIX:现役 buffer 无去重会重复投递旧值)。
|
|
|
|
|
|
*/
|
|
|
|
|
|
object SchdAggregation {
|
|
|
|
|
|
fun latestPerFlight(pending: List<MsgEvent>): List<String> =
|
|
|
|
|
|
pending
|
|
|
|
|
|
.groupBy { it.partitionKey ?: "" }
|
|
|
|
|
|
.map { (_, evs) -> evs.maxBy { it.eventId ?: 0 }.payloadJson }
|
|
|
|
|
|
|
|
|
|
|
|
/** 由 Decision 直接构造时的等价聚合(测试与 dispatcher 共用语义)。 */
|
|
|
|
|
|
fun latestPerFlightOfPush(pushes: List<SchdPush>): List<String> =
|
|
|
|
|
|
pushes
|
|
|
|
|
|
.groupBy { it.flid }
|
2026-09-07 17:04:57 +08:00
|
|
|
|
.map { (_, ps) -> ps.maxBy { it.eventSeq }.payloadJson }
|
2026-09-06 16:13:50 +08:00
|
|
|
|
}
|