From 40202aef72d93a6fb3acabf719d121ea88534dd7 Mon Sep 17 00:00:00 2001 From: jiangshuai <291802688@qq.com> Date: 星期一, 23 十月 2023 09:53:53 +0800 Subject: [PATCH] 1.获取调拨类型列表 --- models/operation_type.go | 4 ++ controllers/operation_type.go | 42 +++++++++++++++++++++ docs/swagger.yaml | 10 ---- request/operation_type.go | 4 ++ docs/docs.go | 16 ------- docs/swagger.json | 14 ------ router/router.go | 1 7 files changed, 54 insertions(+), 37 deletions(-) diff --git a/controllers/operation_type.go b/controllers/operation_type.go index 8737781..c0ea4a9 100644 --- a/controllers/operation_type.go +++ b/controllers/operation_type.go @@ -166,3 +166,45 @@ } util.ResponseFormat(c, code.UpdateSuccess, "鍒犻櫎鎴愬姛") } + +// ListTransfer +// @Tags 涓氬姟绫诲瀷 +// @Summary 璋冩嫧绫诲瀷鍒楄〃 +// @Produce application/json +// @Param object query request.ListTransfer true "鏌ヨ鍙傛暟" +// @Success 200 {object} util.ResponseList "鎴愬姛" +// @Router /api-wms/v1/operationType/operationType [get] +func (slf OperationTypeController) ListTransfer(c *gin.Context) { + var params request.GetOperationTypeList + if err := c.ShouldBindQuery(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + list, total, err := models.NewOperationTypeSearch().SetPage(params.Page, params.PageSize).SetBaseOperationType(constvar.BaseOperationTypeInternal).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find() + if err != nil { + util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触") + return + } + var idList []int + for _, v := range list { + idList = append(idList, v.Id) + } + statistics, err := models.NewOperationTypeSearch().ListByStatusAndCount(idList) + if err != nil { + util.ResponseFormat(c, code.RequestError, err.Error()) + return + } + mapStatistics := make(map[string]*models.OperationTypeByStatus, 0) + for _, v := range statistics { + mapStatistics[strconv.Itoa(v.Id)+string(v.Status)] = v + } + for k, v := range list { + if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Ready)]; ok { + list[k].ReadyCount = value.Count + } + if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Finish)]; ok { + list[k].FinishCount = value.Count + } + } + util.ResponseFormatListWithPage(c, code.Success, list, cast.ToInt(total), params.Page, params.PageSize) +} diff --git a/docs/docs.go b/docs/docs.go index 2f157ba..e233c6b 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1069,23 +1069,11 @@ "tags": [ "涓氬姟绫诲瀷" ], - "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "summary": "璋冩嫧绫诲瀷鍒楄〃", "parameters": [ { "type": "string", "name": "keyword", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", "in": "query" } ], @@ -3724,8 +3712,6 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index 971a4ab..2201051 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1057,23 +1057,11 @@ "tags": [ "涓氬姟绫诲瀷" ], - "summary": "鏌ヨ浣滀笟绫诲瀷鍒楄〃", + "summary": "璋冩嫧绫诲瀷鍒楄〃", "parameters": [ { "type": "string", "name": "keyword", - "in": "query" - }, - { - "type": "integer", - "description": "椤电爜", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "description": "姣忛〉澶у皬", - "name": "pageSize", "in": "query" } ], diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a2594cc..7e559df 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1927,14 +1927,6 @@ - in: query name: keyword type: string - - description: 椤电爜 - in: query - name: page - type: integer - - description: 姣忛〉澶у皬 - in: query - name: pageSize - type: integer produces: - application/json responses: @@ -1942,7 +1934,7 @@ description: 鎴愬姛 schema: $ref: '#/definitions/util.ResponseList' - summary: 鏌ヨ浣滀笟绫诲瀷鍒楄〃 + summary: 璋冩嫧绫诲瀷鍒楄〃 tags: - 涓氬姟绫诲瀷 post: diff --git a/models/operation_type.go b/models/operation_type.go index 5c1c4b3..ed03f46 100644 --- a/models/operation_type.go +++ b/models/operation_type.go @@ -135,6 +135,10 @@ db = db.Where("warehouse_id = ?", slf.WarehouseId) } + if int(slf.BaseOperationType) != 0 { + db = db.Where("base_operation_type = ?", slf.BaseOperationType) + } + return db } diff --git a/request/operation_type.go b/request/operation_type.go index a76c5d3..573eb4d 100644 --- a/request/operation_type.go +++ b/request/operation_type.go @@ -31,3 +31,7 @@ ID uint `gorm:"comment:涓婚敭ID;primaryKey;" json:"id"` AddOperationType } + +type ListTransfer struct { + Keyword string `json:"keyword"` +} diff --git a/router/router.go b/router/router.go index cdc3be6..4ac8ab8 100644 --- a/router/router.go +++ b/router/router.go @@ -68,6 +68,7 @@ operationTypeAPI := r.Group(urlPrefix + "/operationType") { operationTypeAPI.GET("operationType", operationTypeController.List) // 鑾峰彇浣滀笟绫诲瀷鍒楄〃 + operationTypeAPI.GET("listTransfer", operationTypeController.ListTransfer) // 鑾峰彇浣滀笟绫诲瀷鍒楄〃 operationTypeAPI.POST("operationType", operationTypeController.Add) // 鏂板浣滀笟绫诲瀷 operationTypeAPI.PUT("operationType/:id", operationTypeController.Update) // 淇敼浣滀笟绫诲瀷 operationTypeAPI.DELETE("operationType/:id", operationTypeController.Delete) // 鍒犻櫎浣滀笟绫诲瀷 -- Gitblit v1.8.0