Commit f8931d40 by mushishixian

fix

parent d1c06c2d
......@@ -14,16 +14,16 @@ type RecvPro struct {
}
func init() {
//queueExchange := rabbitmq.QueueExchange{
// "bom_match",
// "bom_match",
// "bom",
// "direct",
// "amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
//}
//
//str := `{"bom_id":436,"delivery_type":1,"sort":1}`
//rabbitmq.Send(queueExchange, str)
queueExchange := rabbitmq.QueueExchange{
"bom_match",
"bom_match",
"bom",
"direct",
"amqp://huntadmin:jy2y2900@192.168.1.237:5672/",
}
str := `{"bom_id":491,"delivery_type":1,"sort":1}`
rabbitmq.Send(queueExchange, str)
}
func (t *RecvPro) Consumer(dataByte []byte) (err error) {
......@@ -34,6 +34,7 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
if err != nil {
log.Error(err)
}
err = logic.MatchGoods(message)
if err != nil {
log.Error(err)
......
......@@ -85,6 +85,8 @@ func UpdateBomItem(bomId, bomItemId int) (err error) {
return err
}
defer client.Stop()
//匹配之前,去遍历bom_item,把没有型号名称但是有参数的bom_item进行型号补充
bomItems, err = MatchGoodsNameByAttrs(bomItems)
//直接模糊匹配
goodsMapList, err := getUpdateGoodsData(bomId, bomItems, where.DeliveryType, where.Sort, client, true)
//fmt.Println(goodsMapList)
......
......@@ -110,7 +110,7 @@ func SearchGoods(bomId int, bomItems []model.BomItem, deliveryType, sort int, wg
}
}
//先去处理没有匹配到的数据
err = UpdateNoMatchBomItem(notMatchBomItems, false)
err = UpdateNoMatchBomItem(notMatchBomItems, true)
if err != nil {
return
}
......@@ -286,7 +286,7 @@ func search(index string, bomId int, bomItems []model.BomItem, deliveryType, sor
//构建请求参数
func getSearchParams(index, goodsName, brandName string, sort, number int, flag bool) (searchRequest *es.SearchRequest) {
query := getTermQuery(goodsName, brandName, number, flag)
query := getTermQuery(goodsName, brandName, sort, number, flag)
source := es.NewSearchSource().Query(query)
if sort == 1 {
source.Sort("sort", false)
......@@ -299,6 +299,7 @@ func getSearchParams(index, goodsName, brandName string, sort, number int, flag
// source.Sort("single_price_sort", false)
//}
//source.Sort("single_price_sort", false)
//source.Sort("stock", false)
source.Sort("single_price", true)
//sort=3是按照库存排序
} else if sort == 3 {
......@@ -313,7 +314,7 @@ func getSearchParams(index, goodsName, brandName string, sort, number int, flag
}
//构建term条件
func getTermQuery(goodsName, brandName string, number int, flag bool) (query *es.BoolQuery) {
func getTermQuery(goodsName, brandName string, sort, number int, flag bool) (query *es.BoolQuery) {
query = es.NewBoolQuery()
if flag {
field := "auto_goods_name.raw"
......@@ -333,6 +334,14 @@ func getTermQuery(goodsName, brandName string, number int, flag bool) (query *es
field := "auto_goods_name"
query = query.Must(es.NewTermQuery(field, goodsName))
}
//按价格排序
if sort == 2 {
query = query.Filter(es.NewRangeQuery("single_price").Gt(0))
}
//库存排序
if sort == 3 {
query = query.Filter(es.NewRangeQuery("stock").Gt(0))
}
//query = query.Filter(es.NewRangeQuery("single_price").Gt(0))
//query = query.Filter(es.NewRangeQuery("stock").Gt(0))
if configs.ApiSetting.Mode != "debug" {
......
......@@ -21,3 +21,82 @@ var GetAttrUnitRegular = `[\d.]|±|\+_|\+-|/|\(.*\)|\+/-|`
//`^[\d\.]+(Uf|uf|μf|uF|UF)$`: "μF",
//`^[\d\.]+(Uh|uh|μh|uH|UH)$`: "μH",
//`^[\d\.]+K$`: "KΩ",
//属性单位对应属性
var UnitAttrMapping = map[string]string{
"r": "阻值(欧姆)|直流电阻(内阻)",
"Ω": "阻值(欧姆)|直流电阻(内阻)",
"OHM": "阻值(欧姆)|直流电阻(内阻)",
"mh": "电感",
"F": "容值",
"w": "功率",
"W": "功率",
"Ω/r ": "内阻",
"%": "精度",
"V": "额定电压",
"A": "额定电流",
}
//属性对应的基础属性
var UnitBaseMapping = map[string]string{
"μΩ": "Ω",
"mΩ": "Ω",
"Ω": "Ω",
"kΩ": "Ω",
"KΩ": "Ω",
"MΩ": "Ω",
"pF": "F",
"nF": "F",
"μF": "F",
"μf": "F",
"mF": "F",
"F": "F",
"μH": "H",
"mH": "H",
"H": "H",
"V": "V",
"kV": "V",
"mA": "A",
"A": "A",
"W": "W",
"kW": "W",
"KW": "W",
"%": "%",
}
//根据单位对值的转换,比如1kΩ=>1000Ω
var UnitValueMapping = map[string]string{
"μΩ": "0.000001",
"mΩ": "0.001",
"Ω": "1",
"kΩ": "1000",
"KΩ": "1000",
"MΩ": "1000000",
"pF": "1",
"nF": "1000",
"μF": "1000000",
"mF": "1000000000",
"F": "1000000000000",
"μH": "1",
"mH": "1000",
"H": "1000000",
"V": "1",
"kV": "1000",
"mA": "1",
"A": "1000",
"W": "1",
"kW": "1000",
"%": "0.01",
}
package mapping
//属性单位对应属性
var UnitAttrMapping = map[string]string{
"r": "阻值(欧姆)|直流电阻(内阻)",
"Ω": "阻值(欧姆)|直流电阻(内阻)",
"OHM": "阻值(欧姆)|直流电阻(内阻)",
"mh": "电感",
"F": "容值",
"w": "功率",
"W": "功率",
"Ω/r ": "内阻",
"%": "精度",
"V": "额定电压",
"A": "额定电流",
}
//属性对应的基础属性
var UnitBaseMapping = map[string]string{
"μΩ": "Ω",
"mΩ": "Ω",
"Ω": "Ω",
"kΩ": "Ω",
"KΩ": "Ω",
"MΩ": "Ω",
"pF": "F",
"nF": "F",
"μF": "F",
"μf": "F",
"mF": "F",
"F": "F",
"μH": "H",
"mH": "H",
"H": "H",
"V": "V",
"kV": "V",
"mA": "A",
"A": "A",
"W": "W",
"kW": "W",
"KW": "W",
"%": "%",
}
//根据单位对值的转换,比如1kΩ=>1000Ω
var UnitValueMapping = map[string]string{
"μΩ": "0.000001",
"mΩ": "0.001",
"Ω": "1",
"kΩ": "1000",
"KΩ": "1000",
"MΩ": "1000000",
"pF": "1",
"nF": "1000",
"μF": "1000000",
"mF": "1000000000",
"F": "1000000000000",
"μH": "1",
"mH": "1000",
"H": "1000000",
"V": "1",
"kV": "1000",
"mA": "1",
"A": "1000",
"W": "1",
"kW": "1000",
"%": "0.01",
}
package mapping
//封装列表
var PackingList = []string{
"0402",
"0603",
}
//介质列表
var MediaList = []string{
"X5U",
"X7R",
}
......@@ -3,6 +3,7 @@ package main
import (
"bom_server/configs"
"bom_server/internal/model"
"bom_server/internal/pkg/gredis"
"bom_server/server/http"
"flag"
)
......@@ -13,6 +14,7 @@ func main() {
flag.Parse()
configs.Setup(path)
model.Setup()
gredis.Setup()
err := http.InitApiServer()
if err != nil {
panic(err)
......
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