liujiandao
2023-09-27 b3a318b7f707ca49fa9127881bbe709654eaa761
报表功能开发
3个文件已添加
11个文件已修改
1507 ■■■■■ 已修改文件
controllers/location.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/report_forms_controller.go 199 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/warehouse.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 434 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 434 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 284 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location.go 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location_product.go 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/material.go 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation_details.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/report_forms_request.go 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
response/report_forms_response.go 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location.go
@@ -33,7 +33,7 @@
    }
    if params.ParentId != 0 {
        //查询上级名称
        first, err := models.NewLocationSearch().SetParentId(params.ParentId).First()
        first, err := models.NewLocationSearch().SetID(params.ParentId).First()
        if err != nil {
            util.ResponseFormat(c, code.RequestParamError, "查询上级名称失败")
            return
controllers/report_forms_controller.go
New file
@@ -0,0 +1,199 @@
package controllers
import (
    "github.com/gin-gonic/gin"
    "wms/constvar"
    "wms/extend/code"
    "wms/extend/util"
    "wms/models"
    "wms/request"
    "wms/response"
)
type ReportFormsController struct {
}
// GetInventoryForms
// @Tags      报表
// @Summary   获取库存报表
// @Produce   application/json
// @Param     object  body  request.GetInventoryForms true  "查询参数"
// @Success   200 {object} util.ResponseList{data=[]response.InventoryForms}    "成功"
// @Router    /api-wms/v1/forms/getInventoryForms [post]
func (slf ReportFormsController) GetInventoryForms(c *gin.Context) {
    var params request.GetInventoryForms
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    //查询产品
    search := models.NewMaterialSearch()
    if params.PageInfo.Check() {
        search.SetPage(params.Page, params.PageSize)
    }
    materials, total, err := search.SetCategoryIds(params.CategoryIds).Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询产品类型失败")
        return
    }
    //查询产品类型
    categories, err := models.NewProductCategorySearch().SetIds(params.CategoryIds).FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询产品类型失败")
        return
    }
    //查询出入库数量
    locations, err := models.NewLocationSearch().SetJointName(params.WarehouseCode).FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询仓库位置失败")
        return
    }
    locationIds := make([]int, 0)
    for _, location := range locations {
        locationIds = append(locationIds, location.Id)
    }
    var inHouse []models.OperationDetails
    var outHouse []models.OperationDetails
    dbIn := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}).
        Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id").
        Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeIncoming).
        Where("wms_operation.status=?", constvar.OperationStatus_Ready)
    dbOut := models.NewOperationDetailsSearch().Orm.Model(&models.OperationDetails{}).
        Joins("left join wms_operation ON wms_operation_details.operation_id=wms_operation.id").
        Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeOutgoing).
        Where("wms_operation.status=?", constvar.OperationStatus_Ready)
    if len(locationIds) > 0 {
        dbIn.Where("wms_operation.from_location_id in (?)", locationIds)
        dbOut.Where("wms_operation.from_location_id in (?)", locationIds)
    }
    err = dbIn.Find(&inHouse).Error
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询入库数量失败")
        return
    }
    err = dbOut.Find(&outHouse).Error
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询出库数量失败")
        return
    }
    var result []response.InventoryForms
    for _, material := range materials {
        var resp response.InventoryForms
        resp.ProduceId = material.ID
        resp.ProductName = material.Name
        resp.Cost = material.Cost
        resp.Amount = material.Amount
        resp.Unit = material.Unit
        resp.Value = material.Amount.Mul(material.Cost)
        for _, category := range categories {
            if material.CategoryId == int(category.ID) {
                resp.ProductType = category.Name
                break
            }
        }
        for _, details := range inHouse {
            if material.ID == details.ProductId {
                resp.In = resp.In.Add(details.Amount)
            }
        }
        for _, details := range outHouse {
            if material.ID == details.ProductId {
                resp.Out = resp.Out.Add(details.Amount)
            }
        }
        resp.AvailableNumber = resp.Amount
        result = append(result, resp)
    }
    util.ResponseFormatList(c, code.Success, result, int(total))
}
// GetHistory
// @Tags      报表
// @Summary   获取历史信息
// @Produce   application/json
// @Param     object  body  request.GetInventoryHistory true  "查询参数"
// @Success   200 {object} util.ResponseList{data=[]response.InventoryHistory}    "成功"
// @Router    /api-wms/v1/forms/getHistory [post]
func (slf ReportFormsController) GetHistory(c *gin.Context) {
    var params request.GetInventoryHistory
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    //获取操作详情
    detailsSearch := models.NewOperationDetailsSearch()
    if params.PageInfo.Check() {
        detailsSearch.SetPage(params.Page, params.PageSize)
    }
    details, total, err := detailsSearch.SetProductId(params.ProduceId).Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询操作详情失败")
        return
    }
    var operationIds []int
    for _, detail := range details {
        operationIds = append(operationIds, detail.OperationID)
    }
    //获取操作记录
    operations, err := models.NewOperationSearch().SetIds(operationIds).SetStatus(constvar.OperationStatus_Finish).FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询操作记录失败")
        return
    }
    var result []response.InventoryHistory
    for _, detail := range details {
        var resp response.InventoryHistory
        resp.Amount = detail.Amount
        resp.Unit = params.Unit
        for _, operation := range operations {
            if detail.OperationID == operation.Id {
                resp.Number = operation.Number
                resp.Date = operation.UpdateTime
                resp.BaseOperationType = operation.BaseOperationType
                resp.ContactedName = operation.ContacterName
                resp.FromLocation = operation.FromLocation.Name
                resp.ToLocation = operation.ToLocation.Name
                result = append(result, resp)
                break
            }
        }
    }
    util.ResponseFormatList(c, code.Success, result, int(total))
}
// GetLocationForms
// @Tags      报表
// @Summary   获取位置报表
// @Produce   application/json
// @Param     object  body  request.PageInfo true  "查询参数"
// @Success   200 {object} util.ResponseList{data=[]response.LocationForms}    "成功"
// @Router    /api-wms/v1/forms/getLocationForms [post]
func (slf ReportFormsController) GetLocationForms(c *gin.Context) {
    var params request.GetLocationForms
    if err := c.BindJSON(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    search := models.NewLocationProductSearch()
    if params.PageInfo.Check() {
        search.SetPage(params.Page, params.PageSize)
    }
    find, total, err := search.SetKeyword(params.KeyWord).FindByPage()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查询上架规则失败")
        return
    }
    var result []response.LocationForms
    for _, product := range find {
        var resp response.LocationForms
        resp.LocationName = product.Location.Name
        resp.ProduceId = product.Product.ID
        resp.ProductName = product.Product.Name
        resp.ProductTypeName = product.ProductCategory.Name
        resp.Amount = product.Product.Amount
        resp.Unit = product.Product.Unit
        resp.Value = product.Product.Amount.Mul(product.Product.Cost)
        result = append(result, resp)
    }
    util.ResponseFormatList(c, code.Success, result, int(total))
}
controllers/warehouse.go
@@ -143,7 +143,7 @@
    for _, warehouse := range list {
        codes = append(codes, warehouse.Code)
    }
    locations, err := models.NewLocationSearch().SetCodes(codes).FindNotTotal()
    locations, err := models.NewLocationSearch().SetJointNames(codes).FindNotTotal()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "位置信息查找失败")
        return
