Путь заявки из всех источников: сделка, QUIK, события DEPO (с обработкой/ошибкой), поручение 16 и документы НРД (регистрация, GS036, GS116 сквитовано, MS010); «Обновлена» — последнее событие; статус учитывает сквитовку (GS116), время MS010 в строке статуса

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
This commit is contained in:
zuevav
2026-09-29 12:44:52 +03:00
parent e123eda691
commit 340fca7bd7
7 changed files with 405 additions and 46 deletions
+53
View File
@@ -0,0 +1,53 @@
//go:build live
package lkgateway
import (
"bytes"
"context"
"fmt"
"os"
"regexp"
"strings"
"testing"
"git.zetit.ru/zuevav/Bridge-and-Join-s/internal/m2mcore"
)
// Путь заявки на живых данных: go test -c -tags live; запуск от bj с TL_ID=<id сделки>.
func TestTimelineLive(t *testing.T) {
rc, err := NewRuntimeConfig("/var/lib/bj/.bj/setup.json")
if err != nil {
t.Fatal(err)
}
globalRC = rc
globalOutgoingStore = NewOutgoingStore()
repo, err := m2mcore.NewPostgresRepository(context.Background(), rc.Snapshot().Postgres.DSN)
if err != nil {
t.Fatal(err)
}
svc := NewService(Config{Repository: repo})
for _, id := range strings.Split(os.Getenv("TL_ID"), ",") {
v, err := svc.GetClaim(context.Background(), id)
if err != nil {
t.Fatal(err)
}
v.Timeline = buildClaimTimeline(context.Background(), v)
fmt.Printf("=== %s создана %s обновлена(сделка) %s, последнее событие %s\n", id[:8], v.CreatedAt.Format("15:04:05 MST"), v.UpdatedAt.Format("15:04:05 MST"), timelineLast(v.Timeline).Format("15:04:05"))
for _, e := range v.Timeline {
fmt.Printf(" %-9s %-8s [%s] %s — %s\n", e.Time.Format("15:04:05"), e.Since, e.Kind, e.Title, e.Detail)
}
if os.Getenv("TL_HTML") != "" {
a, _ := newAdmin()
var b bytes.Buffer
if err := a.claim.ExecuteTemplate(&b, "layout", claimData{page: page{Title: "Заявка"}, Claim: v, Watch: globalOrderWatch.Get(string(v.M2MGUID))}); err != nil {
t.Fatal(err)
}
txt := regexp.MustCompile(`(?s)<style.*?</style>|<script.*?</script>`).ReplaceAllString(b.String(), "")
txt = regexp.MustCompile(`<[^>]+>`).ReplaceAllString(txt, " ")
txt = regexp.MustCompile(`\s+`).ReplaceAllString(txt, " ")
i := strings.Index(txt, "Заявка ")
fmt.Println(txt[i:min(len(txt), i+1500)])
}
}
}