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
b459f35d
authored
May 19, 2021
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
重新同步订单
parent
1cb0089d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
17 deletions
cmd/scm/sync_customs/main.go
cmd/scm/sync_customs/main.go
View file @
b459f35d
...
...
@@ -7,7 +7,6 @@ import (
"github.com/ichunt2019/cfg/lib"
"github.com/tidwall/gjson"
"golang-asynctask/app/dao/scm_data_dao"
"runtime"
"sync"
"time"
"xorm.io/xorm"
...
...
@@ -49,22 +48,42 @@ func init(){
var
currentDatetime
int64
//同步海关信息至中间库
//func main() {
// runtime.GOMAXPROCS(5)
// //获取当天时间
// var currentDate = time.Now().Format("2006-01-02")
// //获取当前时间
// currentDatetime = getSysLogLastTIme(scm_data_dao.GetScmDataDb())
// fmt.Println(currentDatetime)
//
// //删除订单
// deleteOrder(currentDate)
//
// for _,v := range syncTable {
// wg.Add(1)
// go handleCurrentTable(v,currentDate)
// }
// wg.Wait()
//}
func
main
()
{
runtime
.
GOMAXPROCS
(
5
)
//获取当天时间
var
currentDate
=
time
.
Now
()
.
Format
(
"2006-01-02"
)
//获取当前时间
currentDatetime
=
getSysLogLastTIme
(
scm_data_dao
.
GetScmDataDb
())
fmt
.
Println
(
currentDatetime
)
//删除订单
deleteOrder
(
currentDate
)
for
_
,
v
:=
range
syncTable
{
wg
.
Add
(
1
)
go
handleCurrentTable
(
v
,
currentDate
)
sqlDb
:=
scm_data_dao
.
GetScmDataDb
()
sqlDb
.
Exec
(
"truncate Ent_balance_sheet"
)
sqlDb
.
Exec
(
"truncate Ent_cash_flow"
)
sqlDb
.
Exec
(
"truncate Ent_profit"
)
sqlDb
.
Exec
(
"truncate Purchase_Order"
)
sqlDb
.
Exec
(
"truncate SYS_OPERATE_LOG"
)
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
{
handleCurrentTable
(
v
,
currentDate
)
}
startTime
+=
86400
}
wg
.
Wait
()
}
...
...
@@ -97,9 +116,9 @@ func deleteOrder(currentDate string) {
//处理当前的这个表任务
func
handleCurrentTable
(
tableName
,
currentDate
string
)
{
defer
wg
.
Done
()
//
defer wg.Done()
fmt
.
Println
(
currentDate
+
"开始同步"
+
tableName
)
//
fmt.Println(currentDate+"开始同步"+tableName)
currentJson
:=
requestTableInfo
(
tableName
,
currentDate
)
if
currentJson
==
""
{
...
...
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