docs/docs.go
@@ -294,6 +294,96 @@
                }
            }
        },
        "/api-wms/v1/forms/getInventoryForms": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "报表"
                ],
                "summary": "获取库存报表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetInventoryForms"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/response.InventoryForms"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/forms/getInventoryHistory": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "报表"
                ],
                "summary": "获取库存历史",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetInventoryHistory"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/response.InventoryHistory"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/location/addLocation": {
            "post": {
                "produces": [
@@ -454,6 +544,124 @@
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Location"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "添加上架规则",
                "parameters": [
                    {
                        "description": "新增上架规则",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddLocationProduct"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "删除上架规则",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/list": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "库存盘点列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/update": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "修改上架规则",
                "parameters": [
                    {
                        "description": "入库信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateLocationProduct"
                        }
                    }
                ],
@@ -1467,9 +1675,13 @@
            "enum": [
                1,
                2,
                3
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BaseOperationTypeAdjust": "库存盘点",
                "BaseOperationTypeDisuse": "报废",
                "BaseOperationTypeIncoming": "收货",
                "BaseOperationTypeInternal": "内部调拨",
                "BaseOperationTypeOutgoing": "交货"
@@ -1477,7 +1689,9 @@
            "x-enum-varnames": [
                "BaseOperationTypeIncoming",
                "BaseOperationTypeOutgoing",
                "BaseOperationTypeInternal"
                "BaseOperationTypeInternal",
                "BaseOperationTypeDisuse",
                "BaseOperationTypeAdjust"
            ]
        },
        "constvar.CostingMethod": {
@@ -1798,7 +2012,7 @@
                },
                "parentId": {
                    "description": "上级id",
                    "type": "string"
                    "type": "integer"
                },
                "recentlyCount": {
                    "description": "最近盘点",
@@ -2016,6 +2230,14 @@
        "models.Operation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "type": "string"
                },
@@ -2311,6 +2533,27 @@
                }
            }
        },
        "request.AddLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.AddOperation": {
            "type": "object",
            "properties": {
@@ -2506,6 +2749,55 @@
                }
            }
        },
        "request.GetInventoryForms": {
            "type": "object",
            "properties": {
                "categoryIds": {
                    "description": "产品类型id",
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "warehouseCode": {
                    "description": "仓库缩写",
                    "type": "string"
                }
            }
        },
        "request.GetInventoryHistory": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "produceId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "description": "单位",
                    "type": "string"
                }
            }
        },
        "request.GetProductList": {
            "type": "object",
            "properties": {
@@ -2580,6 +2872,19 @@
                },
                "sourceNumber": {
                    "type": "string"
                }
            }
        },
        "request.PageInfo": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
