You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
starainrt/net_test.go

185 lines
3.9 KiB
Go

package starainrt
import (
"fmt"
"testing"
)
func Test_oldddd(t *testing.T) {
a := []int{}
a = append(a, 1)
a = append(a, 2)
a = append(a, 3)
fmt.Println(a)
a = a[3:]
fmt.Println(a)
}
func Test_binary(t *testing.T) {
bytes := Uint16ToByte(65512)
fmt.Println(bytes)
fmt.Println(ByteToUint16(bytes))
}
func Test_test(t *testing.T) {
que := NewQueue()
okk := que.BuildMessage([]byte(`
with
all_values as (
(select V.ID,
V.OBJID,
V.TITLE,
V.CONTENT,
V.URL,
V.URL_TYPE,
V.STATUS,
V.SEARCH_TIMES,
V.UPDATE_TIMES
from SPMS_SEARCH_VIEW V
)
),
in_values as (
select T1.*
from SPMS_SEARCH_DATASET T1,
(select V.ID,
V.OBJID,
V.TITLE,
V.CONTENT,
V.URL,
V.URL_TYPE,
V.STATUS,
V.SEARCH_TIMES,
V.UPDATE_TIMES
from SPMS_SEARCH_VIEW V
) T
where T.OBJID = T1.OBJID
),
upsert as (
update SPMS_SEARCH_DATASET as T1
set
ID = T.ID,
TITLE = T.TITLE,
CONTENT = T.CONTENT,
URL = T.URL,
URL_TYPE = T.URL_TYPE,
STATUS = T.STATUS,
SEARCH_TIMES = T.SEARCH_TIMES,
UPDATE_TIMES = TO_CHAR(T.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss'),
SYNC_TIMES = V_CUR_TIME
from all_values T
where T.OBJID = T1.OBJID and TO_DATE(T1.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss') \u003c TO_DATE(TO_CHAR(T.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss'), 'yyyy-MM-dd hh24:mi:ss')
)
insert into SPMS_SEARCH_DATASET(ID, OBJID, TITLE, CONTENT, URL, URL_TYPE, STATUS, SEARCH_TIMES, UPDATE_TIMES, SYNC_TIMES)
select T.ID,
T.OBJID,
T.TITLE,
T.CONTENT,
T.URL,
T.URL_TYPE,
T.STATUS,
T.SEARCH_TIMES,
TO_CHAR(T.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss'),
V_CUR_TIME
from (select V.ID,
V.OBJID,
V.TITLE,
V.CONTENT,
V.URL,
V.URL_TYPE,
V.STATUS,
V.SEARCH_TIMES,
V.UPDATE_TIMES
from SPMS_SEARCH_VIEW V
) T
where not exists(select 1
from in_values T1
where T.OBJID = T1.OBJID
)
with
all_values as (
(select V.ID,
V.OBJID,
V.TITLE,
V.CONTENT,
V.URL,
V.URL_TYPE,
V.STATUS,
V.SEARCH_TIMES,
V.UPDATE_TIMES
from SPMS_SEARCH_VIEW V
)
),
in_values as (
select T1.*
from SPMS_SEARCH_DATASET T1,
(select V.ID,
V.OBJID,
V.TITLE,
V.CONTENT,
V.URL,
V.URL_TYPE,
V.STATUS,
V.SEARCH_TIMES,
V.UPDATE_TIMES
from SPMS_SEARCH_VIEW V
) T
where T.OBJID = T1.OBJID
),
upsert as (
update SPMS_SEARCH_DATASET as T1
set
ID = T.ID,
TITLE = T.TITLE,
CONTENT = T.CONTENT,
URL = T.URL,
URL_TYPE = T.URL_TYPE,
STATUS = T.STATUS,
SEARCH_TIMES = T.SEARCH_TIMES,
UPDATE_TIMES = TO_CHAR(T.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss'),
SYNC_TIMES = V_CUR_TIME
from all_values T
where T.OBJID = T1.OBJID and TO_DATE(T1.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss') \u003c TO_DATE(TO_CHAR(T.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss'), 'yyyy-MM-dd hh24:mi:ss')
)
insert into SPMS_SEARCH_DATASET(ID, OBJID, TITLE, CONTENT, URL, URL_TYPE, STATUS, SEARCH_TIMES, UPDATE_TIMES, SYNC_TIMES)
select T.ID,
T.OBJID,
T.TITLE,
T.CONTENT,
T.URL,
T.URL_TYPE,
T.STATUS,
T.SEARCH_TIMES,
TO_CHAR(T.UPDATE_TIMES, 'yyyy-MM-dd hh24:mi:ss'),
V_CUR_TIME
from (select V.ID,
V.OBJID,
V.TITLE,
V.CONTENT,
V.URL,
V.URL_TYPE,
V.STATUS,
V.SEARCH_TIMES,
V.UPDATE_TIMES
from SPMS_SEARCH_VIEW V
) T
where not exists(select 1
from in_values T1
where T.OBJID = T1.OBJID
)
`))
fmt.Println(string(okk))
que.ParseMessage([]byte{'n', 'm', 'b'}, "nbb")
// que.ParseMessage([]byte{'n', 23, 24, 4, 45, 6, 56, 56, 2, 3, 1, 2}, "nbb")
que.ParseMessage(okk[0:123], "nbb")
que.ParseMessage([]byte{}, "nbb")
que.ParseMessage([]byte{}, "nbb")
que.ParseMessage([]byte{}, "nbb")
que.ParseMessage(okk[123:135], "nbb")
que.ParseMessage(okk[135:], "nbb")
fmt.Println(string(que.MsgPool[0].Msg))
}