| | |
| | | } |
| | | 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) |
| | | } |
| | |
| | | "tags": [ |
| | | "业务类型" |
| | | ], |
| | | "summary": "查询作业类型列表", |
| | | "summary": "调拨类型列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | "tags": [ |
| | | "业务类型" |
| | | ], |
| | | "summary": "查询作业类型列表", |
| | | "summary": "调拨类型列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | |
| | | - in: query |
| | | name: keyword |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.ResponseList' |
| | | summary: 查询作业类型列表 |
| | | summary: 调拨类型列表 |
| | | tags: |
| | | - 业务类型 |
| | | post: |
| | |
| | | db = db.Where("warehouse_id = ?", slf.WarehouseId) |
| | | } |
| | | |
| | | if int(slf.BaseOperationType) != 0 { |
| | | db = db.Where("base_operation_type = ?", slf.BaseOperationType) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | ID uint `gorm:"comment:主键ID;primaryKey;" json:"id"` |
| | | AddOperationType |
| | | } |
| | | |
| | | type ListTransfer struct { |
| | | Keyword string `json:"keyword"` |
| | | } |
| | |
| | | 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) // 删除作业类型 |