Commit 97dc9094 by Joneq

增加忽略文件

parent b5b3efee
......@@ -5,4 +5,5 @@
*.properties
*.exe
*.exe~
gowatch.yml
\ No newline at end of file
gowatch.yml
./logs
\ No newline at end of file
package scm_data_dao
import (
"database/sql"
"fmt"
"log"
_ "github.com/lib/pq"
"github.com/jmoiron/sqlx"
)
//初始化数据库
func GetScmDataDb() {
sqlx.Open("mysql")
}
#供应链的公布
sync_customs 海关所需要的信息同步
\ No newline at end of file
package main
import (
"fmt"
"github.com/ichunt2019/cfg/lib"
"sync"
"time"
"github.com/hprose/hprose-golang/rpc"
"github.com/tidwall/gjson"
)
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",
}
wg sync.WaitGroup
)
//同步海关信息至中间库
func main() {
fmt.Println(lib.Instance("db").GetString("scm_data"))
panic(1)
//获取当天时间
var currentDate = time.Now().Format("2006-01-02")
//循环获取表名,然后获取表内当天信息,并且存入mysql,协程处理
for _,v := range syncTable {
wg.Add(1)
go handleCurrentTable(v,currentDate)
}
wg.Wait()
}
//处理当前的这个表任务
func handleCurrentTable(tableName,currentDate string) {
fmt.Println(currentDate+"开始同步"+tableName)
currentJson := requestTableInfo(tableName,currentDate)
if currentJson == "" {
return
}
//var sqlInsert string = "insert into "+ tableName
for _, res := range gjson.Parse(currentJson).Array() {
//sqlkey
res.ForEach(func(key, value gjson.Result) bool {
//获取key和val并拼接字符串
return true
})
}
}
//获取表信息,返回byte
//request example //http://119.23.228.186:50005/ getCustomsDockingData {"tableName":"SYS_OPERATE_LOG","bizDate":"2021-05-07"}
func requestTableInfo(tableName,currentDate string)string {
type Sub struct {
GetCustomsDockingData func(string) (string, error)
}
var sub *Sub
client := rpc.NewHTTPClient("http://119.23.228.186:50005/")
client.UseService(&sub)
result,err := sub.GetCustomsDockingData(`{"tableName":"`+tableName+`","bizDate":"`+currentDate+`"}`)
if err != nil {
fmt.Println(tableName+"请求服务器出错"+err.Error())
return ""
}
//json字符串
return result
}
......@@ -41,3 +41,32 @@ ShowSQL = true
max_idle_conn = 10
table_prefix = ""
max_conn_life_time = 100
[scm_data]
dns = "liexin_scm_data:scm_data@tcp(192.168.1.235:3306)/liexin_scm_data?charset=utf8&parseTime=true&loc=Asia%2FShanghai"
max_open_conn = 20
max_idle_conn = 10
table_prefix = ""
max_conn_life_time = 100
......@@ -3,38 +3,20 @@ module golang-asynctask
go 1.14
require (
github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 // indirect
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/CloudyKit/jet v2.1.2+incompatible // indirect
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee // indirect
github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 // indirect
github.com/bndr/gotabulate v1.1.2 // indirect
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/clbanning/mxj v1.8.4 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19 // indirect
github.com/gin-gonic/gin v1.6.3
github.com/go-redis/redis/v7 v7.4.0
github.com/go-sql-driver/mysql v1.5.0
github.com/gorilla/sessions v1.2.1 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/hprose/hprose-golang v2.0.6+incompatible
github.com/ichunt2019/cfg v0.0.0-20210310074903-4b1bcab17717
github.com/ichunt2019/go-redis-pool v0.0.0-20210305064829-86b9011c57f5
github.com/ichunt2019/golang-rbmq-sl v0.0.0-20200515075131-59a37ab77d7d
github.com/ichunt2019/ichunt-micro-registry v1.0.1
github.com/ichunt2019/lxLog v0.0.0-20210226024426-781becb3c042
github.com/lib/pq v1.9.0 // indirect
github.com/mattn/go-sqlite3 v1.14.6 // indirect
github.com/jmoiron/sqlx v1.3.3
github.com/spf13/viper v1.7.1
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/syyongx/php2go v0.9.4
github.com/tealeg/xlsx v1.0.5 // indirect
github.com/tidwall/gjson v1.6.8
github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect
github.com/xormplus/xorm v0.0.0-20210107091022-175d736afaae // indirect
google.golang.org/grpc/examples v0.0.0-20210226164526-c949703b4b98 // indirect
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
google.golang.org/protobuf v1.25.0 // indirect
xorm.io/xorm v1.0.7
)
......
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