| | |
| | | LocationTypeInventoryLoss // 库存损失 |
| | | LocationTypeProduction // 生产 |
| | | LocationTypeTransit // 中转位置 |
| | | LocationTypeDisuse |
| | | LocationTypeDisuse //报废位置 |
| | | LocationTypeAdjust //库存盘点 |
| | | ) |
| | | |
| | | func (t LocationType) Valid() bool { |
| | |
| | | // @Tags 上架规则 |
| | | // @Summary 修改上架规则 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateLocationProduct true "入库信息" |
| | | // @Param object body request.UpdateLocationProduct true "修改参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/locationProduct/update [post] |
| | | func (slf LocationProductController) Update(c *gin.Context) { |
| | |
| | | import ( |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "strconv" |
| | | "time" |
| | | "wms/constvar" |
| | | "wms/extend/code" |
| | | "wms/extend/util" |
| | |
| | | // @Produce application/json |
| | | // @Param object body request.PageInfo true "查询参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/locationProduct/list [post] |
| | | // @Router /api-wms/v1/locationProductamount/list [post] |
| | | func (slf LocationProductAmountController) List(c *gin.Context) { |
| | | var params request.PageInfo |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | |
| | | // @Produce application/json |
| | | // @Param object body request.AddLocationProductAmount true "入库/出库信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/operation/operation [post] |
| | | //func (slf LocationProductAmountController) Add(c *gin.Context) { |
| | | // var reqParams request.AddLocationProductAmount |
| | | // if err := c.BindJSON(&reqParams); err != nil { |
| | | // util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | // return |
| | | // } |
| | | // if reqParams.LocationProductAmountId==0 { |
| | | // util.ResponseFormat(c, code.RequestParamError, "参数异常,locationProductAmountId为0") |
| | | // return |
| | | // } |
| | | // locAmount:=models.LocationProductAmount{ |
| | | // LocationProductId: reqParams.LocationProductAmountId |
| | | // } |
| | | // operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First() |
| | | // if err != nil { |
| | | // util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | // return |
| | | // } |
| | | // ////// |
| | | // if location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeCustomer)).First(); err != nil { |
| | | // return err |
| | | // } else { |
| | | // params.ToLocationID = location.Id |
| | | // } |
| | | // |
| | | // |
| | | // params.Status = constvar.OperationStatus_Ready |
| | | // params.Number = strconv.FormatInt(time.Now().Unix(), 10) |
| | | // params.BaseOperationType = operationType.BaseOperationType |
| | | // if err := models.NewOperationSearch().Create(¶ms); err != nil { |
| | | // logx.Errorf("Operation create err: %v", err) |
| | | // util.ResponseFormat(c, code.SaveFail, "添加失败:"+err.Error()) |
| | | // return |
| | | // } |
| | | // util.ResponseFormat(c, code.Success, "添加成功") |
| | | //} |
| | | // @Router /api-wms/v1/locationProductamount/add [post] |
| | | func (slf LocationProductAmountController) Add(c *gin.Context) { |
| | | var reqParams request.AddLocationProductAmount |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if reqParams.LocationId == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数异常,请选择位置") |
| | | return |
| | | } |
| | | if reqParams.ProductId == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数异常,请选择产品") |
| | | return |
| | | } |
| | | |
| | | var existCount int64 |
| | | if err := models.NewOperationSearch().Orm.Table("wms_operation").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.from_location_id=? and wms_operation_details.product_id=? and wms_operation.base_operation_type=? and wms_operaton.status=?", reqParams.LocationId, reqParams.ProductId, constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready).Count(&existCount).Error; err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | if existCount > 0 { |
| | | util.ResponseFormat(c, code.RequestError, "该商品在已选中的位置存在未验证的库存盘点信息,无法继续添加相关信息") |
| | | return |
| | | } |
| | | |
| | | locProduct, err := models.NewLocationProductSearch().SetLocationId(reqParams.LocationId).SetProductId(reqParams.ProductId).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数异常,未找到该上架规则") |
| | | return |
| | | } |
| | | if locProduct.Id == 0 { |
| | | util.ResponseFormat(c, code.RequestError, "不存在该上架规则,无法进行库存盘点") |
| | | return |
| | | } |
| | | location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeAdjust)).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | reqParams.AdjustAmount = reqParams.Amount.Sub(reqParams.DifferenceAmount) |
| | | //reqParams.AdjustAmount = reqParams.DifferenceAmount.Sub(reqParams.Amount) |
| | | locAmount := models.LocationProductAmount{ |
| | | LocationProductId: locProduct.Id, |
| | | Amount: decimal.NewFromInt(0), |
| | | } |
| | | detail := &models.OperationDetails{ |
| | | ProductId: reqParams.ProductId, |
| | | Amount: reqParams.AdjustAmount, |
| | | } |
| | | operation := models.Operation{ |
| | | Number: strconv.FormatInt(time.Now().Unix(), 10), |
| | | Status: constvar.OperationStatus_Ready, |
| | | OperationDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | Comment: "库存盘点", |
| | | BaseOperationType: constvar.BaseOperationTypeAdjust, |
| | | Details: []*models.OperationDetails{detail}, |
| | | FromLocationID: reqParams.LocationId, |
| | | ToLocationID: location.Id, |
| | | } |
| | | |
| | | //if reqParams.AdjustAmount.GreaterThanOrEqual(decimal.NewFromInt(0)) { |
| | | // operation.FromLocationID = Location.Id |
| | | // operation.ToLocationID = reqParams.LocationId |
| | | //} else { |
| | | // operation.FromLocationID = reqParams.LocationId |
| | | // operation.ToLocationID = Location.Id |
| | | //} |
| | | |
| | | if err := models.WithTransaction(func(tx *gorm.DB) error { |
| | | if err := models.NewOperationSearch().SetOrm(tx).Create(&operation); err != nil { |
| | | return err |
| | | } |
| | | if err := models.NewLocationProductAmountSearch().SetOrm(tx).Create(&locAmount); err != nil { |
| | | return err |
| | | } |
| | | return nil |
| | | }); err != nil { |
| | | util.ResponseFormat(c, code.RequestError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "添加成功") |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductamount/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "添加库存盘点信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "入库/出库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddLocationProductAmount" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductamount/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/operation/finish/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | |
| | | "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": { |
| | |
| | | 5, |
| | | 6, |
| | | 7, |
| | | 8 |
| | | 8, |
| | | 9 |
| | | ], |
| | | "x-enum-comments": { |
| | | "LocationTypeCustomer": "客户位置", |
| | | "LocationTypeDisuse": "报废位置", |
| | | "LocationTypeInternal": "内部位置", |
| | | "LocationTypeInventoryLoss": "库存损失", |
| | | "LocationTypeProduction": "生产", |
| | |
| | | "LocationTypeInventoryLoss", |
| | | "LocationTypeProduction", |
| | | "LocationTypeTransit", |
| | | "LocationTypeDisuse" |
| | | "LocationTypeDisuse", |
| | | "LocationTypeAdjust" |
| | | ] |
| | | }, |
| | | "constvar.MaterialMode": { |
| | |
| | | }, |
| | | "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.AddLocationProductAmount": { |
| | | "type": "object", |
| | | "properties": { |
| | | "adjustAmount": { |
| | | "description": "差值", |
| | | "type": "number" |
| | | }, |
| | | "decimal": { |
| | | "description": "库存数量", |
| | | "type": "number" |
| | | }, |
| | | "difference_amount": { |
| | | "description": "计数数量", |
| | | "type": "number" |
| | | }, |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddOperation": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.PageInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryDisuseList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "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" |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductamount/add": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "添加库存盘点信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "入库/出库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddLocationProductAmount" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductamount/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/operation/finish/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | |
| | | "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": { |
| | |
| | | 5, |
| | | 6, |
| | | 7, |
| | | 8 |
| | | 8, |
| | | 9 |
| | | ], |
| | | "x-enum-comments": { |
| | | "LocationTypeCustomer": "客户位置", |
| | | "LocationTypeDisuse": "报废位置", |
| | | "LocationTypeInternal": "内部位置", |
| | | "LocationTypeInventoryLoss": "库存损失", |
| | | "LocationTypeProduction": "生产", |
| | |
| | | "LocationTypeInventoryLoss", |
| | | "LocationTypeProduction", |
| | | "LocationTypeTransit", |
| | | "LocationTypeDisuse" |
| | | "LocationTypeDisuse", |
| | | "LocationTypeAdjust" |
| | | ] |
| | | }, |
| | | "constvar.MaterialMode": { |
| | |
| | | }, |
| | | "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.AddLocationProductAmount": { |
| | | "type": "object", |
| | | "properties": { |
| | | "adjustAmount": { |
| | | "description": "差值", |
| | | "type": "number" |
| | | }, |
| | | "decimal": { |
| | | "description": "库存数量", |
| | | "type": "number" |
| | | }, |
| | | "difference_amount": { |
| | | "description": "计数数量", |
| | | "type": "number" |
| | | }, |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.AddOperation": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.PageInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryDisuseList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "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" |
| | |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | type: integer |
| | | x-enum-comments: |
| | | BaseOperationTypeAdjust: 库存盘点 |
| | | BaseOperationTypeDisuse: 报废 |
| | | BaseOperationTypeIncoming: 收货 |
| | | BaseOperationTypeInternal: 内部调拨 |
| | | BaseOperationTypeOutgoing: 交货 |
| | |
| | | - BaseOperationTypeIncoming |
| | | - BaseOperationTypeOutgoing |
| | | - BaseOperationTypeInternal |
| | | - BaseOperationTypeDisuse |
| | | - BaseOperationTypeAdjust |
| | | constvar.CostingMethod: |
| | | enum: |
| | | - 1 |
| | |
| | | - 6 |
| | | - 7 |
| | | - 8 |
| | | - 9 |
| | | type: integer |
| | | x-enum-comments: |
| | | LocationTypeCustomer: 客户位置 |
| | | LocationTypeDisuse: 报废位置 |
| | | LocationTypeInternal: 内部位置 |
| | | LocationTypeInventoryLoss: 库存损失 |
| | | LocationTypeProduction: 生产 |
| | |
| | | - LocationTypeProduction |
| | | - LocationTypeTransit |
| | | - LocationTypeDisuse |
| | | - LocationTypeAdjust |
| | | constvar.MaterialMode: |
| | | enum: |
| | | - 原材料 |
| | |
| | | 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.AddLocationProductAmount: |
| | | properties: |
| | | adjustAmount: |
| | | description: 差值 |
| | | type: number |
| | | decimal: |
| | | description: 库存数量 |
| | | type: number |
| | | difference_amount: |
| | | description: 计数数量 |
| | | type: number |
| | | locationId: |
| | | type: integer |
| | | productId: |
| | | type: string |
| | | type: object |
| | | request.AddOperation: |
| | | properties: |
| | | comment: |
| | |
| | | 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 |
| | |
| | | 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/locationProductamount/add: |
| | | post: |
| | | parameters: |
| | | - description: 入库/出库信息 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddLocationProductAmount' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 添加库存盘点信息 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductamount/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/operation/finish/{id}: |
| | | put: |
| | | parameters: |
| | |
| | | //Product{}, |
| | | ProductCategory{}, |
| | | Material{}, |
| | | LocationProduct{}, |
| | | LocationProductAmount{}, |
| | | ) |
| | | return err |
| | | } |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetProductId(productId string) *LocationProductSearch { |
| | | slf.ProductId = productId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) SetLocationId(locationId int) *LocationProductSearch { |
| | | slf.LocationId = locationId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationProductSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&LocationProduct{}) |
| | | |
| | |
| | | db = db.Model(&LocationProduct{}).Preload("Location").Preload("Area").Preload("ProductCategory").Preload("Product") |
| | | } |
| | | |
| | | if slf.LocationId != 0 { |
| | | db = db.Where("location_id = ?", slf.LocationId) |
| | | } |
| | | |
| | | if slf.ProductId != "" { |
| | | db = db.Where("product_id=?", slf.ProductId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | import "github.com/shopspring/decimal" |
| | | |
| | | type AddLocationProductAmount struct { |
| | | LocationProductAmountId int `json:"locationProductAmountId"` //库存盘点id |
| | | AdjustAmount decimal.Decimal `json:"adjustAmount" ` //差值 |
| | | DifferenceAmount decimal.Decimal `json:"difference_amount"` //计数数量 |
| | | LocationId int `json:"locationId"` |
| | | ProductId string `json:"productId"` |
| | | Amount decimal.Decimal `json:"decimal"` //库存数量 |
| | | AdjustAmount decimal.Decimal `json:"adjustAmount" ` //差值 |
| | | DifferenceAmount decimal.Decimal `json:"difference_amount"` //计数数量 |
| | | } |
| | | |
| | | type UpdateLocationProductAmount struct { |
| | |
| | | locationProductController := new(controllers.LocationProductController) |
| | | locationProductAPI := r.Group(urlPrefix + "/locationProduct") |
| | | { |
| | | locationProductAPI.GET("operationType", locationProductController.List) // 获取上架规则列表 |
| | | locationProductAPI.POST("operationType", locationProductController.Add) // 新增上架规则 |
| | | locationProductAPI.PUT("operationType/:id", locationProductController.Update) // 修改上架规则 |
| | | locationProductAPI.DELETE("operationType/:id", locationProductController.Delete) // 删除上架规则 |
| | | locationProductAPI.POST("list", locationProductController.List) // 获取上架规则列表 |
| | | locationProductAPI.POST("add", locationProductController.Add) // 新增上架规则 |
| | | locationProductAPI.POST("update", locationProductController.Update) // 修改上架规则 |
| | | locationProductAPI.DELETE("delete/:id", locationProductController.Delete) // 删除上架规则 |
| | | } |
| | | |
| | | //库存盘点 |
| | | locationProductAmountController := new(controllers.LocationProductAmountController) |
| | | locationProductAmountAPI := r.Group(urlPrefix + "/locationProductAmount") |
| | | { |
| | | locationProductAmountAPI.POST("add", locationProductAmountController.Add) //添加库存盘点信息 |
| | | locationProductAmountAPI.POST("list", locationProductAmountController.List) //查看库存盘点列表 |
| | | } |
| | | |
| | | return r |