From 07079a17b93d1dc2f06d73a5a08f6ba63a87d9a3 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期五, 10 十一月 2023 10:51:32 +0800 Subject: [PATCH] 出入库操作添加物流信息 --- controllers/operation.go | 21 + models/logistic_company.go | 153 +++++++++++++++ models/db.go | 1 models/operation.go | 9 docs/swagger.yaml | 97 +++++++++ request/operation.go | 14 docs/docs.go | 146 ++++++++++++++ docs/swagger.json | 144 ++++++++++++++ router/router.go | 1 9 files changed, 576 insertions(+), 10 deletions(-) diff --git a/controllers/operation.go b/controllers/operation.go index 5bd16ef..ed353ff 100644 --- a/controllers/operation.go +++ b/controllers/operation.go @@ -257,7 +257,7 @@ util.ResponseFormat(c, code.Success, "淇敼鎴愬姛") } -// DeleteDevice +// Delete // // @Tags 鍏ュ簱/鍑哄簱 // @Summary 鍒犻櫎鍏ュ簱/鍑哄簱淇℃伅 @@ -299,7 +299,7 @@ util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛") } -// DeleteDevice +// Finish // // @Tags 鍏ュ簱/鍑哄簱 // @Summary 鏇存敼璁板綍鐘舵�� @@ -682,7 +682,7 @@ util.ResponseFormat(c, code.Success, "鎿嶄綔鎴愬姛") } -// listTransfer +// ListTransfer // @Tags 鍏ュ簱/鍑哄簱 // @Summary 搴撳瓨璋冩嫧鍒楄〃 // @Produce application/json @@ -712,3 +712,18 @@ } util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) } + +// GetLogisticCompanyList +// @Tags 鍏ュ簱/鍑哄簱 +// @Summary 鑾峰彇鐗╂祦鍏徃鍒楄〃 +// @Produce application/json +// @Success 200 {object} util.ResponseList{data=[]models.LogisticCompany} "鎴愬姛" +// @Router /api-wms/v1/operation/getLogisticCompanyList [get] +func (slf OperationController) GetLogisticCompanyList(c *gin.Context) { + companies, err := models.NewLogisticCompanySearch().FindNotTotal() + if err != nil { + util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error()) + return + } + util.ResponseFormat(c, code.Success, companies) +} diff --git a/docs/docs.go b/docs/docs.go index 1a45405..31880ec 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -963,6 +963,40 @@ } } }, + "/api-wms/v1/operation/getLogisticCompanyList": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏ュ簱/鍑哄簱" + ], + "summary": "鑾峰彇鐗╂祦鍏徃鍒楄〃", + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.LogisticCompany" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/operation/list": { "post": { "produces": [ @@ -2224,6 +2258,24 @@ "CostingMethodAverageCost" ] }, + "constvar.FileType": { + "type": "string", + "enum": [ + "file", + "picture", + "thumbnail" + ], + "x-enum-comments": { + "FileType_File": "鏂囦欢", + "FileType_Picture": "鍥剧墖", + "FileType_Thumbnail": "缂╃暐鍥�" + }, + "x-enum-varnames": [ + "FileType_File", + "FileType_Picture", + "FileType_Thumbnail" + ] + }, "constvar.ForceRemovalStrategy": { "type": "integer", "enum": [ @@ -2436,6 +2488,26 @@ "ReservationNever" ] }, + "models.Attachment": { + "type": "object", + "properties": { + "FileUrl": { + "type": "string" + }, + "ext": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "fileType": { + "$ref": "#/definitions/constvar.FileType" + }, + "id": { + "type": "integer" + } + } + }, "models.Company": { "type": "object", "properties": { @@ -2572,12 +2644,51 @@ } } }, + "models.LogisticCompany": { + "type": "object", + "properties": { + "contact": { + "description": "鑱旂郴浜�", + "type": "string" + }, + "contact_phone": { + "description": "鑱旂郴鐢佃瘽", + "type": "string" + }, + "hidden": { + "description": "闅愯棌", + "type": "boolean" + }, + "id": { + "type": "string" + }, + "monthly_account": { + "description": "鏈堢粨璐﹀彿", + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "models.Material": { "type": "object", "properties": { "amount": { "description": "鏁伴噺", "type": "number" + }, + "attachmentIDs": { + "type": "array", + "items": { + "type": "integer" + } + }, + "attachmentList": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Attachment" + } }, "barcode": { "description": "鏉$爜", @@ -2814,6 +2925,16 @@ "id": { "type": "integer" }, + "logisticCompany": { + "$ref": "#/definitions/models.LogisticCompany" + }, + "logisticCompanyId": { + "type": "string" + }, + "logisticWeight": { + "description": "鐗╂祦閲嶉噺", + "type": "number" + }, "number": { "description": "鍗曞彿", "type": "string" @@ -2855,6 +2976,14 @@ }, "updateTime": { "type": "string" + }, + "waybillNumber": { + "description": "杩愬崟鍙�", + "type": "string" + }, + "weight": { + "description": "閲嶉噺", + "type": "number" } } }, @@ -3191,6 +3320,13 @@ "id": { "type": "integer" }, + "logisticCompanyId": { + "type": "string" + }, + "logisticWeight": { + "description": "鐗╂祦閲嶉噺", + "type": "number" + }, "number": { "description": "鍗曞彿", "type": "string" @@ -3222,6 +3358,14 @@ "toLocationId": { "description": "鐩爣浣嶇疆id", "type": "integer" + }, + "waybillNumber": { + "description": "杩愬崟鍙�", + "type": "string" + }, + "weight": { + "description": "閲嶉噺", + "type": "number" } } }, @@ -4154,6 +4298,8 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index 12bd7d8..a3b9b1e 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -951,6 +951,40 @@ } } }, + "/api-wms/v1/operation/getLogisticCompanyList": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "鍏ュ簱/鍑哄簱" + ], + "summary": "鑾峰彇鐗╂祦鍏徃鍒楄〃", + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.LogisticCompany" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/operation/list": { "post": { "produces": [ @@ -2212,6 +2246,24 @@ "CostingMethodAverageCost" ] }, + "constvar.FileType": { + "type": "string", + "enum": [ + "file", + "picture", + "thumbnail" + ], + "x-enum-comments": { + "FileType_File": "鏂囦欢", + "FileType_Picture": "鍥剧墖", + "FileType_Thumbnail": "缂╃暐鍥�" + }, + "x-enum-varnames": [ + "FileType_File", + "FileType_Picture", + "FileType_Thumbnail" + ] + }, "constvar.ForceRemovalStrategy": { "type": "integer", "enum": [ @@ -2424,6 +2476,26 @@ "ReservationNever" ] }, + "models.Attachment": { + "type": "object", + "properties": { + "FileUrl": { + "type": "string" + }, + "ext": { + "type": "string" + }, + "fileName": { + "type": "string" + }, + "fileType": { + "$ref": "#/definitions/constvar.FileType" + }, + "id": { + "type": "integer" + } + } + }, "models.Company": { "type": "object", "properties": { @@ -2560,12 +2632,51 @@ } } }, + "models.LogisticCompany": { + "type": "object", + "properties": { + "contact": { + "description": "鑱旂郴浜�", + "type": "string" + }, + "contact_phone": { + "description": "鑱旂郴鐢佃瘽", + "type": "string" + }, + "hidden": { + "description": "闅愯棌", + "type": "boolean" + }, + "id": { + "type": "string" + }, + "monthly_account": { + "description": "鏈堢粨璐﹀彿", + "type": "string" + }, + "name": { + "type": "string" + } + } + }, "models.Material": { "type": "object", "properties": { "amount": { "description": "鏁伴噺", "type": "number" + }, + "attachmentIDs": { + "type": "array", + "items": { + "type": "integer" + } + }, + "attachmentList": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Attachment" + } }, "barcode": { "description": "鏉$爜", @@ -2802,6 +2913,16 @@ "id": { "type": "integer" }, + "logisticCompany": { + "$ref": "#/definitions/models.LogisticCompany" + }, + "logisticCompanyId": { + "type": "string" + }, + "logisticWeight": { + "description": "鐗╂祦閲嶉噺", + "type": "number" + }, "number": { "description": "鍗曞彿", "type": "string" @@ -2843,6 +2964,14 @@ }, "updateTime": { "type": "string" + }, + "waybillNumber": { + "description": "杩愬崟鍙�", + "type": "string" + }, + "weight": { + "description": "閲嶉噺", + "type": "number" } } }, @@ -3179,6 +3308,13 @@ "id": { "type": "integer" }, + "logisticCompanyId": { + "type": "string" + }, + "logisticWeight": { + "description": "鐗╂祦閲嶉噺", + "type": "number" + }, "number": { "description": "鍗曞彿", "type": "string" @@ -3210,6 +3346,14 @@ "toLocationId": { "description": "鐩爣浣嶇疆id", "type": "integer" + }, + "waybillNumber": { + "description": "杩愬崟鍙�", + "type": "string" + }, + "weight": { + "description": "閲嶉噺", + "type": "number" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index c2d1ffe..b36a994 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -33,6 +33,20 @@ - CostingMethodStandardPrice - CostingMethodFIFO - CostingMethodAverageCost + constvar.FileType: + enum: + - file + - picture + - thumbnail + type: string + x-enum-comments: + FileType_File: 鏂囦欢 + FileType_Picture: 鍥剧墖 + FileType_Thumbnail: 缂╃暐鍥� + x-enum-varnames: + - FileType_File + - FileType_Picture + - FileType_Thumbnail constvar.ForceRemovalStrategy: enum: - 1 @@ -203,6 +217,19 @@ - WhetherTypeAsk - WhetherTypeAlways - ReservationNever + models.Attachment: + properties: + FileUrl: + type: string + ext: + type: string + fileName: + type: string + fileType: + $ref: '#/definitions/constvar.FileType' + id: + type: integer + type: object models.Company: properties: createTime: @@ -297,11 +324,38 @@ updateTime: type: string type: object + models.LogisticCompany: + properties: + contact: + description: 鑱旂郴浜� + type: string + contact_phone: + description: 鑱旂郴鐢佃瘽 + type: string + hidden: + description: 闅愯棌 + type: boolean + id: + type: string + monthly_account: + description: 鏈堢粨璐﹀彿 + type: string + name: + type: string + type: object models.Material: properties: amount: description: 鏁伴噺 type: number + attachmentIDs: + items: + type: integer + type: array + attachmentList: + items: + $ref: '#/definitions/models.Attachment' + type: array barcode: description: 鏉$爜 type: string @@ -476,6 +530,13 @@ type: integer id: type: integer + logisticCompany: + $ref: '#/definitions/models.LogisticCompany' + logisticCompanyId: + type: string + logisticWeight: + description: 鐗╂祦閲嶉噺 + type: number number: description: 鍗曞彿 type: string @@ -503,6 +564,12 @@ type: integer updateTime: type: string + waybillNumber: + description: 杩愬崟鍙� + type: string + weight: + description: 閲嶉噺 + type: number type: object models.OperationDetails: properties: @@ -733,6 +800,11 @@ type: integer id: type: integer + logisticCompanyId: + type: string + logisticWeight: + description: 鐗╂祦閲嶉噺 + type: number number: description: 鍗曞彿 type: string @@ -755,6 +827,12 @@ toLocationId: description: 鐩爣浣嶇疆id type: integer + waybillNumber: + description: 杩愬崟鍙� + type: string + weight: + description: 閲嶉噺 + type: number type: object request.AddOperationType: properties: @@ -1971,6 +2049,25 @@ summary: 鏇存敼璁板綍鐘舵�� tags: - 鍏ュ簱/鍑哄簱 + /api-wms/v1/operation/getLogisticCompanyList: + get: + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.LogisticCompany' + type: array + type: object + summary: 鑾峰彇鐗╂祦鍏徃鍒楄〃 + tags: + - 鍏ュ簱/鍑哄簱 /api-wms/v1/operation/list: post: parameters: diff --git a/models/db.go b/models/db.go index bb59b3b..e4c25d0 100644 --- a/models/db.go +++ b/models/db.go @@ -87,6 +87,7 @@ LocationProductAmount{}, ReorderRule{}, Attachment{}, + LogisticCompany{}, ) return err } diff --git a/models/logistic_company.go b/models/logistic_company.go new file mode 100644 index 0000000..d15574b --- /dev/null +++ b/models/logistic_company.go @@ -0,0 +1,153 @@ +package models + +import ( + "fmt" + "gorm.io/gorm" + "wms/pkg/mysqlx" +) + +type ( + // LogisticCompany 鐗╂祦鍏徃 + //todo 涓巃ps鍏辩敤,淇敼瀛楁瑕佸悓姝ヤ慨鏀筧ps + LogisticCompany struct { + BaseModelString + Name string `gorm:"unique;type:varchar(191);not null;comment:鍚嶇О" json:"name"` + // 鏈堢粨璐﹀彿 + MonthlyAccount string `gorm:"type:varchar(191);comment:鏈堢粨璐﹀彿" json:"monthly_account"` + // 鑱旂郴浜� + Contact string `gorm:"type:varchar(191);comment:鑱旂郴浜�" json:"contact"` + // 鑱旂郴鐢佃瘽 + ContactPhone string `gorm:"type:varchar(191);comment:鑱旂郴鐢佃瘽" json:"contact_phone"` + // 闅愯棌 + Hidden bool `gorm:"type:tinyint(1);comment:鏄惁闅愯棌" json:"hidden"` + } + + LogisticCompanySearch struct { + LogisticCompany + Order string + PageNum int + PageSize int + Orm *gorm.DB + } +) + +func (slf LogisticCompany) TableName() string { + return "logistic_company" +} + +func NewLogisticCompanySearch() *LogisticCompanySearch { + return &LogisticCompanySearch{Orm: mysqlx.GetDB()} +} + +func (slf *LogisticCompanySearch) SetOrm(tx *gorm.DB) *LogisticCompanySearch { + slf.Orm = tx + return slf +} + +func (slf *LogisticCompanySearch) SetPage(page, size int) *LogisticCompanySearch { + slf.PageNum, slf.PageSize = page, size + return slf +} + +func (slf *LogisticCompanySearch) SetOrder(order string) *LogisticCompanySearch { + slf.Order = order + return slf +} + +func (slf *LogisticCompanySearch) SetID(id string) *LogisticCompanySearch { + slf.ID = id + return slf +} + +func (slf *LogisticCompanySearch) SetName(name string) *LogisticCompanySearch { + slf.Name = name + return slf +} + +func (slf *LogisticCompanySearch) SetKeyword(keyword string) *LogisticCompanySearch { + slf.Name = keyword + return slf +} + +func (slf *LogisticCompanySearch) build() *gorm.DB { + var db = slf.Orm.Table(slf.TableName()) + if slf.ID != "" { + db = db.Where("id = ?", slf.ID) + } + if slf.Name != "" { + db = db.Where("name like ?", "%"+slf.Name+"%") + } + if slf.Order != "" { + db = db.Order(slf.Order) + } + if slf.PageNum > 0 && slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + return db +} + +func (slf *LogisticCompanySearch) CreateBatch(data []LogisticCompany) error { + var db = slf.build() + if err := db.Create(&data).Error; err != nil { + return err + } + + return nil +} + +func (slf *LogisticCompanySearch) Create(record *LogisticCompany) error { + var db = slf.build() + if err := db.Create(record).Error; err != nil { + return err + } + + return nil +} + +func (slf *LogisticCompanySearch) Save(record *LogisticCompany) error { + var db = slf.build() + if err := db.Save(record).Error; err != nil { + return err + } + + return nil +} + +func (slf *LogisticCompanySearch) Delete() error { + var db = slf.build() + if err := db.Delete(slf).Error; err != nil { + return err + } + + return nil +} + +func (slf *LogisticCompanySearch) Find() ([]LogisticCompany, int64, error) { + var db = slf.build() + var records []LogisticCompany + var total int64 + + if err := db.Count(&total).Error; err != nil { + return nil, 0, err + } + + if slf.PageNum*slf.PageSize > 0 { + db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) + } + if err := db.Find(&records).Error; err != nil { + return records, total, fmt.Errorf("find records err: %v", err) + } + + return records, total, nil +} + +func (slf *LogisticCompanySearch) FindNotTotal() ([]LogisticCompany, error) { + var db = slf.build() + var records []LogisticCompany + + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("find records err: %v", err) + } + + return records, nil +} diff --git a/models/operation.go b/models/operation.go index 7a62987..a06bdda 100644 --- a/models/operation.go +++ b/models/operation.go @@ -2,6 +2,7 @@ import ( "fmt" + "github.com/shopspring/decimal" "gorm.io/gorm" "wms/constvar" "wms/pkg/mysqlx" @@ -27,6 +28,11 @@ CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID-瀹㈡埛"` CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О-瀹㈡埛"` Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` + LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"` + LogisticCompany LogisticCompany `json:"logisticCompany" gorm:"foreignKey:LogisticCompanyId"` + WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙� + Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺 + LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺 Details []*OperationDetails `json:"details" gorm:"foreignKey:OperationID;references:Id"` BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 @@ -145,7 +151,8 @@ } if slf.Preload { - db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").Preload("ToLocation") + db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation"). + Preload("ToLocation").Preload("LogisticCompany") } if slf.Disuse { diff --git a/request/operation.go b/request/operation.go index ba5b594..966c299 100644 --- a/request/operation.go +++ b/request/operation.go @@ -21,12 +21,10 @@ CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID"` //鍏徃ID-瀹㈡埛 CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О-瀹㈡埛鍚嶇О Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` //澶囨敞 - - //Weight decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);comment:閲嶉噺(kg)"` //閲嶉噺(kg)-闈炲繀濉� - //TransferWeight decimal.Decimal `json:"transferWeight" gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺(kg)"` //鐗╂祦閲嶉噺(kg)-闈炲繀濉� - //CarrierID int `json:"carrierID" gorm:"type:int;comment:鎵胯繍鍟咺D"` //鎵胯繍鍟咺D-闈炲繀濉� - //CarrierName string `json:"carrierName" gorm:"type:varchar(63);comment:鎵胯繍鍟嗗悕绉�"` //鎵胯繍鍟嗗悕绉�-闈炲繀濉� - //Tracking string `json:"tracking" gorm:"type:varchar(127);comment:杩借釜鍙傝��"` //杩借釜鍙傝��-闈炲繀濉� + LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"` + WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙� + Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺 + LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺 } type OperationDetails struct { @@ -62,6 +60,10 @@ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О-瀹㈡埛鍚嶇О Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` //澶囨敞 BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` //鍩虹浣滀笟绫诲瀷 + LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"` + WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙� + Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺 + LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺 } type OperationAllList struct { diff --git a/router/router.go b/router/router.go index 27e49d9..fedd7c4 100644 --- a/router/router.go +++ b/router/router.go @@ -86,6 +86,7 @@ operationAPI.DELETE("operation/:id", operationController.Delete) operationAPI.PUT("finish/:id", operationController.Finish) operationAPI.POST("listTransfer", operationController.ListTransfer) + operationAPI.GET("getLogisticCompanyList", operationController.GetLogisticCompanyList) } -- Gitblit v1.8.0