Merge branch 'master' of http://192.168.5.5:10010/r/silk/silkServer
| | |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "gorm.io/gorm" |
| | | "silkserver/controllers/request" |
| | | "silkserver/extend/code" |
| | | "silkserver/extend/util" |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | if err := models.NewFinenessRegisterSearch().Create(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.SaveFail, "插入失败") |
| | | return |
| | | err := models.WithTransaction(func(db *gorm.DB) error { |
| | | search := models.NewFinenessRegisterSearch().SetOrm(db) |
| | | |
| | | if params.ID != 0 { |
| | | if err := models.NewFinenessItemSearch().SetOrm(db).SetFinenessRegisterID(params.ID).Delete(); err != nil { |
| | | return err |
| | | } |
| | | return search.Save(¶ms) |
| | | } else { |
| | | return search.Create(¶ms) |
| | | } |
| | | }) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "保存失败") |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "添加成功") |
| | | util.ResponseFormat(c, code.Success, "保存成功") |
| | | } |
| | | |
| | | func (slf FinenessController) ParamsCheck(params models.FinenessRegister) (err error) { |
| | |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormatList(c, code.Success, list, int(total)) |
| | | util.ResponseFormatList(c, code.Success, list, total) |
| | | } |
| | | |
| | | // Info |
| | | // @Tags 纤度登记 |
| | | // @Summary 纤度登记详情 |
| | | // @Produce application/json |
| | | // @Param id path string true "字典信息" |
| | | // @Success 200 {object} util.ResponseList{data=models.FinenessRegister} "成功" |
| | | // @Router /api-jl/v1/fineness/register/{id} [get] |
| | | func (slf FinenessController) Info(c *gin.Context) { |
| | | idStr := c.Param("id") |
| | | if idStr == "0" || idStr == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | id := convertx.StringToUInt(idStr) |
| | | if id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | | return |
| | | } |
| | | |
| | | info, err := models.NewFinenessRegisterSearch().SetID(id).SetPreload().First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, info) |
| | | } |
| | | |
| | | // Delete |
| | |
| | | package request |
| | | |
| | | import "github.com/shopspring/decimal" |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | ) |
| | | |
| | | type AddFinenessRegister struct { |
| | | ID uint `json:"id"` //id 添加时传0 |
| | | Number string `gorm:"type:varchar(255);not null;comment:编号" json:"number"` //编号 |
| | | FinishDate string `gorm:"type:varchar(255);not null;comment:落丝时间" json:"finishDate"` //落丝时间 |
| | | Workshop string `gorm:"type:varchar(255);not null;comment:车间" json:"name"` //车间 |
| | |
| | | StartCircle uint8 `gorm:"type:varchar(255);not null;comment:开始回数" json:"startCircle"` //开始回数 |
| | | EndCircle uint8 `gorm:"type:varchar(255);not null;comment:结束回数" json:"endCircle"` //结束回数 |
| | | FinenessList []FinenessItem `json:"finenessList"` |
| | | Sum FinenessItem `json:"sum"` |
| | | SumFineness decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计纤度" json:"sumFineness"` |
| | | SumQuantity decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计数量" json:"sumQuantity"` |
| | | } |
| | | |
| | | type FinenessItem struct { |
| | |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/register/{id}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度登记" |
| | | ], |
| | | "summary": "纤度登记详情", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "字典信息", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/models.FinenessRegister" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/system/getPriceStandardList": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "系统设置/生丝定价标准" |
| | | ], |
| | | "summary": "获取生丝定价标准", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/models.RawSilkPriceStandard" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/system/savePriceStandard": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "系统设置/生丝定价标准" |
| | | ], |
| | | "summary": "保存生丝定价标准", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/models.RawSilkPriceStandard" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "definitions": { |
| | |
| | | "description": "开始回数", |
| | | "type": "integer" |
| | | }, |
| | | "sumFineness": { |
| | | "type": "number" |
| | | }, |
| | | "sumQuantity": { |
| | | "type": "number" |
| | | }, |
| | | "updatedAt": { |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "models.RawSilkPriceStandard": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createdAt": { |
| | | "type": "string" |
| | | }, |
| | | "deletedAt": { |
| | | "$ref": "#/definitions/gorm.DeletedAt" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "marketNumber": { |
| | | "type": "string" |
| | | }, |
| | | "notes": { |
| | | "type": "string" |
| | | }, |
| | | "payStandard": { |
| | | "type": "number" |
| | | }, |
| | | "rawSilkGradeNumber": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | }, |
| | | "updatedAt": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "description": "落丝时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "id 添加时传0", |
| | | "type": "integer" |
| | | }, |
| | | "market": { |
| | | "description": "庄口", |
| | | "type": "string" |
| | |
| | | "description": "开始回数", |
| | | "type": "integer" |
| | | }, |
| | | "sum": { |
| | | "$ref": "#/definitions/request.FinenessItem" |
| | | "sumFineness": { |
| | | "type": "number" |
| | | }, |
| | | "sumQuantity": { |
| | | "type": "number" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | |
| | | "pageSize": { |
| | | "type": "integer" |
| | | }, |
| | | "total": { |
| | | "type": "integer" |
| | | } |
| | | "total": {} |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/register/{id}": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度登记" |
| | | ], |
| | | "summary": "纤度登记详情", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "字典信息", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "$ref": "#/definitions/models.FinenessRegister" |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/system/getPriceStandardList": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "系统设置/生丝定价标准" |
| | | ], |
| | | "summary": "获取生丝定价标准", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/models.RawSilkPriceStandard" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/system/savePriceStandard": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "系统设置/生丝定价标准" |
| | | ], |
| | | "summary": "保存生丝定价标准", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/models.RawSilkPriceStandard" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "definitions": { |
| | |
| | | "description": "开始回数", |
| | | "type": "integer" |
| | | }, |
| | | "sumFineness": { |
| | | "type": "number" |
| | | }, |
| | | "sumQuantity": { |
| | | "type": "number" |
| | | }, |
| | | "updatedAt": { |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "models.RawSilkPriceStandard": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createdAt": { |
| | | "type": "string" |
| | | }, |
| | | "deletedAt": { |
| | | "$ref": "#/definitions/gorm.DeletedAt" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "marketNumber": { |
| | | "type": "string" |
| | | }, |
| | | "notes": { |
| | | "type": "string" |
| | | }, |
| | | "payStandard": { |
| | | "type": "number" |
| | | }, |
| | | "rawSilkGradeNumber": { |
| | | "type": "string" |
| | | }, |
| | | "unit": { |
| | | "type": "string" |
| | | }, |
| | | "updatedAt": { |
| | | "type": "string" |
| | | } |
| | | } |
| | |
| | | "description": "落丝时间", |
| | | "type": "string" |
| | | }, |
| | | "id": { |
| | | "description": "id 添加时传0", |
| | | "type": "integer" |
| | | }, |
| | | "market": { |
| | | "description": "庄口", |
| | | "type": "string" |
| | |
| | | "description": "开始回数", |
| | | "type": "integer" |
| | | }, |
| | | "sum": { |
| | | "$ref": "#/definitions/request.FinenessItem" |
| | | "sumFineness": { |
| | | "type": "number" |
| | | }, |
| | | "sumQuantity": { |
| | | "type": "number" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | |
| | | "pageSize": { |
| | | "type": "integer" |
| | | }, |
| | | "total": { |
| | | "type": "integer" |
| | | } |
| | | "total": {} |
| | | } |
| | | } |
| | | } |
| | |
| | | startCircle: |
| | | description: 开始回数 |
| | | type: integer |
| | | sumFineness: |
| | | type: number |
| | | sumQuantity: |
| | | type: number |
| | | updatedAt: |
| | | type: string |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: string |
| | | type: object |
| | | models.RawSilkPriceStandard: |
| | | properties: |
| | | createdAt: |
| | | type: string |
| | | deletedAt: |
| | | $ref: '#/definitions/gorm.DeletedAt' |
| | | id: |
| | | type: integer |
| | | marketNumber: |
| | | type: string |
| | | notes: |
| | | type: string |
| | | payStandard: |
| | | type: number |
| | | rawSilkGradeNumber: |
| | | type: string |
| | | unit: |
| | | type: string |
| | | updatedAt: |
| | | type: string |
| | | type: object |
| | | request.AddDict: |
| | |
| | | finishDate: |
| | | description: 落丝时间 |
| | | type: string |
| | | id: |
| | | description: id 添加时传0 |
| | | type: integer |
| | | market: |
| | | description: 庄口 |
| | | type: string |
| | |
| | | startCircle: |
| | | description: 开始回数 |
| | | type: integer |
| | | sum: |
| | | $ref: '#/definitions/request.FinenessItem' |
| | | sumFineness: |
| | | type: number |
| | | sumQuantity: |
| | | type: number |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: string |
| | |
| | | type: integer |
| | | pageSize: |
| | | type: integer |
| | | total: |
| | | type: integer |
| | | total: {} |
| | | type: object |
| | | info: |
| | | contact: {} |
| | |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 纤度登记删除 |
| | | tags: |
| | | - 纤度登记 |
| | | get: |
| | | parameters: |
| | | - description: 字典信息 |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | $ref: '#/definitions/models.FinenessRegister' |
| | | type: object |
| | | summary: 纤度登记详情 |
| | | tags: |
| | | - 纤度登记 |
| | | /api-jl/v1/system/dict: |
| | |
| | | summary: 删除字典 |
| | | tags: |
| | | - 系统设置/字典 |
| | | /api-jl/v1/system/getPriceStandardList: |
| | | get: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/models.RawSilkPriceStandard' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 获取生丝定价标准 |
| | | tags: |
| | | - 系统设置/生丝定价标准 |
| | | /api-jl/v1/system/savePriceStandard: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/models.RawSilkPriceStandard' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 保存生丝定价标准 |
| | | tags: |
| | | - 系统设置/生丝定价标准 |
| | | swagger: "2.0" |
| | |
| | | |
| | | import ( |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "silkserver/pkg/mysqlx" |
| | | ) |
| | |
| | | Spec string `gorm:"type:varchar(255);not null;comment:规格" json:"spec"` //规格 |
| | | StartCircle uint8 `gorm:"type:varchar(255);not null;comment:开始回数" json:"startCircle"` //开始回数 |
| | | EndCircle uint8 `gorm:"type:varchar(255);not null;comment:结束回数" json:"endCircle"` //结束回数 |
| | | FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID" json:"finenessList"` |
| | | FinenessList []FinenessItem `gorm:"foreignkey:FinenessRegisterID;references:ID" json:"finenessList"` |
| | | SumFineness decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计纤度" json:"sumFineness"` |
| | | SumQuantity decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:合计数量" json:"sumQuantity"` |
| | | } |
| | | FinenessRegisterSearch struct { |
| | | FinenessRegister |
| | |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetPreload() *FinenessRegisterSearch { |
| | | slf.Preload = true |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetID(id uint) *FinenessRegisterSearch { |
| | | slf.ID = id |
| | | return slf |
| | |
| | | db = db.Where("number = ?", slf.Number) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Model(&FinenessRegister{}).Preload("FinenessList") |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessItemSearch) SetFinenessRegisterID(id uint) *FinenessItemSearch { |
| | | slf.FinenessRegisterID = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessItemSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | if slf.FinenessRegisterID != 0 { |
| | | db = db.Where("fineness_register_id = ?", slf.FinenessRegisterID) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | finenessApi.GET("register", FinenessController.List) // 获取纤度登记列表 |
| | | finenessApi.DELETE("register/:id", FinenessController.Delete) // 删除纤度登记 |
| | | finenessApi.POST("register", FinenessController.Add) // 新增纤度登记 |
| | | finenessApi.GET("register/:id", FinenessController.Info) // 获取纤度登记详情 |
| | | } |
| | | |
| | | // 生丝管理 |