| | |
| | | if params.Keyword != "" { |
| | | search.SetKeyword(params.Keyword) |
| | | } |
| | | if params.ParentId != 0 { |
| | | if params.ParentId != "" { |
| | | search.SetParentId(params.ParentId) |
| | | } |
| | | if params.CompanyId != 0 { |
| | |
| | | if params.Type == 0 { |
| | | return errors.New("请选择正确的位置类型") |
| | | } |
| | | if params.ParentId < 0 { |
| | | if params.ParentId == "" { |
| | | return errors.New("错误参数ParentId") |
| | | } |
| | | if params.CompanyId < 0 { |
| | |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/spf13/cast" |
| | | "gorm.io/gorm" |
| | | "strconv" |
| | | "wms/constvar" |
| | | "wms/extend/code" |
| | | "wms/extend/util" |
| | | "wms/models" |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | //创建默认位置 |
| | | location := &models.Location{ |
| | | Name: "默认位置", |
| | | ParentId: params.Code, |
| | | Type: constvar.LocationTypeInternal, |
| | | ReplenishLocation: true, |
| | | } |
| | | locationId, err := models.NewLocationSearch().CreateReturnId(location) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.SaveFail, "位置创建失败") |
| | | return |
| | | } |
| | | params.LocationId = locationId |
| | | if err := models.NewWarehouseSearch().Create(¶ms); err != nil { |
| | | logx.Errorf("warehouse create err: %v", err) |
| | | util.ResponseFormat(c, code.SaveFail, "插入失败") |
| | |
| | | util.ResponseFormat(c, code.Success, "添加成功") |
| | | } |
| | | |
| | | // Update |
| | | // UpdateWarehouse |
| | | // @Tags 仓库 |
| | | // @Summary 编辑仓库 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateWarehouse true "仓库信息" |
| | | // @Param id path string true "仓库id" |
| | | // @Param object body models.Warehouse true "仓库信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/warehouse/warehouse/{id} [put] |
| | | func (slf WarehouseController) Update(c *gin.Context) { |
| | | id := cast.ToUint(c.Param("id")) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | var ( |
| | | reqParams request.UpdateWarehouse |
| | | params models.Warehouse |
| | | ) |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | // @Router /api-wms/v1/warehouse/updateWarehouse [post] |
| | | func (slf WarehouseController) UpdateWarehouse(c *gin.Context) { |
| | | var params models.Warehouse |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("参数解析失败: %v"+err.Error())) |
| | | return |
| | | } |
| | | if err := structx.AssignTo(reqParams, ¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, fmt.Sprintf("数据转换错误: %v", err.Error())) |
| | | return |
| | | } |
| | | params.ID = id |
| | | if err := slf.ParamsCheck(params); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | err := models.NewWarehouseSearch().SetID(params.ID).Update(¶ms) |
| | | err := models.NewWarehouseSearch().SetID(params.Id).Update(¶ms) |
| | | |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "修改失败") |
| | |
| | | |
| | | func (slf WarehouseController) ParamsCheck(params models.Warehouse) (err error) { |
| | | var oldRecord *models.Warehouse |
| | | if params.ID != 0 { |
| | | oldRecord, err = models.NewWarehouseSearch().SetID(params.ID).First() |
| | | if params.Id != 0 { |
| | | oldRecord, err = models.NewWarehouseSearch().SetID(params.Id).First() |
| | | if err == gorm.ErrRecordNotFound { |
| | | return errors.New("记录不存在") |
| | | } |
| | | } |
| | | if oldRecord == nil || params.Code != oldRecord.Code { |
| | | _, err = models.NewWarehouseSearch().SetCode(params.Code).First() |
| | | if err != gorm.ErrRecordNotFound { |
| | | //更新位置信息 |
| | | if oldRecord != nil && params.Code != oldRecord.Code { |
| | | m := make(map[string]interface{}) |
| | | m["parent_id"] = params.Code |
| | | err := models.NewLocationSearch().SetID(oldRecord.LocationId).UpdateByMap(m) |
| | | if err != nil { |
| | | return errors.New("更新位置信息失败") |
| | | } |
| | | } |
| | | if oldRecord == nil { |
| | | record, err := models.NewWarehouseSearch().SetCode(params.Code).First() |
| | | if record != nil && record.Code == params.Code { |
| | | fmt.Println(err) |
| | | return errors.New("仓库编号重复") |
| | | } |
| | | } |
| | | |
| | | if params.Code == "" { |
| | | return errors.New("缩写不能为空") |
| | | } |
| | | return nil |
| | | } |
| | | |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | | } |
| | | //获取位置信息 |
| | | codes := make([]string, 0) |
| | | for _, warehouse := range list { |
| | | codes = append(codes, warehouse.Code) |
| | | } |
| | | locations, err := models.NewLocationSearch().SetParents(codes).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "位置信息查找失败") |
| | | return |
| | | } |
| | | for _, warehouse := range list { |
| | | for _, location := range locations { |
| | | if warehouse.LocationId == location.Id { |
| | | warehouse.WarehouseLocation = warehouse.Code + "/" + location.Name |
| | | break |
| | | } |
| | | } |
| | | } |
| | | |
| | | util.ResponseFormatList(c, code.Success, list, cast.ToInt(total)) |
| | | } |
| | |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/warehouse/warehouse/{id} [delete] |
| | | func (slf WarehouseController) Delete(c *gin.Context) { |
| | | id := cast.ToUint(c.Param("id")) |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | err := models.NewWarehouseSearch().SetID(id).Delete() |
| | | //删除位置信息 |
| | | first, err := models.NewWarehouseSearch().SetID(id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除失败") |
| | | util.ResponseFormat(c, code.RequestParamError, "获取仓库信息失败") |
| | | return |
| | | } |
| | | err = models.NewLocationSearch().SetID(first.LocationId).Delete() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除位置信息失败") |
| | | return |
| | | } |
| | | err = models.NewWarehouseSearch().SetID(id).Delete() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除仓库信息失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.UpdateSuccess, "删除成功") |
| | | } |
| | | |
| | | // GetWarehouseDetails |
| | | // @Tags 仓库 |
| | | // @Summary 获取仓库详情 |
| | | // @Produce application/json |
| | | // @Param id path string true "仓库id" |
| | | // @Success 200 {object} util.Response{data=models.Warehouse} "成功" |
| | | // @Router /api-wms/v1/warehouse/getWarehouseDetails/{id} [get] |
| | | func (slf WarehouseController) GetWarehouseDetails(c *gin.Context) { |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | first, err := models.NewWarehouseSearch().SetID(id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "获取仓库信息失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.UpdateSuccess, first) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/getWarehouseDetails/{id}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "仓库" |
| | | ], |
| | | "summary": "获取仓库详情", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "仓库id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/models.Warehouse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/updateWarehouse": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "仓库" |
| | | ], |
| | | "summary": "编辑仓库", |
| | | "parameters": [ |
| | | { |
| | | "description": "仓库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/models.Warehouse" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/warehouse": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/warehouse/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "仓库" |
| | | ], |
| | | "summary": "编辑仓库", |
| | | "parameters": [ |
| | | { |
| | | "description": "仓库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateWarehouse" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "仓库id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "TaskAndObject" |
| | | ] |
| | | }, |
| | | "constvar.ProductType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "Consumables": "消耗品", |
| | | "Server": "服务", |
| | | "StoredProduct": "可储存的产品" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "Consumables", |
| | | "Server", |
| | | "StoredProduct" |
| | | ] |
| | | }, |
| | | "constvar.ReservationMethod": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | }, |
| | | "parentId": { |
| | | "description": "上级id", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "replenishLocation": { |
| | | "description": "是否补充位置", |
| | |
| | | "categoryId": { |
| | | "description": "产品类别id", |
| | | "type": "integer" |
| | | }, |
| | | "categoryName": { |
| | | "description": "产品类别名称", |
| | | "type": "string" |
| | | }, |
| | | "companyId": { |
| | | "description": "公司id", |
| | |
| | | "type": "string" |
| | | }, |
| | | "invoicingStrategy": { |
| | | "description": "wms添加字段", |
| | | "description": "开票策略", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.InvoicingStrategy" |
| | |
| | | "productTagName": { |
| | | "description": "产品标签名称", |
| | | "type": "string" |
| | | }, |
| | | "productType": { |
| | | "description": "wms添加字段", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.ProductType" |
| | | } |
| | | ] |
| | | }, |
| | | "purchasePrice": { |
| | | "description": "采购价格", |
| | |
| | | "description": "入向运输", |
| | | "type": "integer" |
| | | }, |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "仓库名称", |
| | | "type": "string" |
| | |
| | | } |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouseLocation": { |
| | | "description": "库存位置", |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | }, |
| | | "inboundTransportation": { |
| | | "description": "入向运输", |
| | | "type": "integer" |
| | | }, |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | |
| | | "warehouseId": { |
| | | "description": "仓库id", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateWarehouse": { |
| | | "type": "object", |
| | | "required": [ |
| | | "code" |
| | | ], |
| | | "properties": { |
| | | "active": { |
| | | "description": "是否启用,传true就行", |
| | | "type": "boolean" |
| | | }, |
| | | "address": { |
| | | "description": "地址", |
| | | "type": "string" |
| | | }, |
| | | "buyToResupply": { |
| | | "description": "购买补给,已购买产品能够发送到此仓库", |
| | | "type": "boolean" |
| | | }, |
| | | "code": { |
| | | "description": "仓库编码", |
| | | "type": "string", |
| | | "maxLength": 5, |
| | | "minLength": 1 |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "inboundTransportation": { |
| | | "description": "入向运输", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "仓库名称", |
| | | "type": "string" |
| | | }, |
| | | "outboundTransportation": { |
| | | "description": "出库运输", |
| | | "type": "integer" |
| | | }, |
| | | "partnerId": { |
| | | "description": "合作伙伴id", |
| | | "type": "integer" |
| | | }, |
| | | "resupplyWhIds": { |
| | | "description": "补给来源仓库ID", |
| | | "type": "array", |
| | | "items": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/getWarehouseDetails/{id}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "仓库" |
| | | ], |
| | | "summary": "获取仓库详情", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "仓库id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.Response" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/models.Warehouse" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/updateWarehouse": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "仓库" |
| | | ], |
| | | "summary": "编辑仓库", |
| | | "parameters": [ |
| | | { |
| | | "description": "仓库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/models.Warehouse" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/warehouse": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | } |
| | | }, |
| | | "/api-wms/v1/warehouse/warehouse/{id}": { |
| | | "put": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "仓库" |
| | | ], |
| | | "summary": "编辑仓库", |
| | | "parameters": [ |
| | | { |
| | | "description": "仓库信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateWarehouse" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "仓库id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "TaskAndObject" |
| | | ] |
| | | }, |
| | | "constvar.ProductType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "Consumables": "消耗品", |
| | | "Server": "服务", |
| | | "StoredProduct": "可储存的产品" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "Consumables", |
| | | "Server", |
| | | "StoredProduct" |
| | | ] |
| | | }, |
| | | "constvar.ReservationMethod": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | }, |
| | | "parentId": { |
| | | "description": "上级id", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "replenishLocation": { |
| | | "description": "是否补充位置", |
| | |
| | | "categoryId": { |
| | | "description": "产品类别id", |
| | | "type": "integer" |
| | | }, |
| | | "categoryName": { |
| | | "description": "产品类别名称", |
| | | "type": "string" |
| | | }, |
| | | "companyId": { |
| | | "description": "公司id", |
| | |
| | | "type": "string" |
| | | }, |
| | | "invoicingStrategy": { |
| | | "description": "wms添加字段", |
| | | "description": "开票策略", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.InvoicingStrategy" |
| | |
| | | "productTagName": { |
| | | "description": "产品标签名称", |
| | | "type": "string" |
| | | }, |
| | | "productType": { |
| | | "description": "wms添加字段", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.ProductType" |
| | | } |
| | | ] |
| | | }, |
| | | "purchasePrice": { |
| | | "description": "采购价格", |
| | |
| | | "description": "入向运输", |
| | | "type": "integer" |
| | | }, |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "仓库名称", |
| | | "type": "string" |
| | |
| | | } |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouseLocation": { |
| | | "description": "库存位置", |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | }, |
| | | "inboundTransportation": { |
| | | "description": "入向运输", |
| | | "type": "integer" |
| | | }, |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | |
| | | "warehouseId": { |
| | | "description": "仓库id", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateWarehouse": { |
| | | "type": "object", |
| | | "required": [ |
| | | "code" |
| | | ], |
| | | "properties": { |
| | | "active": { |
| | | "description": "是否启用,传true就行", |
| | | "type": "boolean" |
| | | }, |
| | | "address": { |
| | | "description": "地址", |
| | | "type": "string" |
| | | }, |
| | | "buyToResupply": { |
| | | "description": "购买补给,已购买产品能够发送到此仓库", |
| | | "type": "boolean" |
| | | }, |
| | | "code": { |
| | | "description": "仓库编码", |
| | | "type": "string", |
| | | "maxLength": 5, |
| | | "minLength": 1 |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "inboundTransportation": { |
| | | "description": "入向运输", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "仓库名称", |
| | | "type": "string" |
| | | }, |
| | | "outboundTransportation": { |
| | | "description": "出库运输", |
| | | "type": "integer" |
| | | }, |
| | | "partnerId": { |
| | | "description": "合作伙伴id", |
| | | "type": "integer" |
| | | }, |
| | | "resupplyWhIds": { |
| | | "description": "补给来源仓库ID", |
| | | "type": "array", |
| | | "items": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | - Task |
| | | - Object |
| | | - TaskAndObject |
| | | constvar.ProductType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | type: integer |
| | | x-enum-comments: |
| | | Consumables: 消耗品 |
| | | Server: 服务 |
| | | StoredProduct: 可储存的产品 |
| | | x-enum-varnames: |
| | | - Consumables |
| | | - Server |
| | | - StoredProduct |
| | | constvar.ReservationMethod: |
| | | enum: |
| | | - 1 |
| | |
| | | type: string |
| | | parentId: |
| | | description: 上级id |
| | | type: integer |
| | | type: string |
| | | replenishLocation: |
| | | description: 是否补充位置 |
| | | type: boolean |
| | |
| | | categoryId: |
| | | description: 产品类别id |
| | | type: integer |
| | | categoryName: |
| | | description: 产品类别名称 |
| | | type: string |
| | | companyId: |
| | | description: 公司id |
| | | type: integer |
| | |
| | | invoicingStrategy: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.InvoicingStrategy' |
| | | description: wms添加字段 |
| | | description: 开票策略 |
| | | isSale: |
| | | description: PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:采购类型" |
| | | json:"purchaseType"` |
| | |
| | | productTagName: |
| | | description: 产品标签名称 |
| | | type: string |
| | | productType: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.ProductType' |
| | | description: wms添加字段 |
| | | purchasePrice: |
| | | description: 采购价格 |
| | | type: number |
| | |
| | | inboundTransportation: |
| | | description: 入向运输 |
| | | type: integer |
| | | locationId: |
| | | description: 位置id |
| | | type: integer |
| | | name: |
| | | description: 仓库名称 |
| | | type: string |
| | |
| | | type: string |
| | | type: array |
| | | updateTime: |
| | | type: string |
| | | warehouseLocation: |
| | | description: 库存位置 |
| | | type: string |
| | | required: |
| | | - code |
| | |
| | | type: string |
| | | inboundTransportation: |
| | | description: 入向运输 |
| | | type: integer |
| | | locationId: |
| | | description: 位置id |
| | | type: integer |
| | | name: |
| | | description: 仓库名称 |
| | |
| | | warehouseId: |
| | | description: 仓库id |
| | | type: integer |
| | | type: object |
| | | request.UpdateWarehouse: |
| | | properties: |
| | | active: |
| | | description: 是否启用,传true就行 |
| | | type: boolean |
| | | address: |
| | | description: 地址 |
| | | type: string |
| | | buyToResupply: |
| | | description: 购买补给,已购买产品能够发送到此仓库 |
| | | type: boolean |
| | | code: |
| | | description: 仓库编码 |
| | | maxLength: 5 |
| | | minLength: 1 |
| | | type: string |
| | | id: |
| | | type: integer |
| | | inboundTransportation: |
| | | description: 入向运输 |
| | | type: integer |
| | | name: |
| | | description: 仓库名称 |
| | | type: string |
| | | outboundTransportation: |
| | | description: 出库运输 |
| | | type: integer |
| | | partnerId: |
| | | description: 合作伙伴id |
| | | type: integer |
| | | resupplyWhIds: |
| | | description: 补给来源仓库ID |
| | | items: |
| | | type: string |
| | | type: array |
| | | required: |
| | | - code |
| | | type: object |
| | | util.Response: |
| | | properties: |
| | |
| | | summary: 修改产品类型 |
| | | tags: |
| | | - 产品类型 |
| | | /api-wms/v1/warehouse/getWarehouseDetails/{id}: |
| | | get: |
| | | parameters: |
| | | - description: 仓库id |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.Response' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/models.Warehouse' |
| | | type: object |
| | | summary: 获取仓库详情 |
| | | tags: |
| | | - 仓库 |
| | | /api-wms/v1/warehouse/updateWarehouse: |
| | | post: |
| | | parameters: |
| | | - description: 仓库信息 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/models.Warehouse' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 编辑仓库 |
| | | tags: |
| | | - 仓库 |
| | | /api-wms/v1/warehouse/warehouse: |
| | | get: |
| | | parameters: |
| | |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 删除仓库 |
| | | tags: |
| | | - 仓库 |
| | | put: |
| | | parameters: |
| | | - description: 仓库信息 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateWarehouse' |
| | | - description: 仓库id |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 编辑仓库 |
| | | tags: |
| | | - 仓库 |
| | | swagger: "2.0" |
| | |
| | | Location struct { |
| | | WmsModel |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:位置名称"` //位置名称 |
| | | ParentId int `json:"parentId" gorm:"type:int;not null"` //上级id |
| | | CompanyId int `json:"companyId" gorm:"type:int;not null"` //公司id |
| | | Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | Type constvar.LocationType `json:"type" gorm:"type:int(11);not null;comment:位置类型"` //位置类型 |
| | | CountFrequency int `json:"countFrequency" gorm:"type:tinyint;not null;comment:盘点频率(天)"` //盘点频率(天) |
| | | IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;not null;comment:是否报废位置"` //是否报废位置 |
| | | IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;not null;comment:是否退货位置"` //是否退货位置 |
| | | ReplenishLocation bool `json:"replenishLocation" gorm:"type:tinyint;not null;comment:是否补充位置"` //是否补充位置 |
| | | Name string `json:"name" gorm:"index;type:varchar(255);not null;comment:位置名称"` //位置名称 |
| | | ParentId string `json:"parentId" gorm:"type:varchar(255)"` //上级id |
| | | CompanyId int `json:"companyId" gorm:"type:int"` //公司id |
| | | Company Company `json:"company" gorm:"foreignKey:CompanyId"` //公司 |
| | | Type constvar.LocationType `json:"type" gorm:"type:int(11);comment:位置类型"` //位置类型 |
| | | CountFrequency int `json:"countFrequency" gorm:"type:tinyint;comment:盘点频率(天)"` //盘点频率(天) |
| | | IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;comment:是否报废位置"` //是否报废位置 |
| | | IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;comment:是否退货位置"` //是否退货位置 |
| | | ReplenishLocation bool `json:"replenishLocation" gorm:"type:tinyint;comment:是否补充位置"` //是否补充位置 |
| | | } |
| | | |
| | | LocationSearch struct { |
| | |
| | | Keyword string |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Parents []string |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) SetID(id uint) *LocationSearch { |
| | | slf.ID = id |
| | | func (slf *LocationSearch) SetID(id int) *LocationSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | func (slf *LocationSearch) SetParents(ids []string) *LocationSearch { |
| | | slf.Parents = ids |
| | | return slf |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *LocationSearch) SetParentId(parentId int) *LocationSearch { |
| | | func (slf *LocationSearch) SetParentId(parentId string) *LocationSearch { |
| | | slf.ParentId = parentId |
| | | return slf |
| | | } |
| | |
| | | } |
| | | |
| | | func (slf *LocationSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Location{}) |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | db = db.Where("type=?", slf.Type) |
| | | } |
| | | |
| | | if slf.ParentId != 0 { |
| | | if slf.ParentId != "" { |
| | | db = db.Where("parent_id=?", slf.ParentId) |
| | | } |
| | | if slf.CompanyId != 0 { |
| | | db = db.Where("company_id=?", slf.CompanyId) |
| | | } |
| | | if len(slf.Parents) != 0 { |
| | | db = db.Where("parent_id in (?)", slf.Parents) |
| | | } |
| | | |
| | | return db |
| | |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *LocationSearch) CreateReturnId(record *Location) (int, error) { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(record).Error; err != nil { |
| | | return 0, err |
| | | } |
| | | |
| | | return record.Id, nil |
| | | } |
| | | |
| | | // CreateBatch 批量插入 |
| | |
| | | |
| | | func (slf *LocationSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&Location{}).Error |
| | | return db.Unscoped().Delete(&Location{}).Error |
| | | } |
| | | |
| | | func (slf *LocationSearch) First() (*Location, error) { |
| | |
| | | records = make([]*Location, 0) |
| | | db = slf.build() |
| | | ) |
| | | if err := db.Find(&records); err != nil { |
| | | err := db.Find(&records) |
| | | if err != nil { |
| | | fmt.Println(err) |
| | | return records, fmt.Errorf("func FindAll err: %v", err) |
| | | } |
| | | return records, nil |
| | |
| | | SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:销售单价" json:"salePrice"` //销售单价 |
| | | AutoIncr uint `gorm:"type:int(11);comment:自增ID;default:0;" json:"-"` |
| | | //wms添加字段 |
| | | ProductType constvar.ProductType `gorm:"type:int(11);comment:产品类型" json:"productType"` //产品类型 |
| | | InvoicingStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:开票策略" json:"invoicingStrategy"` //开票策略 |
| | | OrderCreation constvar.OrderCreation `gorm:"type:int(11);comment:订单创建" json:"orderCreation"` //订单创建 |
| | | CustomerTaxes decimal.Decimal `gorm:"type:decimal(20,2);comment:客户税" json:"customerTaxes"` //客户税百分比 |
| | | Cost decimal.Decimal `gorm:"type:decimal(20,2);comment:成本" json:"cost"` //成本 |
| | | CategoryId int `gorm:"type:int(11);comment:产品类别id" json:"categoryId"` //产品类别id |
| | | CategoryName string `gorm:"type:varchar(255);comment:产品类别名称" json:"categoryName"` //产品类别名称 |
| | | InternalReference string `gorm:"type:varchar(255);comment:内部参考" json:"internalReference"` //内部参考 |
| | | Barcode string `gorm:"type:varchar(255);comment:条码" json:"barcode"` //条码 |
| | | ProductTagId int `gorm:"type:int(11);comment:产品标签id" json:"productTagId"` //产品标签id |
| | |
| | | Address string `json:"address" gorm:"type:varchar(512);comment:地址"` //地址 |
| | | InboundTransportation int `json:"inboundTransportation" gorm:"type:int;comment:入向运输"` //入向运输 |
| | | OutboundTransportation int `json:"outboundTransportation" gorm:"type:int;comment:出库运输"` //出库运输 |
| | | LocationId int `json:"locationId" gorm:"type:int;comment:位置id"` //位置id |
| | | WarehouseLocation string `json:"warehouseLocation" gorm:"-"` //库存位置 |
| | | } |
| | | |
| | | WarehouseSearch struct { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WarehouseSearch) SetID(id uint) *WarehouseSearch { |
| | | slf.ID = id |
| | | func (slf *WarehouseSearch) SetID(id int) *WarehouseSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | func (slf *WarehouseSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&Warehouse{}) |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | |
| | | |
| | | if slf.Preload { |
| | | db = db.Preload("Company") |
| | | } |
| | | if slf.Code != "" { |
| | | db = db.Where("code = ?", slf.Code) |
| | | } |
| | | |
| | | return db |
| | |
| | | |
| | | func (slf *WarehouseSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&Warehouse{}).Error |
| | | return db.Unscoped().Delete(&Warehouse{}).Error |
| | | } |
| | | |
| | | func (slf *WarehouseSearch) First() (*Warehouse, error) { |
| | |
| | | type LocationByType struct { |
| | | Type int `json:"type" form:"type"` |
| | | Keyword string `json:"keyword" form:"keyword"` |
| | | ParentId int `json:"parentId" form:"parentId"` |
| | | ParentId string `json:"parentId" form:"parentId"` |
| | | CompanyId int `json:"companyId" form:"companyId"` |
| | | } |
| | |
| | | Address string `json:"address" gorm:"type:varchar(512);comment:地址"` //地址 |
| | | InboundTransportation int `json:"inboundTransportation" gorm:"type:int;comment:入向运输"` //入向运输 |
| | | OutboundTransportation int `json:"outboundTransportation" gorm:"type:int;comment:出库运输"` //出库运输 |
| | | LocationId int `json:"locationId" gorm:"type:int;comment:位置id"` //位置id |
| | | } |
| | | |
| | | type UpdateWarehouse struct { |
| | |
| | | warehouseController := new(controllers.WarehouseController) |
| | | warehouseAPI := r.Group(urlPrefix + "/warehouse") |
| | | { |
| | | warehouseAPI.GET("warehouse", warehouseController.List) // 获取仓库列表 |
| | | warehouseAPI.POST("warehouse", warehouseController.Add) // 新增仓库 |
| | | warehouseAPI.PUT("warehouse/:id", warehouseController.Update) // 修改仓库 |
| | | warehouseAPI.DELETE("warehouse/:id", warehouseController.Delete) // 删除仓库 |
| | | warehouseAPI.GET("warehouse", warehouseController.List) // 获取仓库列表 |
| | | warehouseAPI.POST("warehouse", warehouseController.Add) // 新增仓库 |
| | | warehouseAPI.POST("updateWarehouse", warehouseController.UpdateWarehouse) // 修改仓库 |
| | | warehouseAPI.DELETE("warehouse/:id", warehouseController.Delete) // 删除仓库 |
| | | warehouseAPI.GET("getWarehouseDetails/:id", warehouseController.GetWarehouseDetails) // 获取仓库详情 |
| | | } |
| | | |
| | | // 作业类型 |