@@ -2658,8 +2963,10 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string                   ` + "`" + `json:\"productName\"` + "`" + `",
                    "type": "number"
                },
                "baseOperationType": {
                    "$ref": "#/definitions/constvar.BaseOperationType"
                },
                "fromLocationId": {
                    "type": "integer"
@@ -2668,7 +2975,6 @@
                    "type": "integer"
                },
                "number": {
                    "description": "Unit           string                   ` + "`" + `json:\"unit\"` + "`" + `",
                    "type": "string"
                },
                "operationDate": {
@@ -2688,9 +2994,41 @@
                }
            }
        },
        "request.UpdateLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.UpdateOperation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "description": "备注",
                    "type": "string"
@@ -2830,6 +3168,92 @@
                }
            }
        },
        "response.InventoryForms": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "在库数量",
                    "type": "number"
                },
                "availableNumber": {
                    "description": "可用库存",
                    "type": "number"
                },
                "cost": {
                    "description": "成本",
                    "type": "number"
                },
                "in": {
                    "description": "入库",
                    "type": "number"
                },
                "out": {
                    "description": "出库",
                    "type": "number"
                },
                "produceId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "productType": {
                    "description": "产品类型",
                    "type": "string"
                },
                "unit": {
                    "description": "单位",
                    "type": "string"
                },
                "value": {
                    "description": "总价值",
                    "type": "number"
                }
            }
        },
        "response.InventoryHistory": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "type": "number"
                },
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "contactedName": {
                    "description": "完成者",
                    "type": "string"
                },
                "date": {
                    "description": "日期",
                    "type": "string"
                },
                "fromLocation": {
                    "description": "源位置",
                    "type": "string"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "toLocation": {
                    "description": "目标位置",
                    "type": "string"
                },
                "unit": {
                    "description": "单位",
                    "type": "string"
                }
            }
        },
        "util.Response": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -282,6 +282,96 @@
                }
            }
        },
        "/api-wms/v1/forms/getInventoryForms": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "报表"
                ],
                "summary": "获取库存报表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetInventoryForms"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/response.InventoryForms"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/forms/getInventoryHistory": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "报表"
                ],
                "summary": "获取库存历史",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetInventoryHistory"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/response.InventoryHistory"
                                            }
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        },
        "/api-wms/v1/location/addLocation": {
            "post": {
                "produces": [
@@ -442,6 +532,124 @@
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Location"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "添加上架规则",
                "parameters": [
                    {
                        "description": "新增上架规则",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddLocationProduct"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "删除上架规则",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/list": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "库存盘点列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/update": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "修改上架规则",
                "parameters": [
                    {
                        "description": "入库信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateLocationProduct"
                        }
                    }
                ],
@@ -1455,9 +1663,13 @@
            "enum": [
                1,
                2,
                3
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BaseOperationTypeAdjust": "库存盘点",
                "BaseOperationTypeDisuse": "报废",
                "BaseOperationTypeIncoming": "收货",
                "BaseOperationTypeInternal": "内部调拨",
                "BaseOperationTypeOutgoing": "交货"
@@ -1465,7 +1677,9 @@
            "x-enum-varnames": [
                "BaseOperationTypeIncoming",
                "BaseOperationTypeOutgoing",
                "BaseOperationTypeInternal"
                "BaseOperationTypeInternal",
                "BaseOperationTypeDisuse",
                "BaseOperationTypeAdjust"
            ]
        },
        "constvar.CostingMethod": {
@@ -1786,7 +2000,7 @@
                },
                "parentId": {
                    "description": "上级id",
                    "type": "string"
                    "type": "integer"
                },
                "recentlyCount": {
                    "description": "最近盘点",
@@ -2004,6 +2218,14 @@
        "models.Operation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "type": "string"
                },
@@ -2299,6 +2521,27 @@
                }
            }
        },
        "request.AddLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.AddOperation": {
            "type": "object",
            "properties": {
@@ -2494,6 +2737,55 @@
                }
            }
        },
        "request.GetInventoryForms": {
            "type": "object",
            "properties": {
                "categoryIds": {
                    "description": "产品类型id",
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "warehouseCode": {
                    "description": "仓库缩写",
                    "type": "string"
                }
            }
        },
        "request.GetInventoryHistory": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "produceId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "unit": {
                    "description": "单位",
                    "type": "string"
                }
            }
        },
        "request.GetProductList": {
            "type": "object",
            "properties": {
@@ -2568,6 +2860,19 @@
                },
                "sourceNumber": {
                    "type": "string"
                }
            }
        },
        "request.PageInfo": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
