jiangshuai
2023-09-22 34e1e9dbc7a750048c0825b8f91b07ed526ae577
1.根据产品获取出入库历史记录
6个文件已修改
525 ■■■■■ 已修改文件
controllers/product_controller.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 186 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 184 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/product_request.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/product_controller.go
@@ -274,3 +274,33 @@
    }
    util.ResponseFormat(c, code.Success, "删除成功")
}
// ListOperation
// @Tags      产品
// @Summary   产品历史出入库信息
// @Produce   application/json
// @Param         object  body  request.QueryOperationList true  "查询参数"
// @Success   200 {object} util.ResponseList{data=[]models.Operation}    "成功"
// @Router    /api-wms/v1/product/listOperaton [post]
func (slf ProductController) ListOperation(c *gin.Context) {
    var params request.QueryOperationList
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error())
        return
    }
    if !params.PageInfo.Check() {
        util.ResponseFormat(c, code.RequestParamError, "页码信息错误")
        return
    }
    search := models.NewOperationSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetOrder("created_at desc")
    search.SetOrm(search.Orm.InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation_details.product_id=?", params.ProductId))
    list, total, err := search.Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestError, "查找失败:"+err.Error())
        return
    }
    util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize)
}
docs/docs.go
@@ -1052,6 +1052,51 @@
                }
            }
        },
        "/api-wms/v1/product/listOperaton": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "产品历史出入库信息",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.QueryOperationList"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/models.Operation"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/product/updateProduct": {
            "post": {
                "produces": [
@@ -1609,6 +1654,10 @@
                    "description": "是否报废位置",
                    "type": "boolean"
                },
                "jointName": {
                    "description": "拼接名称",
                    "type": "string"
                },
                "name": {
                    "description": "位置名称",
                    "type": "string"
@@ -1835,6 +1884,125 @@
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
        "models.Operation": {
            "type": "object",
            "properties": {
                "comment": {
                    "type": "string"
                },
                "companyID": {
                    "type": "integer"
                },
                "companyName": {
                    "type": "string"
                },
                "contacterID": {
                    "type": "integer"
                },
                "contacterName": {
                    "type": "string"
                },
                "createTime": {
                    "type": "string"
                },
                "details": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/models.OperationDetails"
                    }
                },
                "fromLocation": {
                    "description": "源位置",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Location"
                        }
                    ]
                },
                "fromLocationId": {
                    "description": "源位置id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "operationDate": {
                    "type": "string"
                },
                "operationTypeId": {
                    "description": "作业类型id",
                    "type": "integer"
                },
                "operationTypeName": {
                    "description": "作业类型名称",
                    "type": "string"
                },
                "sourceNumber": {
                    "description": "源单号",
                    "type": "string"
                },
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.OperationStatus"
                        }
                    ]
                },
                "toLocation": {
                    "description": "目标位置",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Location"
                        }
                    ]
                },
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                },
                "updateTime": {
                    "type": "string"
                }
            }
        },
        "models.OperationDetails": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "type": "number"
                },
                "createTime": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "operationId": {
                    "description": "操作id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                },
                "updateTime": {
                    "type": "string"
                }
            }
        },
@@ -2352,6 +2520,22 @@
                }
            }
        },
        "request.QueryOperationList": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "productId": {
                    "type": "string"
                }
            }
        },
        "request.UpdateCompany": {
            "type": "object",
            "properties": {
@@ -2576,8 +2760,6 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -1040,6 +1040,51 @@
                }
            }
        },
        "/api-wms/v1/product/listOperaton": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                ],
                "summary": "产品历史出入库信息",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.QueryOperationList"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/models.Operation"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/product/updateProduct": {
            "post": {
                "produces": [
@@ -1597,6 +1642,10 @@
                    "description": "是否报废位置",
                    "type": "boolean"
                },
                "jointName": {
                    "description": "拼接名称",
                    "type": "string"
                },
                "name": {
                    "description": "位置名称",
                    "type": "string"
@@ -1823,6 +1872,125 @@
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
        "models.Operation": {
            "type": "object",
            "properties": {
                "comment": {
                    "type": "string"
                },
                "companyID": {
                    "type": "integer"
                },
                "companyName": {
                    "type": "string"
                },
                "contacterID": {
                    "type": "integer"
                },
                "contacterName": {
                    "type": "string"
                },
                "createTime": {
                    "type": "string"
                },
                "details": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/models.OperationDetails"
                    }
                },
                "fromLocation": {
                    "description": "源位置",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Location"
                        }
                    ]
                },
                "fromLocationId": {
                    "description": "源位置id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "operationDate": {
                    "type": "string"
                },
                "operationTypeId": {
                    "description": "作业类型id",
                    "type": "integer"
                },
                "operationTypeName": {
                    "description": "作业类型名称",
                    "type": "string"
                },
                "sourceNumber": {
                    "description": "源单号",
                    "type": "string"
                },
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.OperationStatus"
                        }
                    ]
                },
                "toLocation": {
                    "description": "目标位置",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.Location"
                        }
                    ]
                },
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                },
                "updateTime": {
                    "type": "string"
                }
            }
        },
        "models.OperationDetails": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "type": "number"
                },
                "createTime": {
                    "type": "string"
                },
                "id": {
                    "type": "integer"
                },
                "operationId": {
                    "description": "操作id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "type": "string"
                },
                "updateTime": {
                    "type": "string"
                }
            }
        },
