| | |
| | | // @Tags 入库/出库 |
| | | // @Summary 入库/出库列表 |
| | | // @Produce application/json |
| | | // @Accept json |
| | | // @Param object query request.OperationList true "参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/operation [get] |
| | | // @Param object body request.OperationList true "查询参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/list [post] |
| | | func (slf OperationController) List(c *gin.Context) { |
| | | var params request.OperationList |
| | | if err := c.ShouldBindQuery(¶ms); err != nil { |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error()) |
| | | return |
| | | } |
| | |
| | | } |
| | | search := models.NewOperationSearch() |
| | | search.SetPage(params.Page, params.PageSize) |
| | | if params.Number != "" { |
| | | search.SetNumber(params.Number) |
| | | } |
| | | if params.SourceNumber != "" { |
| | | search.SetSourceNumber(params.SourceNumber) |
| | | } |
| | | list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error()) |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormatList(c, code.Success, list, int(total)) |
| | | util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | | // ListAll |
| | | // @Tags 入库/出库 |
| | | // @Summary 调拨 |
| | | // @Produce application/json |
| | | // @Param object body request.OperationAllList true "参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/listAll [post] |
| | | func (slf OperationController) ListAll(c *gin.Context) { |
| | | var params request.OperationAllList |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error()) |
| | | return |
| | | } |
| | | if !params.PageInfo.Check() { |
| | | util.ResponseFormat(c, code.RequestParamError, "数据分页信息错误") |
| | | return |
| | | } |
| | | search := models.NewOperationSearch() |
| | | search.SetPage(params.Page, params.PageSize) |
| | | search.SetPage(params.Page, params.PageSize) |
| | | if params.Number != "" { |
| | | search.SetNumber(params.Number) |
| | | } |
| | | if params.SourceNumber != "" { |
| | | search.SetSourceNumber(params.SourceNumber) |
| | | } |
| | | list, total, err := search.SetPreload(true).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error()) |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/operation": { |
| | | "get": { |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "/api-wms/v1/operation/list": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "summary": "入库/出库列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "name": "operationTypeId", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.OperationList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/listAll": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "入库/出库" |
| | | ], |
| | | "summary": "调拨", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.OperationAllList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/operation": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationAllList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "operationTypeId": { |
| | | "type": "integer" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryOperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/operation": { |
| | | "get": { |
| | | "consumes": [ |
| | | "application/json" |
| | | ], |
| | | "/api-wms/v1/operation/list": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | |
| | | "summary": "入库/出库列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "name": "operationTypeId", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.OperationList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/listAll": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "入库/出库" |
| | | ], |
| | | "summary": "调拨", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.OperationAllList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/operation/operation": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationAllList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationDetails": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "number": { |
| | | "type": "string" |
| | | }, |
| | | "operationTypeId": { |
| | | "type": "integer" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryOperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.OperationAllList: |
| | | properties: |
| | | number: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | sourceNumber: |
| | | type: string |
| | | type: object |
| | | request.OperationDetails: |
| | | properties: |
| | | OperationId: |
| | |
| | | description: 产品名称 |
| | | type: string |
| | | unit: |
| | | type: string |
| | | type: object |
| | | request.OperationList: |
| | | properties: |
| | | number: |
| | | type: string |
| | | operationTypeId: |
| | | type: integer |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | sourceNumber: |
| | | type: string |
| | | type: object |
| | | request.QueryOperationList: |
| | |
| | | summary: 更改记录状态 |
| | | tags: |
| | | - 入库/出库 |
| | | /api-wms/v1/operation/operation: |
| | | get: |
| | | consumes: |
| | | - application/json |
| | | /api-wms/v1/operation/list: |
| | | post: |
| | | parameters: |
| | | - in: query |
| | | name: operationTypeId |
| | | type: integer |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.OperationList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | summary: 入库/出库列表 |
| | | tags: |
| | | - 入库/出库 |
| | | /api-wms/v1/operation/listAll: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.OperationAllList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 调拨 |
| | | tags: |
| | | - 入库/出库 |
| | | /api-wms/v1/operation/operation: |
| | | post: |
| | | parameters: |
| | | - description: 入库/出库信息 |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetNumber(number string) *OperationSearch { |
| | | slf.Number = number |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) SetSourceNumber(sourceNumber string) *OperationSearch { |
| | | slf.SourceNumber = sourceNumber |
| | | return slf |
| | | } |
| | | |
| | | func (slf *OperationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Operation{}) |
| | | |
| | |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | //if slf.Keyword != "" { |
| | | // db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | //} |
| | | if slf.Keyword != "" { |
| | | db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | } |
| | | |
| | | if slf.SourceNumber != "" { |
| | | db = db.Where("source_number like ?", fmt.Sprintf("%%%v%%", slf.SourceNumber)) |
| | | } |
| | | |
| | | if slf.Number != "" { |
| | | db = db.Where("number like ?", fmt.Sprintf("%%%v%%", slf.Number)) |
| | | } |
| | | |
| | | if slf.OperationTypeId != 0 { |
| | | db.Where("operation_type_id = ?", slf.OperationTypeId) |
| | |
| | | |
| | | type OperationList struct { |
| | | PageInfo |
| | | OperationTypeId int `json:"operationTypeId" form:"operationTypeId"` |
| | | OperationTypeId int `json:"operationTypeId" form:"operationTypeId"` |
| | | Number string `json:"number"` |
| | | SourceNumber string `json:"sourceNumber"` |
| | | } |
| | | |
| | | type UpdateOperation struct { |
| | |
| | | //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)-非必填 |
| | | } |
| | | |
| | | type OperationAllList struct { |
| | | PageInfo |
| | | Number string `json:"number"` |
| | | SourceNumber string `json:"sourceNumber"` |
| | | } |
| | |
| | | operationController := new(controllers.OperationController) |
| | | operationAPI := r.Group(urlPrefix + "/operation") |
| | | { |
| | | operationAPI.GET("operation", operationController.List) |
| | | operationAPI.POST("list", operationController.List) |
| | | operationAPI.POST("operation", operationController.Add) |
| | | operationAPI.POST("update", operationController.Update) |
| | | operationAPI.DELETE("operation/:id", operationController.Delete) |
| | | operationAPI.PUT("finish/:id", operationController.Finish) |
| | | operationAPI.POST("listAll", operationController.ListAll) |
| | | |
| | | } |
| | | |
| | | //产品 |