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
8790642e
authored
May 20, 2021
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
正常同步
parent
b459f35d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
33 deletions
cmd/scm/sync_customs/main.go
cmd/scm/sync_customs/main.go
View file @
8790642e
...
...
@@ -7,6 +7,7 @@ import (
"github.com/ichunt2019/cfg/lib"
"github.com/tidwall/gjson"
"golang-asynctask/app/dao/scm_data_dao"
"runtime"
"sync"
"time"
"xorm.io/xorm"
...
...
@@ -48,44 +49,44 @@ 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)
// 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 {
// wg.Add(1)
// go handleCurrentTable(v,currentDate)
// handleCurrentTable(v,currentDate)
// }
// startTime+=86400
// }
// wg.Wait()
//}
func
main
()
{
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
}
}
func
deleteOrder
(
currentDate
string
)
{
table
:=
"Purchase_delete_Order"
...
...
@@ -116,9 +117,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