| | |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/mysqlx" |
| | | "wms/pkg/structx" |
| | | "wms/request" |
| | | ) |
| | | |
| | |
| | | } |
| | | util.ResponseFormatList(c, code.Success, dicts, int(total)) |
| | | } |
| | | |
| | | // SaveUnitDict |
| | | // |
| | | // @Tags 数据字典 |
| | | // @Summary 更新计量单位字典 |
| | | // @Produce application/json |
| | | // @Param object body request.SaveUnitDict true "参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/product/saveUnitDict [post] |
| | | func (slf ProductController) SaveUnitDict(c *gin.Context) { |
| | | var reqParams request.SaveUnitDict |
| | | var params []*models.UnitDict |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if err := structx.AssignTo(reqParams.Data, ¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "数据转换错误") |
| | | return |
| | | } |
| | | |
| | | for i, v := range params { |
| | | if len(v.Name) == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "名称为空") |
| | | return |
| | | } |
| | | v.Sort = i + 1 |
| | | } |
| | | |
| | | err := models.WithTransaction(func(tx *gorm.DB) error { |
| | | err := models.NewUnitDictSearch().SetOrm(tx).Delete() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | err = models.NewUnitDictSearch().SetOrm(tx).CreateBatch(params) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | return nil |
| | | }) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "添加成功") |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/saveUnitDict": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "数据字典" |
| | | ], |
| | | "summary": "更新计量单位字典", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SaveUnitDict" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/updateDisuse": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "MaterialModeVirtual" |
| | | ] |
| | | }, |
| | | "constvar.OperationSource": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5, |
| | | 6 |
| | | ], |
| | | "x-enum-comments": { |
| | | "OperationSourceOutsourcing": "委外入库", |
| | | "OperationSourceOutsourcingApply": "委外领料", |
| | | "OperationSourceProduction": "生产入库", |
| | | "OperationSourceProductionApply": "生产领料", |
| | | "OperationSourcePurchase": "采购入库", |
| | | "OperationSourceSaleDelivery": "销售发货" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "OperationSourcePurchase", |
| | | "OperationSourceProduction", |
| | | "OperationSourceOutsourcing", |
| | | "OperationSourceProductionApply", |
| | | "OperationSourceOutsourcingApply", |
| | | "OperationSourceSaleDelivery" |
| | | ] |
| | | }, |
| | | "constvar.OperationStatus": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouse": { |
| | | "description": "仓库", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Warehouse" |
| | | } |
| | | ] |
| | | }, |
| | | "warehouseId": { |
| | | "description": "仓库ID", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "description": "FromLocationID int ` + "`" + `json:\"fromLocationId\" gorm:\"type:int;not null;comment:源位置id\"` + "`" + ` //源位置id\nFromLocation Location ` + "`" + `json:\"fromLocation\" gorm:\"foreignKey:FromLocationID;references:Id\"` + "`" + ` //源位置\nToLocationID int ` + "`" + `json:\"toLocationId\" gorm:\"type:int;not null;comment:目标位置id\"` + "`" + ` //目标位置id\nToLocation Location ` + "`" + `json:\"toLocation\" gorm:\"foreignKey:ToLocationID;references:Id\"` + "`" + ` //目标位置", |
| | | "type": "string" |
| | | }, |
| | | "operationSource": { |
| | | "description": "操作来源", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.OperationSource" |
| | | } |
| | | ] |
| | | }, |
| | | "operationTypeId": { |
| | | "description": "作业类型id", |
| | | "type": "integer" |
| | |
| | | "type": "string" |
| | | }, |
| | | "receiverPhone": { |
| | | "type": "string" |
| | | }, |
| | | "salesDetailsNumber": { |
| | | "type": "string" |
| | | }, |
| | | "source": { |
| | |
| | | }, |
| | | "models.Warehouse": { |
| | | "type": "object", |
| | | "required": [ |
| | | "code" |
| | | ], |
| | | "properties": { |
| | | "active": { |
| | | "description": "是否启用,传true就行", |
| | |
| | | }, |
| | | "code": { |
| | | "description": "仓库编码", |
| | | "type": "string", |
| | | "maxLength": 5, |
| | | "minLength": 1 |
| | | "type": "string" |
| | | }, |
| | | "company": { |
| | | "$ref": "#/definitions/models.Company" |
| | |
| | | "type": "integer" |
| | | }, |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "description": "默认位置id", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SaveUnitDict": { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UnitDict" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UnitDict": { |
| | | "type": "object", |
| | | "properties": { |
| | | "isDefault": { |
| | | "type": "boolean" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCompany": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/saveUnitDict": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "数据字典" |
| | | ], |
| | | "summary": "更新计量单位字典", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SaveUnitDict" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/product/updateDisuse": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | "MaterialModeVirtual" |
| | | ] |
| | | }, |
| | | "constvar.OperationSource": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5, |
| | | 6 |
| | | ], |
| | | "x-enum-comments": { |
| | | "OperationSourceOutsourcing": "委外入库", |
| | | "OperationSourceOutsourcingApply": "委外领料", |
| | | "OperationSourceProduction": "生产入库", |
| | | "OperationSourceProductionApply": "生产领料", |
| | | "OperationSourcePurchase": "采购入库", |
| | | "OperationSourceSaleDelivery": "销售发货" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "OperationSourcePurchase", |
| | | "OperationSourceProduction", |
| | | "OperationSourceOutsourcing", |
| | | "OperationSourceProductionApply", |
| | | "OperationSourceOutsourcingApply", |
| | | "OperationSourceSaleDelivery" |
| | | ] |
| | | }, |
| | | "constvar.OperationStatus": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | }, |
| | | "updateTime": { |
| | | "type": "string" |
| | | }, |
| | | "warehouse": { |
| | | "description": "仓库", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Warehouse" |
| | | } |
| | | ] |
| | | }, |
| | | "warehouseId": { |
| | | "description": "仓库ID", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "description": "FromLocationID int `json:\"fromLocationId\" gorm:\"type:int;not null;comment:源位置id\"` //源位置id\nFromLocation Location `json:\"fromLocation\" gorm:\"foreignKey:FromLocationID;references:Id\"` //源位置\nToLocationID int `json:\"toLocationId\" gorm:\"type:int;not null;comment:目标位置id\"` //目标位置id\nToLocation Location `json:\"toLocation\" gorm:\"foreignKey:ToLocationID;references:Id\"` //目标位置", |
| | | "type": "string" |
| | | }, |
| | | "operationSource": { |
| | | "description": "操作来源", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.OperationSource" |
| | | } |
| | | ] |
| | | }, |
| | | "operationTypeId": { |
| | | "description": "作业类型id", |
| | | "type": "integer" |
| | |
| | | "type": "string" |
| | | }, |
| | | "receiverPhone": { |
| | | "type": "string" |
| | | }, |
| | | "salesDetailsNumber": { |
| | | "type": "string" |
| | | }, |
| | | "source": { |
| | |
| | | }, |
| | | "models.Warehouse": { |
| | | "type": "object", |
| | | "required": [ |
| | | "code" |
| | | ], |
| | | "properties": { |
| | | "active": { |
| | | "description": "是否启用,传true就行", |
| | |
| | | }, |
| | | "code": { |
| | | "description": "仓库编码", |
| | | "type": "string", |
| | | "maxLength": 5, |
| | | "minLength": 1 |
| | | "type": "string" |
| | | }, |
| | | "company": { |
| | | "$ref": "#/definitions/models.Company" |
| | |
| | | "type": "integer" |
| | | }, |
| | | "locationId": { |
| | | "description": "位置id", |
| | | "description": "默认位置id", |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SaveUnitDict": { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/request.UnitDict" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.UnitDict": { |
| | | "type": "object", |
| | | "properties": { |
| | | "isDefault": { |
| | | "type": "boolean" |
| | | }, |
| | | "name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateCompany": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | - MaterialModeConsumables |
| | | - MaterialModeOther |
| | | - MaterialModeVirtual |
| | | constvar.OperationSource: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | - 6 |
| | | type: integer |
| | | x-enum-comments: |
| | | OperationSourceOutsourcing: 委外入库 |
| | | OperationSourceOutsourcingApply: 委外领料 |
| | | OperationSourceProduction: 生产入库 |
| | | OperationSourceProductionApply: 生产领料 |
| | | OperationSourcePurchase: 采购入库 |
| | | OperationSourceSaleDelivery: 销售发货 |
| | | x-enum-varnames: |
| | | - OperationSourcePurchase |
| | | - OperationSourceProduction |
| | | - OperationSourceOutsourcing |
| | | - OperationSourceProductionApply |
| | | - OperationSourceOutsourcingApply |
| | | - OperationSourceSaleDelivery |
| | | constvar.OperationStatus: |
| | | enum: |
| | | - 1 |
| | |
| | | gorm:"foreignKey:CompanyId"` //公司 |
| | | updateTime: |
| | | type: string |
| | | warehouse: |
| | | allOf: |
| | | - $ref: '#/definitions/models.Warehouse' |
| | | description: 仓库 |
| | | warehouseId: |
| | | description: 仓库ID |
| | | type: integer |
| | | type: object |
| | | models.LogisticCompany: |
| | | properties: |
| | |
| | | ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:目标位置id"` //目标位置id |
| | | ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //目标位置 |
| | | type: string |
| | | operationSource: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.OperationSource' |
| | | description: 操作来源 |
| | | operationTypeId: |
| | | description: 作业类型id |
| | | type: integer |
| | |
| | | receiverName: |
| | | type: string |
| | | receiverPhone: |
| | | type: string |
| | | salesDetailsNumber: |
| | | type: string |
| | | source: |
| | | type: string |
| | |
| | | type: boolean |
| | | code: |
| | | description: 仓库编码 |
| | | maxLength: 5 |
| | | minLength: 1 |
| | | type: string |
| | | company: |
| | | $ref: '#/definitions/models.Company' |
| | |
| | | description: 入向运输 |
| | | type: integer |
| | | locationId: |
| | | description: 位置id |
| | | description: 默认位置id |
| | | type: integer |
| | | name: |
| | | description: 仓库名称 |
| | |
| | | warehouseLocation: |
| | | description: 库存位置 |
| | | type: string |
| | | required: |
| | | - code |
| | | type: object |
| | | request.AddCompany: |
| | | properties: |
| | |
| | | description: 每页大小 |
| | | type: integer |
| | | productId: |
| | | type: string |
| | | type: object |
| | | request.SaveUnitDict: |
| | | properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/request.UnitDict' |
| | | type: array |
| | | type: object |
| | | request.UnitDict: |
| | | properties: |
| | | isDefault: |
| | | type: boolean |
| | | name: |
| | | type: string |
| | | type: object |
| | | request.UpdateCompany: |
| | |
| | | summary: 产品历史出入库信息 |
| | | tags: |
| | | - 产品 |
| | | /api-wms/v1/product/saveUnitDict: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.SaveUnitDict' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 更新计量单位字典 |
| | | tags: |
| | | - 数据字典 |
| | | /api-wms/v1/product/updateDisuse: |
| | | post: |
| | | parameters: |
| | |
| | | ProductId string `gorm:"column:product_id"` |
| | | TotalAmount decimal.Decimal `gorm:"column:total_amount"` |
| | | } |
| | | |
| | | type UnitDict struct { |
| | | Name string `gorm:"unique;type:varchar(191);not null;comment:名称" json:"name"` |
| | | IsDefault bool `gorm:"type:tinyint(1);comment:是否默认" json:"isDefault"` |
| | | } |
| | | |
| | | type SaveUnitDict struct { |
| | | Data []*UnitDict `json:"data"` |
| | | } |
| | |
| | | productAPI.PUT("cancelDisuse/:id", productController.CancelDisuse) //取消报废 |
| | | productAPI.GET("getUserInfo", productController.GetUserInfo) //获取登录用户信息 |
| | | productAPI.GET("getUnitInfo", productController.GetUnitInfo) //获取单位信息 |
| | | productAPI.POST("saveUnitDict", productController.SaveUnitDict) //更新计量单位字典 |
| | | |
| | | } |
| | | |