From 627f52cf5d9c2561fa6895b091f591330137dcf3 Mon Sep 17 00:00:00 2001 From: zuevav Date: Thu, 24 Sep 2026 12:05:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=20DEPO:=20SEC=5FCODE?= =?UTF-8?q?=20=3D=20=D0=BA=D0=BE=D0=B4=20=D0=B1=D1=83=D0=BC=D0=B0=D0=B3?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D0=9D=D0=A0=D0=94=20(=D0=BA=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D1=89=D0=B8=D0=BA=20=D0=9D=D0=94=D0=A6?= =?UTF-8?q?),=20=D0=BA=D0=B0=D0=BA=20=D0=B2=20=D0=BD=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=8F=D1=89=D0=B5=D0=BC=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82?= =?UTF-8?q?=D0=B5;=20=D0=BF=D1=80=D0=B5=D0=B4=D1=83=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5,=20=D0=B5=D1=81=D0=BB?= =?UTF-8?q?=D0=B8=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=BD=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- internal/lkgateway/depotest.go | 23 +++++++++++++++++-- internal/lkgateway/fsql/depotest.go | 4 ++++ .../web/templates/admin_depo_test.html | 4 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/internal/lkgateway/depotest.go b/internal/lkgateway/depotest.go index 5b60e3f..dc3550b 100644 --- a/internal/lkgateway/depotest.go +++ b/internal/lkgateway/depotest.go @@ -43,6 +43,7 @@ var depoTestOutcomes = []struct{ Code, Title string }{ type DepoTestLine struct { Ref, ISIN, Qty, Outcome, Code string + Code2 string // код бумаги в НРД, ушедший в SEC_CODE State, DOL, Comment string // результат джобы по строке FTV_M2M_LINES } @@ -157,8 +158,17 @@ func depoTestExec(rc *RuntimeConfig, run *DepoTestRun, pace time.Duration, stopO // 1. шапка и строки place := rc.Snapshot().NSD.SectionID var lines []depoLine - for _, l := range run.Lines { - lines = append(lines, depoLine{Ref: l.Ref, ISIN: l.ISIN, Code: l.ISIN, Amount: parseQty(l.Qty), Place: place}) + for i, l := range run.Lines { + // SEC_CODE — код бумаги в НРД (как в настоящем пакете M2M): по ISIN+коду джоба находит бумагу в DEPO + code := depoNSDCode(db, l.ISIN) + if code == "" { + code = l.ISIN + globalDepoTests.update(id, func(r *DepoTestRun) { + r.Steps = append(r.Steps, DepoTestStep{At: time.Now(), Title: "Бумага " + l.ISIN + ": кода НРД (кодировщик «НДЦ») в DEPO нет — SEC_CODE = ISIN, джоба может не найти бумагу", State: "WARN"}) + }) + } + globalDepoTests.update(id, func(r *DepoTestRun) { r.Lines[i].Code2 = code }) + lines = append(lines, depoLine{Ref: l.Ref, ISIN: l.ISIN, Code: code, Amount: parseQty(l.Qty), Place: place}) } dir := "IN" if run.Direction == "out" { @@ -251,6 +261,15 @@ func depoTestExec(rc *RuntimeConfig, run *DepoTestRun, pace time.Duration, stopO depoTestFinish(db, id, run.GUID) } +// depoNSDCode — код бумаги в НРД из DEPO (кодировщик «НДЦ»). +func depoNSDCode(db *sql.DB, isin string) string { + ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second) + defer cancel() + var c string + _ = db.QueryRowContext(ctx, fsql.DT04, sql.Named("i", strings.ToUpper(strings.TrimSpace(isin)))).Scan(&c) + return strings.TrimSpace(c) +} + func depoTestFinish(db *sql.DB, id, guid string) { ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() diff --git a/internal/lkgateway/fsql/depotest.go b/internal/lkgateway/fsql/depotest.go index 489a4d4..5518d60 100644 --- a/internal/lkgateway/fsql/depotest.go +++ b/internal/lkgateway/fsql/depotest.go @@ -9,3 +9,7 @@ var DT02 = `SELECT TOP 1 ISNULL(STATE,''), ISNULL(COMMENT,'') FROM dbo.FTV_M2M_E var DT03 = `SELECT ISNULL(REFERENCE,''), ISNULL(ISIN,''), ISNULL(STATE,''), ISNULL(CAST(DOL AS varchar(32)),''), ISNULL(COMMENT,'') FROM dbo.FTV_M2M_LINES WHERE GUID=@g ORDER BY ID` + +// DT04 — код бумаги в НРД (кодировщик «НДЦ»), как его ищет джоба bj2depo по ISIN + SEC_CODE. +var DT04 = `SELECT TOP 1 ISNULL(C.CODE,'') FROM OD_VALUES V JOIN OD_VALUE_CODERS C ON C.SHARE = V.ID + JOIN OD_FACES F ON F.SELF_ID = C.CODER AND F.LAST_FLAG = 1 WHERE V.ISIN = @i AND F.MNEM = N'НДЦ' ORDER BY V.ID` diff --git a/internal/lkgateway/web/templates/admin_depo_test.html b/internal/lkgateway/web/templates/admin_depo_test.html index 21ec4d7..eede5f6 100644 --- a/internal/lkgateway/web/templates/admin_depo_test.html +++ b/internal/lkgateway/web/templates/admin_depo_test.html @@ -10,7 +10,7 @@ .st{display:inline-block;padding:1px 8px;border-radius:999px;font-size:12px;font-weight:700} .st.SUCCESS{background:var(--ok-weak,#e6f4ea);color:var(--ok,#12813f)} .st.ERROR{background:var(--err-weak,#fbe9e7);color:var(--err,#b3261e)} - .st.TODO,.st.running{background:var(--warn-weak,#fff4e0);color:var(--warn,#9a6b12)} + .st.TODO,.st.WARN,.st.running{background:var(--warn-weak,#fff4e0);color:var(--warn,#9a6b12)} .st.done{background:var(--ok-weak,#e6f4ea);color:var(--ok,#12813f)} .st.error{background:var(--err-weak,#fbe9e7);color:var(--err,#b3261e)} table.dt{width:100%;border-collapse:collapse;font-size:13px} @@ -66,7 +66,7 @@ {{if eq .Direction "out"}}↗ Списание{{else}}↘ Зачисление{{end}} · {{.Client}} · {{.CPName}} ({{.CP}})

Прогон {{.ID}} · {{.Created.Format "02.01.2006 15:04:05"}} · GUID {{.GUID}} · документ DEPO {{if .Doc}}№ {{.Doc}}{{else}}—{{end}} · шапка {{.HeaderState}}{{if .Errors}} · ошибок: {{.Errors}}{{end}}

- {{range .Lines}}{{end}} + {{range .Lines}}{{end}}
БумагаКол-воСценарийСтрока DEPO
{{.ISIN}}
{{.Ref}}
{{.Qty}}{{.Outcome}}{{if .Code}} {{.Code}}{{end}}{{if .State}}{{.State}} {{if .DOL}}№ {{.DOL}}{{end}} {{.Comment}}{{else}}—{{end}}
{{.ISIN}}{{if .Code2}} · {{.Code2}}{{end}}
{{.Ref}}
{{.Qty}}{{.Outcome}}{{if .Code}} {{.Code}}{{end}}{{if .State}}{{.State}} {{if .DOL}}№ {{.DOL}}{{end}} {{.Comment}}{{else}}—{{end}}
Шаги ({{len .Steps}})
ВремяШагСобытие / строкаДжоба DEPO