From 8cb1da78fd4d237b278ed4d512c6c4f04b663cfc Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期一, 22 四月 2024 11:34:47 +0800
Subject: [PATCH] 库存调整修改
---
request/location_product_amount.go | 5 ++
docs/swagger.yaml | 19 +++++++--
docs/docs.go | 24 ++++++++++--
docs/swagger.json | 24 ++++++++++--
controllers/location_product_amount.go | 33 ++++++++++++++--
5 files changed, 89 insertions(+), 16 deletions(-)
diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go
index 50e03f8..97a6f8e 100644
--- a/controllers/location_product_amount.go
+++ b/controllers/location_product_amount.go
@@ -25,11 +25,11 @@
// @Tags 搴撳瓨鐩樼偣
// @Summary 搴撳瓨鐩樼偣鍒楄〃
// @Produce application/json
-// @Param object body request.PageInfo true "鏌ヨ鍙傛暟"
+// @Param object body request.GetList true "鏌ヨ鍙傛暟"
// @Success 200 {object} util.Response "鎴愬姛"
// @Router /api-wms/v1/locationProductAmount/list [post]
func (slf LocationProductAmountController) List(c *gin.Context) {
- var params request.PageInfo
+ var params request.GetList
if err := c.BindJSON(¶ms); err != nil {
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
return
@@ -37,6 +37,18 @@
if !params.Check() {
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父")
return
+ }
+ productIds := make([]string, 0)
+ locationIds := make([]int, 0)
+ if params.Keyword != "" {
+ materials, _ := models.NewMaterialSearch().SetKeyword(params.Keyword).FindNotTotal()
+ for _, material := range materials {
+ productIds = append(productIds, material.ID)
+ }
+ locations, _ := models.NewLocationSearch().SetKeyword(params.Keyword).FindNotTotal()
+ for _, location := range locations {
+ locationIds = append(locationIds, location.Id)
+ }
}
search := models.NewLocationProductAmountSearch()
@@ -55,6 +67,13 @@
records = make([]*models.LocationProductAmountWithOperation, 0)
total int64
)
+ if len(productIds) > 0 {
+ search.Orm = search.Orm.Where("wms_location_product_amount.product_id in (?)", productIds)
+
+ }
+ if len(locationIds) > 0 {
+ search.Orm = search.Orm.Where("wms_location_product_amount.location_id in (?)", locationIds)
+ }
if err := search.Orm.Count(&total).Error; err != nil {
util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err))
@@ -68,9 +87,14 @@
util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err))
return
}
- var operation models.Operation
+
for k, v := range records {
- if res := mysqlx.GetDB().Table("wms_operation").Preload("Details").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.base_operation_type=? and wms_operation.status=? and wms_operation_details.to_location_id=? and wms_operation_details.product_id=?", constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready, v.LocationId, v.ProductId).First(&operation); res.Error != nil {
+ var operation models.Operation
+ db := mysqlx.GetDB()
+ if res := db.Table("wms_operation").Preload("Details").InnerJoins("inner join wms_operation_details "+
+ "on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.base_operation_type=? and "+
+ "wms_operation.status=? and wms_operation_details.to_location_id=? and wms_operation_details.product_id=?", constvar.BaseOperationTypeAdjust,
+ constvar.OperationStatus_Ready, v.LocationId, v.ProductId).First(&operation); res.Error != nil {
if errors.Is(res.Error, gorm.ErrRecordNotFound) {
records[k].Status = constvar.OperationStatus_Finish
records[k].BaseOperationType = constvar.BaseOperationTypeAdjust
@@ -108,6 +132,7 @@
if err := AddLocationProductAmount(reqParams); err != nil {
util.ResponseFormat(c, code.RequestError, err)
+ return
}
util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛")
diff --git a/docs/docs.go b/docs/docs.go
index fd049ed..7366ea9 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1091,7 +1091,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/request.PageInfo"
+ "$ref": "#/definitions/request.GetList"
}
}
],
@@ -3794,7 +3794,7 @@
"type": "string"
},
"companyID": {
- "type": "integer"
+ "type": "string"
},
"companyName": {
"type": "string"
@@ -4316,7 +4316,7 @@
},
"companyID": {
"description": "鍏徃ID-瀹㈡埛",
- "type": "integer"
+ "type": "string"
},
"companyName": {
"description": "鍏徃鍚嶇О-瀹㈡埛鍚嶇О",
@@ -4636,6 +4636,22 @@
"unit": {
"description": "鍗曚綅",
"type": "string"
+ }
+ }
+ },
+ "request.GetList": {
+ "type": "object",
+ "properties": {
+ "keyword": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
}
}
},
@@ -5111,7 +5127,7 @@
},
"companyID": {
"description": "鍏徃ID-瀹㈡埛",
- "type": "integer"
+ "type": "string"
},
"companyName": {
"description": "鍏徃鍚嶇О-瀹㈡埛鍚嶇О",
diff --git a/docs/swagger.json b/docs/swagger.json
index 880f4dc..30a33fd 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -1079,7 +1079,7 @@
"in": "body",
"required": true,
"schema": {
- "$ref": "#/definitions/request.PageInfo"
+ "$ref": "#/definitions/request.GetList"
}
}
],
@@ -3782,7 +3782,7 @@
"type": "string"
},
"companyID": {
- "type": "integer"
+ "type": "string"
},
"companyName": {
"type": "string"
@@ -4304,7 +4304,7 @@
},
"companyID": {
"description": "鍏徃ID-瀹㈡埛",
- "type": "integer"
+ "type": "string"
},
"companyName": {
"description": "鍏徃鍚嶇О-瀹㈡埛鍚嶇О",
@@ -4624,6 +4624,22 @@
"unit": {
"description": "鍗曚綅",
"type": "string"
+ }
+ }
+ },
+ "request.GetList": {
+ "type": "object",
+ "properties": {
+ "keyword": {
+ "type": "string"
+ },
+ "page": {
+ "description": "椤电爜",
+ "type": "integer"
+ },
+ "pageSize": {
+ "description": "姣忛〉澶у皬",
+ "type": "integer"
}
}
},
@@ -5099,7 +5115,7 @@
},
"companyID": {
"description": "鍏徃ID-瀹㈡埛",
- "type": "integer"
+ "type": "string"
},
"companyName": {
"description": "鍏徃鍚嶇О-瀹㈡埛鍚嶇О",
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index c733427..2f659b0 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -757,7 +757,7 @@
comment:
type: string
companyID:
- type: integer
+ type: string
companyName:
type: string
contacterID:
@@ -1110,7 +1110,7 @@
type: string
companyID:
description: 鍏徃ID-瀹㈡埛
- type: integer
+ type: string
companyName:
description: 鍏徃鍚嶇О-瀹㈡埛鍚嶇О
type: string
@@ -1334,6 +1334,17 @@
unit:
description: 鍗曚綅
type: string
+ type: object
+ request.GetList:
+ properties:
+ keyword:
+ type: string
+ page:
+ description: 椤电爜
+ type: integer
+ pageSize:
+ description: 姣忛〉澶у皬
+ type: integer
type: object
request.GetLocationForms:
properties:
@@ -1663,7 +1674,7 @@
type: string
companyID:
description: 鍏徃ID-瀹㈡埛
- type: integer
+ type: string
companyName:
description: 鍏徃鍚嶇О-瀹㈡埛鍚嶇О
type: string
@@ -2577,7 +2588,7 @@
name: object
required: true
schema:
- $ref: '#/definitions/request.PageInfo'
+ $ref: '#/definitions/request.GetList'
produces:
- application/json
responses:
diff --git a/request/location_product_amount.go b/request/location_product_amount.go
index 6b34041..9b1a386 100644
--- a/request/location_product_amount.go
+++ b/request/location_product_amount.go
@@ -4,6 +4,11 @@
"github.com/shopspring/decimal"
)
+type GetList struct {
+ PageInfo
+ Keyword string `json:"keyword"`
+}
+
type AddLocationProductAmount struct {
AdjustAmount decimal.Decimal `json:"adjustAmount" ` //宸��
DifferenceAmount decimal.Decimal `json:"differenceAmount"` //璁℃暟鏁伴噺
--
Gitblit v1.8.0