FTV_M2M_LINES: TimeNew пишется явно (в боевой DEPO у таблицы строк нет умолчания GETDATE())
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
This commit is contained in:
@@ -242,6 +242,7 @@ func depoUpsertOrder(rc *RuntimeConfig, guid, direction, cpCode, deponentName, d
|
|||||||
}
|
}
|
||||||
// SHARE (ID бумаги в DEPO) — заполняем, если колонка есть (джоба может подставить сама)
|
// SHARE (ID бумаги в DEPO) — заполняем, если колонка есть (джоба может подставить сама)
|
||||||
hasShare := depoHasColumn(ctx, db, "FTV_M2M_LINES", "SHARE")
|
hasShare := depoHasColumn(ctx, db, "FTV_M2M_LINES", "SHARE")
|
||||||
|
hasLineTimeNew := depoHasColumn(ctx, db, "FTV_M2M_LINES", "TimeNew")
|
||||||
for _, ln := range lines {
|
for _, ln := range lines {
|
||||||
var share sql.NullInt64
|
var share sql.NullInt64
|
||||||
if ln.ISIN != "" && hasShare {
|
if ln.ISIN != "" && hasShare {
|
||||||
@@ -255,6 +256,14 @@ func depoUpsertOrder(rc *RuntimeConfig, guid, direction, cpCode, deponentName, d
|
|||||||
if hasDepoNumber {
|
if hasDepoNumber {
|
||||||
cols, vals = cols+", DEPO_NUMBER", vals+", @acc"
|
cols, vals = cols+", DEPO_NUMBER", vals+", @acc"
|
||||||
}
|
}
|
||||||
|
// TimeNew — явно: у FTV_M2M_LINES в боевой DEPO нет умолчания GETDATE() (29.09.2026), время было пустым
|
||||||
|
if hasLineTimeNew {
|
||||||
|
now := "GETDATE()"
|
||||||
|
if rc.Snapshot().Fancy.IsPostgres() {
|
||||||
|
now = "LOCALTIMESTAMP"
|
||||||
|
}
|
||||||
|
cols, vals = cols+", TimeNew", vals+", "+now
|
||||||
|
}
|
||||||
q := fsql.Ev06 + cols + `) VALUES (` + vals + `)`
|
q := fsql.Ev06 + cols + `) VALUES (` + vals + `)`
|
||||||
if _, err := tx.ExecContext(ctx, q,
|
if _, err := tx.ExecContext(ctx, q,
|
||||||
sql.Named("g", guid), sql.Named("r", ln.Ref), sql.Named("i", nullStr(ln.ISIN)), sql.Named("c", nullStr(ln.Code)), sql.Named("sh", share), sql.Named("a", ln.Amount), sql.Named("p", nullStr(ln.Place)), sql.Named("lnk", strings.TrimSpace(rc.Snapshot().NSD.AccountID)), sql.Named("acc", clientAcc)); err != nil {
|
sql.Named("g", guid), sql.Named("r", ln.Ref), sql.Named("i", nullStr(ln.ISIN)), sql.Named("c", nullStr(ln.Code)), sql.Named("sh", share), sql.Named("a", ln.Amount), sql.Named("p", nullStr(ln.Place)), sql.Named("lnk", strings.TrimSpace(rc.Snapshot().NSD.AccountID)), sql.Named("acc", clientAcc)); err != nil {
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
//go:build live
|
||||||
|
|
||||||
|
package lkgateway
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Только чтение: колонки времени и умолчания в таблицах обмена FTV_M2M*.
|
||||||
|
func TestFTVColsLive(t *testing.T) {
|
||||||
|
rc, err := NewRuntimeConfig("/var/lib/bj/.bj/setup.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
fs := rc.Snapshot().Fancy
|
||||||
|
db, err := fancyOpen(fs, fs.DepoDB())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
ctx := context.Background()
|
||||||
|
rows, err := db.QueryContext(ctx, `SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, ISNULL(COLUMN_DEFAULT,'—')
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME LIKE 'FTV_M2M%' AND COLUMN_NAME IN ('TimeNew','TimeBeg','TimeEnd','STATE') ORDER BY TABLE_NAME, ORDINAL_POSITION`)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
for rows.Next() {
|
||||||
|
var tb, c, dt, nl, def string
|
||||||
|
_ = rows.Scan(&tb, &c, &dt, &nl, &def)
|
||||||
|
fmt.Printf("%-18s %-8s %-9s null=%s default=%s\n", tb, c, dt, nl, def)
|
||||||
|
}
|
||||||
|
rows.Close()
|
||||||
|
for _, tb := range []string{"FTV_M2M", "FTV_M2M_LINES", "FTV_M2M_EVENTS"} {
|
||||||
|
var all, nnew, nbeg, nend int
|
||||||
|
_ = db.QueryRowContext(ctx, "SELECT COUNT(*), SUM(CASE WHEN TimeNew IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN TimeBeg IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN TimeEnd IS NULL THEN 1 ELSE 0 END) FROM dbo."+tb).Scan(&all, &nnew, &nbeg, &nend)
|
||||||
|
fmt.Printf("%s: строк %d, TimeNew пусто %d, TimeBeg пусто %d, TimeEnd пусто %d\n", tb, all, nnew, nbeg, nend)
|
||||||
|
}
|
||||||
|
var tn, tb2, te interface{}
|
||||||
|
_ = db.QueryRowContext(ctx, "SELECT TimeNew, TimeBeg, TimeEnd FROM dbo.FTV_M2M WHERE GUID='5A256E6D-9977-4DCD-A481-B2E494F0FE6A'").Scan(&tn, &tb2, &te)
|
||||||
|
fmt.Println("шапка 5A256E6D:", tn, tb2, te)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user