Commit b459f35d by Joneq

重新同步订单

parent 1cb0089d
Showing with 34 additions and 15 deletions
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ 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"
...@@ -49,22 +48,42 @@ func init(){ ...@@ -49,22 +48,42 @@ func init(){
var currentDatetime int64 var currentDatetime int64
//同步海关信息至中间库 //同步海关信息至中间库
func main() { //func main() {
runtime.GOMAXPROCS(5) // runtime.GOMAXPROCS(5)
//获取当天时间 // //获取当天时间
var currentDate = time.Now().Format("2006-01-02") // var currentDate = time.Now().Format("2006-01-02")
//获取当前时间 // //获取当前时间
currentDatetime = getSysLogLastTIme(scm_data_dao.GetScmDataDb()) // currentDatetime = getSysLogLastTIme(scm_data_dao.GetScmDataDb())
fmt.Println(currentDatetime) // fmt.Println(currentDatetime)
//
// //删除订单
// deleteOrder(currentDate)
//
// for _,v := range syncTable {
// wg.Add(1)
// go handleCurrentTable(v,currentDate)
// }
// wg.Wait()
//}
//删除订单 func main() {
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 { for _,v := range syncTable {
wg.Add(1) handleCurrentTable(v,currentDate)
go handleCurrentTable(v,currentDate) }
startTime+=86400
} }
wg.Wait()
} }
...@@ -97,9 +116,9 @@ func deleteOrder(currentDate string) { ...@@ -97,9 +116,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