| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "errors" |
| | | "github.com/gin-gonic/gin" |
| | | "gorm.io/gorm" |
| | | "silkserver/controllers/request" |
| | |
| | | |
| | | type FinenessController struct{} |
| | | |
| | | // Add |
| | | // RegisterAdd |
| | | // @Tags 纤度登记 |
| | | // @Summary 纤度登记添加 |
| | | // @Produce application/json |
| | | // @Param object body request.AddFinenessRegister true "字典信息" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/fineness/register [post] |
| | | func (slf FinenessController) Add(c *gin.Context) { |
| | | func (slf FinenessController) RegisterAdd(c *gin.Context) { |
| | | var reqParams request.AddFinenessRegister |
| | | var params models.FinenessRegister |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | logx.Errorf("RegisterAdd 参数解析失败:%v", err.Error()) |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if err := structx.AssignTo(reqParams, ¶ms); err != nil { |
| | | logx.Errorf("RegisterAdd 数据转换错误:%v", err.Error()) |
| | | util.ResponseFormat(c, code.RequestParamError, "数据转换错误") |
| | | return |
| | | } |
| | |
| | | if err != nil { |
| | | logx.Errorf("service.FinenessCheck err:%v, finenessRegister:%+v", err, params) |
| | | util.ResponseFormat(c, code.RequestParamError, "生成检验表失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "保存成功") |
| | | } |
| | | |
| | | func (slf FinenessController) ParamsCheck(params models.FinenessRegister) (err error) { |
| | | if params.ID == 0 { |
| | | _, err = models.NewFinenessRegisterSearch().SetNumber(params.Number).First() |
| | | if err != gorm.ErrRecordNotFound { |
| | | return errors.New("编码重复") |
| | | } |
| | | } else { |
| | | old, err := models.NewFinenessRegisterSearch().SetID(params.ID).First() |
| | | if err != nil { |
| | | return errors.New("记录不存在") |
| | | } |
| | | if old.Number != params.Number { |
| | | return errors.New("编码不能修改") |
| | | } |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | // List |
| | | // RegisterList |
| | | // @Tags 纤度登记 |
| | | // @Summary 纤度登记列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetFinenessRegisterList true "查询参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.FinenessRegister} "成功" |
| | | // @Router /api-jl/v1/fineness/register [get] |
| | | func (slf FinenessController) List(c *gin.Context) { |
| | | func (slf FinenessController) RegisterList(c *gin.Context) { |
| | | var params request.GetFinenessRegisterList |
| | | if err := c.ShouldBindQuery(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | list, total, err := models.NewFinenessRegisterSearch().Find() |
| | | list, total, err := models.NewFinenessRegisterSearch().SetKeyword(params.Keyword).SetPage(params.Page, params.PageSize).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | |
| | | util.ResponseFormatList(c, code.Success, list, total) |
| | | } |
| | | |
| | | // Info |
| | | // RegisterInfo |
| | | // @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) { |
| | | func (slf FinenessController) RegisterInfo(c *gin.Context) { |
| | | idStr := c.Param("id") |
| | | if idStr == "0" || idStr == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | |
| | | util.ResponseFormat(c, code.Success, info) |
| | | } |
| | | |
| | | // Delete |
| | | // RegisterDelete |
| | | // @Tags 纤度登记 |
| | | // @Summary 纤度登记删除 |
| | | // @Produce application/json |
| | | // @Param id path string true "字典信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/fineness/register/{id} [delete] |
| | | func (slf FinenessController) Delete(c *gin.Context) { |
| | | func (slf FinenessController) RegisterDelete(c *gin.Context) { |
| | | idStr := c.Param("id") |
| | | if idStr == "0" || idStr == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "空的记录id") |
| | |
| | | } |
| | | util.ResponseFormat(c, code.UpdateSuccess, "删除成功") |
| | | } |
| | | |
| | | // CheckList |
| | | // @Tags 纤度检验 |
| | | // @Summary 纤度检验列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetFinenessRegisterList true "查询参数" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.FinenessRegister} "成功" |
| | | // @Router /api-jl/v1/fineness/check [get] |
| | | func (slf FinenessController) CheckList(c *gin.Context) { |
| | | var params request.GetFinenessRegisterList |
| | | if err := c.ShouldBindQuery(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | list, total, err := models.NewFinenessCheckSearch().SetPage(params.Page, params.PageSize).Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormatList(c, code.Success, list, total) |
| | | } |
| | | |
| | | // CheckInfo |
| | | // @Tags 纤度检验 |
| | | // @Summary 纤度检验详情 |
| | | // @Produce application/json |
| | | // @Param id path string true "字典信息" |
| | | // @Success 200 {object} util.ResponseList{data=models.FinenessRegister} "成功" |
| | | // @Router /api-jl/v1/fineness/check/{id} [get] |
| | | func (slf FinenessController) CheckInfo(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.NewFinenessCheckSearch().SetID(id).SetPreload().First() |
| | | //if err != nil { |
| | | // util.ResponseFormat(c, code.RequestParamError, "查找失败") |
| | | // return |
| | | //} |
| | | //resp := new(response.FinenessCheckInfo) |
| | | //resp.Info = info |
| | | //resp.Items, err := models.NewFinenessCheckItemSearch().SetPage() |
| | | // |
| | | // |
| | | //util.ResponseFormat(c, code.Success, info) |
| | | } |
| | | |
| | | // CheckDelete |
| | | // @Tags 纤度检验 |
| | | // @Summary 纤度检验删除 |
| | | // @Produce application/json |
| | | // @Param id path string true "字典信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/fineness/check/{id} [delete] |
| | | func (slf FinenessController) CheckDelete(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 |
| | | } |
| | | |
| | | check, err := models.NewFinenessCheckSearch().SetID(id).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "检验记录不存在") |
| | | return |
| | | } |
| | | |
| | | err = models.WithTransaction(func(db *gorm.DB) error { |
| | | err := models.NewFinenessCheckSearch().SetOrm(db).SetID(id).Delete() |
| | | if err != nil { |
| | | return err |
| | | } |
| | | return models.NewFinenessCheckItemSearch().SetOrm(db).SetFinenessRegisterID(check.FinenessRegisterID).Delete() |
| | | }) |
| | | |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.UpdateSuccess, "删除成功") |
| | | } |
| | | |
| | | // CheckEdit |
| | | // @Tags 纤度检验 |
| | | // @Summary 纤度检验修改 |
| | | // @Produce application/json |
| | | // @Param object body request.AddFinenessRegister true "字典信息" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/fineness/check [post] |
| | | func (slf FinenessController) CheckEdit(c *gin.Context) { |
| | | var reqParams request.AddFinenessRegister |
| | | var params models.FinenessRegister |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if err := structx.AssignTo(reqParams, ¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "数据转换错误") |
| | | return |
| | | } |
| | | |
| | | if err := slf.ParamsCheck(params); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | |
| | | check, err := models.NewFinenessCheckSearch().SetID(params.ID).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "检验记录不存在") |
| | | return |
| | | } |
| | | |
| | | err = models.WithTransaction(func(db *gorm.DB) error { |
| | | search := models.NewFinenessRegisterSearch().SetOrm(db) |
| | | |
| | | if params.ID != 0 { |
| | | if err := models.NewFinenessCheckItemSearch().SetOrm(db).SetFinenessRegisterID(check.FinenessRegisterID).Delete(); err != nil { |
| | | return err |
| | | } |
| | | return search.Save(¶ms) |
| | | } else { |
| | | return search.Create(¶ms) |
| | | } |
| | | }) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "保存失败") |
| | | } |
| | | |
| | | err = service.FinenessCheck(¶ms) |
| | | if err != nil { |
| | | logx.Errorf("service.FinenessCheck err:%v, finenessRegister:%+v", err, params) |
| | | util.ResponseFormat(c, code.RequestParamError, "生成检验表失败") |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "保存成功") |
| | | } |
| | |
| | | ) |
| | | |
| | | 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"` //车间 |
| | | 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"` //规格 |
| | | Circle uint8 `gorm:"not null;comment:回数" json:"circle"` //回数 |
| | | TotalCircle uint8 `gorm:"not null;comment:总回数" json:"totalCircle"` //总回数 |
| | | 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"` //合计数量 |
| | | 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 int `gorm:"type:int(11);not null;default:0;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"` //规格 |
| | | Circle uint8 `gorm:"not null;comment:回数" json:"circle"` //回数 |
| | | TotalCircle uint8 `gorm:"not null;comment:总回数" json:"totalCircle"` //总回数 |
| | | 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 { |
| | | Position int8 `json:"position"` //车号 |
| | | Fineness decimal.Decimal `json:"fineness"` //纤度 |
| | | Fineness float32 `json:"fineness"` //纤度 |
| | | Quantity decimal.Decimal `json:"quantity"` //数量 |
| | | Sum decimal.Decimal `json:"sum"` //合计 |
| | | } |
| | | |
| | | type GetFinenessRegisterList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword" form:"keyword"` |
| | | } |
New file |
| | |
| | | package response |
| | | |
| | | import "silkserver/models" |
| | | |
| | | type FinenessCheckInfo struct { |
| | | Info *models.FinenessCheck `json:"info"` |
| | | Items []*models.FinenessCheckItem `json:"items"` |
| | | } |
| | |
| | | // @Summary 保存车间管理 |
| | | // @Produce application/json |
| | | // @Param object body models.WorkshopManage true "参数" |
| | | // |
| | | // @Param Authorization header string true "token" |
| | | // |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/system/saveWorkshopManage [post] |
| | | func (slf WorkshopManageController) SaveWorkshopManage(c *gin.Context) { |
| | |
| | | "host": "{{.Host}}", |
| | | "basePath": "{{.BasePath}}", |
| | | "paths": { |
| | | "/api-jl/v1/fineness/check": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度检验" |
| | | ], |
| | | "summary": "纤度检验列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.FinenessRegister" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度检验" |
| | | ], |
| | | "summary": "纤度检验修改", |
| | | "parameters": [ |
| | | { |
| | | "description": "字典信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddFinenessRegister" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/check/{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" |
| | | ], |
| | | "tags": [ |
| | | "纤度检验" |
| | | ], |
| | | "summary": "纤度检验删除", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "字典信息", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/register": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | ], |
| | | "summary": "纤度登记列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddFinenessRegister" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | "schema": { |
| | | "$ref": "#/definitions/models.WorkshopManage" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "AllCar": "全车", |
| | | "AllCar": "全车结束", |
| | | "LeftHalfCar": "左半车", |
| | | "RightHalfCar": "右半车" |
| | | }, |
| | |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "string" |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "string" |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "contact": {} |
| | | }, |
| | | "paths": { |
| | | "/api-jl/v1/fineness/check": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度检验" |
| | | ], |
| | | "summary": "纤度检验列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.FinenessRegister" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "纤度检验" |
| | | ], |
| | | "summary": "纤度检验修改", |
| | | "parameters": [ |
| | | { |
| | | "description": "字典信息", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddFinenessRegister" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/check/{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" |
| | | ], |
| | | "tags": [ |
| | | "纤度检验" |
| | | ], |
| | | "summary": "纤度检验删除", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "字典信息", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/fineness/register": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | ], |
| | | "summary": "纤度登记列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddFinenessRegister" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | "schema": { |
| | | "$ref": "#/definitions/models.WorkshopManage" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | 3 |
| | | ], |
| | | "x-enum-comments": { |
| | | "AllCar": "全车", |
| | | "AllCar": "全车结束", |
| | | "LeftHalfCar": "左半车", |
| | | "RightHalfCar": "右半车" |
| | | }, |
| | |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "string" |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "string" |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | - 3 |
| | | type: integer |
| | | x-enum-comments: |
| | | AllCar: 全车 |
| | | AllCar: 全车结束 |
| | | LeftHalfCar: 左半车 |
| | | RightHalfCar: 右半车 |
| | | x-enum-varnames: |
| | |
| | | type: string |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: string |
| | | type: integer |
| | | type: object |
| | | models.RawSilkPriceStandard: |
| | | properties: |
| | |
| | | type: integer |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: string |
| | | type: integer |
| | | type: object |
| | | request.DynamicsRank: |
| | | properties: |
| | |
| | | info: |
| | | contact: {} |
| | | paths: |
| | | /api-jl/v1/fineness/check: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | | name: keyword |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/models.FinenessRegister' |
| | | type: array |
| | | type: object |
| | | summary: 纤度检验列表 |
| | | tags: |
| | | - 纤度检验 |
| | | post: |
| | | parameters: |
| | | - description: 字典信息 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddFinenessRegister' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 纤度检验修改 |
| | | tags: |
| | | - 纤度检验 |
| | | /api-jl/v1/fineness/check/{id}: |
| | | delete: |
| | | parameters: |
| | | - description: 字典信息 |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | 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/fineness/register: |
| | | get: |
| | | parameters: |
| | | - in: query |
| | | name: keyword |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddFinenessRegister' |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/models.WorkshopManage' |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | FinenessRegister{}, |
| | | FinenessItem{}, |
| | | FinenessCheck{}, |
| | | FinenessCheckItem{}, |
| | | RawSilkPriceStandard{}, |
| | | RawSilkRankStandard{}, |
| | | WorkshopManage{}, |
| | |
| | | // 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 int `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"` //规格 |
| | | Circle uint8 `gorm:"not null;comment:回数" json:"circle"` //回数 |
| | | TotalCircle uint8 `gorm:"not null;comment:总回数" json:"totalCircle"` //总回数 |
| | | 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 int `gorm:"type:int(11);not null;default:0;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"` //规格 |
| | | Circle uint8 `gorm:"not null;comment:回数" json:"circle"` //回数 |
| | | TotalCircle uint8 `gorm:"not null;comment:总回数" json:"totalCircle"` //总回数 |
| | | 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"` |
| | |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Keyword string |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) SetKeyword(keyword string) *FinenessRegisterSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessRegisterSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Model(&FinenessRegister{}).Preload("FinenessList") |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("number like ?", fmt.Sprintf("%%%s%%", slf.Keyword)) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Keyword string |
| | | } |
| | | ) |
| | | |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessCheckSearch) SetKeyword(keyword string) *FinenessCheckSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessCheckSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | db = db.Where("number like ?", fmt.Sprintf("%%%s%%", slf.Keyword)) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Model(&FinenessCheck{}).Preload("FinenessRegister") |
| | | } |
| | |
| | | package models |
| | | |
| | | import ( |
| | | "encoding/json" |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | |
| | | // FinenessCheckItem 纤度检验明细 |
| | | FinenessCheckItem struct { |
| | | gorm.Model |
| | | FinenessRegisterID uint `gorm:"not null;comment:纤度登记表ID" json:"finenessRegisterID"` //纤度登记表ID |
| | | FinenessCheckID uint `gorm:"not null;comment:纤度检验表ID" json:"finenessCheckID"` //纤度检验表ID |
| | | Position int `json:"position"` //车号 |
| | | FinenessRoundingItem []*FinenessRoundingItem |
| | | Deviation decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:偏差" json:"deviation"` //偏差 |
| | | TotalDeviation decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:总差" json:"totalDeviation"` //总差 |
| | | FinenessGrade string `gorm:"type:varchar(255);not null;comment:纤度等级" json:"finenessGrade"` //纤度等级 |
| | | Cleanliness decimal.Decimal `gorm:"type:varchar(255);not null;comment:清洁度" json:"cleanliness"` //清洁度 |
| | | Purity decimal.Decimal `gorm:"type:varchar(255);not null;comment:洁净度" json:"purity"` //洁净度 |
| | | TwiceChange decimal.Decimal `gorm:"type:varchar(255);not null;comment:二度变化" json:"twiceChange"` //二度变化 |
| | | Remark string `gorm:"type:varchar(255);not null;comment:备注" json:"remark"` //备注 |
| | | FinenessRegisterID uint `gorm:"not null;comment:纤度登记表ID" json:"finenessRegisterID"` //纤度登记表ID |
| | | //FinenessCheckID uint `gorm:"not null;comment:纤度检验表ID" json:"finenessCheckID"` //纤度检验表ID |
| | | Position int `json:"position"` //车号 |
| | | FinenessRoundingItems []*FinenessRoundingItem `json:"finenessRoundingItems" gorm:"-"` |
| | | FinenessRounding string `json:"-"` |
| | | Deviation decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:偏差" json:"deviation"` //偏差 |
| | | TotalDeviation decimal.Decimal `gorm:"type:decimal(12,2);not null;comment:总差" json:"totalDeviation"` //总差 |
| | | FinenessGrade string `gorm:"type:varchar(255);not null;comment:纤度等级" json:"finenessGrade"` //纤度等级 |
| | | Cleanliness decimal.Decimal `gorm:"type:varchar(255);not null;comment:清洁度" json:"cleanliness"` //清洁度 |
| | | Purity decimal.Decimal `gorm:"type:varchar(255);not null;comment:洁净度" json:"purity"` //洁净度 |
| | | TwiceChange decimal.Decimal `gorm:"type:varchar(255);not null;comment:二度变化" json:"twiceChange"` //二度变化 |
| | | Remark string `gorm:"type:varchar(255);not null;default:'';comment:备注" json:"remark"` //备注 |
| | | } |
| | | |
| | | FinenessRoundingItem struct { |
| | |
| | | ) |
| | | |
| | | func (slf *FinenessCheckItem) TableName() string { |
| | | return "fineness_check" |
| | | return "fineness_check_item" |
| | | } |
| | | |
| | | func (slf *FinenessCheckItem) AfterFind(tx *gorm.DB) error { |
| | | if slf.FinenessRounding != "" { |
| | | items := make([]*FinenessRoundingItem, 0) |
| | | err := json.Unmarshal([]byte(slf.FinenessRounding), &items) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.FinenessRoundingItems = items |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | func (slf *FinenessCheckItem) BeforeCreate(tx *gorm.DB) error { |
| | | if len(slf.FinenessRoundingItems) > 0 { |
| | | bts, err := json.Marshal(slf.FinenessRoundingItems) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | slf.FinenessRounding = string(bts) |
| | | } |
| | | return nil |
| | | } |
| | | |
| | | func NewFinenessCheckItemSearch() *FinenessCheckItemSearch { |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessCheckItemSearch) SetFinenessRegisterID(id uint) *FinenessCheckItemSearch { |
| | | slf.FinenessRegisterID = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FinenessCheckItemSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | |
| | | if slf.FinenessRegisterID != 0 { |
| | | db = db.Where("fineness_register_id = ?", slf.FinenessRegisterID) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | | } |
| | |
| | | r.StaticFS(conf.LocalConf.StorePath, http.Dir(conf.LocalConf.StorePath)) // 为用户头像和文件提供静态地址 |
| | | r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) |
| | | r.Use(middleware.JWTAuth()) |
| | | r.Use(middleware.VerifyResetPwd()) |
| | | //r.Use(middleware.VerifyResetPwd()) |
| | | |
| | | urlPrefix := "/api-jl/v1" |
| | | |
| | |
| | | FinenessController := new(controllers.FinenessController) |
| | | finenessApi := r.Group(urlPrefix + "/fineness") |
| | | { |
| | | finenessApi.GET("register", FinenessController.List) // 获取纤度登记列表 |
| | | finenessApi.DELETE("register/:id", FinenessController.Delete) // 删除纤度登记 |
| | | finenessApi.POST("register", FinenessController.Add) // 新增纤度登记 |
| | | finenessApi.GET("register/:id", FinenessController.Info) // 获取纤度登记详情 |
| | | finenessApi.GET("register", FinenessController.RegisterList) // 获取纤度登记列表 |
| | | finenessApi.DELETE("register/:id", FinenessController.RegisterDelete) // 删除纤度登记 |
| | | finenessApi.POST("register", FinenessController.RegisterAdd) // 新增纤度登记 |
| | | finenessApi.GET("register/:id", FinenessController.RegisterInfo) // 获取纤度登记详情 |
| | | |
| | | finenessApi.GET("check", FinenessController.CheckList) // 获取纤度检验列表 |
| | | finenessApi.DELETE("check/:id", FinenessController.CheckDelete) // 删除纤度检验 |
| | | finenessApi.PUT("check", FinenessController.CheckEdit) // 修改纤度检验 |
| | | finenessApi.GET("check/:id", FinenessController.CheckInfo) // 获取纤度检验详情 |
| | | } |
| | | |
| | | return r |
| | |
| | | }) |
| | | } |
| | | item = &models.FinenessCheckItem{ |
| | | FinenessRegisterID: finenessRegister.ID, |
| | | Position: lastCarNo, |
| | | FinenessRoundingItem: roundingItems, |
| | | Deviation: deviation, |
| | | FinenessGrade: finenessGrade, |
| | | Remark: "", |
| | | FinenessRegisterID: finenessRegister.ID, |
| | | Position: lastCarNo, |
| | | FinenessRoundingItems: roundingItems, |
| | | Deviation: deviation, |
| | | FinenessGrade: finenessGrade, |
| | | Remark: "", |
| | | } |
| | | |
| | | finenessCheckItems = append(finenessCheckItems, item) |
| | |
| | | //等级排名 |
| | | for lineId, standard := range standardMap { |
| | | for k, pair := range standard.ValueList { |
| | | if standardMap[lineId].GradeRank == nil { |
| | | standardMap[lineId].GradeRank = make(map[string]int, 0) |
| | | } |
| | | if standard.SortType == SortTypeAsc { |
| | | standardMap[lineId].GradeRank[pair.RankName] = k + 1 |
| | | } else { |