DEPO: ошибка в карточке перевода снимается, когда запись после возврата в очередь прошла

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q7eREaYwUt1i4fNLZcGnjn
This commit is contained in:
fontvielle
2026-10-22 17:53:28 +03:00
parent 188691557a
commit 56a5a50174
3 changed files with 15 additions and 4 deletions
+13 -2
View File
@@ -44,8 +44,12 @@ type DepoLink struct {
DocState string `json:"doc_state,omitempty"` // состояние документа в DEPO (OD_DOCS.STATE → название)
DocStateAt time.Time `json:"doc_state_at,omitempty"`
Errors []string `json:"errors,omitempty"` // DEPO_ERROR
LastEvent string `json:"last_event,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
// FixedErr/FixedAt — последняя ошибка, после которой запись прошла (вернули в очередь): в карточке —
// серой строкой вместо красной плашки.
FixedErr string `json:"fixed_err,omitempty"`
FixedAt time.Time `json:"fixed_at,omitempty"`
LastEvent string `json:"last_event,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
type depoLinkStore struct {
@@ -540,6 +544,13 @@ func depoPollOrders(ctx context.Context, db *sql.DB, rc *RuntimeConfig) {
globalDepoLinks.update(guid, func(x *DepoLink) { x.DocNo, x.DocAt, x.LastEvent = doc, time.Now(), "FTV_M2M.DOC" })
log.Printf("depo-events: DEPO создала поручение по %s: %s", shortGUID(guid), doc)
}
// запись прошла после ошибки (депозитарий вернул её в очередь) — ошибка устранена
if state == "SUCCESS" && lineErr == "" && l != nil && len(l.Errors) > 0 {
globalDepoLinks.update(guid, func(x *DepoLink) {
x.FixedErr, x.FixedAt, x.Errors = x.Errors[len(x.Errors)-1], time.Now(), nil
})
log.Printf("depo-events: перевод %s обработан в DEPO после ошибки — ошибка снята", shortGUID(guid))
}
if state == "ERROR" || lineErr != "" {
msg := strings.TrimSpace(comment + " " + lineErr)
if l == nil || len(l.Errors) == 0 || !strings.HasSuffix(l.Errors[len(l.Errors)-1], msg) {