Files
msgexchange-v2/src/main/kotlin/com/gzzn/omms/msgexchange/processing/Identity.kt
T

25 lines
862 B
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.gzzn.omms.msgexchange.processing
import com.gzzn.omms.msgexchange.config.PipelineProps
import com.gzzn.omms.msgexchange.domain.DecodedMessage
import java.time.LocalDate
/**
* ACMA-8 I3:幂等键 = SNDR|TYPE|STYP|SEQN。
* 计算集中此处唯一入口;“是否含日边界”可配置且默认关闭(CONFIRM 矩阵 #11
* SEQN 重置作用域确认前不改语义——上线后不改幂等键)。
*/
object Identity {
fun of(
msg: DecodedMessage,
includeDayBoundary: Boolean,
day: LocalDate = LocalDate.now(),
): String {
val base = "${msg.meta.sndr}|${msg.meta.type}|${msg.meta.styp}|${msg.meta.seqn}"
return if (includeDayBoundary) "$base|${day}" else base
}
fun of(msg: DecodedMessage, props: PipelineProps.Identity): String =
of(msg, props.includeDayBoundary)
}