zhangqian
2024-04-07 2234e8fa97e85e1e69a6f970416602f283e09df6
解决联调问题,增加纤度检验相关接口
1个文件已添加
13个文件已修改
806 ■■■■■ 已修改文件
controllers/fineness.go 190 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/request/fineness.go 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/response/fineness.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/workshop_manage_controller.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/db.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/fineness.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/fineness_check.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/fineness_check_item.go 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/fineness.go 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/silk_rank.go 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/fineness.go
@@ -1,6 +1,7 @@
package controllers
import (
    "errors"
    "github.com/gin-gonic/gin"
    "gorm.io/gorm"
    "silkserver/controllers/request"
@@ -15,21 +16,24 @@
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, &params); err != nil {
        logx.Errorf("RegisterAdd 数据转换错误:%v", err.Error())
        util.ResponseFormat(c, code.RequestParamError, "数据转换错误")
        return
    }
@@ -58,30 +62,45 @@
    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(&params); 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
@@ -90,14 +109,14 @@
    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")
@@ -118,14 +137,14 @@
    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")
@@ -145,3 +164,156 @@
    }
    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(&params); 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, &params); 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(&params)
        } else {
            return search.Create(&params)
        }
    })
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "保存失败")
    }
    err = service.FinenessCheck(&params)
    if err != nil {
        logx.Errorf("service.FinenessCheck err:%v, finenessRegister:%+v", err, params)
        util.ResponseFormat(c, code.RequestParamError, "生成检验表失败")
        return
    }
    util.ResponseFormat(c, code.Success, "保存成功")
}
controllers/request/fineness.go
@@ -5,27 +5,28 @@
)
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"`
}
controllers/response/fineness.go
New file
@@ -0,0 +1,8 @@
package response
import "silkserver/models"
type FinenessCheckInfo struct {
    Info  *models.FinenessCheck       `json:"info"`
    Items []*models.FinenessCheckItem `json:"items"`
}
controllers/workshop_manage_controller.go
@@ -18,6 +18,9 @@
//    @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) {
docs/docs.go
@@ -16,6 +16,153 @@
    "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": [
@@ -26,6 +173,11 @@
                ],
                "summary": "纤度登记列表",
                "parameters": [
                    {
                        "type": "string",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
@@ -80,6 +232,13 @@
                        "schema": {
                            "$ref": "#/definitions/request.AddFinenessRegister"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
@@ -588,6 +747,13 @@
                        "schema": {
                            "$ref": "#/definitions/models.WorkshopManage"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
@@ -610,7 +776,7 @@
                3
            ],
            "x-enum-comments": {
                "AllCar": "全车",
                "AllCar": "全车结束",
                "LeftHalfCar": "左半车",
                "RightHalfCar": "右半车"
            },
@@ -807,7 +973,7 @@
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "string"
                    "type": "integer"
                }
            }
        },
@@ -955,7 +1121,7 @@
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "string"
                    "type": "integer"
                }
            }
        },
docs/swagger.json
@@ -4,6 +4,153 @@
        "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": [
@@ -14,6 +161,11 @@
                ],
                "summary": "纤度登记列表",
                "parameters": [
                    {
                        "type": "string",
                        "name": "keyword",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "页码",
@@ -68,6 +220,13 @@
                        "schema": {
                            "$ref": "#/definitions/request.AddFinenessRegister"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
@@ -576,6 +735,13 @@
                        "schema": {
                            "$ref": "#/definitions/models.WorkshopManage"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
@@ -598,7 +764,7 @@
                3
            ],
            "x-enum-comments": {
                "AllCar": "全车",
                "AllCar": "全车结束",
                "LeftHalfCar": "左半车",
                "RightHalfCar": "右半车"
            },
@@ -795,7 +961,7 @@
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "string"
                    "type": "integer"
                }
            }
        },
@@ -943,7 +1109,7 @@
                },
                "workshopGroup": {
                    "description": "车组",
                    "type": "string"
                    "type": "integer"
                }
            }
        },
docs/swagger.yaml
@@ -6,7 +6,7 @@
    - 3
    type: integer
    x-enum-comments:
      AllCar: 全车
      AllCar: 全车结束
      LeftHalfCar: 左半车
      RightHalfCar: 右半车
    x-enum-varnames:
@@ -148,7 +148,7 @@
        type: string
      workshopGroup:
        description: 车组
        type: string
        type: integer
    type: object
  models.RawSilkPriceStandard:
    properties:
@@ -249,7 +249,7 @@
        type: integer
      workshopGroup:
        description: 车组
        type: string
        type: integer
    type: object
  request.DynamicsRank:
    properties:
@@ -397,9 +397,101 @@
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
@@ -433,6 +525,11 @@
        required: true
        schema:
          $ref: '#/definitions/request.AddFinenessRegister'
      - description: token
        in: header
        name: Authorization
        required: true
        type: string
      produces:
      - application/json
      responses:
@@ -748,6 +845,11 @@
        required: true
        schema:
          $ref: '#/definitions/models.WorkshopManage'
      - description: token
        in: header
        name: Authorization
        required: true
        type: string
      produces:
      - application/json
      responses:
models/db.go
@@ -77,6 +77,7 @@
        FinenessRegister{},
        FinenessItem{},
        FinenessCheck{},
        FinenessCheckItem{},
        RawSilkPriceStandard{},
        RawSilkRankStandard{},
        WorkshopManage{},
models/fineness.go
@@ -11,14 +11,14 @@
    // 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"`
@@ -30,6 +30,7 @@
        PageSize int
        Orm      *gorm.DB
        Preload  bool
        Keyword  string
    }
)
@@ -71,6 +72,11 @@
    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())
@@ -90,6 +96,10 @@
        db = db.Model(&FinenessRegister{}).Preload("FinenessList")
    }
    if slf.Keyword != "" {
        db = db.Where("number like ?", fmt.Sprintf("%%%s%%", slf.Keyword))
    }
    return db
}
models/fineness_check.go
@@ -31,6 +31,7 @@
        PageSize int
        Orm      *gorm.DB
        Preload  bool
        Keyword  string
    }
)
@@ -67,6 +68,11 @@
    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())
@@ -77,6 +83,11 @@
    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")
    }
models/fineness_check_item.go
@@ -1,6 +1,7 @@
package models
import (
    "encoding/json"
    "fmt"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
@@ -11,17 +12,18 @@
    // 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 {
@@ -39,7 +41,30 @@
)
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 {
@@ -71,6 +96,11 @@
    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())
@@ -78,6 +108,10 @@
        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)
    }
router/router.go
@@ -19,7 +19,7 @@
    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"
@@ -51,10 +51,15 @@
    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
service/fineness.go
@@ -51,12 +51,12 @@
                })
            }
            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)
service/silk_rank.go
@@ -101,6 +101,9 @@
    //等级排名
    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 {