feat: 增加顺运宝批量 AI 规格匹配 (#202)

This commit is contained in:
chengma
2026-08-14 10:30:08 +08:00
parent 0201dab98c
commit d64579e9b3
26 changed files with 1289 additions and 26 deletions
+8 -4
View File
@@ -33,6 +33,7 @@ type AISpecMatchResult struct {
Source string
OptionKey string
ConfidenceBPS int
ConfidenceSet bool
ContextVersion string
ModelCalled bool
}
@@ -98,7 +99,8 @@ func MatchSybSpecWithAI(ctx context.Context, db *sql.DB, actor *model.User, snap
source = "manual"
}
return AISpecMatchResult{Outcome: "reused", Message: "已复用当前有效规格映射", Source: source,
OptionKey: orderContext.MappingOptionKey, ConfidenceBPS: orderContext.MappingConfidenceBPS, ContextVersion: version}, nil
OptionKey: orderContext.MappingOptionKey, ConfidenceBPS: orderContext.MappingConfidenceBPS,
ConfidenceSet: orderContext.MappingConfidenceSet, ContextVersion: version}, nil
}
choices, keys, names, err := pddOptionChoices(orderContext.PddSkusJSON)
if err != nil {
@@ -289,7 +291,8 @@ func saveAutomaticMapping(db *sql.DB, actor model.User, original repository.SybO
return AISpecMatchResult{}, err
}
return AISpecMatchResult{Outcome: outcome, Message: decision.Reason, Source: actualSource,
OptionKey: actual.PddOptionKey, ConfidenceBPS: actual.ConfidenceBPS, ContextVersion: decision.ContextVersion}, nil
OptionKey: actual.PddOptionKey, ConfidenceBPS: actual.ConfidenceBPS,
ConfidenceSet: actual.ConfidenceSet, ContextVersion: decision.ContextVersion}, nil
}
decision.Outcome = source + "_saved"
decision.ChosenOptionKey = latestChoice.Key
@@ -301,7 +304,8 @@ func saveAutomaticMapping(db *sql.DB, actor model.User, original repository.SybO
return AISpecMatchResult{}, err
}
return AISpecMatchResult{Outcome: decision.Outcome, Message: "规格映射已保存", Source: source,
OptionKey: latestChoice.Key, ConfidenceBPS: decision.ConfidenceBPS, ContextVersion: decision.ContextVersion}, nil
OptionKey: latestChoice.Key, ConfidenceBPS: decision.ConfidenceBPS,
ConfidenceSet: decision.ConfidenceSet, ContextVersion: decision.ContextVersion}, nil
}
func recordAIMatchWithoutSave(db *sql.DB, decision model.AISpecMatchDecision, outcome, reason string) (AISpecMatchResult, error) {
@@ -319,7 +323,7 @@ func recordAIMatchWithoutSave(db *sql.DB, decision model.AISpecMatchDecision, ou
return AISpecMatchResult{}, err
}
return AISpecMatchResult{Outcome: outcome, Message: decision.Reason, ConfidenceBPS: decision.ConfidenceBPS,
ContextVersion: decision.ContextVersion}, nil
ConfidenceSet: decision.ConfidenceSet, ContextVersion: decision.ContextVersion}, nil
}
func newAISpecDecision(c repository.SybOrderContext, actor model.User, snapshot AIMatchSnapshot, version string) model.AISpecMatchDecision {