Commit 14ecfe48 by mushishixian

忽略文件

parent b325966d
/logs /logs
/.idea
/config/*.toml
...@@ -13,32 +13,46 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err ...@@ -13,32 +13,46 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err
supplierMapping := new(model.SupplierMergeMapping) supplierMapping := new(model.SupplierMergeMapping)
//先去根据供应商内部编码找出对应的supplierId //先去根据供应商内部编码找出对应的supplierId
_, err = Dao.GetDb("supplier").Table("lie_supplier_channel").Where("supplier_code = ?", supplierCode).Get(supplier) _, err = Dao.GetDb("supplier").Table("lie_supplier_channel").Where("supplier_code = ?", supplierCode).Get(supplier)
//不存在直接跳过 //不存在插入一条数据
if supplier.SupplierId == 0 { if supplier.SupplierId == 0 {
return err return err
} }
//再去同步表操作对应的数据 //再去同步表操作对应的数据
supplierId := supplier.SupplierId supplierId := supplier.SupplierId
_, err = supplierDao.Table("lie_supplier_sync").Where("supplier_id = ?", supplierId).Where("erp_sync_status = ?", 0). _, err = supplierDao.Table("lie_supplier_sync").Where("supplier_id = ?", supplierId).
Get(supplierSync) Get(supplierSync)
if err != nil { if err != nil {
return err return err
} }
//还要去写映射表lie_supplier_merger_mapping //还要去写映射表lie_supplier_merger_mapping
_, err = supplierDao.Table("lie_supplier_merger_mapping").Where("old_supplier_code = ?", supplierCode).Get(supplierMapping) _, err = supplierDao.Table("lie_supplier_merger_mapping").Where("old_supplier_code = ?", erpSupplierCode).Where("source = ?", 2).
Get(supplierMapping)
if err != nil { if err != nil {
return err return err
} }
//存在更新,不存在就插入
if supplierSync.SupplierId == 0 {
supplierSync.ErpSyncStatus = 1
supplierSync.SupplierId = supplierId
supplierSync.ErpSupplierCode = erpSupplierCode
supplierSync.ErpSupplierName = erpSupplierName
supplierSync.AddTime = int(time.Now().Unix())
_, err = supplierDao.Table("lie_supplier_sync").Insert(supplierSync)
if err != nil {
return err
}
} else {
supplierSync.ErpSyncStatus = 1 supplierSync.ErpSyncStatus = 1
supplierSync.SupplierId = supplierId supplierSync.SupplierId = supplierId
supplierSync.ErpSupplierCode = erpSupplierCode supplierSync.ErpSupplierCode = erpSupplierCode
supplierSync.ErpSupplierName = erpSupplierName supplierSync.ErpSupplierName = erpSupplierName
//存在更新,不存在就插入
supplierSync.UpdateTime = int(time.Now().Unix()) supplierSync.UpdateTime = int(time.Now().Unix())
_, err = supplierDao.Table("lie_supplier_sync").Where("supplier_id = ?", supplierId).Update(supplierSync) _, err = supplierDao.Table("lie_supplier_sync").Where("supplier_id = ?", supplierId).Update(supplierSync)
if err != nil { if err != nil {
return err return err
} }
}
if supplierMapping.SupplierId == 0 { if supplierMapping.SupplierId == 0 {
supplierMapping.OldSupplierCode = erpSupplierCode supplierMapping.OldSupplierCode = erpSupplierCode
...@@ -46,7 +60,7 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err ...@@ -46,7 +60,7 @@ func AddSupplierSync(supplierCode, erpSupplierCode, erpSupplierName string) (err
supplierMapping.SupplierId = supplier.SupplierId supplierMapping.SupplierId = supplier.SupplierId
supplierMapping.SupplierCode = supplier.SupplierCode supplierMapping.SupplierCode = supplier.SupplierCode
supplierMapping.SupplierName = supplier.SupplierName supplierMapping.SupplierName = supplier.SupplierName
supplierMapping.Source = 1 supplierMapping.Source = 2
supplierMapping.CreateTime = int(time.Now().Unix()) supplierMapping.CreateTime = int(time.Now().Unix())
_, err = supplierDao.Table("lie_supplier_merger_mapping").Insert(supplierMapping) _, err = supplierDao.Table("lie_supplier_merger_mapping").Insert(supplierMapping)
if err != nil { if err != nil {
......
...@@ -11,6 +11,8 @@ import ( ...@@ -11,6 +11,8 @@ import (
type RecvPro struct { type RecvPro struct {
} }
var number int
func init() { func init() {
//queueExchange := rabbitmq.QueueExchange{ //queueExchange := rabbitmq.QueueExchange{
// "supplier_erp", // "supplier_erp",
...@@ -21,17 +23,20 @@ func init() { ...@@ -21,17 +23,20 @@ func init() {
//} //}
// //
//str := `{"supplierNumber":"C0000102","PTID":"L0000002","supplierID":"LxYAAAG0CQA3xn38","supplierName":"TestName"}` //str := `{"supplierNumber":"C0000102","PTID":"L0000002","supplierID":"LxYAAAG0CQA3xn38","supplierName":"TestName"}`
//str := `{"supplierNumber":"C0000102","PTID":"12324","supplierID":"LxYAAAG0CQA3xn38"}` ////str := `{"supplierNumber":"C0000102","PTID":"12324","supplierID":"LxYAAAG0CQA3xn38"}`
//rabbitmq.Send(queueExchange, str) //rabbitmq.Send(queueExchange, str)
} }
func (t *RecvPro) Consumer(dataByte []byte) (err error) { func (t *RecvPro) Consumer(dataByte []byte) (err error) {
number++
message := string(dataByte) message := string(dataByte)
supplierCode := gjson.Get(message, "PTID").String() supplierCode := gjson.Get(message, "PTID").String()
erpSupplierCode := gjson.Get(message, "supplierNumber").String() erpSupplierCode := gjson.Get(message, "supplierNumber").String()
erpSupplierName := gjson.Get(message, "supplierName").String() erpSupplierName := gjson.Get(message, "supplierName").String()
fmt.Println(supplierCode,erpSupplierCode)
err = service.AddSupplierSync(supplierCode, erpSupplierCode,erpSupplierName) err = service.AddSupplierSync(supplierCode, erpSupplierCode,erpSupplierName)
if err!=nil {
fmt.Println(err)
}
return nil return nil
} }
......
[xorm] [xorm]
ShowSQL = true ShowSQL = false
[micro] [micro]
data_source_name = "micro_service:lie_micro_service#zsyM@tcp(192.168.2.232:3306)/lie_micro_service?charset=utf8&parseTime=true&loc=Asia%2FChongqing" data_source_name = "micro_service:lie_micro_service#zsyM@tcp(192.168.2.232:3306)/lie_micro_service?charset=utf8&parseTime=true&loc=Asia%2FChongqing"
......
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