| | |
| | | util.ResponseFormatListWithPage(c, code.Success, records, int(total), params.Page, params.PageSize) |
| | | } |
| | | |
| | | // LocationProductList |
| | | // @Tags 库存盘点 |
| | | // @Summary 获取位置对应产品列表 |
| | | // @Produce application/json |
| | | // @Param object body request.GetLocationProductList true "查询参数" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/locationProductAmount/locationProductList [post] |
| | | func (slf LocationProductAmountController) LocationProductList(c *gin.Context) { |
| | | var params request.GetLocationProductList |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error()) |
| | | return |
| | | } |
| | | if !params.Check() { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数异常") |
| | | return |
| | | } |
| | | productIds := make([]string, 0) |
| | | locationIds := make([]int, 0) |
| | | if params.Keyword != "" { |
| | | materials, _ := models.NewMaterialSearch().SetKeyword(params.Keyword).FindNotTotal() |
| | | for _, material := range materials { |
| | | productIds = append(productIds, material.ID) |
| | | } |
| | | locations, _ := models.NewLocationSearch().SetKeyword(params.Keyword).FindNotTotal() |
| | | for _, location := range locations { |
| | | locationIds = append(locationIds, location.Id) |
| | | } |
| | | } |
| | | |
| | | search := models.NewLocationProductAmountSearch() |
| | | records, total, err := search. |
| | | SetLocationIds(locationIds).SetWarehouseId(params.WarehouseId).SetProductIds(productIds).SetLocationId(params.LocationId). |
| | | SetPage(params.Page, params.PageSize). |
| | | SetOrder("id desc"). |
| | | SetPreload(true). |
| | | FindByPage() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.InternalError, "查询失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormatList(c, code.Success, records, int(total)) |
| | | } |
| | | |
| | | // Add |
| | | // @Tags 库存盘点 |
| | | // @Summary 添加库存盘点信息 |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/locationProductList": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "获取位置对应产品列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetLocationProductList" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/update": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "$ref": "#/definitions/models.Location" |
| | | }, |
| | | "locationId": { |
| | | "description": "LocationProductId int ` + "`" + `json:\"locationProductId\" gorm:\"type:int;not null;comment:上架规则id\"` + "`" + ` //上架规则id\nLocationProduct LocationProduct ` + "`" + `json:\"locationProduct\" gorm:\"foreignKey:LocationProductId;references:Id\"` + "`" + `", |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "product": { |
| | |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouseId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetLocationProductList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "warehouseId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetMiniDictList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/locationProductList": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "获取位置对应产品列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetLocationProductList" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/update": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "$ref": "#/definitions/models.Location" |
| | | }, |
| | | "locationId": { |
| | | "description": "LocationProductId int `json:\"locationProductId\" gorm:\"type:int;not null;comment:上架规则id\"` //上架规则id\nLocationProduct LocationProduct `json:\"locationProduct\" gorm:\"foreignKey:LocationProductId;references:Id\"`", |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "product": { |
| | |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouseId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetLocationProductList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "warehouseId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetMiniDictList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | location: |
| | | $ref: '#/definitions/models.Location' |
| | | locationId: |
| | | description: |- |
| | | LocationProductId int `json:"locationProductId" gorm:"type:int;not null;comment:上架规则id"` //上架规则id |
| | | LocationProduct LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"` |
| | | description: 位置id |
| | | type: integer |
| | | product: |
| | | $ref: '#/definitions/models.Material' |
| | |
| | | type: string |
| | | updateTime: |
| | | type: string |
| | | warehouseId: |
| | | type: integer |
| | | type: object |
| | | models.LogisticCompany: |
| | | properties: |
| | |
| | | type: integer |
| | | warehouseId: |
| | | description: 仓库ID |
| | | type: integer |
| | | type: object |
| | | request.GetLocationProductList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | locationId: |
| | | type: integer |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | warehouseId: |
| | | type: integer |
| | | type: object |
| | | request.GetMiniDictList: |
| | |
| | | summary: 库存盘点列表 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/locationProductList: |
| | | post: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.GetLocationProductList' |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 获取位置对应产品列表 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/update: |
| | | post: |
| | | parameters: |
| | |
| | | |
| | | func InsertDefaultData() { |
| | | models := []interface{}{ |
| | | NewDepartmentSearch(), |
| | | NewLocationSearch(), |
| | | } |
| | | for _, model := range models { |
| | |
| | | type ( |
| | | LocationProductAmount struct { |
| | | WmsModel |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | //LocationProductId int `json:"locationProductId" gorm:"type:int;not null;comment:上架规则id"` //上架规则id |
| | | //LocationProduct LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"` |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | LocationId int `json:"locationId" gorm:"type:int;not null;comment:位置id"` //位置id |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;default:0;comment:仓库id"` |
| | | Location Location `json:"location" gorm:"foreignKey:LocationId;references:id"` |
| | | ProductCategoryID int `json:"productCategoryId" gorm:"type:int;not null;comment:产品种类id"` //产品种类id |
| | | ProductCategory ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:Id"` |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) SetWarehouseId(wid int) *LocationProductAmountSearch { |
| | | slf.WarehouseId = wid |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductAmountSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProductAmount{}) |
| | | |
| | |
| | | if slf.Preload { |
| | | db = db.Model(&LocationProductAmount{}).Preload("Location").Preload("Product").Preload("ProductCategory") |
| | | } |
| | | //if slf.LocationProductId != 0 { |
| | | // db = db.Where("location_product_id=?", slf.LocationProductId) |
| | | //} |
| | | |
| | | if len(slf.ProductIds) > 0 { |
| | | db = db.Where("product_id in (?)", slf.ProductIds) |
| | | } |
| | |
| | | db = db.Where(slf.Query) |
| | | } |
| | | |
| | | if slf.WarehouseId != 0 { |
| | | db = db.Where("warehouse_id = ?", slf.WarehouseId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"` |
| | | Remark string `json:"remark"` |
| | | |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"` |
| | | WarehouseId int `json:"warehouseId" gorm:"type:int;not null;default:0;comment:仓库id"` |
| | | Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"` |
| | | IsInternalOutput bool `json:"isInternalOutput"` //是否调拨产生的出库 |
| | | InventoryDealerType int `json:"inventoryDealerType" gorm:"type:varchar(255);comment:调拨出入库分类(对应dict字典表的ID)"` |
| | |
| | | |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | "wms/models" |
| | | ) |
| | | |
| | | type GetList struct { |
| | |
| | | ProductId string `json:"productId"` //产品id |
| | | LocationProductAmountId int `json:"locationProductAmountId"` //库存盘点id |
| | | } |
| | | |
| | | type GetLocationProductList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | WarehouseId int `json:"warehouseId"` |
| | | LocationId int `json:"locationId"` |
| | | } |
| | | |
| | | type GetLocationProductListResponse struct { |
| | | models.Material |
| | | } |
| | |
| | | { |
| | | locationProductAmountAPI.POST("add", locationProductAmountController.Add) //添加库存盘点信息 |
| | | locationProductAmountAPI.POST("list", locationProductAmountController.List) //查看库存盘点列表 |
| | | locationProductAmountAPI.POST("locationProductList", locationProductAmountController.LocationProductList) //查看产品库存列表 |
| | | locationProductAmountAPI.POST("update", locationProductAmountController.Update) //修改库存盘点信息 |
| | | locationProductAmountAPI.POST("finish", locationProductAmountController.Finish) //应用、验证库存盘点信息 |
| | | locationProductAmountAPI.POST("getRuleList", locationProductAmountController.GetRuleList) //获取上架规则 |