Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
golang_asynctask
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
aeab8f3a
authored
Jun 11, 2021
by
孙龙
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://119.23.72.7/sunlong_v5/golang-asynctask
parents
9d1d18b2
e0c310f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
11 deletions
cmd/bigtv/README.md
cmd/scm/sync_bigtv_statistics/main.go → cmd/bigtv/sync_bigtv_statistics/main.go
config/prod/db.toml
cmd/bigtv/README.md
0 → 100644
View file @
aeab8f3a
#供应链的同步
sync_bigtv_statistics 同步erp的每日统计至shuju库
go run ./cmd/bigtv/sync_bigtv_statistics/main.go -config=./config/dev/ -logdir = ./logs/
cmd/
scm
/sync_bigtv_statistics/main.go
→
cmd/
bigtv
/sync_bigtv_statistics/main.go
View file @
aeab8f3a
...
...
@@ -11,6 +11,7 @@ import (
"net/http"
"runtime"
"strconv"
"strings"
"sync"
"time"
)
...
...
@@ -44,13 +45,13 @@ func main() {
runtime
.
GOMAXPROCS
(
2
)
currentDate
=
time
.
Now
()
.
Format
(
"2006-01-02"
)
//currentDate := "2021-05-06"
//请求数据
currentUnix
=
time
.
Now
()
.
Unix
()
timeLocal
,
_
:=
time
.
LoadLocation
(
"Local"
)
timeStart
,
_
=
time
.
ParseInLocation
(
"2006-01-02"
,
currentDate
,
timeLocal
)
//获取当前时间
fmt
.
Println
(
currentDate
)
...
...
@@ -64,6 +65,13 @@ func main() {
wg
.
Wait
()
}
func
main_back
()
{
sqlDb
:=
scm_data_dao
.
GetDashboardDb
()
sqlDb
.
Exec
(
"delete from lie_btv_daily_order_transaction where `datetime` = '2021-05-31'"
)
sqlDb
.
Exec
(
"delete from lie_btv_daily_top_order where `datetime` = '2021-05-31'"
)
sqlDb
.
Exec
(
"delete from lie_btv_daily_top_search where `datetime` = '2021-05-31'"
)
}
func
GetTotalStatistic
()
{
...
...
@@ -72,14 +80,14 @@ func GetTotalStatistic() {
jsonStr
:=
RequestTableInfo
(
"totalStatistic"
)
//{"data": [{"materialQty": 0, "materialCount": 0, "materialTotalQty": 966724502}], "returnCode": "0000", "returnMsg": "\u6210\u529f"}
fmt
.
Println
(
"totalStatistic"
+
jsonStr
)
if
gjson
.
Get
(
jsonStr
,
"returnCode"
)
.
String
()
!=
"0000"
||
gjson
.
Get
(
jsonStr
,
"data"
)
.
String
()
==
"[]"
{
fmt
.
Println
(
jsonStr
)
return
}
sqlDb
:=
scm_data_dao
.
GetDashboardDb
()
currentSearch
:=
TopSearch
()
currentSearch
:=
TopSearch
()
for
_
,
res
:=
range
gjson
.
Get
(
jsonStr
,
"data"
)
.
Array
()
{
...
...
@@ -111,14 +119,16 @@ func GetMaterialstatistic() {
jsonStr
:=
RequestTableInfo
(
"topStatistic"
)
//{"data": [], "returnCode": "0000", "returnMsg": "\u6210\u529f"}
fmt
.
Println
(
"topStatistic json:"
+
jsonStr
)
if
gjson
.
Get
(
jsonStr
,
"returnCode"
)
.
String
()
!=
"0000"
||
gjson
.
Get
(
jsonStr
,
"data"
)
.
String
()
==
"[]"
{
fmt
.
Println
(
jsonStr
)
return
}
sqlDb
:=
scm_data_dao
.
GetDashboardDb
()
i
:=
1
for
_
,
res
:=
range
gjson
.
Get
(
jsonStr
,
"data"
)
.
Array
()
{
erpKey
:=
make
(
map
[
string
]
interface
{})
...
...
@@ -128,8 +138,9 @@ func GetMaterialstatistic() {
})
//添加数据
_
,
err
:=
sqlDb
.
Exec
(
"insert into lie_btv_daily_top_order (datetime,sn,order_num)"
+
"value(?,?,?)"
,
currentDate
,
erpKey
[
"materialName"
],
erpKey
[
"materialQty"
])
_
,
err
:=
sqlDb
.
Exec
(
"insert into lie_btv_daily_top_order (sort,datetime,sn,order_num)"
+
"value(?,?,?,?)"
,
i
,
currentDate
,
erpKey
[
"materialName"
],
erpKey
[
"materialQty"
])
i
++
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
...
...
@@ -159,6 +170,7 @@ func TopSearch()int64 {
sqlDb
:=
scm_data_dao
.
GetDashboardDb
()
i
:=
1
for
_
,
res
:=
range
gjson
.
Get
(
jsonStr
,
"data"
)
.
Array
()
{
erpKey
:=
make
(
map
[
string
]
interface
{})
...
...
@@ -173,13 +185,13 @@ func TopSearch()int64 {
if
insertDataNum
>
0
{
//添加数据
_
,
err
:=
sqlDb
.
Exec
(
"insert into lie_btv_daily_top_search (datetime,sn,search_num)"
+
"value(?,?,?
)"
,
currentDate
,
erpKey
[
"goods_name"
],
erpKey
[
"count"
])
_
,
err
:=
sqlDb
.
Exec
(
"insert into lie_btv_daily_top_search (
sort,
datetime,sn,search_num)"
+
"value(?,?,?
,?)"
,
i
,
currentDate
,
erpKey
[
"goods_name"
],
erpKey
[
"count"
])
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
}
i
++
insertDataNum
--
}
...
...
@@ -200,7 +212,7 @@ func RequestTableInfo(requestType string)string {
client
:=
rpc
.
NewHTTPClient
(
"http://119.23.228.186:50005/"
)
client
.
UseService
(
&
sub
)
result
,
err
:=
sub
.
Get_materialstatistic
(
`{"date":"`
+
currentDate
+
`","requestType":"`
+
requestType
+
`"}`
)
result
,
err
:=
sub
.
Get_materialstatistic
(
`{"date":"`
+
strings
.
Replace
(
currentDate
,
"-"
,
""
,
-
1
)
+
`","requestType":"`
+
requestType
+
`"}`
)
if
err
!=
nil
{
fmt
.
Println
(
requestType
+
"请求服务器出错"
+
err
.
Error
())
return
""
...
...
@@ -210,10 +222,13 @@ func RequestTableInfo(requestType string)string {
return
result
}
func
GetCurrentSku
()
string
{
requestStr
:=
"http://soso12.ichunt.com/search/Es/searchSku?create_time/range="
+
strconv
.
FormatInt
(
timeStart
.
Unix
(),
10
)
+
","
+
strconv
.
FormatInt
(
currentUnix
,
10
)
+
"&goods_status/condition=1"
requestStr
:=
"http://so12.ichunt.com/search/Es/searchSku?goods_status/condition=1"
fmt
.
Println
(
requestStr
)
requestResult
:=
RequestUrl
(
requestStr
)
fmt
.
Println
(
"sku总量json"
+
requestResult
)
return
gjson
.
Get
(
requestResult
,
"data.total"
)
.
String
()
}
...
...
config/prod/db.toml
View file @
aeab8f3a
...
...
@@ -21,4 +21,12 @@ ShowSQL = true
max_open_conn
=
20
max_idle_conn
=
10
table_prefix
=
""
max_conn_life_time
=
100
[dashboard]
dns
=
"dashboard:0633F@bc92af0ecf9789d@tcp(172.18.137.35:3306)/dashboard?charset=utf8&parseTime=true&loc=Asia%2FShanghai"
max_open_conn
=
20
max_idle_conn
=
10
table_prefix
=
""
max_conn_life_time
=
100
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment