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
74f662ea
authored
May 15, 2021
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
同步线上一年的数据
parent
28ec9d33
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
cmd/scm/sync_customs/main.go
cmd/scm/sync_customs/main.go
View file @
74f662ea
...
...
@@ -17,12 +17,15 @@ var (
//需要同步的的表
syncTable
=
[]
string
{
"Ent_balance_sheet"
,
"Ent_cash_flow"
,
"Ent_profit"
,
"Gathering_Account"
,
"HK_Customs_Declaration"
,
"Payment_Account"
,
"Purchase_Order"
,
"Sales_Order"
,
"SYS_OPERATE_LOG"
,
"Ent_profit"
,
"Purchase_Order"
,
"SYS_OPERATE_LOG"
,
}
//"Ent_balance_sheet","Ent_cash_flow",
//"Ent_profit","Gathering_Account",
//"HK_Customs_Declaration","Payment_Account",
//"Purchase_Order","Sales_Order",
//"SYS_OPERATE_LOG",
wg
sync
.
WaitGroup
)
...
...
@@ -46,15 +49,23 @@ func init(){
func
main
()
{
//获取当天时间
var
currentDate
=
time
.
Now
()
.
Format
(
"2006-01-02"
)
//var currentDate = time.Now().Format("2006-01-02")
//循环获取表名,然后获取表内当天信息,并且存入mysql,协程处理
for
_
,
v
:=
range
syncTable
{
wg
.
Add
(
1
)
go
handleCurrentTable
(
v
,
currentDate
)
}
wg
.
Wait
()
var
startTime
int64
=
1577808000
var
nowtime
=
time
.
Now
()
.
Unix
()
for
startTime
<
nowtime
{
currentDate
:=
time
.
Unix
(
startTime
,
0
)
.
Format
(
"2006-01-02"
)
for
_
,
v
:=
range
syncTable
{
//wg.Add(1)
handleCurrentTable
(
v
,
currentDate
)
}
startTime
+=
86400
}
//wg.Wait()
}
...
...
@@ -63,7 +74,7 @@ func main() {
//处理当前的这个表任务
func
handleCurrentTable
(
tableName
,
currentDate
string
)
{
defer
wg
.
Done
()
//
defer wg.Done()
fmt
.
Println
(
currentDate
+
"开始同步"
+
tableName
)
currentJson
:=
requestTableInfo
(
tableName
,
currentDate
)
...
...
@@ -104,6 +115,9 @@ func handleCurrentTable(tableName,currentDate string) {
if
currentNum
!=
""
&&
tableName
!=
"SYS_OPERATE_LOG"
{
sqlDb
.
Exec
(
"delete from "
+
tableName
+
" where number = ?"
,
currentNum
)
}
currentKey
+=
"data_sync_time,"
valueString
+=
"?,"
currentString
=
append
(
currentString
,
time
.
Now
()
.
Format
(
"2006-01-02"
))
currentString
[
0
]
=
`INSERT INTO `
+
tableName
+
` (`
+
currentKey
[
:
len
(
currentKey
)
-
1
]
+
`)VALUES (`
+
valueString
[
:
len
(
valueString
)
-
1
]
+
`)`
_
,
err
:=
sqlDb
.
Exec
(
currentString
...
)
...
...
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