From 6712c63bce309ab3a7642b48595b8ff136cf3847 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期二, 06 二月 2024 10:15:22 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
---
controllers/product_controller.go | 15 +++
middleware/utils.go | 9 ++
controllers/operation.go | 2
request/warehouse.go | 2
models/material.go | 31 ++++---
controllers/warehouse.go | 29 +++++++
main.go | 1
docs/swagger.yaml | 31 +++++++
docs/docs.go | 54 +++++++++++++
docs/swagger.json | 52 +++++++++++++
router/router.go | 1
11 files changed, 210 insertions(+), 17 deletions(-)
diff --git a/controllers/operation.go b/controllers/operation.go
index 8549e48..ae51152 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -1090,7 +1090,7 @@
return
}
- if err := db.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize).Find(&records).Error; err != nil {
+ if err := db.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize).Order("wms_operation.created_at desc").Find(&records).Error; err != nil {
util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
return
}
diff --git a/controllers/product_controller.go b/controllers/product_controller.go
index 075acb4..84d970e 100644
--- a/controllers/product_controller.go
+++ b/controllers/product_controller.go
@@ -12,6 +12,7 @@
"wms/constvar"
"wms/extend/code"
"wms/extend/util"
+ "wms/middleware"
"wms/models"
"wms/pkg/logx"
"wms/pkg/mysqlx"
@@ -746,3 +747,17 @@
}
util.ResponseFormat(c, code.Success, "鎿嶄綔鎴愬姛")
}
+
+// GetUserInfo
+//
+// @Tags 浜у搧
+// @Summary 鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅
+// @Produce application/json
+// @Success 200 {object} util.ResponseList{data=map[string]interface{}} "鎴愬姛"
+// @Router /api-wms/v1/product/getUserInfo [get]
+func (slf ProductController) GetUserInfo(c *gin.Context) {
+ userInfo := middleware.GetUserInfo(c)
+ m := make(map[string]interface{})
+ m["userName"] = userInfo.Username
+ util.ResponseFormat(c, code.Success, m)
+}
diff --git a/controllers/warehouse.go b/controllers/warehouse.go
index bc2aa7f..f9b54c9 100644
--- a/controllers/warehouse.go
+++ b/controllers/warehouse.go
@@ -122,7 +122,34 @@
util.ResponseFormat(c, code.RequestParamError, err.Error())
return
}
- err := models.NewWarehouseSearch().SetID(params.Id).Update(¶ms)
+ warehouse, err := models.NewWarehouseSearch().SetID(params.Id).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "浠撳簱涓嶅瓨鍦�")
+ return
+ }
+ err = models.WithTransaction(func(db *gorm.DB) error {
+ //鏇存柊浣滀笟绫诲瀷鍚嶇О
+ if params.Name != warehouse.Name {
+ m := make(map[string]interface{})
+ m["name"] = params.Name + "-鍏ュ簱"
+ err := models.NewOperationTypeSearch().SetOrm(db).SetBaseOperationType(constvar.BaseOperationTypeIncoming).SetWarehouseId(params.Id).UpdateByMap(m)
+ if err != nil {
+ return err
+ }
+ m["name"] = params.Name + "-鍑哄簱"
+ err = models.NewOperationTypeSearch().SetOrm(db).SetBaseOperationType(constvar.BaseOperationTypeOutgoing).SetWarehouseId(params.Id).UpdateByMap(m)
+ if err != nil {
+ return err
+ }
+ m["name"] = params.Name + "-鍐呴儴璋冩嫧"
+ err = models.NewOperationTypeSearch().SetOrm(db).SetBaseOperationType(constvar.BaseOperationTypeInternal).SetWarehouseId(params.Id).UpdateByMap(m)
+ if err != nil {
+ return err
+ }
+ }
+ err = models.NewWarehouseSearch().SetID(params.Id).Update(¶ms)
+ return err
+ })
if err != nil {
util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触")
diff --git a/docs/docs.go b/docs/docs.go
index 3e5d8f7..5a2c468 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1930,6 +1930,38 @@
}
}
},
+ "/api-wms/v1/product/getUserInfo": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅",
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseList"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "object",
+ "additionalProperties": true
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/listDisuse": {
"post": {
"produces": [
@@ -3431,6 +3463,18 @@
}
]
},
+ "toLocation": {
+ "description": "鐩爣浣嶇疆",
+ "allOf": [
+ {
+ "$ref": "#/definitions/models.Location"
+ }
+ ]
+ },
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
"updateTime": {
"type": "string"
},
@@ -3858,6 +3902,10 @@
"$ref": "#/definitions/constvar.OperationStatus"
}
]
+ },
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
},
"waybillNumber": {
"description": "杩愬崟鍙�",
@@ -4571,6 +4619,10 @@
}
]
},
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
"waybillNumber": {
"description": "杩愬崟鍙�",
"type": "string"
@@ -4873,6 +4925,8 @@
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
+ LeftDelim: "{{",
+ RightDelim: "}}",
}
func init() {
diff --git a/docs/swagger.json b/docs/swagger.json
index 261625a..fce1458 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1918,6 +1918,38 @@
}
}
},
+ "/api-wms/v1/product/getUserInfo": {
+ "get": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅",
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/util.ResponseList"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "object",
+ "additionalProperties": true
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/listDisuse": {
"post": {
"produces": [
@@ -3419,6 +3451,18 @@
}
]
},
+ "toLocation": {
+ "description": "鐩爣浣嶇疆",
+ "allOf": [
+ {
+ "$ref": "#/definitions/models.Location"
+ }
+ ]
+ },
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
"updateTime": {
"type": "string"
},
@@ -3846,6 +3890,10 @@
"$ref": "#/definitions/constvar.OperationStatus"
}
]
+ },
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
},
"waybillNumber": {
"description": "杩愬崟鍙�",
@@ -4559,6 +4607,10 @@
}
]
},
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
"waybillNumber": {
"description": "杩愬崟鍙�",
"type": "string"
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 515cef4..039abfe 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -663,6 +663,13 @@
allOf:
- $ref: '#/definitions/constvar.OperationStatus'
description: 鐘舵��
+ toLocation:
+ allOf:
+ - $ref: '#/definitions/models.Location'
+ description: 鐩爣浣嶇疆
+ toLocationId:
+ description: 鐩爣浣嶇疆id
+ type: integer
updateTime:
type: string
waybillNumber:
@@ -957,6 +964,9 @@
allOf:
- $ref: '#/definitions/constvar.OperationStatus'
description: 鐘舵��
+ toLocationId:
+ description: 鐩爣浣嶇疆id
+ type: integer
waybillNumber:
description: 杩愬崟鍙�
type: string
@@ -1453,6 +1463,9 @@
allOf:
- $ref: '#/definitions/constvar.OperationStatus'
description: 鐘舵��
+ toLocationId:
+ description: 鐩爣浣嶇疆id
+ type: integer
waybillNumber:
description: 杩愬崟鍙�
type: string
@@ -2834,6 +2847,24 @@
summary: 鑾峰彇浜у搧鍒楄〃
tags:
- 浜у搧
+ /api-wms/v1/product/getUserInfo:
+ get:
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ allOf:
+ - $ref: '#/definitions/util.ResponseList'
+ - properties:
+ data:
+ additionalProperties: true
+ type: object
+ type: object
+ summary: 鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅
+ tags:
+ - 浜у搧
/api-wms/v1/product/listDisuse:
post:
parameters:
diff --git a/main.go b/main.go
index 1801bbf..2a44bc8 100644
--- a/main.go
+++ b/main.go
@@ -60,7 +60,6 @@
logx.Errorf("grpc server init error: %v", err.Error())
panic(fmt.Sprintf("grpc server init error: %v", err.Error()))
}
- fmt.Println("-----------鐩戝惉绔彛: ", conf.WebConf.GrpcPort)
s := grpc.NewServer()
//todo 娣诲姞鍏蜂綋鏈嶅姟
product_inventory.RegisterProductInventoryServiceServer(s, &product_inventory.Server{})
diff --git a/middleware/utils.go b/middleware/utils.go
index 58defa0..cf98138 100644
--- a/middleware/utils.go
+++ b/middleware/utils.go
@@ -2,6 +2,7 @@
import (
"errors"
+ "github.com/gin-gonic/gin"
"github.com/golang-jwt/jwt/v4"
"wms/request"
)
@@ -58,3 +59,11 @@
return nil, TokenInvalid
}
}
+
+func GetUserInfo(c *gin.Context) *request.CustomClaims {
+ if claims, exists := c.Get("claims"); exists {
+ waitUse := claims.(*request.CustomClaims)
+ return waitUse
+ }
+ return nil
+}
diff --git a/models/material.go b/models/material.go
index 16a6e10..721368f 100644
--- a/models/material.go
+++ b/models/material.go
@@ -59,7 +59,7 @@
ControlStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:鎺у埗绛栫暐" json:"controlStrategy"` //鎺у埗绛栫暐
BuyExplain string `gorm:"type:varchar(512);comment:閲囪喘璇存槑" json:"buyExplain"` //閲囪喘璇存槑
Principal string `gorm:"type:varchar(255);comment:璐熻矗浜�" json:"principal"` //璐熻矗浜�
- Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺
+ Weight decimal.Decimal `gorm:"type:decimal(20,3);comment:閲嶉噺" json:"weight"` //閲嶉噺
Volume decimal.Decimal `gorm:"type:decimal(20,2);comment:浣撶Н" json:"volume"` //浣撶Н
MakeAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:鍒堕�犲墠缃椂闂�" json:"makeAdvanceTime"` //鍒堕�犲墠缃椂闂�(澶�)
OrderAdvanceTime decimal.Decimal `gorm:"type:decimal(20,2);comment:璁㈠崟鍑嗗澶╂暟" json:"orderAdvanceTime"` //璁㈠崟鍑嗗澶╂暟(澶�)
@@ -67,17 +67,22 @@
//HSCode string `gorm:"type:varchar(255);comment:HS缂栫爜" json:"HSCode"` //HS缂栫爜
//OriginCountryId int `gorm:"type:int(11);comment:鍘熶骇鍦癷d" json:"originCountryId"` //鍘熶骇鍦癷d
//OriginCountryName string `gorm:"type:varchar(255);comment:鍘熶骇鍦板悕绉�" json:"originCountryName"` //鍘熶骇鍦板悕绉�
- InStorageExplain string `gorm:"type:varchar(512);comment:鍏ュ簱璇存槑" json:"inStorageExplain"` //鍏ュ簱璇存槑
- OutStorageExplain string `gorm:"type:varchar(512);comment:鍑哄簱璇存槑" json:"outStorageExplain"` //鍑哄簱璇存槑
- InternalTransferExplain string `gorm:"type:varchar(512);comment:鍐呴儴璋冩嫧璇存槑" json:"internalTransferExplain"` //鍐呴儴璋冩嫧璇存槑
- AttachmentList []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"`
- AttachmentIDs []uint `json:"attachmentIDs" gorm:"-"`
- PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"`
- InputAmount decimal.Decimal `json:"inputAmount" gorm:"-"`
- OutputAmount decimal.Decimal `json:"outputAmount" gorm:"-"`
- MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //鏈�灏忓簱瀛�
- MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //鏈�澶у簱瀛�
- ReorderRuleNum int64 `json:"reorderRuleNum"`
+ InStorageExplain string `gorm:"type:varchar(512);comment:鍏ュ簱璇存槑" json:"inStorageExplain"` //鍏ュ簱璇存槑
+ OutStorageExplain string `gorm:"type:varchar(512);comment:鍑哄簱璇存槑" json:"outStorageExplain"` //鍑哄簱璇存槑
+ InternalTransferExplain string `gorm:"type:varchar(512);comment:鍐呴儴璋冩嫧璇存槑" json:"internalTransferExplain"` //鍐呴儴璋冩嫧璇存槑
+ AttachmentList []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"`
+ IsStorage int `gorm:"type:tinyint(1);default:1;comment:鏄惁瀛樺簱(1鏄�2鍚�)" json:"isStorage"` //鏃犲簱瀛樼殑鍦╳ms浠ュ強srm涓渶瑕佽繃婊ゆ帀
+ IsVirtual int `json:"isVirtual" gorm:"type:tinyint(1);default:2;comment:鏄惁铏氭嫙鐗╂枡(1鏄�2鍚�)"` //铏氭嫙鐗╂枡鍦∕RP璁$畻鏃惰烦杩囪灞傜骇鐩存帴棰嗙敤涓嬬骇鐗╂枡锛岃櫄鎷熺墿鏂欎笉鐢熸垚宸ュ崟
+ ReorderRuleNum int64 `json:"reorderRuleNum"`
+
+ //浠ヤ笅涓轰笉瀛樺簱鐨勫瓧娈�
+ AttachmentIDs []uint `json:"attachmentIDs" gorm:"-"`
+ PredictionAmount decimal.Decimal `json:"predictionAmount" gorm:"-"`
+ InputAmount decimal.Decimal `json:"inputAmount" gorm:"-"`
+ OutputAmount decimal.Decimal `json:"outputAmount" gorm:"-"`
+ MinInventoryRule decimal.Decimal `json:"minInventoryRule" gorm:"-"` //鏈�灏忓簱瀛�
+ MaxInventoryRule decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //鏈�澶у簱瀛�
+
}
MaterialSearch struct {
@@ -105,7 +110,7 @@
}
func NewMaterialSearch() *MaterialSearch {
- return &MaterialSearch{Orm: mysqlx.GetDB()}
+ return &MaterialSearch{Orm: mysqlx.GetDB().Where("is_storage = ?", 1)} //鍙煡璇㈡湁搴撳瓨鐨�
}
func (slf *MaterialSearch) SetOrm(tx *gorm.DB) *MaterialSearch {
diff --git a/request/warehouse.go b/request/warehouse.go
index c509583..74082ff 100644
--- a/request/warehouse.go
+++ b/request/warehouse.go
@@ -2,7 +2,7 @@
type GetWarehouseList struct {
PageInfo
- Keyword string `json:"keyword"`
+ Keyword string `json:"keyword" form:"keyword"`
}
type AddWarehouse struct {
diff --git a/router/router.go b/router/router.go
index d6a01d0..2bee382 100644
--- a/router/router.go
+++ b/router/router.go
@@ -120,6 +120,7 @@
productAPI.POST("updateDisuse", productController.UpdateDisuse) //淇敼鎶ュ簾淇℃伅
productAPI.POST("listHistory", productController.ListHistory) //浜у搧浣嶇疆鍘嗗彶璁板綍
productAPI.PUT("cancelDisuse/:id", productController.CancelDisuse) //鍙栨秷鎶ュ簾
+ productAPI.GET("getUserInfo", productController.GetUserInfo) //鑾峰彇鐧诲綍鐢ㄦ埛淇℃伅
}
--
Gitblit v1.8.0