Commit 7ee4bf02 by mushishixian

ES请求

parent 9dec477a
......@@ -3,6 +3,8 @@ package main
import (
"bom_server/cmd/queue"
"bom_server/configs"
"bom_server/internal/logic"
"bom_server/internal/model"
"flag"
)
......@@ -11,5 +13,9 @@ func main() {
flag.StringVar(&path, "config", "../conf/config.ini", "../conf/config.ini")
flag.Parse()
configs.Setup(path)
model.Setup()
logic.SearchGoods("213")
queue.Sync()
}
......@@ -2,6 +2,7 @@ package queue
import (
"bom_server/configs"
"bom_server/internal/logic"
"fmt"
"github.com/ichunt2019/go-rabbitmq/utils/rabbitmq"
)
......@@ -19,6 +20,7 @@ func (t *RecvPro) FailAction(dataByte []byte) error {
}
func Sync() {
fmt.Println(logic.GetBomInfoWithItems(1))
t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{
"bom_match",
......
[database]
username = root
user_name = root
password = root
host = 192.168.2.250
database = lie_scm_wms_sync
host = 192.168.2.239
database = lie_bom
table_prefix = lie_
type = mysql
[rabbitmq]
url = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
......@@ -12,3 +14,7 @@ base = http://192.168.2.232:40001
[falcon]
push_url = http://192.168.1.237:1988/v1/push
[es]
url = http://192.168.2.232:9200
goods_index_name = future,rochester,tme,verical,element14,digikey,chip1stop,aipco,arrow,alliedelec,avnet,mouser,zhuanmai,peigenesis,powell,rs,buerklin,liexin_ziying
\ No newline at end of file
[mysql]
username = YncsczUxxz
password = ztxaxpzto@y$%lstt
host = 172.18.137.34
database = liexin_scm_wms_sync
[database]
username = root
password = root
host = 192.168.2.250
database = lie_scm_wms_sync
[rabbitmq]
url = "amqp://scmWms:Ptlxuut0lkx@172.18.137.33:5672/"
url = "amqp://huntadmin:jy2y2900@192.168.1.237:5672/"
[api]
base = http://172.18.137.38:40001
out_store = http://172.18.137.38:40003
in_store = http://172.18.137.38:40004
erp_sync_base_data_status = http://172.18.137.20:6878/ormrpc/services/WSInventoryManagementFacade?wsdl
erp_sync_bill_status = http://172.18.137.20:6878/ormrpc/services/WSInventoryManagementFacade?wsdl
erp_login_status = http://172.18.137.20:6878/ormrpc/services/EASLogin?wsdl
base = http://192.168.2.232:40001
[falcon]
push_url = http://172.18.137.35:1988/v1/push
[erp]
userName = WBYH
password = 123456
slnName = eas
dcName = SCM
language = L2
dbType = 1
authPattern = BaseDB
push_url = http://192.168.1.237:1988/v1/push
......@@ -31,13 +31,19 @@ type Redis struct {
IdleTimeout time.Duration `ini:"idle_timeout"`
}
type RabbitMQ struct {
type ES struct {
Url string `ini:"url"`
GoodsIndexName string `ini:"goods_index_name"`
}
type RabbitMQ struct {
Url string `ini:"url"`
}
var DatabaseSetting = &Database{}
var RedisSetting = &Redis{}
var RabbitMQSetting = &RabbitMQ{}
var ESSetting = &ES{}
var (
cfg *ini.File
)
......@@ -53,6 +59,7 @@ func Setup(filePath string) {
mapTo("database", DatabaseSetting)
mapTo("redis", RedisSetting)
mapTo("rabbitmq", RabbitMQSetting)
mapTo("es", ESSetting)
RedisSetting.IdleTimeout = RedisSetting.IdleTimeout * time.Second
}
......
......@@ -8,6 +8,7 @@ require (
github.com/go-kratos/kratos v0.5.0
github.com/ichunt2019/go-rabbitmq v1.0.1
github.com/imroc/req v0.3.0
github.com/jinzhu/gorm v1.9.12
github.com/jmoiron/sqlx v1.2.0
github.com/mushishixian/gosoap v1.2.0
github.com/pkg/errors v0.9.1
......
......@@ -44,6 +44,8 @@ github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM=
github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
......@@ -56,6 +58,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
......@@ -91,6 +95,8 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
......@@ -135,6 +141,12 @@ github.com/imroc/req v0.3.0/go.mod h1:F+NZ+2EFSo6EFXdeIbpfE9hcC233id70kf0byW97Ca
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/influxdb1-client v0.0.0-20190809212627-fc22c7df067e/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q=
github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
......@@ -164,6 +176,8 @@ github.com/leodido/go-urn v1.1.0 h1:Sm1gr51B1kKyfD2BlRcLSiEkffoG96g6TPv6eRoEiB8=
github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw=
github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
......@@ -174,6 +188,8 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
......@@ -299,11 +315,14 @@ go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM=
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
......
package logic
import (
"bom_server/internal/model"
)
//根据bom_id查出bom表信息
func GetBomInfo(bomId int) (bom model.Bom) {
model.Db.Where("bom_id = ?", bomId).First(&bom)
return bom
}
//获取一个完整bom数据
func GetBomInfoWithItems(bomId int) (bom model.Bom) {
var (
bomItems []model.BomItem
)
bom = GetBomInfo(bomId)
bomItems = GetBomItems(bomId)
bom.BomItems = bomItems
return bom
}
package logic
import (
"bom_server/internal/model"
"strconv"
)
//根据bom_id查出bom表信息
func GetBomItems(bomId int) (bomItems []model.BomItem) {
tableEnd := strconv.FormatInt(int64(bomId), 10)
model.Db.Table("lie_bom_item_"+tableEnd).Where("bom_id = ?", bomId).Find(&bomItems)
return bomItems
}
package logic
import (
"bom_server/internal/model"
)
//根据bom_id查出bom表信息
func GetBomMatchings(bomId int) (bomMatchings []model.BomItem) {
model.Db.Where("bom_id = ?", bomId).Find(&bomMatchings)
return bomMatchings
}
package logic
import (
"bom_server/internal/dao"
"bom_server/internal/model"
"time"
)
const CheckCustomerExistSql = "SELECT customer_id FROM lie_customer WHERE binary erp_id = ?"
const CheckCustomerSyncStatusSql = "SELECT sync_status FROM lie_customer WHERE binary erp_id = ?"
const InsertCustomerSql = "Insert INTO `lie_customer` (`erp_client_code`,`name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?)"
const UpdateCustomerSql = "UPDATE `lie_customer` SET `erp_client_code` = ? , `name` = ? , `update_time` = ? WHERE binary `erp_id` = ?"
const DeleteCustomerSql = "UPDATE `lie_customer` SET `status` = ? , `update_time` = ? WHERE binary `erp_id` = ?"
const SyncCustomerSuccessSql = "UPDATE `lie_customer` SET sync_status = 1 , sync_time = ? WHERE binary erp_id = ?"
const SyncCustomerErpSuccessSql = "UPDATE `lie_customer` SET sync_erp_status = 1 , sync_time = ? WHERE binary erp_id = ?"
//修改同步到erp成功的状态
func SyncCustomerErpSuccess(erpId string) (err error) {
_, err = dao.GetDb().Exec(SyncCustomerErpSuccessSql, time.Now().Unix(), erpId)
return
}
//检查用户是否存在
func CheckCustomerExist(erpId string) (exist bool) {
var customerId int
dao.GetDb().QueryRowx(CheckCustomerExistSql, erpId).Scan(&customerId)
return customerId > 0
}
//获取后端同步状态
func CheckCustomerSyncStatus(erpId string) (status bool) {
var statusInt int
dao.GetDb().QueryRowx(CheckCustomerSyncStatusSql, erpId).Scan(&statusInt)
return statusInt > 0
}
//插入用户
func InsertCustomer(customer model.Customer) (err error) {
if !CheckCustomerExist(customer.ErpId) {
_, err = dao.GetDb().Exec(InsertCustomerSql, customer.ErpClientCode, customer.Name, customer.ErpId, time.Now().Unix(), 0)
}
return
}
//更新供应商
func UpdateCustomer(customer model.Customer) (err error) {
_, err = dao.GetDb().Exec(UpdateCustomerSql, customer.ErpClientCode, customer.Name, time.Now().Unix(), customer.ErpId)
if err != nil {
return
}
return nil
}
//删除供应商
func DeleteCustomer(customer model.Customer) (err error) {
_, err = dao.GetDb().Exec(DeleteCustomerSql, customer.Status, time.Now().Unix(), customer.ErpId)
return
}
//修改成功的同步状态
func SyncCustomerSuccess(erpId string) (err error) {
_, err = dao.GetDb().Exec(SyncCustomerSuccessSql, time.Now().Unix(), erpId)
return
}
package logic
import (
"bom_server/configs"
"bom_server/internal/model"
"fmt"
"github.com/imroc/req"
)
//匹配商品
/**
1.先去数据库查出所有需要匹配的数据
2.然后开协程去针对每个bom里的goods_name去请求搜索接口
3.搜索匹配到以后,用goods_id去请求商品服务
4.得到具体的商品数据以后,针对对应的商品进行修改
**/
func MatchGoods(bom model.Bom) {
bomItems := bom.BomItems
for _, item := range bomItems {
fmt.Println(item)
}
}
//去es搜索商品
func SearchGoods(goodsName string) (goodsId int) {
var (
err error
foo []map[string]string
url string
resp *req.Resp
)
url = configs.ESSetting.Url
req.Debug = true
resp, err = req.Get(url, req.BodyJSON(&foo))
if err != nil {
fmt.Println(err)
}
fmt.Println(resp.String())
getSearchParams()
return goodsId
}
//构建请求参数
func getSearchParams(){
var (
indexName string
)
indexName = configs.ESSetting.GoodsIndexName
fmt.Println(indexName)
}
func GetGoodsData(goodsIds []int) () {
}
package model
type Bom struct {
// BomID box_id
BomID int `json:"bom_id" gorm:"primary_key"`
// BomSn 二进制的md5(时间戳+gid)
BomSn string `json:"bom_sn"`
// BomName bom名字
BomName string `json:"bom_name"`
// UserID 所属用户ID
UserID int `json:"user_id"`
// Gid 二进制的md5(gid)
Gid string `json:"gid"`
// UploadIP 创建用户IP
UploadIP string `json:"upload_ip"`
// AddTime 创建时间
AddTime int `json:"add_time"`
// UpdateTime 更新时间
UpdateTime int `json:"update_time"`
// Status 状态 1:正常 2:删除
Status int `json:"status"`
// IsSyncCrm 是否同步过crm 1:否 2:是
IsSyncCrm int `json:"is_sync_crm"`
// bom详情
BomItems []BomItem
}
//func (Bom) TableName() string {
// return "bom"
//}
\ No newline at end of file
package model
type BomItem struct {
// BomItemID bom详情ID
BomItemID int `json:"bom_item_id"`
// BomID bom主表ID
BomID int `json:"bom_id"`
// GoodsName 型号
GoodsName string `json:"goods_name"`
// BrandName 品牌
BrandName string `json:"brand_name"`
// Number 需求数量
Number int `json:"number"`
// ItemStatus 匹配状态 1:等待匹配 2:可购现货 3:待询价 4:需要修正
ItemStatus int `json:"item_status"`
// DelStatus 删除状态 1:正常 2:删除
DelStatus int `json:"del_status"`
// AddTime 添加时间
AddTime int `json:"add_time"`
// UpdateTime 更新时间
UpdateTime int `json:"update_time"`
}
package model
type LieBomItemMatching0 struct {
// MatchingID 匹配ID
MatchingID int `json:"matching_id"`
// BomID bom主表Id(为了方便逆向查找bom_item表)
BomID int `json:"bom_id"`
// BomItemID bom详情ID
BomItemID int `json:"bom_item_id"`
// GoodsID 匹配到的商品ID
GoodsID int `json:"goods_id"`
// GoodsType 0:自营 1:联营 2:专卖
GoodsType int `json:"goods_type"`
// SupplierID 供应商ID
SupplierID int `json:"supplier_id"`
// SupplierName 供应商名字
SupplierName string `json:"supplier_name"`
// CnDelivery 大陆货期
CnDelivery string `json:"cn_delivery"`
// HkDelivery 香港货期
HkDelivery string `json:"hk_delivery"`
Number int `json:"number"`
// CnPrice 大陆单价
CnPrice float64 `json:"cn_price"`
// HkPrice 香港单价
HkPrice float64 `json:"hk_price"`
// Stock 库存
Stock int `json:"stock"`
// Moq 起订量
Moq int `json:"moq"`
// Mpq 包装量
Mpq int `json:"mpq"`
// Encap 封装
Encap string `json:"encap"`
// Status 1:正常 2:取消匹配(被替换)
Status uint8 `json:"status"`
// AddTime 创建时间
AddTime int `json:"add_time"`
// UpdateTime 更新时间
UpdateTime int `json:"update_time"`
// LadderPrice 阶梯价
LadderPrice string `json:"ladder_price"`
}
package model
type BomRefresh struct {
// BomRefreshID 主键id
BomRefreshID int `json:"bom_refresh_id"`
// BomID bom主表id
BomID int `json:"bom_id"`
// RefreshTime 刷新时间
RefreshTime int `json:"refresh_time"`
// RefreshIP 刷新人的ip
RefreshIP string `json:"refresh_ip"`
// AddTime 添加时间
AddTime int `json:"add_time"`
}
package model
type Customer struct {
ErpClientCode string
Name string
ErpId string
AddTime int
SyncTime int
SyncStatus int
SyncErpStatus int
Status int
SyncError string
}
package model
import (
"bom_server/configs"
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mysql"
)
var Db *gorm.DB
// Setup initializes the database instance
func Setup() {
var err error
Db, err = gorm.Open(configs.DatabaseSetting.Type, fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=True&loc=Local",
configs.DatabaseSetting.UserName,
configs.DatabaseSetting.Password,
configs.DatabaseSetting.Host,
configs.DatabaseSetting.Database))
if err != nil {
panic(fmt.Sprintf("链接数据库失败 : %v", err))
}
gorm.DefaultTableNameHandler = func(Db *gorm.DB, defaultTableName string) string {
return configs.DatabaseSetting.TablePrefix + defaultTableName
}
Db.SingularTable(true)
Db.DB().SetMaxIdleConns(10)
Db.DB().SetMaxOpenConns(100)
}
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