Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
| | |
| | | webConf struct { |
| | | Host string // 本机ip地址 |
| | | Port string // 端口号 |
| | | APPort string // 本机作为的Grpc服务端的端口号 |
| | | AlHost string // 算法服务ip地址 |
| | | AlPort string // 算法服务端口号 |
| | | NodeId string // 主账户用户名 |
| | | OssType string // 对象存储类型 |
| | | JWTSecret string |
| | | } |
| | | |
| | | nsqConf struct { |
| | | NsqdAddr string |
| | | NsqlookupdAddr string |
| | | } |
| | | |
| | | localConf struct { |
| | |
| | | WebConf = &webConf{} |
| | | LogConf = &logx.Conf{} |
| | | DbConf = &mysqlx.Conf{} |
| | | NsqConf = &nsqConf{} |
| | | LocalConf = &localConf{} |
| | | NodeId string |
| | | GrpcPort string |
| | | Viper *viper.Viper |
| | | ) |
| | | |
| | |
| | | } |
| | | read2Conf(Viper) |
| | | |
| | | GrpcPort = os.Getenv("GRPC_PORT") // 只给grpc算法服务使用,本服务不用 |
| | | nodeId := os.Getenv("NODE_ID") // 主账户用户名 |
| | | host := os.Getenv("HOST") // 本机IP地址 |
| | | algHost := os.Getenv("AL_HOST") // 算法服务的IP地址 |
| | | nsqdAddr := os.Getenv("NSQD_ADDR") |
| | | if len(GrpcPort) == 0 { // 如果gprcPort为空,那么用配置的APPort |
| | | GrpcPort = WebConf.APPort |
| | | } |
| | | nodeId := os.Getenv("NODE_ID") // 主账户用户名 |
| | | host := os.Getenv("HOST") // 本机IP地址 |
| | | if len(nodeId) > 0 { |
| | | WebConf.NodeId = nodeId |
| | | } |
| | | if len(algHost) > 0 { |
| | | WebConf.AlHost = algHost |
| | | } |
| | | if len(host) > 0 { |
| | | WebConf.Host = host |
| | | } |
| | | if len(nsqdAddr) > 0 { |
| | | NsqConf.NsqdAddr = nsqdAddr |
| | | } |
| | | |
| | | DBHost := os.Getenv("DB_HOST") |
| | |
| | | _ = v.UnmarshalKey("web", WebConf) |
| | | _ = v.UnmarshalKey("log", LogConf) |
| | | _ = v.UnmarshalKey("db", DbConf) |
| | | _ = v.UnmarshalKey("nsq", NsqConf) |
| | | _ = v.UnmarshalKey("local", LocalConf) |
| | | showConfig() |
| | | } |
| | |
| | | log.Printf(" WebConf: %+v", WebConf) |
| | | log.Printf(" LogConf: %+v", LogConf) |
| | | log.Printf(" DbConf: %+v", DbConf) |
| | | log.Printf(" NsqConf: %+v", NsqConf) |
| | | log.Printf(" GrpcPort: %+v", GrpcPort) |
| | | log.Printf(" LocalConf: %+v", LocalConf) |
| | | log.Println("......................................................") |
| | | } |
| | |
| | | web: |
| | | port: 8005 |
| | | host: 192.168.20.119 |
| | | apport: 9091 |
| | | alhost: 192.168.20.119 |
| | | alport: 9090 |
| | | nodeId: wangpengfei |
| | | ossType: local |
| | | db: |
| | |
| | | log: |
| | | path: ./logs/aps-server.log |
| | | encoder: console |
| | | nsq: |
| | | nsqdAddr: 121.31.232.83:4150 |
| | | nsqlookupdAddr: |
| | | local: |
| | | storePath: uploads/file |
| | |
| | | if params.PageInfo.Check() { |
| | | search.SetPage(params.Page, params.PageSize) |
| | | } |
| | | find, total, err := search.SetKeyword(params.KeyWord).FindByPage() |
| | | //查询位置 |
| | | locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).FindAll() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询位置失败") |
| | | return |
| | | } |
| | | ids := make([]int, 0) |
| | | for _, location := range locations { |
| | | ids = append(ids, location.Id) |
| | | } |
| | | |
| | | find, total, err := search.SetKeyword(params.KeyWord).SetProductId(params.ProductId).SetLocationIds(ids).FindByPage() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询上架规则失败") |
| | | return |
| | | } |
| | | ruleIds := make([]int, 0) |
| | | for _, product := range find { |
| | | ruleIds = append(ruleIds, product.Id) |
| | | } |
| | | amounts, err := models.NewLocationProductAmountSearch().SetLocationProductIds(ruleIds).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询数量失败") |
| | | return |
| | | } |
| | | var result []response.LocationForms |
| | | for _, product := range find { |
| | | var resp response.LocationForms |
| | | for _, amount := range amounts { |
| | | if product.Id == amount.LocationProductId { |
| | | resp.Amount = amount.Amount |
| | | break |
| | | } |
| | | } |
| | | resp.LocationName = product.Location.Name |
| | | resp.ProduceId = product.Product.ID |
| | | resp.ProductName = product.Product.Name |
| | | resp.ProductTypeName = product.ProductCategory.Name |
| | | resp.Amount = product.Product.Amount |
| | | resp.Unit = product.Product.Unit |
| | | resp.Value = product.Product.Amount.Mul(product.Product.Cost) |
| | | resp.Value = resp.Amount.Mul(product.Product.Cost) |
| | | result = append(result, resp) |
| | | } |
| | | util.ResponseFormatList(c, code.Success, result, int(total)) |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | }, |
| | | "wareHouseCode": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | }, |
| | | "wareHouseCode": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | productId: |
| | | type: string |
| | | wareHouseCode: |
| | | type: string |
| | | type: object |
| | | request.GetProductList: |
| | | properties: |
| | |
| | | records = make([]*Location, 0) |
| | | db = slf.build() |
| | | ) |
| | | err := db.Find(&records) |
| | | err := db.Find(&records).Error |
| | | if err != nil { |
| | | fmt.Println(err) |
| | | return records, fmt.Errorf("func FindAll err: %v", err) |
| | |
| | | |
| | | LocationProductSearch struct { |
| | | LocationProduct |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | LocationIds []int |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetLocationIds(locationIds []int) *LocationProductSearch { |
| | | slf.LocationIds = locationIds |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProduct{}) |
| | | |
| | |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | if len(slf.LocationIds) > 0 { |
| | | db = db.Where("location_id in (?)", slf.LocationIds) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | |
| | | LocationProductAmountSearch struct { |
| | | LocationProductAmount |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | LocationProductIds []int |
| | | } |
| | | |
| | | LocationProductAmountWithOperation struct { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) SetLocationProductIds(ids []int) *LocationProductAmountSearch { |
| | | slf.LocationProductIds = ids |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProductAmount{}) |
| | | |
| | |
| | | if slf.LocationProductId != 0 { |
| | | db = db.Where("location_product_id=?", slf.LocationProductId) |
| | | } |
| | | if len(slf.LocationProductIds) > 0 { |
| | | db = db.Where("location_product_id in (?)", slf.LocationProductIds) |
| | | } |
| | | |
| | | return db |
| | | } |
| | |
| | | |
| | | type GetLocationForms struct { |
| | | PageInfo |
| | | KeyWord string `json:"keyWord"` |
| | | KeyWord string `json:"keyWord"` |
| | | WareHouseCode string `json:"wareHouseCode"` |
| | | ProductId string `json:"productId"` |
| | | } |