Commit 14ecfe48 by mushishixian

忽略文件

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