| | |
| | | } |
| | | 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 |
New file |
| | |
| | | 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(¶ms); 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(¶ms); 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(¶ms); 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)) |
| | | } |
| | |
| | | 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 |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | "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" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3 |
| | | 3, |
| | | 4, |
| | | 5 |
| | | ], |
| | | "x-enum-comments": { |
| | | "BaseOperationTypeAdjust": "库存盘点", |
| | | "BaseOperationTypeDisuse": "报废", |
| | | "BaseOperationTypeIncoming": "收货", |
| | | "BaseOperationTypeInternal": "内部调拨", |
| | | "BaseOperationTypeOutgoing": "交货" |
| | |
| | | "x-enum-varnames": [ |
| | | "BaseOperationTypeIncoming", |
| | | "BaseOperationTypeOutgoing", |
| | | "BaseOperationTypeInternal" |
| | | "BaseOperationTypeInternal", |
| | | "BaseOperationTypeDisuse", |
| | | "BaseOperationTypeAdjust" |
| | | ] |
| | | }, |
| | | "constvar.CostingMethod": { |
| | |
| | | }, |
| | | "parentId": { |
| | | "description": "上级id", |
| | | "type": "string" |
| | | "type": "integer" |
| | | }, |
| | | "recentlyCount": { |
| | | "description": "最近盘点", |
| | |
| | | "models.Operation": { |
| | | "type": "object", |
| | | "properties": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "comment": { |
| | | "type": "string" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.PageInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "ProductName string ` + "`" + `json:\"productName\"` + "`" + `", |
| | | "type": "number" |
| | | }, |
| | | "baseOperationType": { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | }, |
| | | "fromLocationId": { |
| | | "type": "integer" |
| | |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "description": "Unit string ` + "`" + `json:\"unit\"` + "`" + `", |
| | | "type": "string" |
| | | }, |
| | | "operationDate": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | "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" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3 |
| | | 3, |
| | | 4, |
| | | 5 |
| | | ], |
| | | "x-enum-comments": { |
| | | "BaseOperationTypeAdjust": "库存盘点", |
| | | "BaseOperationTypeDisuse": "报废", |
| | | "BaseOperationTypeIncoming": "收货", |
| | | "BaseOperationTypeInternal": "内部调拨", |
| | | "BaseOperationTypeOutgoing": "交货" |
| | |
| | | "x-enum-varnames": [ |
| | | "BaseOperationTypeIncoming", |
| | | "BaseOperationTypeOutgoing", |
| | | "BaseOperationTypeInternal" |
| | | "BaseOperationTypeInternal", |
| | | "BaseOperationTypeDisuse", |
| | | "BaseOperationTypeAdjust" |
| | | ] |
| | | }, |
| | | "constvar.CostingMethod": { |
| | |
| | | }, |
| | | "parentId": { |
| | | "description": "上级id", |
| | | "type": "string" |
| | | "type": "integer" |
| | | }, |
| | | "recentlyCount": { |
| | | "description": "最近盘点", |
| | |
| | | "models.Operation": { |
| | | "type": "object", |
| | | "properties": { |
| | | "baseOperationType": { |
| | | "description": "基础作业类型", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | } |
| | | ] |
| | | }, |
| | | "comment": { |
| | | "type": "string" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.PageInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "ProductName string `json:\"productName\"`", |
| | | "type": "number" |
| | | }, |
| | | "baseOperationType": { |
| | | "$ref": "#/definitions/constvar.BaseOperationType" |
| | | }, |
| | | "fromLocationId": { |
| | | "type": "integer" |
| | |
| | | "type": "integer" |
| | | }, |
| | | "number": { |
| | | "description": "Unit string `json:\"unit\"`", |
| | | "type": "string" |
| | | }, |
| | | "operationDate": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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" |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": { |
| | |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | type: integer |
| | | x-enum-comments: |
| | | BaseOperationTypeAdjust: 库存盘点 |
| | | BaseOperationTypeDisuse: 报废 |
| | | BaseOperationTypeIncoming: 收货 |
| | | BaseOperationTypeInternal: 内部调拨 |
| | | BaseOperationTypeOutgoing: 交货 |
| | |
| | | - BaseOperationTypeIncoming |
| | | - BaseOperationTypeOutgoing |
| | | - BaseOperationTypeInternal |
| | | - BaseOperationTypeDisuse |
| | | - BaseOperationTypeAdjust |
| | | constvar.CostingMethod: |
| | | enum: |
| | | - 1 |
| | |
| | | type: string |
| | | parentId: |
| | | description: 上级id |
| | | type: string |
| | | type: integer |
| | | recentlyCount: |
| | | description: 最近盘点 |
| | | type: string |
| | |
| | | type: object |
| | | models.Operation: |
| | | properties: |
| | | baseOperationType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.BaseOperationType' |
| | | description: 基础作业类型 |
| | | comment: |
| | | type: string |
| | | companyID: |
| | |
| | | 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: |
| | |
| | | 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: |
| | |
| | | sourceNumber: |
| | | type: string |
| | | type: object |
| | | request.PageInfo: |
| | | properties: |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.QueryDisuseList: |
| | | properties: |
| | | number: |
| | |
| | | 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 |
| | |
| | | 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 |
| | |
| | | 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: |
| | |
| | | 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: |
| | |
| | | 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: |
| | |
| | | |
| | | 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 |
| | | } |
| | | ) |
| | | |
| | |
| | | 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 |
| | | } |
| | | |
| | |
| | | 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 |
| | |
| | | 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) |
| | | } |
| | | |
| | |
| | | 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) |
| | | } |
| | | |
| | |
| | | //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 { |
| | |
| | | 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 |
| | |
| | | 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 |
| | | } |
| | |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Disuse bool |
| | | Ids []int |
| | | } |
| | | ) |
| | | |
| | |
| | | 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{}) |
| | | |
| | |
| | | |
| | | 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 |
| | |
| | | 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) |
| | | } |
| | | |
| | |
| | | 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) |
| | | } |
| | | |
| | |
| | | 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{}) |
| | | |
| | |
| | | if slf.OperationID != 0 { |
| | | db = db.Where("operation_id = ?", slf.OperationID) |
| | | } |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id = ?", slf.ProductId) |
| | | } |
| | | |
| | | return db |
| | | } |
New file |
| | |
| | | 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"` |
| | | } |
New file |
| | |
| | | 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"` //总价值 |
| | | } |
| | |
| | | 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 |
| | | } |