获取位置列表增加仓库ID传参,默认位置去掉仓库code拼接, 修复若干bug
| | |
| | | serverId: wms |
| | | # 通过公司名称区分出入库明细打印模版,目前支持:geruimi,jialian |
| | | companyName: jialian |
| | | env: dev |
| | | db: |
| | | # dsn: root:c++java123@tcp(192.168.20.119:3306)/wms?charset=utf8&parseTime=True&loc=Local |
| | | dsn: root:c++java123@tcp(127.0.0.1:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err) |
| | | return |
| | | } |
| | | |
| | | if params.WarehouseId == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "仓库ID参数缺失") |
| | | return |
| | | } |
| | | |
| | | if params.ParentId != 0 { |
| | | //查询上级名称 |
| | | first, err := models.NewLocationSearch().SetID(params.ParentId).First() |
| | |
| | | search.SetPage(params.Page, params.PageSize) |
| | | } |
| | | list, total, err := search.SetKeyword(params.KeyWord).SetType(params.Type).SetJointName(params.JointName). |
| | | SetIsScrapLocation(params.IsScrapLocation).SetOrder("created_at desc").Find() |
| | | SetIsScrapLocation(params.IsScrapLocation).SetOrder("created_at desc"). |
| | | SetWarehouseId(params.WarehouseId). |
| | | Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | |
| | | "wms/extend/code" |
| | | "wms/extend/util" |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/structx" |
| | | "wms/request" |
| | | ) |
| | |
| | | util.ResponseFormat(c, code.SaveFail, "视图创建失败") |
| | | return |
| | | } |
| | | //创建默认位置 |
| | | location := &models.Location{ |
| | | Name: params.Name, |
| | | JointName: params.Name, |
| | | Type: constvar.LocationTypeInternal, |
| | | ReplenishLocation: true, |
| | | ParentId: id, |
| | | } |
| | | locationId, err := models.NewLocationSearch().CreateReturnId(location) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.SaveFail, "位置创建失败") |
| | | return |
| | | } |
| | | params.LocationId = locationId |
| | | err = models.WithTransaction(func(tx *gorm.DB) error { |
| | | err := models.NewWarehouseSearch().SetOrm(tx).Create(¶ms) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | //创建默认位置 |
| | | location := &models.Location{ |
| | | Name: params.Name, |
| | | JointName: params.Name, |
| | | Type: constvar.LocationTypeInternal, |
| | | ReplenishLocation: true, |
| | | ParentId: id, |
| | | WarehouseId: params.Id, |
| | | } |
| | | locationId, err := models.NewLocationSearch().SetOrm(tx).CreateReturnId(location) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | //更改仓库记录里的位置id |
| | | params.LocationId = locationId |
| | | err = models.NewWarehouseSearch().SetOrm(tx).SetID(params.Id).UpdateByMap(map[string]interface{}{"location_id": locationId}) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | //创建三个默认操作类型 |
| | | var types []*models.OperationType |
| | | inType := &models.OperationType{ |
| | |
| | | err = models.NewOperationTypeSearch().SetOrm(tx).CreateBatch(types) |
| | | return err |
| | | }) |
| | | |
| | | if err != nil { |
| | | _ = models.NewLocationSearch().SetID(locationId).Delete() |
| | | logx.Errorf("warehouse create err: %v", err) |
| | | util.ResponseFormat(c, code.SaveFail, "插入失败") |
| | | return |
| | | } |
| | |
| | | for _, warehouse := range list { |
| | | for _, location := range locations { |
| | | if warehouse.LocationId == location.Id { |
| | | warehouse.WarehouseLocation = warehouse.Code + "/" + location.Name |
| | | warehouse.WarehouseLocation = location.Name |
| | | break |
| | | } |
| | | } |
| | |
| | | "入库/出库" |
| | | ], |
| | | "summary": "获取人员列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.OperationCondition" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/inventory_order.WorkerInfo" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/downloadInputFormat": { |
| | | "get": { |
| | | "tags": [ |
| | | "产品" |
| | | ], |
| | | "summary": "下载导入物料/产品模板", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/finishDisuse/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | |
| | | "application/xlsx" |
| | | ], |
| | | "tags": [ |
| | | "物料管理" |
| | | "产品" |
| | | ], |
| | | "summary": "导入物料", |
| | | "summary": "导入物料/产品", |
| | | "parameters": [ |
| | | { |
| | | "type": "file", |
| | |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4 |
| | | 4, |
| | | 5 |
| | | ], |
| | | "x-enum-comments": { |
| | | "DisuseType": "报废类型", |
| | | "StockoutType": "出库类型", |
| | | "StorageType": "入库类型", |
| | | "TakeStock": "盘点类型", |
| | | "TakeStockType": "盘点类型", |
| | | "TransferType": "调拨类型" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "StorageType", |
| | | "StockoutType", |
| | | "TransferType", |
| | | "TakeStock" |
| | | "TakeStockType", |
| | | "DisuseType" |
| | | ] |
| | | }, |
| | | "constvar.OperationSource": { |
| | |
| | | "valid": { |
| | | "description": "Valid is true if Time is not NULL", |
| | | "type": "boolean" |
| | | } |
| | | } |
| | | }, |
| | | "inventory_order.WorkerInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "number" |
| | | } |
| | | } |
| | | }, |
| | | "models.MonthStatsItemsType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "MonthStatsItemsTypeInput": "入库", |
| | | "MonthStatsItemsTypeOutput": "出库" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "MonthStatsItemsTypeInput", |
| | | "MonthStatsItemsTypeOutput" |
| | | ] |
| | | }, |
| | | "models.MoveHistory": { |
| | | "type": "object", |
| | |
| | | "description": "入库来源,出库去处", |
| | | "type": "string" |
| | | }, |
| | | "type": { |
| | | "$ref": "#/definitions/models.MonthStatsItemsType" |
| | | }, |
| | | "warehouseMonthStatsId": { |
| | | "type": "integer" |
| | | } |
| | |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "locationIds": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | }, |
| | | "type": { |
| | | "type": "integer" |
| | | }, |
| | | "warehouseId": { |
| | | "description": "仓库ID", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "入库/出库" |
| | | ], |
| | | "summary": "获取人员列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.OperationCondition" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/inventory_order.WorkerInfo" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/downloadInputFormat": { |
| | | "get": { |
| | | "tags": [ |
| | | "产品" |
| | | ], |
| | | "summary": "下载导入物料/产品模板", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/finishDisuse/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | |
| | | "application/xlsx" |
| | | ], |
| | | "tags": [ |
| | | "物料管理" |
| | | "产品" |
| | | ], |
| | | "summary": "导入物料", |
| | | "summary": "导入物料/产品", |
| | | "parameters": [ |
| | | { |
| | | "type": "file", |
| | |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4 |
| | | 4, |
| | | 5 |
| | | ], |
| | | "x-enum-comments": { |
| | | "DisuseType": "报废类型", |
| | | "StockoutType": "出库类型", |
| | | "StorageType": "入库类型", |
| | | "TakeStock": "盘点类型", |
| | | "TakeStockType": "盘点类型", |
| | | "TransferType": "调拨类型" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "StorageType", |
| | | "StockoutType", |
| | | "TransferType", |
| | | "TakeStock" |
| | | "TakeStockType", |
| | | "DisuseType" |
| | | ] |
| | | }, |
| | | "constvar.OperationSource": { |
| | |
| | | "valid": { |
| | | "description": "Valid is true if Time is not NULL", |
| | | "type": "boolean" |
| | | } |
| | | } |
| | | }, |
| | | "inventory_order.WorkerInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | | "id": { |
| | | "type": "string" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "type": "number" |
| | | } |
| | | } |
| | | }, |
| | | "models.MonthStatsItemsType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2 |
| | | ], |
| | | "x-enum-comments": { |
| | | "MonthStatsItemsTypeInput": "入库", |
| | | "MonthStatsItemsTypeOutput": "出库" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "MonthStatsItemsTypeInput", |
| | | "MonthStatsItemsTypeOutput" |
| | | ] |
| | | }, |
| | | "models.MoveHistory": { |
| | | "type": "object", |
| | |
| | | "description": "入库来源,出库去处", |
| | | "type": "string" |
| | | }, |
| | | "type": { |
| | | "$ref": "#/definitions/models.MonthStatsItemsType" |
| | | }, |
| | | "warehouseMonthStatsId": { |
| | | "type": "integer" |
| | | } |
| | |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "locationIds": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | |
| | | }, |
| | | "type": { |
| | | "type": "integer" |
| | | }, |
| | | "warehouseId": { |
| | | "description": "仓库ID", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | type: integer |
| | | x-enum-comments: |
| | | DisuseType: 报废类型 |
| | | StockoutType: 出库类型 |
| | | StorageType: 入库类型 |
| | | TakeStock: 盘点类型 |
| | | TakeStockType: 盘点类型 |
| | | TransferType: 调拨类型 |
| | | x-enum-varnames: |
| | | - StorageType |
| | | - StockoutType |
| | | - TransferType |
| | | - TakeStock |
| | | - TakeStockType |
| | | - DisuseType |
| | | constvar.OperationSource: |
| | | enum: |
| | | - 1 |
| | |
| | | valid: |
| | | description: Valid is true if Time is not NULL |
| | | type: boolean |
| | | type: object |
| | | inventory_order.WorkerInfo: |
| | | properties: |
| | | id: |
| | | type: string |
| | | name: |
| | | type: string |
| | | type: object |
| | | models.Attachment: |
| | | properties: |
| | |
| | | description: 重量 |
| | | type: number |
| | | type: object |
| | | models.MonthStatsItemsType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | type: integer |
| | | x-enum-comments: |
| | | MonthStatsItemsTypeInput: 入库 |
| | | MonthStatsItemsTypeOutput: 出库 |
| | | x-enum-varnames: |
| | | - MonthStatsItemsTypeInput |
| | | - MonthStatsItemsTypeOutput |
| | | models.MoveHistory: |
| | | properties: |
| | | amount: |
| | |
| | | name: |
| | | description: 入库来源,出库去处 |
| | | type: string |
| | | type: |
| | | $ref: '#/definitions/models.MonthStatsItemsType' |
| | | warehouseMonthStatsId: |
| | | type: integer |
| | | type: object |
| | |
| | | type: string |
| | | locationId: |
| | | type: integer |
| | | locationIds: |
| | | items: |
| | | type: integer |
| | | type: array |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | |
| | | description: 每页大小 |
| | | type: integer |
| | | type: |
| | | type: integer |
| | | warehouseId: |
| | | description: 仓库ID |
| | | type: integer |
| | | type: object |
| | | request.GetMiniDictList: |
| | |
| | | - 入库/出库 |
| | | /api-wms/v1/operation/getPersonnelList: |
| | | get: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.OperationCondition' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/inventory_order.WorkerInfo' |
| | | type: array |
| | | type: object |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 获取人员列表 |
| | | tags: |
| | | - 入库/出库 |
| | |
| | | summary: 删除产品类型 |
| | | tags: |
| | | - 产品类型 |
| | | /api-wms/v1/product/downloadInputFormat: |
| | | get: |
| | | parameters: |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 下载导入物料/产品模板 |
| | | tags: |
| | | - 产品 |
| | | /api-wms/v1/product/finishDisuse/{id}: |
| | | put: |
| | | parameters: |
| | |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 导入物料 |
| | | summary: 导入物料/产品 |
| | | tags: |
| | | - 物料管理 |
| | | - 产品 |
| | | /api-wms/v1/product/listDisuse: |
| | | post: |
| | | parameters: |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) SetWarehouseId(warehouseId int) *LocationSearch { |
| | | slf.WarehouseId = warehouseId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Preload("Warehouse") |
| | | } |
| | | |
| | | if slf.WarehouseId != 0 { |
| | | db = db.Where("warehouse_id = ?", slf.WarehouseId) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | KeyWord string `json:"keyWord"` |
| | | JointName string `json:"jointName"` //拼接名称 |
| | | IsScrapLocation bool `json:"isScrapLocation"` //是否报废 |
| | | WarehouseId int `json:"warehouseId"` //仓库ID |
| | | } |
| | |
| | | ids := params.LocationIds |
| | | if params.LocationId != 0 { |
| | | ids = append(ids, params.LocationId) |
| | | } else { |
| | | } |
| | | if len(ids) == 0 { |
| | | //查询位置 |
| | | locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).SetType(3).FindAll() |
| | | if err != nil { |
| | |
| | | } else { |
| | | if locAmount, aok := mapLocAmount[strconv.Itoa(operation.LocationID)+v.ProductId]; aok { |
| | | locAmount.Amount = locAmount.Amount.Add(v.Amount) |
| | | locAmount.ID = uint(locAmount.Id) |
| | | if err := models.NewLocationProductAmountSearch().SetOrm(tx).SetID(int(locAmount.ID)).Save(locAmount); err != nil { |
| | | return err |
| | | } |