@@ -2646,8 +2951,10 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string                   `json:\"productName\"`",
                    "type": "number"
                },
                "baseOperationType": {
                    "$ref": "#/definitions/constvar.BaseOperationType"
                },
                "fromLocationId": {
                    "type": "integer"
@@ -2656,7 +2963,6 @@
                    "type": "integer"
                },
                "number": {
                    "description": "Unit           string                   `json:\"unit\"`",
                    "type": "string"
                },
                "operationDate": {
@@ -2676,9 +2982,41 @@
                }
            }
        },
        "request.UpdateLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.UpdateOperation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "description": "备注",
                    "type": "string"
@@ -2818,6 +3156,92 @@
                }
            }
        },
        "response.InventoryForms": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "在库数量",
                    "type": "number"
                },
                "availableNumber": {
                    "description": "可用库存",
                    "type": "number"
                },
                "cost": {
                    "description": "成本",
                    "type": "number"
                },
                "in": {
                    "description": "入库",
                    "type": "number"
                },
                "out": {
                    "description": "出库",
                    "type": "number"
                },
                "produceId": {
                    "description": "产品id",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "productType": {
                    "description": "产品类型",
                    "type": "string"
                },
                "unit": {
                    "description": "单位",
                    "type": "string"
                },
                "value": {
                    "description": "总价值",
                    "type": "number"
                }
            }
        },
        "response.InventoryHistory": {
            "type": "object",
            "properties": {
                "amount": {
                    "description": "数量",
                    "type": "number"
                },
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "contactedName": {
                    "description": "完成者",
                    "type": "string"
                },
                "date": {
                    "description": "日期",
                    "type": "string"
                },
                "fromLocation": {
                    "description": "源位置",
                    "type": "string"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "toLocation": {
                    "description": "目标位置",
                    "type": "string"
                },
                "unit": {
                    "description": "单位",
                    "type": "string"
                }
            }
        },
        "util.Response": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -4,8 +4,12 @@
    - 1
    - 2
    - 3
    - 4
    - 5
    type: integer
    x-enum-comments:
      BaseOperationTypeAdjust: 库存盘点
      BaseOperationTypeDisuse: 报废
      BaseOperationTypeIncoming: 收货
      BaseOperationTypeInternal: 内部调拨
      BaseOperationTypeOutgoing: 交货
@@ -13,6 +17,8 @@
    - BaseOperationTypeIncoming
    - BaseOperationTypeOutgoing
    - BaseOperationTypeInternal
    - BaseOperationTypeDisuse
    - BaseOperationTypeAdjust
  constvar.CostingMethod:
    enum:
    - 1
@@ -257,7 +263,7 @@
        type: string
      parentId:
        description: 上级id
        type: string
        type: integer
      recentlyCount:
        description: 最近盘点
        type: string
@@ -422,6 +428,10 @@
    type: object
  models.Operation:
    properties:
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型
      comment:
        type: string
      companyID:
@@ -619,6 +629,21 @@
      toLocationId:
        type: integer
    type: object
  request.AddLocationProduct:
    properties:
      areaId:
        description: 区域id
        type: integer
      locationId:
        description: 位置id
        type: integer
      productCategoryId:
        description: 产品种类id
        type: integer
      productId:
        description: 产品id
        type: string
    type: object
  request.AddOperation:
    properties:
      comment:
@@ -754,6 +779,41 @@
    required:
    - code
    type: object
  request.GetInventoryForms:
    properties:
      categoryIds:
        description: 产品类型id
        items:
          type: integer
        type: array
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
      warehouseCode:
        description: 仓库缩写
        type: string
    type: object
  request.GetInventoryHistory:
    properties:
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
      produceId:
        description: 产品id
        type: string
      productName:
        description: 产品名称
        type: string
      unit:
        description: 单位
        type: string
    type: object
  request.GetProductList:
    properties:
      categoryId:
@@ -808,6 +868,15 @@
      sourceNumber:
        type: string
    type: object
  request.PageInfo:
    properties:
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
    type: object
  request.QueryDisuseList:
    properties:
      number:
@@ -860,14 +929,14 @@
  request.UpdateDisuse:
    properties:
      amount:
        description: ProductName    string                   `json:"productName"`
        type: number
      baseOperationType:
        $ref: '#/definitions/constvar.BaseOperationType'
      fromLocationId:
        type: integer
      id:
        type: integer
      number:
        description: Unit           string                   `json:"unit"`
        type: string
      operationDate:
        type: string
@@ -880,8 +949,29 @@
      toLocationId:
        type: integer
    type: object
  request.UpdateLocationProduct:
    properties:
      areaId:
        description: 区域id
        type: integer
      id:
        type: integer
      locationId:
        description: 位置id
        type: integer
      productCategoryId:
        description: 产品种类id
        type: integer
      productId:
        description: 产品id
        type: string
    type: object
  request.UpdateOperation:
    properties:
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型
      comment:
        description: 备注
        type: string
@@ -975,6 +1065,67 @@
      warehouseId:
        description: 仓库id
        type: integer
    type: object
  response.InventoryForms:
    properties:
      amount:
        description: 在库数量
        type: number
      availableNumber:
        description: 可用库存
        type: number
      cost:
        description: 成本
        type: number
      in:
        description: 入库
        type: number
      out:
        description: 出库
        type: number
      produceId:
        description: 产品id
        type: string
      productName:
        description: 产品名称
        type: string
      productType:
        description: 产品类型
        type: string
      unit:
        description: 单位
        type: string
      value:
        description: 总价值
        type: number
    type: object
  response.InventoryHistory:
    properties:
      amount:
        description: 数量
        type: number
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型
      contactedName:
        description: 完成者
        type: string
      date:
        description: 日期
        type: string
      fromLocation:
        description: 源位置
        type: string
      number:
        description: 单号
        type: string
      toLocation:
        description: 目标位置
        type: string
      unit:
        description: 单位
        type: string
    type: object
  util.Response:
    properties:
@@ -1174,6 +1325,58 @@
      summary: 编辑公司
      tags:
      - 公司
  /api-wms/v1/forms/getInventoryForms:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.GetInventoryForms'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/util.ResponseList'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/response.InventoryForms'
                  type: array
              type: object
      summary: 获取库存报表
      tags:
      - 报表
  /api-wms/v1/forms/getInventoryHistory:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.GetInventoryHistory'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/util.ResponseList'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/response.InventoryHistory'
                  type: array
              type: object
      summary: 获取库存历史
      tags:
      - 报表
  /api-wms/v1/location/addLocation:
    post:
      parameters:
@@ -1279,6 +1482,81 @@
      summary: 修改位置
      tags:
      - 位置
  /api-wms/v1/locationProduct/add:
    post:
      parameters:
      - description: 新增上架规则
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddLocationProduct'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 添加上架规则
      tags:
      - 上架规则
  /api-wms/v1/locationProduct/delete/{id}:
    delete:
      parameters:
      - description: id
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 删除上架规则
      tags:
      - 上架规则
  /api-wms/v1/locationProduct/list:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.PageInfo'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 库存盘点列表
      tags:
      - 库存盘点
  /api-wms/v1/locationProduct/update:
    post:
      parameters:
      - description: 入库信息
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateLocationProduct'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 修改上架规则
      tags:
      - 上架规则
  /api-wms/v1/operation/finish/{id}:
    put:
      parameters:
models/location.go
@@ -30,13 +30,13 @@
    LocationSearch struct {
        Location
        Order    string
        PageNum  int
        PageSize int
        Keyword  string
        Orm      *gorm.DB
        Preload  bool
        Codes    []string
        Order      string
        PageNum    int
        PageSize   int
        Keyword    string
        Orm        *gorm.DB
        Preload    bool
        JointNames []string
    }
)
@@ -67,8 +67,14 @@
    slf.Id = ID
    return slf
}
func (slf *LocationSearch) SetCodes(ids []string) *LocationSearch {
    slf.Codes = ids
func (slf *LocationSearch) SetJointName(code string) *LocationSearch {
    slf.JointName = code
    return slf
}
func (slf *LocationSearch) SetJointNames(codes []string) *LocationSearch {
    slf.JointNames = codes
    return slf
}
@@ -131,8 +137,11 @@
    if slf.CompanyId != 0 {
        db = db.Where("company_id=?", slf.CompanyId)
    }
    if len(slf.Codes) != 0 {
        db = db.Where("warehouse_code in (?)", slf.Codes)
    if slf.JointName != "" {
        db = db.Where("joint_name like ?", slf.JointName+"%")
    }
    if len(slf.JointNames) != 0 {
        db = db.Where("joint_name in (?)", slf.JointNames)
    }
    return db
models/location_product.go
@@ -153,7 +153,7 @@
    if slf.PageNum*slf.PageSize > 0 {
        db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
    }
    if err := db.Find(&records).Error; err != nil {
    if err := db.Preload("Location").Preload("ProductCategory").Preload("Product").Find(&records).Error; err != nil {
        return records, total, fmt.Errorf("find records err: %v", err)
    }
@@ -166,7 +166,7 @@
        db      = slf.build()
    )
    if err := db.Find(&records).Error; err != nil {
    if err := db.Preload("Location").Preload("ProductCategory").Preload("Product").Find(&records).Error; err != nil {
        return records, fmt.Errorf("find records err: %v", err)
    }
models/material.go
@@ -77,11 +77,12 @@
        //MaterialTypes   []constvar.MaterialType
        Keyword string
        //SetTemplateType constvar.SetTemplateType
        Order    string
        PageNum  int
        PageSize int
        Ids      []string
        Orm      *gorm.DB
        Order       string
        PageNum     int
        PageSize    int
        Ids         []string
        Orm         *gorm.DB
        CategoryIds []int
    }
    IdAndName struct {
@@ -157,6 +158,11 @@
    return slf
}
func (slf *MaterialSearch) SetCategoryIds(ids []int) *MaterialSearch {
    slf.CategoryIds = ids
    return slf
}
//
//func (slf *MaterialSearch) SetSetTemplateType(setType constvar.SetTemplateType) *MaterialSearch {
//    slf.SetTemplateType = setType
@@ -230,6 +236,9 @@
    if slf.CategoryId > 0 {
        db = db.Where("category_id = ?", slf.CategoryId)
    }
    if len(slf.CategoryIds) > 0 {
        db = db.Where("category_id in ?", slf.CategoryIds)
    }
    return db
}
models/operation.go
@@ -41,6 +41,7 @@
        Orm      *gorm.DB
        Preload  bool
        Disuse   bool
        Ids      []int
    }
)
@@ -102,6 +103,15 @@
    return slf
}
func (slf *OperationSearch) SetIds(ids []int) *OperationSearch {
    slf.Ids = ids
    return slf
}
func (slf *OperationSearch) SetStatus(status constvar.OperationStatus) *OperationSearch {
    slf.Status = status
    return slf
}
func (slf *OperationSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&Operation{})
@@ -134,6 +144,14 @@
    if slf.Disuse {
        db = db.Where("operation_type_id = ?", 0)
    }
    if len(slf.Ids) > 0 {
        db = db.Where("id in (?)", slf.Ids)
    }
    if slf.Status > 0 {
        db = db.Where("status = ?", slf.Status)
    }
    return db
