| | |
| | | |
| | | 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) { |
| | |
| | | package request |
| | | |
| | | import "github.com/shopspring/decimal" |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | ) |
| | | |
| | | type AddFinenessRegister struct { |
| | | 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"` //车间 |
| | | WorkshopGroup string `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组 |
| | | Market string `gorm:"type:varchar(255);not null;comment:庄口" json:"market"` //庄口 |
| | | 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 `json:"finenessList"` |
| | | Sum FinenessItem `json:"sum"` |
| | | 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"` //车间 |
| | | WorkshopGroup string `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组 |
| | | Market string `gorm:"type:varchar(255);not null;comment:庄口" json:"market"` //庄口 |
| | | 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 `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"` |
| | | } |
| | | |
| | | type FinenessItem struct { |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/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/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: {} |
| | |
| | | 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" |
| | | ) |
| | |
| | | // FinenessRegister 纤度登记 |
| | | FinenessRegister struct { |
| | | gorm.Model |
| | | 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"` //车间 |
| | | WorkshopGroup string `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组 |
| | | Market string `gorm:"type:varchar(255);not null;comment:庄口" json:"market"` //庄口 |
| | | 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;references:ID" json:"finenessList"` |
| | | 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"` //车间 |
| | | WorkshopGroup string `gorm:"type:varchar(255);not null;comment:车组" json:"workshopGroup"` //车组 |
| | | Market string `gorm:"type:varchar(255);not null;comment:庄口" json:"market"` //庄口 |
| | | 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;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 |
| | |
| | | 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 |
| | | } |
| | | |