Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
New file |
| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/spf13/cast" |
| | | "google.golang.org/grpc" |
| | | "google.golang.org/grpc/credentials/insecure" |
| | | "wms/conf" |
| | | cd "wms/extend/code" |
| | | "wms/extend/util" |
| | | "wms/models" |
| | | "wms/pkg/contextx" |
| | | "wms/pkg/logx" |
| | | "wms/proto/code" |
| | | "wms/request" |
| | | ) |
| | | |
| | | type CodeApi struct{} |
| | | |
| | | var ( |
| | | codeServiceConn *grpc.ClientConn |
| | | ) |
| | | |
| | | func InitCodeServiceConn() { |
| | | var err error |
| | | codeServiceConn, err = grpc.Dial(conf.GrpcServerConf.ApsAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) |
| | | if err != nil { |
| | | logx.Errorf("grpc dial product service error: %v", err.Error()) |
| | | return |
| | | } |
| | | } |
| | | |
| | | func CloseCodeServiceConn() { |
| | | if codeServiceConn != nil { |
| | | codeServiceConn.Close() |
| | | } |
| | | } |
| | | |
| | | // GetCodeList |
| | | // |
| | | // @Tags 编码 |
| | | // @Summary 获取编码列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetCodeList true "参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]code.CodeStandard} |
| | | // |
| | | // @Router /api-wms/v1/code/getCodeList [get] |
| | | func (ca *CodeApi) GetCodeList(c *gin.Context) { |
| | | var params request.GetCodeList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | params.CodeStandID = c.Query("codeStandID") |
| | | params.Name = c.Query("name") |
| | | params.Type = c.Query("type") |
| | | client := code.NewCodeServiceClient(codeServiceConn) |
| | | list, err := client.GetCodeList(ctx.GetCtx(), &code.GetCodeListRequest{ |
| | | Page: cast.ToInt32(params.Page), |
| | | PageSize: cast.ToInt32(params.PageSize), |
| | | CodeStandID: params.CodeStandID, |
| | | Name: params.Name, |
| | | Type: params.Type, |
| | | }) |
| | | if err != nil { |
| | | logx.Errorf("GetCodeList err: %v", err.Error()) |
| | | util.ResponseFormat(c, cd.RequestParamError, "产品名称不能为空") |
| | | return |
| | | } |
| | | util.ResponseFormatList(c, cd.Success, list.List, int(list.Total)) |
| | | } |
| | | |
| | | // GetAutoCode |
| | | // |
| | | // @Tags 编码 |
| | | // @Summary 获取自动编码 |
| | | // @Produce application/json |
| | | // @Param object body code.CodeStandard true "参数" |
| | | // @Success 200 {object} util.ResponseList{data=map[string]interface{}} |
| | | // |
| | | // @Router /api-wms/v1/code/getAutoCode [post] |
| | | func (ca *CodeApi) GetAutoCode(c *gin.Context) { |
| | | var params code.CodeStandard |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | var ( |
| | | id = 0 |
| | | err error |
| | | ) |
| | | switch params.Type { |
| | | case "物料编码": |
| | | id, err = models.NewMaterialSearch().MaxAutoIncr() |
| | | default: |
| | | util.ResponseFormat(c, cd.RequestError, "编码规则不存在") |
| | | return |
| | | } |
| | | if err != nil { |
| | | util.ResponseFormat(c, cd.RequestError, "获取最大值失败") |
| | | return |
| | | } |
| | | m := make(map[string]interface{}) |
| | | autoCode := models.GetAutoCode(id, ¶ms) |
| | | m["id"] = autoCode |
| | | m["codeStandardID"] = params.ID |
| | | m["maxAutoIncr"] = id + 1 |
| | | ctx.OkWithDetailed(m) |
| | | } |
| | |
| | | "wms/models" |
| | | "wms/pkg/logx" |
| | | "wms/request" |
| | | "wms/utils" |
| | | ) |
| | | |
| | | type ProductController struct { |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if params.ID == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品编码不能为空") |
| | | return |
| | | } |
| | | if params.Name == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品名称不能为空") |
| | | return |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, "单位不能为空") |
| | | return |
| | | } |
| | | params.ID = utils.GetUUID() |
| | | //params.ID = utils.GetUUID() |
| | | err := models.NewMaterialSearch().Create(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "产品信息保存失败") |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/code/getAutoCode": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "编码" |
| | | ], |
| | | "summary": "获取自动编码", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/code.CodeStandard" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/code/getCodeList": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "编码" |
| | | ], |
| | | "summary": "获取编码列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "codeStandID", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "name", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "type", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/code.CodeStandard" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/company/company": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | } |
| | | }, |
| | | "definitions": { |
| | | "code.CodeAuto": { |
| | | "type": "object", |
| | | "properties": { |
| | | "AutoLength": { |
| | | "type": "integer" |
| | | }, |
| | | "Desc": { |
| | | "type": "string" |
| | | }, |
| | | "PrefixMethod": { |
| | | "type": "integer" |
| | | }, |
| | | "PrefixValue": { |
| | | "type": "string" |
| | | }, |
| | | "SuffixMethod": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "code.CodeRule": { |
| | | "type": "object", |
| | | "properties": { |
| | | "Desc": { |
| | | "type": "string" |
| | | }, |
| | | "Length": { |
| | | "type": "integer" |
| | | }, |
| | | "Name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "code.CodeStandard": { |
| | | "type": "object", |
| | | "properties": { |
| | | "AutoRule": { |
| | | "$ref": "#/definitions/code.CodeAuto" |
| | | }, |
| | | "ID": { |
| | | "type": "string" |
| | | }, |
| | | "List": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/code.CodeRule" |
| | | } |
| | | }, |
| | | "Method": { |
| | | "type": "integer" |
| | | }, |
| | | "Name": { |
| | | "type": "string" |
| | | }, |
| | | "Status": { |
| | | "type": "string" |
| | | }, |
| | | "Type": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "constvar.BaseOperationType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | "Consumables", |
| | | "Server", |
| | | "StoredProduct" |
| | | ] |
| | | }, |
| | | "constvar.PurchaseType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "PurchaseTypeEntrust": "委外", |
| | | "PurchaseTypeOutSource": "采购", |
| | | "PurchaseTypeSelf": "自制" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "PurchaseTypeOutSource", |
| | | "PurchaseTypeSelf", |
| | | "PurchaseTypeEntrust" |
| | | ] |
| | | }, |
| | | "constvar.ReservationMethod": { |
| | |
| | | "$ref": "#/definitions/models.Attachment" |
| | | } |
| | | }, |
| | | "autoIncr": { |
| | | "type": "integer" |
| | | }, |
| | | "barcode": { |
| | | "description": "条码", |
| | | "type": "string" |
| | |
| | | }, |
| | | "categoryName": { |
| | | "description": "产品类别名称", |
| | | "type": "string" |
| | | }, |
| | | "codeStandardID": { |
| | | "description": "Explain string ` + "`" + `gorm:\"type:varchar(512);comment:编号说明\" json:\"explain\"` + "`" + `", |
| | | "type": "string" |
| | | }, |
| | | "companyId": { |
| | |
| | | ] |
| | | }, |
| | | "isSale": { |
| | | "description": "PurchaseType constvar.PurchaseType ` + "`" + `gorm:\"type:int(11);comment:采购类型\" json:\"purchaseType\"` + "`" + `", |
| | | "description": "是否销售", |
| | | "type": "boolean" |
| | | }, |
| | | "makeAdvanceTime": { |
| | |
| | | "type": "number" |
| | | }, |
| | | "minInventory": { |
| | | "description": "Explain string ` + "`" + `gorm:\"type:varchar(512);comment:编号说明\" json:\"explain\"` + "`" + `\nCodeStandardID string ` + "`" + `gorm:\"type:varchar(191);comment:编码规范ID\" json:\"codeStandardID\"` + "`" + `\nSpecs string ` + "`" + `gorm:\"type:varchar(191);comment:物料规格\" json:\"specs\"` + "`" + `\nType string ` + "`" + `gorm:\"type:varchar(191);comment:物料型号\" json:\"type\"` + "`" + `", |
| | | "description": "最小库存", |
| | | "type": "number" |
| | | }, |
| | | "minPurchaseAmount": { |
| | |
| | | }, |
| | | "name": { |
| | | "description": "物料名称", |
| | | "type": "string" |
| | | }, |
| | | "note": { |
| | | "type": "string" |
| | | }, |
| | | "orderAdvanceTime": { |
| | |
| | | "description": "采购价格", |
| | | "type": "number" |
| | | }, |
| | | "purchaseType": { |
| | | "$ref": "#/definitions/constvar.PurchaseType" |
| | | }, |
| | | "salePrice": { |
| | | "description": "销售单价", |
| | | "type": "number" |
| | |
| | | "description": "销售说明", |
| | | "type": "string" |
| | | }, |
| | | "specs": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "description": "FSource string ` + "`" + `gorm:\"type:varchar(191);comment:生产车间\" json:\"-\"` + "`" + `\nStatus constvar.MaterialStatus ` + "`" + `gorm:\"type:int(11);comment:状态\" json:\"status\"` + "`" + `", |
| | | "type": "string" |
| | | }, |
| | | "templateID": { |
| | | "description": "Note string ` + "`" + `gorm:\"type:varchar(1024);comment:备注\" json:\"note\"` + "`" + `", |
| | | "description": "模板ID", |
| | | "type": "string" |
| | | }, |
| | | "type": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/code/getAutoCode": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "编码" |
| | | ], |
| | | "summary": "获取自动编码", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/code.CodeStandard" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/code/getCodeList": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "编码" |
| | | ], |
| | | "summary": "获取编码列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "codeStandID", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "name", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "name": "type", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "OK", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/code.CodeStandard" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/company/company": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | } |
| | | }, |
| | | "definitions": { |
| | | "code.CodeAuto": { |
| | | "type": "object", |
| | | "properties": { |
| | | "AutoLength": { |
| | | "type": "integer" |
| | | }, |
| | | "Desc": { |
| | | "type": "string" |
| | | }, |
| | | "PrefixMethod": { |
| | | "type": "integer" |
| | | }, |
| | | "PrefixValue": { |
| | | "type": "string" |
| | | }, |
| | | "SuffixMethod": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "code.CodeRule": { |
| | | "type": "object", |
| | | "properties": { |
| | | "Desc": { |
| | | "type": "string" |
| | | }, |
| | | "Length": { |
| | | "type": "integer" |
| | | }, |
| | | "Name": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "code.CodeStandard": { |
| | | "type": "object", |
| | | "properties": { |
| | | "AutoRule": { |
| | | "$ref": "#/definitions/code.CodeAuto" |
| | | }, |
| | | "ID": { |
| | | "type": "string" |
| | | }, |
| | | "List": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/code.CodeRule" |
| | | } |
| | | }, |
| | | "Method": { |
| | | "type": "integer" |
| | | }, |
| | | "Name": { |
| | | "type": "string" |
| | | }, |
| | | "Status": { |
| | | "type": "string" |
| | | }, |
| | | "Type": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "constvar.BaseOperationType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | |
| | | "Consumables", |
| | | "Server", |
| | | "StoredProduct" |
| | | ] |
| | | }, |
| | | "constvar.PurchaseType": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | | 2, |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "PurchaseTypeEntrust": "委外", |
| | | "PurchaseTypeOutSource": "采购", |
| | | "PurchaseTypeSelf": "自制" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "PurchaseTypeOutSource", |
| | | "PurchaseTypeSelf", |
| | | "PurchaseTypeEntrust" |
| | | ] |
| | | }, |
| | | "constvar.ReservationMethod": { |
| | |
| | | "$ref": "#/definitions/models.Attachment" |
| | | } |
| | | }, |
| | | "autoIncr": { |
| | | "type": "integer" |
| | | }, |
| | | "barcode": { |
| | | "description": "条码", |
| | | "type": "string" |
| | |
| | | }, |
| | | "categoryName": { |
| | | "description": "产品类别名称", |
| | | "type": "string" |
| | | }, |
| | | "codeStandardID": { |
| | | "description": "Explain string `gorm:\"type:varchar(512);comment:编号说明\" json:\"explain\"`", |
| | | "type": "string" |
| | | }, |
| | | "companyId": { |
| | |
| | | ] |
| | | }, |
| | | "isSale": { |
| | | "description": "PurchaseType constvar.PurchaseType `gorm:\"type:int(11);comment:采购类型\" json:\"purchaseType\"`", |
| | | "description": "是否销售", |
| | | "type": "boolean" |
| | | }, |
| | | "makeAdvanceTime": { |
| | |
| | | "type": "number" |
| | | }, |
| | | "minInventory": { |
| | | "description": "Explain string `gorm:\"type:varchar(512);comment:编号说明\" json:\"explain\"`\nCodeStandardID string `gorm:\"type:varchar(191);comment:编码规范ID\" json:\"codeStandardID\"`\nSpecs string `gorm:\"type:varchar(191);comment:物料规格\" json:\"specs\"`\nType string `gorm:\"type:varchar(191);comment:物料型号\" json:\"type\"`", |
| | | "description": "最小库存", |
| | | "type": "number" |
| | | }, |
| | | "minPurchaseAmount": { |
| | |
| | | }, |
| | | "name": { |
| | | "description": "物料名称", |
| | | "type": "string" |
| | | }, |
| | | "note": { |
| | | "type": "string" |
| | | }, |
| | | "orderAdvanceTime": { |
| | |
| | | "description": "采购价格", |
| | | "type": "number" |
| | | }, |
| | | "purchaseType": { |
| | | "$ref": "#/definitions/constvar.PurchaseType" |
| | | }, |
| | | "salePrice": { |
| | | "description": "销售单价", |
| | | "type": "number" |
| | |
| | | "description": "销售说明", |
| | | "type": "string" |
| | | }, |
| | | "specs": { |
| | | "type": "string" |
| | | }, |
| | | "supplier": { |
| | | "description": "FSource string `gorm:\"type:varchar(191);comment:生产车间\" json:\"-\"`\nStatus constvar.MaterialStatus `gorm:\"type:int(11);comment:状态\" json:\"status\"`", |
| | | "type": "string" |
| | | }, |
| | | "templateID": { |
| | | "description": "Note string `gorm:\"type:varchar(1024);comment:备注\" json:\"note\"`", |
| | | "description": "模板ID", |
| | | "type": "string" |
| | | }, |
| | | "type": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | |
| | | definitions: |
| | | code.CodeAuto: |
| | | properties: |
| | | AutoLength: |
| | | type: integer |
| | | Desc: |
| | | type: string |
| | | PrefixMethod: |
| | | type: integer |
| | | PrefixValue: |
| | | type: string |
| | | SuffixMethod: |
| | | type: integer |
| | | type: object |
| | | code.CodeRule: |
| | | properties: |
| | | Desc: |
| | | type: string |
| | | Length: |
| | | type: integer |
| | | Name: |
| | | type: string |
| | | type: object |
| | | code.CodeStandard: |
| | | properties: |
| | | AutoRule: |
| | | $ref: '#/definitions/code.CodeAuto' |
| | | ID: |
| | | type: string |
| | | List: |
| | | items: |
| | | $ref: '#/definitions/code.CodeRule' |
| | | type: array |
| | | Method: |
| | | type: integer |
| | | Name: |
| | | type: string |
| | | Status: |
| | | type: string |
| | | Type: |
| | | type: string |
| | | type: object |
| | | constvar.BaseOperationType: |
| | | enum: |
| | | - 1 |
| | |
| | | - Consumables |
| | | - Server |
| | | - StoredProduct |
| | | constvar.PurchaseType: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | | - 3 |
| | | type: integer |
| | | x-enum-comments: |
| | | PurchaseTypeEntrust: 委外 |
| | | PurchaseTypeOutSource: 采购 |
| | | PurchaseTypeSelf: 自制 |
| | | x-enum-varnames: |
| | | - PurchaseTypeOutSource |
| | | - PurchaseTypeSelf |
| | | - PurchaseTypeEntrust |
| | | constvar.ReservationMethod: |
| | | enum: |
| | | - 1 |
| | |
| | | items: |
| | | $ref: '#/definitions/models.Attachment' |
| | | type: array |
| | | autoIncr: |
| | | type: integer |
| | | barcode: |
| | | description: 条码 |
| | | type: string |
| | |
| | | type: integer |
| | | categoryName: |
| | | description: 产品类别名称 |
| | | type: string |
| | | codeStandardID: |
| | | description: Explain string `gorm:"type:varchar(512);comment:编号说明" |
| | | json:"explain"` |
| | | type: string |
| | | companyId: |
| | | description: 公司id |
| | |
| | | - $ref: '#/definitions/constvar.InvoicingStrategy' |
| | | description: 开票策略 |
| | | isSale: |
| | | description: PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:采购类型" |
| | | json:"purchaseType"` |
| | | description: 是否销售 |
| | | type: boolean |
| | | makeAdvanceTime: |
| | | description: 制造前置时间(天) |
| | |
| | | description: 最大库存 |
| | | type: number |
| | | minInventory: |
| | | description: |- |
| | | Explain string `gorm:"type:varchar(512);comment:编号说明" json:"explain"` |
| | | CodeStandardID string `gorm:"type:varchar(191);comment:编码规范ID" json:"codeStandardID"` |
| | | Specs string `gorm:"type:varchar(191);comment:物料规格" json:"specs"` |
| | | Type string `gorm:"type:varchar(191);comment:物料型号" json:"type"` |
| | | description: 最小库存 |
| | | type: number |
| | | minPurchaseAmount: |
| | | description: |- |
| | |
| | | json:"materialType"` |
| | | name: |
| | | description: 物料名称 |
| | | type: string |
| | | note: |
| | | type: string |
| | | orderAdvanceTime: |
| | | description: 订单准备天数(天) |
| | |
| | | purchasePrice: |
| | | description: 采购价格 |
| | | type: number |
| | | purchaseType: |
| | | $ref: '#/definitions/constvar.PurchaseType' |
| | | salePrice: |
| | | description: 销售单价 |
| | | type: number |
| | |
| | | sellExplain: |
| | | description: 销售说明 |
| | | type: string |
| | | specs: |
| | | type: string |
| | | supplier: |
| | | description: |- |
| | | FSource string `gorm:"type:varchar(191);comment:生产车间" json:"-"` |
| | | Status constvar.MaterialStatus `gorm:"type:int(11);comment:状态" json:"status"` |
| | | type: string |
| | | templateID: |
| | | description: Note string `gorm:"type:varchar(1024);comment:备注" |
| | | json:"note"` |
| | | description: 模板ID |
| | | type: string |
| | | type: |
| | | type: string |
| | | unit: |
| | | description: LockAmount decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:锁定数量" |
| | |
| | | summary: 上传附件 |
| | | tags: |
| | | - 附件管理 |
| | | /api-wms/v1/code/getAutoCode: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/code.CodeStandard' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | additionalProperties: true |
| | | type: object |
| | | type: object |
| | | summary: 获取自动编码 |
| | | tags: |
| | | - 编码 |
| | | /api-wms/v1/code/getCodeList: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | | name: codeStandID |
| | | type: string |
| | | - in: query |
| | | name: name |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | - in: query |
| | | name: type |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: OK |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/code.CodeStandard' |
| | | type: array |
| | | type: object |
| | | summary: 获取编码列表 |
| | | tags: |
| | | - 编码 |
| | | /api-wms/v1/company/company: |
| | | get: |
| | | parameters: |
| | |
| | | //启动grpc客户端 |
| | | go controllers.InitInventoryOrderServiceConn() |
| | | go controllers.InitProductInventoryServiceConn() |
| | | go controllers.InitCodeServiceConn() |
| | | //启动grpc服务 |
| | | go func() { |
| | | ln, err := net.Listen("tcp", ":"+conf.WebConf.GrpcPort) |
| | |
| | | |
| | | controllers.CloseInventoryOrderServiceConn() |
| | | controllers.CloseProductInventoryServiceConn() |
| | | controllers.CloseCodeServiceConn() |
| | | // 关闭HTTP服务器 |
| | | if err := server.Shutdown(ctx); err != nil { |
| | | logx.Infof("服务优雅退出失败: %v", err) |
| | |
| | | import ( |
| | | "fmt" |
| | | "gorm.io/gorm/schema" |
| | | "strconv" |
| | | "time" |
| | | "wms/conf" |
| | | "wms/extend/util" |
| | | "wms/pkg/logx" |
| | | "wms/pkg/mysqlx" |
| | | "wms/pkg/snowflake" |
| | | "wms/proto/code" |
| | | |
| | | "gorm.io/gorm" |
| | | ) |
| | |
| | | return nil |
| | | } |
| | | |
| | | func GetAutoCode(id int, codeStandard *code.CodeStandard) string { |
| | | autoCode := "" |
| | | var prefixValue string |
| | | if codeStandard.AutoRule.PrefixMethod == 2 { // 来源单据 |
| | | prefixValue = "" |
| | | } else { // 固定值 |
| | | prefixValue = codeStandard.AutoRule.PrefixValue |
| | | } |
| | | strMaxAutoIncr := strconv.Itoa(id + 1) |
| | | count := int(codeStandard.AutoRule.AutoLength) - len(strMaxAutoIncr) |
| | | for i := 0; i < count; i++ { |
| | | strMaxAutoIncr = "0" + strMaxAutoIncr |
| | | } |
| | | |
| | | var suffixValue string |
| | | if codeStandard.AutoRule.SuffixMethod == 2 { // 年月日+自增长 |
| | | suffixValue = fmt.Sprintf("%v%v", time.Now().Format("20060102"), strMaxAutoIncr) |
| | | } else { // 自增长 |
| | | suffixValue = strMaxAutoIncr |
| | | } |
| | | |
| | | autoCode = prefixValue + suffixValue |
| | | return autoCode |
| | | } |
| | | |
| | | func Init() error { |
| | | fmt.Printf("dsn=%v\n", conf.DbConf.Dsn) |
| | | if err := mysqlx.Init(conf.DbConf, logx.GetLogger()); err != nil { |
| | |
| | | //MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:物料类型(数字)" json:"materialType"` |
| | | Model constvar.MaterialMode `gorm:"type:varchar(191);not null;comment:物料类型(字符串)" json:"model"` //物料类型(字符串) |
| | | //Explain string `gorm:"type:varchar(512);comment:编号说明" json:"explain"` |
| | | //CodeStandardID string `gorm:"type:varchar(191);comment:编码规范ID" json:"codeStandardID"` |
| | | //Specs string `gorm:"type:varchar(191);comment:物料规格" json:"specs"` |
| | | //Type string `gorm:"type:varchar(191);comment:物料型号" json:"type"` |
| | | CodeStandardID string `gorm:"type:varchar(191);comment:编码规范ID" json:"codeStandardID"` |
| | | Specs string `gorm:"type:varchar(191);comment:物料规格" json:"specs"` |
| | | Type string `gorm:"type:varchar(191);comment:物料型号" json:"type"` |
| | | MinInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:最小库存" json:"minInventory"` //最小库存 |
| | | MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:最大库存" json:"maxInventory"` //最大库存 |
| | | Amount decimal.Decimal `gorm:"type:decimal(35,18);comment:数量" json:"amount"` //数量 |
| | | //LockAmount decimal.Decimal `gorm:"type:decimal(35,18);default:0;comment:锁定数量" json:"lockAmount"` |
| | | Unit string `gorm:"type:varchar(100);comment:单位" json:"unit"` //单位 |
| | | //Note string `gorm:"type:varchar(1024);comment:备注" json:"note"` |
| | | Note string `gorm:"type:varchar(1024);comment:备注" json:"note"` |
| | | TemplateID string `gorm:"type:varchar(191);comment:模板ID" json:"templateID"` //模板ID |
| | | //FSource string `gorm:"type:varchar(191);comment:生产车间" json:"-"` |
| | | //Status constvar.MaterialStatus `gorm:"type:int(11);comment:状态" json:"status"` |
| | |
| | | //PurchaseAheadDay int `gorm:"type:int(11);comment:采购提前期(天)" json:"purchaseAheadDay"` |
| | | //ProduceAheadDay int `gorm:"type:int(11);comment:制造提前期(天)" json:"produceAheadDay"` |
| | | MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:最小采购量" json:"minPurchaseAmount"` //最小采购量 |
| | | //PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:采购类型" json:"purchaseType"` |
| | | PurchaseType constvar.PurchaseType `gorm:"type:int(11);comment:采购类型" json:"purchaseType"` |
| | | IsSale bool `gorm:"type:tinyint(1);comment:是否销售" json:"isSale"` //是否销售 |
| | | SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:销售单价" json:"salePrice"` //销售单价 |
| | | AutoIncr uint `gorm:"type:int(11);comment:自增ID;default:0;" json:"-"` |
| | | AutoIncr uint `gorm:"type:int(11);comment:自增ID;default:0;" json:"autoIncr"` |
| | | //wms添加字段 |
| | | ProductType constvar.ProductType `gorm:"type:int(11);comment:产品类型" json:"productType"` //产品类型 |
| | | InvoicingStrategy constvar.InvoicingStrategy `gorm:"type:int(11);comment:开票策略" json:"invoicingStrategy"` //开票策略 |
| | |
| | | // return fileName, nil |
| | | //} |
| | | |
| | | func (slf *MaterialSearch) MaxAutoIncr() (int64, error) { |
| | | func (slf *MaterialSearch) MaxAutoIncr() (int, error) { |
| | | type Result struct { |
| | | Max int64 |
| | | Max int |
| | | } |
| | | |
| | | var ( |
New file |
| | |
| | | syntax = "proto3"; |
| | | |
| | | option go_package = "./code"; |
| | | |
| | | service codeService { |
| | | rpc GetCodeList(GetCodeListRequest) returns(GetCodeListResponse) {} |
| | | } |
| | | |
| | | message CodeStandard { |
| | | string ID = 1; |
| | | string Name = 2; |
| | | string Type = 3; |
| | | int32 Method = 4; |
| | | string Status = 5; |
| | | repeated CodeRule List = 6; |
| | | CodeAuto AutoRule = 7; |
| | | } |
| | | |
| | | message CodeRule { |
| | | string Name = 1; |
| | | int32 Length = 2; |
| | | string Desc = 3; |
| | | } |
| | | |
| | | message CodeAuto { |
| | | int32 PrefixMethod = 1; |
| | | string PrefixValue = 2; |
| | | int32 SuffixMethod = 3; |
| | | int32 AutoLength = 4; |
| | | string Desc = 5; |
| | | } |
| | | |
| | | |
| | | |
| | | message GetCodeListRequest{ |
| | | int32 page = 1; |
| | | int32 pageSize = 2; |
| | | string CodeStandID = 3; |
| | | string Name = 4; |
| | | string Type = 5; |
| | | } |
| | | |
| | | message GetCodeListResponse{ |
| | | int32 Code = 1; |
| | | string Msg = 2; |
| | | repeated CodeStandard List = 3; |
| | | int64 Total = 4; |
| | | } |
New file |
| | |
| | | // Code generated by protoc-gen-go. DO NOT EDIT. |
| | | // versions: |
| | | // protoc-gen-go v1.26.0 |
| | | // protoc v4.24.0 |
| | | // source: code.proto |
| | | |
| | | package code |
| | | |
| | | import ( |
| | | protoreflect "google.golang.org/protobuf/reflect/protoreflect" |
| | | protoimpl "google.golang.org/protobuf/runtime/protoimpl" |
| | | reflect "reflect" |
| | | sync "sync" |
| | | ) |
| | | |
| | | const ( |
| | | // Verify that this generated code is sufficiently up-to-date. |
| | | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) |
| | | // Verify that runtime/protoimpl is sufficiently up-to-date. |
| | | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) |
| | | ) |
| | | |
| | | type CodeStandard struct { |
| | | state protoimpl.MessageState |
| | | sizeCache protoimpl.SizeCache |
| | | unknownFields protoimpl.UnknownFields |
| | | |
| | | ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` |
| | | Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` |
| | | Type string `protobuf:"bytes,3,opt,name=Type,proto3" json:"Type,omitempty"` |
| | | Method int32 `protobuf:"varint,4,opt,name=Method,proto3" json:"Method,omitempty"` |
| | | Status string `protobuf:"bytes,5,opt,name=Status,proto3" json:"Status,omitempty"` |
| | | List []*CodeRule `protobuf:"bytes,6,rep,name=List,proto3" json:"List,omitempty"` |
| | | AutoRule *CodeAuto `protobuf:"bytes,7,opt,name=AutoRule,proto3" json:"AutoRule,omitempty"` |
| | | } |
| | | |
| | | func (x *CodeStandard) Reset() { |
| | | *x = CodeStandard{} |
| | | if protoimpl.UnsafeEnabled { |
| | | mi := &file_code_proto_msgTypes[0] |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | } |
| | | |
| | | func (x *CodeStandard) String() string { |
| | | return protoimpl.X.MessageStringOf(x) |
| | | } |
| | | |
| | | func (*CodeStandard) ProtoMessage() {} |
| | | |
| | | func (x *CodeStandard) ProtoReflect() protoreflect.Message { |
| | | mi := &file_code_proto_msgTypes[0] |
| | | if protoimpl.UnsafeEnabled && x != nil { |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | if ms.LoadMessageInfo() == nil { |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | return ms |
| | | } |
| | | return mi.MessageOf(x) |
| | | } |
| | | |
| | | // Deprecated: Use CodeStandard.ProtoReflect.Descriptor instead. |
| | | func (*CodeStandard) Descriptor() ([]byte, []int) { |
| | | return file_code_proto_rawDescGZIP(), []int{0} |
| | | } |
| | | |
| | | func (x *CodeStandard) GetID() string { |
| | | if x != nil { |
| | | return x.ID |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *CodeStandard) GetName() string { |
| | | if x != nil { |
| | | return x.Name |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *CodeStandard) GetType() string { |
| | | if x != nil { |
| | | return x.Type |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *CodeStandard) GetMethod() int32 { |
| | | if x != nil { |
| | | return x.Method |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *CodeStandard) GetStatus() string { |
| | | if x != nil { |
| | | return x.Status |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *CodeStandard) GetList() []*CodeRule { |
| | | if x != nil { |
| | | return x.List |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | func (x *CodeStandard) GetAutoRule() *CodeAuto { |
| | | if x != nil { |
| | | return x.AutoRule |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | type CodeRule struct { |
| | | state protoimpl.MessageState |
| | | sizeCache protoimpl.SizeCache |
| | | unknownFields protoimpl.UnknownFields |
| | | |
| | | Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` |
| | | Length int32 `protobuf:"varint,2,opt,name=Length,proto3" json:"Length,omitempty"` |
| | | Desc string `protobuf:"bytes,3,opt,name=Desc,proto3" json:"Desc,omitempty"` |
| | | } |
| | | |
| | | func (x *CodeRule) Reset() { |
| | | *x = CodeRule{} |
| | | if protoimpl.UnsafeEnabled { |
| | | mi := &file_code_proto_msgTypes[1] |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | } |
| | | |
| | | func (x *CodeRule) String() string { |
| | | return protoimpl.X.MessageStringOf(x) |
| | | } |
| | | |
| | | func (*CodeRule) ProtoMessage() {} |
| | | |
| | | func (x *CodeRule) ProtoReflect() protoreflect.Message { |
| | | mi := &file_code_proto_msgTypes[1] |
| | | if protoimpl.UnsafeEnabled && x != nil { |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | if ms.LoadMessageInfo() == nil { |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | return ms |
| | | } |
| | | return mi.MessageOf(x) |
| | | } |
| | | |
| | | // Deprecated: Use CodeRule.ProtoReflect.Descriptor instead. |
| | | func (*CodeRule) Descriptor() ([]byte, []int) { |
| | | return file_code_proto_rawDescGZIP(), []int{1} |
| | | } |
| | | |
| | | func (x *CodeRule) GetName() string { |
| | | if x != nil { |
| | | return x.Name |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *CodeRule) GetLength() int32 { |
| | | if x != nil { |
| | | return x.Length |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *CodeRule) GetDesc() string { |
| | | if x != nil { |
| | | return x.Desc |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | type CodeAuto struct { |
| | | state protoimpl.MessageState |
| | | sizeCache protoimpl.SizeCache |
| | | unknownFields protoimpl.UnknownFields |
| | | |
| | | PrefixMethod int32 `protobuf:"varint,1,opt,name=PrefixMethod,proto3" json:"PrefixMethod,omitempty"` |
| | | PrefixValue string `protobuf:"bytes,2,opt,name=PrefixValue,proto3" json:"PrefixValue,omitempty"` |
| | | SuffixMethod int32 `protobuf:"varint,3,opt,name=SuffixMethod,proto3" json:"SuffixMethod,omitempty"` |
| | | AutoLength int32 `protobuf:"varint,4,opt,name=AutoLength,proto3" json:"AutoLength,omitempty"` |
| | | Desc string `protobuf:"bytes,5,opt,name=Desc,proto3" json:"Desc,omitempty"` |
| | | } |
| | | |
| | | func (x *CodeAuto) Reset() { |
| | | *x = CodeAuto{} |
| | | if protoimpl.UnsafeEnabled { |
| | | mi := &file_code_proto_msgTypes[2] |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | } |
| | | |
| | | func (x *CodeAuto) String() string { |
| | | return protoimpl.X.MessageStringOf(x) |
| | | } |
| | | |
| | | func (*CodeAuto) ProtoMessage() {} |
| | | |
| | | func (x *CodeAuto) ProtoReflect() protoreflect.Message { |
| | | mi := &file_code_proto_msgTypes[2] |
| | | if protoimpl.UnsafeEnabled && x != nil { |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | if ms.LoadMessageInfo() == nil { |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | return ms |
| | | } |
| | | return mi.MessageOf(x) |
| | | } |
| | | |
| | | // Deprecated: Use CodeAuto.ProtoReflect.Descriptor instead. |
| | | func (*CodeAuto) Descriptor() ([]byte, []int) { |
| | | return file_code_proto_rawDescGZIP(), []int{2} |
| | | } |
| | | |
| | | func (x *CodeAuto) GetPrefixMethod() int32 { |
| | | if x != nil { |
| | | return x.PrefixMethod |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *CodeAuto) GetPrefixValue() string { |
| | | if x != nil { |
| | | return x.PrefixValue |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *CodeAuto) GetSuffixMethod() int32 { |
| | | if x != nil { |
| | | return x.SuffixMethod |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *CodeAuto) GetAutoLength() int32 { |
| | | if x != nil { |
| | | return x.AutoLength |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *CodeAuto) GetDesc() string { |
| | | if x != nil { |
| | | return x.Desc |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | type GetCodeListRequest struct { |
| | | state protoimpl.MessageState |
| | | sizeCache protoimpl.SizeCache |
| | | unknownFields protoimpl.UnknownFields |
| | | |
| | | Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` |
| | | PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"` |
| | | CodeStandID string `protobuf:"bytes,3,opt,name=CodeStandID,proto3" json:"CodeStandID,omitempty"` |
| | | Name string `protobuf:"bytes,4,opt,name=Name,proto3" json:"Name,omitempty"` |
| | | Type string `protobuf:"bytes,5,opt,name=Type,proto3" json:"Type,omitempty"` |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) Reset() { |
| | | *x = GetCodeListRequest{} |
| | | if protoimpl.UnsafeEnabled { |
| | | mi := &file_code_proto_msgTypes[3] |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) String() string { |
| | | return protoimpl.X.MessageStringOf(x) |
| | | } |
| | | |
| | | func (*GetCodeListRequest) ProtoMessage() {} |
| | | |
| | | func (x *GetCodeListRequest) ProtoReflect() protoreflect.Message { |
| | | mi := &file_code_proto_msgTypes[3] |
| | | if protoimpl.UnsafeEnabled && x != nil { |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | if ms.LoadMessageInfo() == nil { |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | return ms |
| | | } |
| | | return mi.MessageOf(x) |
| | | } |
| | | |
| | | // Deprecated: Use GetCodeListRequest.ProtoReflect.Descriptor instead. |
| | | func (*GetCodeListRequest) Descriptor() ([]byte, []int) { |
| | | return file_code_proto_rawDescGZIP(), []int{3} |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) GetPage() int32 { |
| | | if x != nil { |
| | | return x.Page |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) GetPageSize() int32 { |
| | | if x != nil { |
| | | return x.PageSize |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) GetCodeStandID() string { |
| | | if x != nil { |
| | | return x.CodeStandID |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) GetName() string { |
| | | if x != nil { |
| | | return x.Name |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *GetCodeListRequest) GetType() string { |
| | | if x != nil { |
| | | return x.Type |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | type GetCodeListResponse struct { |
| | | state protoimpl.MessageState |
| | | sizeCache protoimpl.SizeCache |
| | | unknownFields protoimpl.UnknownFields |
| | | |
| | | Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` |
| | | Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` |
| | | List []*CodeStandard `protobuf:"bytes,3,rep,name=List,proto3" json:"List,omitempty"` |
| | | Total int64 `protobuf:"varint,4,opt,name=Total,proto3" json:"Total,omitempty"` |
| | | } |
| | | |
| | | func (x *GetCodeListResponse) Reset() { |
| | | *x = GetCodeListResponse{} |
| | | if protoimpl.UnsafeEnabled { |
| | | mi := &file_code_proto_msgTypes[4] |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | } |
| | | |
| | | func (x *GetCodeListResponse) String() string { |
| | | return protoimpl.X.MessageStringOf(x) |
| | | } |
| | | |
| | | func (*GetCodeListResponse) ProtoMessage() {} |
| | | |
| | | func (x *GetCodeListResponse) ProtoReflect() protoreflect.Message { |
| | | mi := &file_code_proto_msgTypes[4] |
| | | if protoimpl.UnsafeEnabled && x != nil { |
| | | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
| | | if ms.LoadMessageInfo() == nil { |
| | | ms.StoreMessageInfo(mi) |
| | | } |
| | | return ms |
| | | } |
| | | return mi.MessageOf(x) |
| | | } |
| | | |
| | | // Deprecated: Use GetCodeListResponse.ProtoReflect.Descriptor instead. |
| | | func (*GetCodeListResponse) Descriptor() ([]byte, []int) { |
| | | return file_code_proto_rawDescGZIP(), []int{4} |
| | | } |
| | | |
| | | func (x *GetCodeListResponse) GetCode() int32 { |
| | | if x != nil { |
| | | return x.Code |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | func (x *GetCodeListResponse) GetMsg() string { |
| | | if x != nil { |
| | | return x.Msg |
| | | } |
| | | return "" |
| | | } |
| | | |
| | | func (x *GetCodeListResponse) GetList() []*CodeStandard { |
| | | if x != nil { |
| | | return x.List |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | func (x *GetCodeListResponse) GetTotal() int64 { |
| | | if x != nil { |
| | | return x.Total |
| | | } |
| | | return 0 |
| | | } |
| | | |
| | | var File_code_proto protoreflect.FileDescriptor |
| | | |
| | | var file_code_proto_rawDesc = []byte{ |
| | | 0x0a, 0x0a, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbc, 0x01, 0x0a, |
| | | 0x0c, 0x43, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x12, 0x0e, 0x0a, |
| | | 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x12, 0x0a, |
| | | 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, |
| | | 0x65, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, |
| | | 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, |
| | | 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x16, 0x0a, |
| | | 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, |
| | | 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x06, 0x20, |
| | | 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, |
| | | 0x4c, 0x69, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x75, 0x6c, 0x65, |
| | | 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x41, 0x75, 0x74, |
| | | 0x6f, 0x52, 0x08, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x4a, 0x0a, 0x08, 0x43, |
| | | 0x6f, 0x64, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, |
| | | 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x4c, |
| | | 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x4c, 0x65, 0x6e, |
| | | 0x67, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x65, 0x73, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, |
| | | 0x09, 0x52, 0x04, 0x44, 0x65, 0x73, 0x63, 0x22, 0xa8, 0x01, 0x0a, 0x08, 0x43, 0x6f, 0x64, 0x65, |
| | | 0x41, 0x75, 0x74, 0x6f, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x4d, 0x65, |
| | | 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x50, 0x72, 0x65, 0x66, |
| | | 0x69, 0x78, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x72, 0x65, 0x66, |
| | | 0x69, 0x78, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x50, |
| | | 0x72, 0x65, 0x66, 0x69, 0x78, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x53, 0x75, |
| | | 0x66, 0x66, 0x69, 0x78, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, |
| | | 0x52, 0x0c, 0x53, 0x75, 0x66, 0x66, 0x69, 0x78, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, |
| | | 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x6f, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, |
| | | 0x28, 0x05, 0x52, 0x0a, 0x41, 0x75, 0x74, 0x6f, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x12, |
| | | 0x0a, 0x04, 0x44, 0x65, 0x73, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x65, |
| | | 0x73, 0x63, 0x22, 0x8e, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x4c, 0x69, |
| | | 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, |
| | | 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, |
| | | 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, |
| | | 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x43, 0x6f, 0x64, |
| | | 0x65, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, |
| | | 0x43, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x4e, |
| | | 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, |
| | | 0x12, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, |
| | | 0x79, 0x70, 0x65, 0x22, 0x74, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x4c, 0x69, |
| | | 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, |
| | | 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, |
| | | 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, |
| | | 0x12, 0x21, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, |
| | | 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x52, 0x04, 0x4c, |
| | | 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, |
| | | 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x32, 0x49, 0x0a, 0x0b, 0x63, 0x6f, 0x64, |
| | | 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x43, |
| | | 0x6f, 0x64, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x13, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x64, |
| | | 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x47, |
| | | 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, |
| | | 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x62, 0x06, |
| | | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, |
| | | } |
| | | |
| | | var ( |
| | | file_code_proto_rawDescOnce sync.Once |
| | | file_code_proto_rawDescData = file_code_proto_rawDesc |
| | | ) |
| | | |
| | | func file_code_proto_rawDescGZIP() []byte { |
| | | file_code_proto_rawDescOnce.Do(func() { |
| | | file_code_proto_rawDescData = protoimpl.X.CompressGZIP(file_code_proto_rawDescData) |
| | | }) |
| | | return file_code_proto_rawDescData |
| | | } |
| | | |
| | | var file_code_proto_msgTypes = make([]protoimpl.MessageInfo, 5) |
| | | var file_code_proto_goTypes = []interface{}{ |
| | | (*CodeStandard)(nil), // 0: CodeStandard |
| | | (*CodeRule)(nil), // 1: CodeRule |
| | | (*CodeAuto)(nil), // 2: CodeAuto |
| | | (*GetCodeListRequest)(nil), // 3: GetCodeListRequest |
| | | (*GetCodeListResponse)(nil), // 4: GetCodeListResponse |
| | | } |
| | | var file_code_proto_depIdxs = []int32{ |
| | | 1, // 0: CodeStandard.List:type_name -> CodeRule |
| | | 2, // 1: CodeStandard.AutoRule:type_name -> CodeAuto |
| | | 0, // 2: GetCodeListResponse.List:type_name -> CodeStandard |
| | | 3, // 3: codeService.GetCodeList:input_type -> GetCodeListRequest |
| | | 4, // 4: codeService.GetCodeList:output_type -> GetCodeListResponse |
| | | 4, // [4:5] is the sub-list for method output_type |
| | | 3, // [3:4] is the sub-list for method input_type |
| | | 3, // [3:3] is the sub-list for extension type_name |
| | | 3, // [3:3] is the sub-list for extension extendee |
| | | 0, // [0:3] is the sub-list for field type_name |
| | | } |
| | | |
| | | func init() { file_code_proto_init() } |
| | | func file_code_proto_init() { |
| | | if File_code_proto != nil { |
| | | return |
| | | } |
| | | if !protoimpl.UnsafeEnabled { |
| | | file_code_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { |
| | | switch v := v.(*CodeStandard); i { |
| | | case 0: |
| | | return &v.state |
| | | case 1: |
| | | return &v.sizeCache |
| | | case 2: |
| | | return &v.unknownFields |
| | | default: |
| | | return nil |
| | | } |
| | | } |
| | | file_code_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { |
| | | switch v := v.(*CodeRule); i { |
| | | case 0: |
| | | return &v.state |
| | | case 1: |
| | | return &v.sizeCache |
| | | case 2: |
| | | return &v.unknownFields |
| | | default: |
| | | return nil |
| | | } |
| | | } |
| | | file_code_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { |
| | | switch v := v.(*CodeAuto); i { |
| | | case 0: |
| | | return &v.state |
| | | case 1: |
| | | return &v.sizeCache |
| | | case 2: |
| | | return &v.unknownFields |
| | | default: |
| | | return nil |
| | | } |
| | | } |
| | | file_code_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { |
| | | switch v := v.(*GetCodeListRequest); i { |
| | | case 0: |
| | | return &v.state |
| | | case 1: |
| | | return &v.sizeCache |
| | | case 2: |
| | | return &v.unknownFields |
| | | default: |
| | | return nil |
| | | } |
| | | } |
| | | file_code_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { |
| | | switch v := v.(*GetCodeListResponse); i { |
| | | case 0: |
| | | return &v.state |
| | | case 1: |
| | | return &v.sizeCache |
| | | case 2: |
| | | return &v.unknownFields |
| | | default: |
| | | return nil |
| | | } |
| | | } |
| | | } |
| | | type x struct{} |
| | | out := protoimpl.TypeBuilder{ |
| | | File: protoimpl.DescBuilder{ |
| | | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
| | | RawDescriptor: file_code_proto_rawDesc, |
| | | NumEnums: 0, |
| | | NumMessages: 5, |
| | | NumExtensions: 0, |
| | | NumServices: 1, |
| | | }, |
| | | GoTypes: file_code_proto_goTypes, |
| | | DependencyIndexes: file_code_proto_depIdxs, |
| | | MessageInfos: file_code_proto_msgTypes, |
| | | }.Build() |
| | | File_code_proto = out.File |
| | | file_code_proto_rawDesc = nil |
| | | file_code_proto_goTypes = nil |
| | | file_code_proto_depIdxs = nil |
| | | } |
New file |
| | |
| | | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. |
| | | |
| | | package code |
| | | |
| | | import ( |
| | | context "context" |
| | | grpc "google.golang.org/grpc" |
| | | codes "google.golang.org/grpc/codes" |
| | | status "google.golang.org/grpc/status" |
| | | ) |
| | | |
| | | // This is a compile-time assertion to ensure that this generated file |
| | | // is compatible with the grpc package it is being compiled against. |
| | | // Requires gRPC-Go v1.32.0 or later. |
| | | const _ = grpc.SupportPackageIsVersion7 |
| | | |
| | | // CodeServiceClient is the client API for CodeService service. |
| | | // |
| | | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. |
| | | type CodeServiceClient interface { |
| | | GetCodeList(ctx context.Context, in *GetCodeListRequest, opts ...grpc.CallOption) (*GetCodeListResponse, error) |
| | | } |
| | | |
| | | type codeServiceClient struct { |
| | | cc grpc.ClientConnInterface |
| | | } |
| | | |
| | | func NewCodeServiceClient(cc grpc.ClientConnInterface) CodeServiceClient { |
| | | return &codeServiceClient{cc} |
| | | } |
| | | |
| | | func (c *codeServiceClient) GetCodeList(ctx context.Context, in *GetCodeListRequest, opts ...grpc.CallOption) (*GetCodeListResponse, error) { |
| | | out := new(GetCodeListResponse) |
| | | err := c.cc.Invoke(ctx, "/codeService/GetCodeList", in, out, opts...) |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | return out, nil |
| | | } |
| | | |
| | | // CodeServiceServer is the server API for CodeService service. |
| | | // All implementations must embed UnimplementedCodeServiceServer |
| | | // for forward compatibility |
| | | type CodeServiceServer interface { |
| | | GetCodeList(context.Context, *GetCodeListRequest) (*GetCodeListResponse, error) |
| | | mustEmbedUnimplementedCodeServiceServer() |
| | | } |
| | | |
| | | // UnimplementedCodeServiceServer must be embedded to have forward compatible implementations. |
| | | type UnimplementedCodeServiceServer struct { |
| | | } |
| | | |
| | | func (UnimplementedCodeServiceServer) GetCodeList(context.Context, *GetCodeListRequest) (*GetCodeListResponse, error) { |
| | | return nil, status.Errorf(codes.Unimplemented, "method GetCodeList not implemented") |
| | | } |
| | | func (UnimplementedCodeServiceServer) mustEmbedUnimplementedCodeServiceServer() {} |
| | | |
| | | // UnsafeCodeServiceServer may be embedded to opt out of forward compatibility for this service. |
| | | // Use of this interface is not recommended, as added methods to CodeServiceServer will |
| | | // result in compilation errors. |
| | | type UnsafeCodeServiceServer interface { |
| | | mustEmbedUnimplementedCodeServiceServer() |
| | | } |
| | | |
| | | func RegisterCodeServiceServer(s grpc.ServiceRegistrar, srv CodeServiceServer) { |
| | | s.RegisterService(&CodeService_ServiceDesc, srv) |
| | | } |
| | | |
| | | func _CodeService_GetCodeList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
| | | in := new(GetCodeListRequest) |
| | | if err := dec(in); err != nil { |
| | | return nil, err |
| | | } |
| | | if interceptor == nil { |
| | | return srv.(CodeServiceServer).GetCodeList(ctx, in) |
| | | } |
| | | info := &grpc.UnaryServerInfo{ |
| | | Server: srv, |
| | | FullMethod: "/codeService/GetCodeList", |
| | | } |
| | | handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
| | | return srv.(CodeServiceServer).GetCodeList(ctx, req.(*GetCodeListRequest)) |
| | | } |
| | | return interceptor(ctx, in, info, handler) |
| | | } |
| | | |
| | | // CodeService_ServiceDesc is the grpc.ServiceDesc for CodeService service. |
| | | // It's only intended for direct use with grpc.RegisterService, |
| | | // and not to be introspected or modified (even as a copy) |
| | | var CodeService_ServiceDesc = grpc.ServiceDesc{ |
| | | ServiceName: "codeService", |
| | | HandlerType: (*CodeServiceServer)(nil), |
| | | Methods: []grpc.MethodDesc{ |
| | | { |
| | | MethodName: "GetCodeList", |
| | | Handler: _CodeService_GetCodeList_Handler, |
| | | }, |
| | | }, |
| | | Streams: []grpc.StreamDesc{}, |
| | | Metadata: "code.proto", |
| | | } |
New file |
| | |
| | | package request |
| | | |
| | | type GetCodeList struct { |
| | | PageInfo |
| | | CodeStandID string `json:"codeStandID"` |
| | | Name string `json:"name"` |
| | | Type string `json:"type"` |
| | | } |
| | | |
| | | type CodeStandard struct { |
| | | ID string `json:"id"` |
| | | Name string `json:"name"` |
| | | Type string `json:"type"` |
| | | Method int32 `json:"method"` |
| | | Status string `json:"status"` |
| | | List []*CodeRule `json:"list"` |
| | | AutoRule *CodeAuto `json:"autoRule"` |
| | | } |
| | | |
| | | type CodeRule struct { |
| | | Name string `json:"name"` |
| | | Length int32 `json:"length"` |
| | | Desc string `json:"desc"` |
| | | } |
| | | |
| | | type CodeAuto struct { |
| | | PrefixMethod int32 `json:"prefixMethod"` |
| | | PrefixValue string `json:"prefixValue"` |
| | | SuffixMethod int32 `json:"suffixMethod"` |
| | | AutoLength int32 `json:"autoLength"` |
| | | Desc string `json:"desc"` |
| | | } |
| | |
| | | attachmentAPI.POST("uploadFiles", attachmentController.UploadFiles) //上传文件 |
| | | } |
| | | |
| | | codeApiController := new(controllers.CodeApi) |
| | | codeApi := r.Group(urlPrefix + "/code") |
| | | { |
| | | codeApi.GET("getCodeList", codeApiController.GetCodeList) //获取编码列表 |
| | | codeApi.POST("getAutoCode", codeApiController.GetAutoCode) //获取自动编码 |
| | | } |
| | | |
| | | return r |
| | | } |