Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
# Conflicts:
# docs/docs.go
# docs/swagger.json
# docs/swagger.yaml
# router/router.go
| | |
| | | // @Param object body request.UpdateLocationProductAmount true "入库/出库信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/locationProductAmount/update [post] |
| | | //func (slf LocationProductAmountController) Update(c *gin.Context) { |
| | | // var reqParams request.UpdateLocationProductAmount |
| | | // if err := c.BindJSON(&reqParams); err != nil { |
| | | // 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_operation.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), |
| | | // CreateDate: time.Now().Format("2006-01-02 15:04:05"), |
| | | // } |
| | | // 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: location.Id, |
| | | // ToLocationID: reqParams.LocationId, |
| | | // } |
| | | // |
| | | // //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, "添加成功") |
| | | //} |
| | | func (slf LocationProductAmountController) Update(c *gin.Context) { |
| | | var reqParams request.UpdateLocationProductAmount |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | reqParams.AdjustAmount = reqParams.DifferenceAmount.Sub(reqParams.Amount) |
| | | operation, err := models.NewOperationSearch().SetID(reqParams.OperationId).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "未找到相关数据") |
| | | return |
| | | } |
| | | if operation.Status != constvar.OperationStatus_Ready { |
| | | util.ResponseFormat(c, code.RequestParamError, "该记录已验证通过,无法进行修改") |
| | | return |
| | | } |
| | | |
| | | if err := models.NewOperationDetailsSearch().SetOperationId(reqParams.OperationId).SetProductId(reqParams.ProductId).Update(&models.OperationDetails{Amount: reqParams.AdjustAmount}); err != nil { |
| | | util.ResponseFormat(c, code.RequestError, "修改失败:"+err.Error()) |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "修改成功") |
| | | } |
| | |
| | | search := models.NewOperationSearch() |
| | | search.SetPage(params.Page, params.PageSize) |
| | | if params.Number != "" { |
| | | search.SetNumber(params.Number) |
| | | } |
| | | if params.SourceNumber != "" { |
| | | search.SetSourceNumber(params.SourceNumber) |
| | | search.SetKeyword(params.Number) |
| | | } |
| | | list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | |
| | | search.SetPage(params.Page, params.PageSize) |
| | | search.SetPage(params.Page, params.PageSize) |
| | | if params.Number != "" { |
| | | search.SetNumber(params.Number) |
| | | } |
| | | if params.SourceNumber != "" { |
| | | search.SetSourceNumber(params.SourceNumber) |
| | | search.SetKeyword(params.Number) |
| | | } |
| | | list, total, err := search.SetPreload(true).SetOrder("created_at desc").Find() |
| | | if err != nil { |
| | |
| | | |
| | | db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id") |
| | | |
| | | if params.SourceNumber != "" { |
| | | db = db.Where("wms_operation.source_number like ?", fmt.Sprintf("%%%v%%", params.SourceNumber)) |
| | | } |
| | | if params.Number != "" { |
| | | db = db.Where("wms_operation.number like ?", fmt.Sprintf("%%%v%%", params.Number)) |
| | | db = db.Where("wms_operation.number like ? or wms_operation.source_number like ?", fmt.Sprintf("%%%v%%", params.Number), fmt.Sprintf("%%%v%%", params.Number)) |
| | | } |
| | | db = db.Where("wms_operation.operation_type_id=?", 0) |
| | | var ( |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/getRuleList": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "获取上架规则", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetRuleList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.RuleList" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/list": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.PageInfo" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/update": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "修改库存盘点信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "入库/出库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateLocationProductAmount" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetRuleList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationAllList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "productCategoryId": { |
| | | "description": "产品种类id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateLocationProductAmount": { |
| | | "type": "object", |
| | | "properties": { |
| | | "Amount": { |
| | | "description": "库存数量", |
| | | "type": "number" |
| | | }, |
| | | "adjustAmount": { |
| | | "description": "LocationProductAmountId int ` + "`" + `json:\"locationProductAmountId\"` + "`" + ` //库存盘点id", |
| | | "type": "number" |
| | | }, |
| | | "differenceAmount": { |
| | | "description": "计数数量", |
| | | "type": "number" |
| | | }, |
| | | "operationId": { |
| | | "description": "出入库id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "response.RuleList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationList": { |
| | | "description": "位置列表", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.Location" |
| | | } |
| | | }, |
| | | "productList": { |
| | | "description": "产品列表", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.Material" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "util.Response": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/getRuleList": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "获取上架规则", |
| | | "parameters": [ |
| | | { |
| | | "description": "查询信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetRuleList" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/response.RuleList" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/list": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.PageInfo" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/update": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "修改库存盘点信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "入库/出库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateLocationProductAmount" |
| | | } |
| | | } |
| | | ], |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.GetRuleList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.OperationAllList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "sourceNumber": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "productCategoryId": { |
| | | "description": "产品种类id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateLocationProductAmount": { |
| | | "type": "object", |
| | | "properties": { |
| | | "Amount": { |
| | | "description": "库存数量", |
| | | "type": "number" |
| | | }, |
| | | "adjustAmount": { |
| | | "description": "LocationProductAmountId int `json:\"locationProductAmountId\"` //库存盘点id", |
| | | "type": "number" |
| | | }, |
| | | "differenceAmount": { |
| | | "description": "计数数量", |
| | | "type": "number" |
| | | }, |
| | | "operationId": { |
| | | "description": "出入库id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | |
| | | "value": { |
| | | "description": "总价值", |
| | | "type": "number" |
| | | } |
| | | } |
| | | }, |
| | | "response.RuleList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationList": { |
| | | "description": "位置列表", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.Location" |
| | | } |
| | | }, |
| | | "productList": { |
| | | "description": "产品列表", |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.Material" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.GetRuleList: |
| | | properties: |
| | | locationId: |
| | | description: 位置id |
| | | type: integer |
| | | productId: |
| | | description: 产品id |
| | | type: string |
| | | type: object |
| | | request.OperationAllList: |
| | | properties: |
| | | number: |
| | |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | sourceNumber: |
| | | type: string |
| | | type: object |
| | | request.PageInfo: |
| | | properties: |
| | |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | sourceNumber: |
| | | type: string |
| | | type: object |
| | | request.QueryOperationHistory: |
| | | properties: |
| | |
| | | type: integer |
| | | productCategoryId: |
| | | description: 产品种类id |
| | | type: integer |
| | | productId: |
| | | description: 产品id |
| | | type: string |
| | | type: object |
| | | request.UpdateLocationProductAmount: |
| | | properties: |
| | | Amount: |
| | | description: 库存数量 |
| | | type: number |
| | | adjustAmount: |
| | | description: LocationProductAmountId int `json:"locationProductAmountId"` |
| | | //库存盘点id |
| | | type: number |
| | | differenceAmount: |
| | | description: 计数数量 |
| | | type: number |
| | | operationId: |
| | | description: 出入库id |
| | | type: integer |
| | | productId: |
| | | description: 产品id |
| | |
| | | value: |
| | | description: 总价值 |
| | | type: number |
| | | type: object |
| | | response.RuleList: |
| | | properties: |
| | | locationList: |
| | | description: 位置列表 |
| | | items: |
| | | $ref: '#/definitions/models.Location' |
| | | type: array |
| | | productList: |
| | | description: 产品列表 |
| | | items: |
| | | $ref: '#/definitions/models.Material' |
| | | type: array |
| | | type: object |
| | | util.Response: |
| | | properties: |
| | |
| | | summary: 添加库存盘点信息 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/getRuleList: |
| | | post: |
| | | parameters: |
| | | - description: 查询信息 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.GetRuleList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/response.RuleList' |
| | | type: array |
| | | type: object |
| | | summary: 获取上架规则 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/list: |
| | | post: |
| | | parameters: |
| | |
| | | summary: 库存盘点列表 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/update: |
| | | post: |
| | | parameters: |
| | | - description: 入库/出库信息 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateLocationProductAmount' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 修改库存盘点信息 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/operation/finish/{id}: |
| | | put: |
| | | parameters: |
| | |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | db = db.Where("number like ? or source_number like ?", fmt.Sprintf("%%%v%%", slf.Keyword), fmt.Sprintf("%%%v%%", slf.Keyword)) |
| | | } |
| | | |
| | | if slf.SourceNumber != "" { |
| | |
| | | } |
| | | |
| | | type UpdateLocationProductAmount struct { |
| | | LocationProductAmountId int `json:"locationProductAmountId"` //库存盘点id |
| | | AdjustAmount decimal.Decimal `json:"adjustAmount" ` //差值 |
| | | DifferenceAmount decimal.Decimal `json:"differenceAmount"` //计数数量 |
| | | OperationId int `json:"operationId"` //出入库id |
| | | //LocationProductAmountId int `json:"locationProductAmountId"` //库存盘点id |
| | | AdjustAmount decimal.Decimal `json:"adjustAmount" ` //差值 |
| | | DifferenceAmount decimal.Decimal `json:"differenceAmount"` //计数数量 |
| | | OperationId int `json:"operationId"` //出入库id |
| | | Amount decimal.Decimal `json:"Amount"` //库存数量 |
| | | ProductId string `json:"productId"` //产品id |
| | | } |
| | | |
| | | type GetRuleList struct { |
| | |
| | | PageInfo |
| | | OperationTypeId int `json:"operationTypeId" form:"operationTypeId"` |
| | | Number string `json:"number"` |
| | | SourceNumber string `json:"sourceNumber"` |
| | | } |
| | | |
| | | type UpdateOperation struct { |
| | |
| | | |
| | | type QueryDisuseList struct { |
| | | PageInfo |
| | | Number string `json:"number"` |
| | | SourceNumber string `json:"sourceNumber"` |
| | | Number string `json:"number"` |
| | | } |
| | | |
| | | type UpdateDisuse struct { |
| | |
| | | locationProductAmountController := new(controllers.LocationProductAmountController) |
| | | locationProductAmountAPI := r.Group(urlPrefix + "/locationProductAmount") |
| | | { |
| | | locationProductAmountAPI.POST("add", locationProductAmountController.Add) //添加库存盘点信息 |
| | | locationProductAmountAPI.POST("list", locationProductAmountController.List) //查看库存盘点列表 |
| | | locationProductAmountAPI.POST("add", locationProductAmountController.Add) //添加库存盘点信息 |
| | | locationProductAmountAPI.POST("list", locationProductAmountController.List) //查看库存盘点列表 |
| | | locationProductAmountAPI.POST("update", locationProductAmountController.Update) //修改库存盘点信息 |
| | | locationProductAmountAPI.POST("getRuleList", locationProductAmountController.GetRuleList) //获取上架规则 |
| | | } |
| | | |