@@ -236,7 +254,7 @@
    if slf.PageNum*slf.PageSize > 0 {
        db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
    }
    if err := db.Find(&records).Error; err != nil {
    if err := db.Preload("FromLocation").Preload("ToLocation").Find(&records).Error; err != nil {
        return records, total, fmt.Errorf("find records err: %v", err)
    }
@@ -252,7 +270,7 @@
    if slf.PageNum*slf.PageSize > 0 {
        db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
    }
    if err := db.Find(&records).Error; err != nil {
    if err := db.Preload("FromLocation").Preload("ToLocation").Find(&records).Error; err != nil {
        return records, fmt.Errorf("find records err: %v", err)
    }
models/operation_details.go
@@ -74,6 +74,11 @@
    return slf
}
func (slf *OperationDetailsSearch) SetProductId(productId string) *OperationDetailsSearch {
    slf.ProductId = productId
    return slf
}
func (slf *OperationDetailsSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&OperationDetails{})
@@ -92,6 +97,9 @@
    if slf.OperationID != 0 {
        db = db.Where("operation_id = ?", slf.OperationID)
    }
    if slf.ProductId != "" {
        db = db.Where("product_id = ?", slf.ProductId)
    }
    return db
}
request/report_forms_request.go
New file
@@ -0,0 +1,19 @@
package request
type GetInventoryForms struct {
    PageInfo
    CategoryIds   []int  `json:"categoryIds"`   //产品类型id
    WarehouseCode string `json:"warehouseCode"` //仓库缩写
}
type GetInventoryHistory struct {
    PageInfo
    ProduceId   string `json:"produceId"`   //产品id
    ProductName string `json:"productName"` //产品名称
    Unit        string `json:"unit"`        //单位
}
type GetLocationForms struct {
    PageInfo
    KeyWord string `json:"keyWord"`
}
response/report_forms_response.go
New file
@@ -0,0 +1,40 @@
package response
import (
    "github.com/shopspring/decimal"
    "wms/constvar"
)
type InventoryForms struct {
    ProduceId       string          `json:"produceId"`       //产品id
    ProductName     string          `json:"productName"`     //产品名称
    ProductType     string          `json:"productType"`     //产品类型
    Cost            decimal.Decimal `json:"cost"`            //成本
    Value           decimal.Decimal `json:"value"`           //总价值
    Amount          decimal.Decimal `json:"amount"`          //在库数量
    AvailableNumber decimal.Decimal `json:"availableNumber"` //可用库存
    In              decimal.Decimal `json:"in"`              //入库
    Out             decimal.Decimal `json:"out"`             //出库
    Unit            string          `json:"unit"`            //单位
}
type InventoryHistory struct {
    Number            string                     `json:"number"`            //单号
    Date              string                     `json:"date"`              //日期
    FromLocation      string                     `json:"fromLocation"`      //源位置
    ToLocation        string                     `json:"toLocation"`        //目标位置
    Amount            decimal.Decimal            `json:"amount"`            //数量
    Unit              string                     `json:"unit"`              //单位
    ContactedName     string                     `json:"contactedName"`     //完成者
    BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` //基础作业类型
}
type LocationForms struct {
    ProduceId       string          `json:"produceId"`       //产品id
    LocationName    string          `json:"locationName"`    //位置名称
    ProductName     string          `json:"productName"`     //产品名称
    ProductTypeName string          `json:"productTypeName"` //产品类别
    Amount          decimal.Decimal `json:"amount"`          //数量
    Unit            string          `json:"unit"`            //单位
    Value           decimal.Decimal `json:"value"`           //总价值
}
router/router.go
@@ -119,5 +119,14 @@
        locationProductAPI.DELETE("operationType/:id", locationProductController.Delete) // 删除上架规则
    }
    //报表
    reportFormsController := new(controllers.ReportFormsController)
    reportFormsAPI := r.Group(urlPrefix + "/forms")
    {
        reportFormsAPI.POST("getInventoryForms", reportFormsController.GetInventoryForms) //获取库存报表
        reportFormsAPI.POST("getHistory", reportFormsController.GetHistory)               //获取库存历史
        reportFormsAPI.POST("getLocationForms", reportFormsController.GetLocationForms)   //获取位置报表
    }
    return r
}