@@ -2340,6 +2508,22 @@
                }
            }
        },
        "request.QueryOperationList": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "productId": {
                    "type": "string"
                }
            }
        },
        "request.UpdateCompany": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -241,6 +241,9 @@
      isScrapLocation:
        description: 是否报废位置
        type: boolean
      jointName:
        description: 拼接名称
        type: string
      name:
        description: 位置名称
        type: string
@@ -414,6 +417,84 @@
      weight:
        description: 重量
        type: number
    type: object
  models.Operation:
    properties:
      comment:
        type: string
      companyID:
        type: integer
      companyName:
        type: string
      contacterID:
        type: integer
      contacterName:
        type: string
      createTime:
        type: string
      details:
        items:
          $ref: '#/definitions/models.OperationDetails'
        type: array
      fromLocation:
        allOf:
        - $ref: '#/definitions/models.Location'
        description: 源位置
      fromLocationId:
        description: 源位置id
        type: integer
      id:
        type: integer
      number:
        description: 单号
        type: string
      operationDate:
        type: string
      operationTypeId:
        description: 作业类型id
        type: integer
      operationTypeName:
        description: 作业类型名称
        type: string
      sourceNumber:
        description: 源单号
        type: string
      status:
        allOf:
        - $ref: '#/definitions/constvar.OperationStatus'
        description: 状态
      toLocation:
        allOf:
        - $ref: '#/definitions/models.Location'
        description: 目标位置
      toLocationId:
        description: 目标位置id
        type: integer
      updateTime:
        type: string
    type: object
  models.OperationDetails:
    properties:
      amount:
        description: 数量
        type: number
      createTime:
        type: string
      id:
        type: integer
      operationId:
        description: 操作id
        type: integer
      productId:
        description: 产品id
        type: string
      productName:
        description: 产品名称
        type: string
      unit:
        type: string
      updateTime:
        type: string
    type: object
  models.OperationType:
    properties:
@@ -759,6 +840,17 @@
        description: 产品名称
        type: string
      unit:
        type: string
    type: object
  request.QueryOperationList:
    properties:
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
      productId:
        type: string
    type: object
  request.UpdateCompany:
@@ -1546,6 +1638,32 @@
      summary: 获取产品列表
      tags:
      - 产品
  /api-wms/v1/product/listOperaton:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.QueryOperationList'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/util.ResponseList'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/models.Operation'
                  type: array
              type: object
      summary: 产品历史出入库信息
      tags:
      - 产品
  /api-wms/v1/product/updateProduct:
    post:
      parameters:
request/product_request.go
@@ -4,3 +4,8 @@
    PageInfo
    KeyWord string `json:"keyWord"`
}
type QueryOperationList struct {
    PageInfo
    ProductId string `json:"productId"`
}
router/router.go
@@ -99,6 +99,8 @@
        productAPI.GET("getProductCategoryDetails/:id", productController.GetProductCategoryDetails) //获取产品类型详情
        productAPI.POST("updateProductCategory", productController.UpdateProductCategory)            //修改产品类型
        productAPI.DELETE("deleteProductCategory/:id", productController.DeleteProductCategory)      //删除产品类型
        productAPI.POST("listOperaton", productController.ListOperation) //查看产品的历史出入库信息
    }
    return r