Commit 8790642e by Joneq

正常同步

parent b459f35d
Showing with 34 additions and 33 deletions
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/ichunt2019/cfg/lib" "github.com/ichunt2019/cfg/lib"
"github.com/tidwall/gjson" "github.com/tidwall/gjson"
"golang-asynctask/app/dao/scm_data_dao" "golang-asynctask/app/dao/scm_data_dao"
"runtime"
"sync" "sync"
"time" "time"
"xorm.io/xorm" "xorm.io/xorm"
...@@ -48,44 +49,44 @@ func init(){ ...@@ -48,44 +49,44 @@ func init(){
var currentDatetime int64 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() { //func main() {
// runtime.GOMAXPROCS(5)
// //获取当天时间
// var currentDate = time.Now().Format("2006-01-02")
// //获取当前时间
// currentDatetime = getSysLogLastTIme(scm_data_dao.GetScmDataDb())
// fmt.Println(currentDatetime)
// //
// //删除订单 // sqlDb := scm_data_dao.GetScmDataDb()
// deleteOrder(currentDate) // 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 { // for _,v := range syncTable {
// wg.Add(1) // handleCurrentTable(v,currentDate)
// go 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) { func deleteOrder(currentDate string) {
table := "Purchase_delete_Order" table := "Purchase_delete_Order"
...@@ -116,9 +117,9 @@ func deleteOrder(currentDate string) { ...@@ -116,9 +117,9 @@ func deleteOrder(currentDate string) {
//处理当前的这个表任务 //处理当前的这个表任务
func handleCurrentTable(tableName,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) currentJson := requestTableInfo(tableName,currentDate)
if currentJson == "" { if currentJson == "" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment