From 2234e8fa97e85e1e69a6f970416602f283e09df6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期日, 07 四月 2024 21:57:28 +0800
Subject: [PATCH] 解决联调问题,增加纤度检验相关接口

---
 models/fineness_check_item.go             |   58 +++
 service/silk_rank.go                      |    3 
 controllers/response/fineness.go          |    8 
 controllers/fineness.go                   |  190 ++++++++++++
 models/fineness.go                        |   26 +
 controllers/request/fineness.go           |   27 +
 docs/swagger.yaml                         |  108 +++++++
 docs/docs.go                              |  172 ++++++++++++
 docs/swagger.json                         |  172 ++++++++++++
 controllers/workshop_manage_controller.go |    3 
 router/router.go                          |   15 
 service/fineness.go                       |   12 
 models/fineness_check.go                  |   11 
 models/db.go                              |    1 
 14 files changed, 744 insertions(+), 62 deletions(-)

diff --git a/controllers/fineness.go b/controllers/fineness.go
index 43981d1..f7a9b20 100644
--- a/controllers/fineness.go
+++ b/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 鍙傛暟瑙f瀽澶辫触:%v", err.Error())
 		util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
 		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, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+		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, "淇濆瓨鎴愬姛")
+}
diff --git a/controllers/request/fineness.go b/controllers/request/fineness.go
index 76757a5..41da3f1 100644
--- a/controllers/request/fineness.go
+++ b/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"`
 }
diff --git a/controllers/response/fineness.go b/controllers/response/fineness.go
new file mode 100644
index 0000000..efdb12a
--- /dev/null
+++ b/controllers/response/fineness.go
@@ -0,0 +1,8 @@
+package response
+
+import "silkserver/models"
+
+type FinenessCheckInfo struct {
+	Info  *models.FinenessCheck       `json:"info"`
+	Items []*models.FinenessCheckItem `json:"items"`
+}
diff --git a/controllers/workshop_manage_controller.go b/controllers/workshop_manage_controller.go
index c1c85c2..5b4b706 100644
--- a/controllers/workshop_manage_controller.go
+++ b/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) {
diff --git a/docs/docs.go b/docs/docs.go
index 0b5baf6..9332540 100644
--- a/docs/docs.go
+++ b/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"
                 }
             }
         },
diff --git a/docs/swagger.json b/docs/swagger.json
index 57c171c..5e4759f 100644
--- a/docs/swagger.json
+++ b/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"
                 }
             }
         },
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 732df48..bf95cdd 100644
--- a/docs/swagger.yaml
+++ b/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:
diff --git a/models/db.go b/models/db.go
index 28a4108..f4b1266 100644
--- a/models/db.go
+++ b/models/db.go
@@ -77,6 +77,7 @@
 		FinenessRegister{},
 		FinenessItem{},
 		FinenessCheck{},
+		FinenessCheckItem{},
 		RawSilkPriceStandard{},
 		RawSilkRankStandard{},
 		WorkshopManage{},
diff --git a/models/fineness.go b/models/fineness.go
index a323ce0..bed5a7a 100644
--- a/models/fineness.go
+++ b/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
 }
 
diff --git a/models/fineness_check.go b/models/fineness_check.go
index ebe9d70..5620fee 100644
--- a/models/fineness_check.go
+++ b/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")
 	}
diff --git a/models/fineness_check_item.go b/models/fineness_check_item.go
index 9a22f55..778f74a 100644
--- a/models/fineness_check_item.go
+++ b/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:绾ゅ害鐧昏琛↖D" json:"finenessRegisterID"` //绾ゅ害鐧昏琛↖D
-		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:绾ゅ害鐧昏琛↖D" json:"finenessRegisterID"` //绾ゅ害鐧昏琛↖D
+		//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)
 	}
diff --git a/router/router.go b/router/router.go
index 8e8214f..c4d26c1 100644
--- a/router/router.go
+++ b/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
diff --git a/service/fineness.go b/service/fineness.go
index e44e1ab..95039f3 100644
--- a/service/fineness.go
+++ b/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)
diff --git a/service/silk_rank.go b/service/silk_rank.go
index a694467..ea8c57e 100644
--- a/service/silk_rank.go
+++ b/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 {

--
Gitblit v1.8.0