From a2cfbd59045d7426088e9ec9e93794dc895849a9 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 03 七月 2024 23:13:40 +0800
Subject: [PATCH] 获取位置列表增加仓库ID传参,默认位置去掉仓库code拼接, 修复若干bug
---
models/location.go | 9 +
controllers/warehouse.go | 42 ++++---
docs/swagger.yaml | 70 +++++++----
service/location_forms.go | 3
controllers/location.go | 10 +
docs/docs.go | 105 ++++++++++-------
conf/config.yaml | 1
docs/swagger.json | 105 ++++++++++-------
request/location.go | 1
service/operation.go | 1
10 files changed, 215 insertions(+), 132 deletions(-)
diff --git a/conf/config.yaml b/conf/config.yaml
index d608c0d..3098340 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -9,6 +9,7 @@
serverId: wms
# 閫氳繃鍏徃鍚嶇О鍖哄垎鍑哄叆搴撴槑缁嗘墦鍗版ā鐗�,鐩墠鏀寔:geruimi,jialian
companyName: jialian
+ env: dev
db:
# dsn: root:c++java123@tcp(192.168.20.119:3306)/wms?charset=utf8&parseTime=True&loc=Local
dsn: root:c++java123@tcp(127.0.0.1:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local
diff --git a/controllers/location.go b/controllers/location.go
index 5a4a3f9..90e6749 100644
--- a/controllers/location.go
+++ b/controllers/location.go
@@ -31,6 +31,12 @@
util.ResponseFormat(c, code.RequestParamError, err)
return
}
+
+ if params.WarehouseId == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "浠撳簱ID鍙傛暟缂哄け")
+ return
+ }
+
if params.ParentId != 0 {
//鏌ヨ涓婄骇鍚嶇О
first, err := models.NewLocationSearch().SetID(params.ParentId).First()
@@ -82,7 +88,9 @@
search.SetPage(params.Page, params.PageSize)
}
list, total, err := search.SetKeyword(params.KeyWord).SetType(params.Type).SetJointName(params.JointName).
- SetIsScrapLocation(params.IsScrapLocation).SetOrder("created_at desc").Find()
+ SetIsScrapLocation(params.IsScrapLocation).SetOrder("created_at desc").
+ SetWarehouseId(params.WarehouseId).
+ Find()
if err != nil {
util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触")
return
diff --git a/controllers/warehouse.go b/controllers/warehouse.go
index 14d63c3..fda7851 100644
--- a/controllers/warehouse.go
+++ b/controllers/warehouse.go
@@ -12,7 +12,6 @@
"wms/extend/code"
"wms/extend/util"
"wms/models"
- "wms/pkg/logx"
"wms/pkg/structx"
"wms/request"
)
@@ -53,25 +52,33 @@
util.ResponseFormat(c, code.SaveFail, "瑙嗗浘鍒涘缓澶辫触")
return
}
- //鍒涘缓榛樿浣嶇疆
- location := &models.Location{
- Name: params.Name,
- JointName: params.Name,
- Type: constvar.LocationTypeInternal,
- ReplenishLocation: true,
- ParentId: id,
- }
- locationId, err := models.NewLocationSearch().CreateReturnId(location)
- if err != nil {
- util.ResponseFormat(c, code.SaveFail, "浣嶇疆鍒涘缓澶辫触")
- return
- }
- params.LocationId = locationId
err = models.WithTransaction(func(tx *gorm.DB) error {
err := models.NewWarehouseSearch().SetOrm(tx).Create(¶ms)
if err != nil {
return err
}
+
+ //鍒涘缓榛樿浣嶇疆
+ location := &models.Location{
+ Name: params.Name,
+ JointName: params.Name,
+ Type: constvar.LocationTypeInternal,
+ ReplenishLocation: true,
+ ParentId: id,
+ WarehouseId: params.Id,
+ }
+ locationId, err := models.NewLocationSearch().SetOrm(tx).CreateReturnId(location)
+ if err != nil {
+ return err
+ }
+
+ //鏇存敼浠撳簱璁板綍閲岀殑浣嶇疆id
+ params.LocationId = locationId
+ err = models.NewWarehouseSearch().SetOrm(tx).SetID(params.Id).UpdateByMap(map[string]interface{}{"location_id": locationId})
+ if err != nil {
+ return err
+ }
+
//鍒涘缓涓変釜榛樿鎿嶄綔绫诲瀷
var types []*models.OperationType
inType := &models.OperationType{
@@ -95,9 +102,8 @@
err = models.NewOperationTypeSearch().SetOrm(tx).CreateBatch(types)
return err
})
+
if err != nil {
- _ = models.NewLocationSearch().SetID(locationId).Delete()
- logx.Errorf("warehouse create err: %v", err)
util.ResponseFormat(c, code.SaveFail, "鎻掑叆澶辫触")
return
}
@@ -238,7 +244,7 @@
for _, warehouse := range list {
for _, location := range locations {
if warehouse.LocationId == location.Id {
- warehouse.WarehouseLocation = warehouse.Code + "/" + location.Name
+ warehouse.WarehouseLocation = location.Name
break
}
}
diff --git a/docs/docs.go b/docs/docs.go
index 709fcde..597d1c7 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -2023,37 +2023,11 @@
"鍏ュ簱/鍑哄簱"
],
"summary": "鑾峰彇浜哄憳鍒楄〃",
- "parameters": [
- {
- "description": "鍙傛暟",
- "name": "object",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/request.OperationCondition"
- }
- }
- ],
"responses": {
"200": {
"description": "鎴愬姛",
"schema": {
- "allOf": [
- {
- "$ref": "#/definitions/util.ResponseList"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/inventory_order.WorkerInfo"
- }
- }
- }
- }
- ]
+ "$ref": "#/definitions/util.Response"
}
}
}
@@ -2797,6 +2771,31 @@
}
}
},
+ "/api-wms/v1/product/downloadInputFormat": {
+ "get": {
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "涓嬭浇瀵煎叆鐗╂枡/浜у搧妯℃澘",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/finishDisuse/{id}": {
"put": {
"produces": [
@@ -3124,9 +3123,9 @@
"application/xlsx"
],
"tags": [
- "鐗╂枡绠$悊"
+ "浜у搧"
],
- "summary": "瀵煎叆鐗╂枡",
+ "summary": "瀵煎叆鐗╂枡/浜у搧",
"parameters": [
{
"type": "file",
@@ -4152,19 +4151,22 @@
1,
2,
3,
- 4
+ 4,
+ 5
],
"x-enum-comments": {
+ "DisuseType": "鎶ュ簾绫诲瀷",
"StockoutType": "鍑哄簱绫诲瀷",
"StorageType": "鍏ュ簱绫诲瀷",
- "TakeStock": "鐩樼偣绫诲瀷",
+ "TakeStockType": "鐩樼偣绫诲瀷",
"TransferType": "璋冩嫧绫诲瀷"
},
"x-enum-varnames": [
"StorageType",
"StockoutType",
"TransferType",
- "TakeStock"
+ "TakeStockType",
+ "DisuseType"
]
},
"constvar.OperationSource": {
@@ -4347,17 +4349,6 @@
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
- }
- }
- },
- "inventory_order.WorkerInfo": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "name": {
- "type": "string"
}
}
},
@@ -5038,6 +5029,21 @@
"type": "number"
}
}
+ },
+ "models.MonthStatsItemsType": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-comments": {
+ "MonthStatsItemsTypeInput": "鍏ュ簱",
+ "MonthStatsItemsTypeOutput": "鍑哄簱"
+ },
+ "x-enum-varnames": [
+ "MonthStatsItemsTypeInput",
+ "MonthStatsItemsTypeOutput"
+ ]
},
"models.MoveHistory": {
"type": "object",
@@ -5740,6 +5746,9 @@
"description": "鍏ュ簱鏉ユ簮锛屽嚭搴撳幓澶�",
"type": "string"
},
+ "type": {
+ "$ref": "#/definitions/models.MonthStatsItemsType"
+ },
"warehouseMonthStatsId": {
"type": "integer"
}
@@ -6333,6 +6342,12 @@
"locationId": {
"type": "integer"
},
+ "locationIds": {
+ "type": "array",
+ "items": {
+ "type": "integer"
+ }
+ },
"page": {
"description": "椤电爜",
"type": "integer"
@@ -6373,6 +6388,10 @@
},
"type": {
"type": "integer"
+ },
+ "warehouseId": {
+ "description": "浠撳簱ID",
+ "type": "integer"
}
}
},
diff --git a/docs/swagger.json b/docs/swagger.json
index 0f87c8f..340d84d 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -2012,37 +2012,11 @@
"鍏ュ簱/鍑哄簱"
],
"summary": "鑾峰彇浜哄憳鍒楄〃",
- "parameters": [
- {
- "description": "鍙傛暟",
- "name": "object",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/request.OperationCondition"
- }
- }
- ],
"responses": {
"200": {
"description": "鎴愬姛",
"schema": {
- "allOf": [
- {
- "$ref": "#/definitions/util.ResponseList"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/inventory_order.WorkerInfo"
- }
- }
- }
- }
- ]
+ "$ref": "#/definitions/util.Response"
}
}
}
@@ -2786,6 +2760,31 @@
}
}
},
+ "/api-wms/v1/product/downloadInputFormat": {
+ "get": {
+ "tags": [
+ "浜у搧"
+ ],
+ "summary": "涓嬭浇瀵煎叆鐗╂枡/浜у搧妯℃澘",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "token",
+ "name": "Authorization",
+ "in": "header",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
"/api-wms/v1/product/finishDisuse/{id}": {
"put": {
"produces": [
@@ -3113,9 +3112,9 @@
"application/xlsx"
],
"tags": [
- "鐗╂枡绠$悊"
+ "浜у搧"
],
- "summary": "瀵煎叆鐗╂枡",
+ "summary": "瀵煎叆鐗╂枡/浜у搧",
"parameters": [
{
"type": "file",
@@ -4141,19 +4140,22 @@
1,
2,
3,
- 4
+ 4,
+ 5
],
"x-enum-comments": {
+ "DisuseType": "鎶ュ簾绫诲瀷",
"StockoutType": "鍑哄簱绫诲瀷",
"StorageType": "鍏ュ簱绫诲瀷",
- "TakeStock": "鐩樼偣绫诲瀷",
+ "TakeStockType": "鐩樼偣绫诲瀷",
"TransferType": "璋冩嫧绫诲瀷"
},
"x-enum-varnames": [
"StorageType",
"StockoutType",
"TransferType",
- "TakeStock"
+ "TakeStockType",
+ "DisuseType"
]
},
"constvar.OperationSource": {
@@ -4336,17 +4338,6 @@
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
- }
- }
- },
- "inventory_order.WorkerInfo": {
- "type": "object",
- "properties": {
- "id": {
- "type": "string"
- },
- "name": {
- "type": "string"
}
}
},
@@ -5027,6 +5018,21 @@
"type": "number"
}
}
+ },
+ "models.MonthStatsItemsType": {
+ "type": "integer",
+ "enum": [
+ 1,
+ 2
+ ],
+ "x-enum-comments": {
+ "MonthStatsItemsTypeInput": "鍏ュ簱",
+ "MonthStatsItemsTypeOutput": "鍑哄簱"
+ },
+ "x-enum-varnames": [
+ "MonthStatsItemsTypeInput",
+ "MonthStatsItemsTypeOutput"
+ ]
},
"models.MoveHistory": {
"type": "object",
@@ -5729,6 +5735,9 @@
"description": "鍏ュ簱鏉ユ簮锛屽嚭搴撳幓澶�",
"type": "string"
},
+ "type": {
+ "$ref": "#/definitions/models.MonthStatsItemsType"
+ },
"warehouseMonthStatsId": {
"type": "integer"
}
@@ -6322,6 +6331,12 @@
"locationId": {
"type": "integer"
},
+ "locationIds": {
+ "type": "array",
+ "items": {
+ "type": "integer"
+ }
+ },
"page": {
"description": "椤电爜",
"type": "integer"
@@ -6362,6 +6377,10 @@
},
"type": {
"type": "integer"
+ },
+ "warehouseId": {
+ "description": "浠撳簱ID",
+ "type": "integer"
}
}
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 8285221..6dd0214 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -212,17 +212,20 @@
- 2
- 3
- 4
+ - 5
type: integer
x-enum-comments:
+ DisuseType: 鎶ュ簾绫诲瀷
StockoutType: 鍑哄簱绫诲瀷
StorageType: 鍏ュ簱绫诲瀷
- TakeStock: 鐩樼偣绫诲瀷
+ TakeStockType: 鐩樼偣绫诲瀷
TransferType: 璋冩嫧绫诲瀷
x-enum-varnames:
- StorageType
- StockoutType
- TransferType
- - TakeStock
+ - TakeStockType
+ - DisuseType
constvar.OperationSource:
enum:
- 1
@@ -365,13 +368,6 @@
valid:
description: Valid is true if Time is not NULL
type: boolean
- type: object
- inventory_order.WorkerInfo:
- properties:
- id:
- type: string
- name:
- type: string
type: object
models.Attachment:
properties:
@@ -854,6 +850,17 @@
description: 閲嶉噺
type: number
type: object
+ models.MonthStatsItemsType:
+ enum:
+ - 1
+ - 2
+ type: integer
+ x-enum-comments:
+ MonthStatsItemsTypeInput: 鍏ュ簱
+ MonthStatsItemsTypeOutput: 鍑哄簱
+ x-enum-varnames:
+ - MonthStatsItemsTypeInput
+ - MonthStatsItemsTypeOutput
models.MoveHistory:
properties:
amount:
@@ -1329,6 +1336,8 @@
name:
description: 鍏ュ簱鏉ユ簮锛屽嚭搴撳幓澶�
type: string
+ type:
+ $ref: '#/definitions/models.MonthStatsItemsType'
warehouseMonthStatsId:
type: integer
type: object
@@ -1734,6 +1743,10 @@
type: string
locationId:
type: integer
+ locationIds:
+ items:
+ type: integer
+ type: array
page:
description: 椤电爜
type: integer
@@ -1762,6 +1775,9 @@
description: 姣忛〉澶у皬
type: integer
type:
+ type: integer
+ warehouseId:
+ description: 浠撳簱ID
type: integer
type: object
request.GetMiniDictList:
@@ -3627,27 +3643,13 @@
- 鍏ュ簱/鍑哄簱
/api-wms/v1/operation/getPersonnelList:
get:
- parameters:
- - description: 鍙傛暟
- in: body
- name: object
- required: true
- schema:
- $ref: '#/definitions/request.OperationCondition'
produces:
- application/json
responses:
"200":
description: 鎴愬姛
schema:
- allOf:
- - $ref: '#/definitions/util.ResponseList'
- - properties:
- data:
- items:
- $ref: '#/definitions/inventory_order.WorkerInfo'
- type: array
- type: object
+ $ref: '#/definitions/util.Response'
summary: 鑾峰彇浜哄憳鍒楄〃
tags:
- 鍏ュ簱/鍑哄簱
@@ -4117,6 +4119,22 @@
summary: 鍒犻櫎浜у搧绫诲瀷
tags:
- 浜у搧绫诲瀷
+ /api-wms/v1/product/downloadInputFormat:
+ get:
+ parameters:
+ - description: token
+ in: header
+ name: Authorization
+ required: true
+ type: string
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 涓嬭浇瀵煎叆鐗╂枡/浜у搧妯℃澘
+ tags:
+ - 浜у搧
/api-wms/v1/product/finishDisuse/{id}:
put:
parameters:
@@ -4325,9 +4343,9 @@
description: 鎴愬姛
schema:
$ref: '#/definitions/util.Response'
- summary: 瀵煎叆鐗╂枡
+ summary: 瀵煎叆鐗╂枡/浜у搧
tags:
- - 鐗╂枡绠$悊
+ - 浜у搧
/api-wms/v1/product/listDisuse:
post:
parameters:
diff --git a/models/location.go b/models/location.go
index 6bb50a0..fde650b 100644
--- a/models/location.go
+++ b/models/location.go
@@ -122,6 +122,11 @@
return slf
}
+func (slf *LocationSearch) SetWarehouseId(warehouseId int) *LocationSearch {
+ slf.WarehouseId = warehouseId
+ return slf
+}
+
func (slf *LocationSearch) build() *gorm.DB {
var db = slf.Orm.Table(slf.TableName())
@@ -171,6 +176,10 @@
db = db.Preload("Warehouse")
}
+ if slf.WarehouseId != 0 {
+ db = db.Where("warehouse_id = ?", slf.WarehouseId)
+ }
+
return db
}
diff --git a/request/location.go b/request/location.go
index 8f6546d..4f49f33 100644
--- a/request/location.go
+++ b/request/location.go
@@ -13,4 +13,5 @@
KeyWord string `json:"keyWord"`
JointName string `json:"jointName"` //鎷兼帴鍚嶇О
IsScrapLocation bool `json:"isScrapLocation"` //鏄惁鎶ュ簾
+ WarehouseId int `json:"warehouseId"` //浠撳簱ID
}
diff --git a/service/location_forms.go b/service/location_forms.go
index 15275ce..27932a2 100644
--- a/service/location_forms.go
+++ b/service/location_forms.go
@@ -49,7 +49,8 @@
ids := params.LocationIds
if params.LocationId != 0 {
ids = append(ids, params.LocationId)
- } else {
+ }
+ if len(ids) == 0 {
//鏌ヨ浣嶇疆
locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).SetType(3).FindAll()
if err != nil {
diff --git a/service/operation.go b/service/operation.go
index 3b9c43b..47902e3 100644
--- a/service/operation.go
+++ b/service/operation.go
@@ -182,6 +182,7 @@
} else {
if locAmount, aok := mapLocAmount[strconv.Itoa(operation.LocationID)+v.ProductId]; aok {
locAmount.Amount = locAmount.Amount.Add(v.Amount)
+ locAmount.ID = uint(locAmount.Id)
if err := models.NewLocationProductAmountSearch().SetOrm(tx).SetID(int(locAmount.ID)).Save(locAmount); err != nil {
return err
}
--
Gitblit v1.8.0