From 84ba1d3f701f6f128ffc1b23b333453ea153b5f5 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 09 四月 2024 09:56:19 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/silk/silkServer --- models/fineness_check_item.go | 58 ++ service/silk_rank.go | 3 controllers/response/fineness.go | 8 controllers/fineness.go | 173 +++++++ models/fineness.go | 26 controllers/request/fineness.go | 27 docs/swagger.yaml | 223 ++++++++++ docs/docs.go | 335 +++++++++++++++ docs/swagger.json | 335 +++++++++++++++ controllers/workshop_manage_controller.go | 16 router/router.go | 17 service/fineness.go | 21 models/fineness_check.go | 11 models/db.go | 1 14 files changed, 1,185 insertions(+), 69 deletions(-) diff --git a/controllers/fineness.go b/controllers/fineness.go index 43981d1..b675bcf 100644 --- a/controllers/fineness.go +++ b/controllers/fineness.go @@ -1,9 +1,11 @@ package controllers import ( + "errors" "github.com/gin-gonic/gin" "gorm.io/gorm" "silkserver/controllers/request" + "silkserver/controllers/response" "silkserver/extend/code" "silkserver/extend/util" "silkserver/models" @@ -15,21 +17,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, ¶ms); err != nil { + logx.Errorf("RegisterAdd 鏁版嵁杞崲閿欒:%v", err.Error()) util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒") return } @@ -58,30 +63,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(¶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 @@ -90,14 +110,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 +138,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 +165,138 @@ } util.ResponseFormat(c, code.UpdateSuccess, "鍒犻櫎鎴愬姛") } + +// CheckList +// @Tags 绾ゅ害妫�楠� +// @Summary 绾ゅ害妫�楠屽垪琛� +// @Produce application/json +// @Param object query request.GetFinenessRegisterList true "鏌ヨ鍙傛暟" +// @Success 200 {object} util.ResponseList{data=[]models.FinenessCheck} "鎴愬姛" +// @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=response.FinenessCheckInfo} "鎴愬姛" +// @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().SetFinenessRegisterID(info.FinenessRegisterID).FindAll() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") + return + } + + util.ResponseFormat(c, code.Success, resp) +} + +// 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 models.FinenessCheck true "瀛楀吀淇℃伅" +// @Success 200 {object} util.Response "鎴愬姛" +// @Router /api-jl/v1/fineness/check [post] +func (slf FinenessController) CheckEdit(c *gin.Context) { + var params models.FinenessCheck + if err := c.BindJSON(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + return + } + + _, err := models.NewFinenessCheckSearch().SetID(params.ID).First() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "妫�楠岃褰曚笉瀛樺湪") + return + } + + err = service.FinenessReCheck(¶ms) + if err != nil { + logx.Errorf("service.FinenessReCheck err:%v, finenessCheck:%+v", err, params) + util.ResponseFormat(c, code.RequestParamError, "妫�楠屽け璐�") + return + } + + err = models.NewFinenessCheckSearch().Save(¶ms) + if err != nil { + 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 b06c4d9..dfd7e4e 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) { @@ -41,12 +44,13 @@ // GetWorkshopManageList // -// @Tags 绯荤粺璁剧疆/杞﹂棿绠$悊 -// @Summary 鑾峰彇杞﹂棿绠$悊鍒楄〃 -// @Produce application/json -// @Param object query request.GetPriceStandard true "鍙傛暟" -// @Success 200 {object} util.ResponseList{data=[]models.WorkshopManage} "鎴愬姛" -// @Router /api-jl/v1/system/getWorkshopManageList [get] +// @Tags 绯荤粺璁剧疆/杞﹂棿绠$悊 +// @Summary 鑾峰彇杞﹂棿绠$悊鍒楄〃 +// @Produce application/json +// @Param Authorization header string true "token" +// @Param object query request.GetPriceStandard true "鍙傛暟" +// @Success 200 {object} util.ResponseList{data=[]models.WorkshopManage} "鎴愬姛" +// @Router /api-jl/v1/system/getWorkshopManageList [get] func (slf WorkshopManageController) GetWorkshopManageList(c *gin.Context) { var param request.GetWorkshopManage err := c.ShouldBindQuery(¶m) diff --git a/docs/docs.go b/docs/docs.go index 0b5baf6..ad2a8c8 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.FinenessCheck" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "绾ゅ害妫�楠�" + ], + "summary": "绾ゅ害妫�楠屼慨鏀�", + "parameters": [ + { + "description": "瀛楀吀淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.FinenessCheck" + } + } + ], + "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/response.FinenessCheckInfo" + } + } + } + ] + } + } + } + }, + "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": { @@ -469,6 +628,13 @@ "parameters": [ { "type": "string", + "description": "token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", "name": "keyWord", "in": "query" }, @@ -588,6 +754,13 @@ "schema": { "$ref": "#/definitions/models.WorkshopManage" } + }, + { + "type": "string", + "description": "token", + "name": "Authorization", + "in": "header", + "required": true } ], "responses": { @@ -610,7 +783,7 @@ 3 ], "x-enum-comments": { - "AllCar": "鍏ㄨ溅", + "AllCar": "鍏ㄨ溅缁撴潫", "LeftHalfCar": "宸﹀崐杞�", "RightHalfCar": "鍙冲崐杞�" }, @@ -714,6 +887,135 @@ } } }, + "models.FinenessCheck": { + "type": "object", + "properties": { + "averageFineness": { + "description": "骞冲潎绾ゅ害", + "type": "number" + }, + "cleanliness": { + "description": "娓呮磥搴�", + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "deletedAt": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "deviation": { + "description": "鍋忓樊", + "type": "number" + }, + "finenessGrade": { + "description": "绾ゅ害绛夌骇", + "type": "string" + }, + "finenessRegister": { + "description": "绾ゅ害鐧昏", + "allOf": [ + { + "$ref": "#/definitions/models.FinenessRegister" + } + ] + }, + "finenessRegisterID": { + "description": "绾ゅ害鐧昏琛↖D", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "inspector": { + "description": "妫�楠屽憳", + "type": "string" + }, + "marketProcessOrderNumber": { + "description": "搴勫彛宸ヨ壓鍗曠紪鍙�", + "type": "string" + }, + "measureFineness": { + "description": "鍏噺绾ゅ害", + "type": "number" + }, + "purity": { + "description": "娲佸噣搴�", + "type": "number" + }, + "totalDeviation": { + "description": "鎬诲樊", + "type": "number" + }, + "twiceChange": { + "description": "浜屽害鍙樺寲", + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "models.FinenessCheckItem": { + "type": "object", + "properties": { + "cleanliness": { + "description": "娓呮磥搴�", + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "deletedAt": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "deviation": { + "description": "鍋忓樊", + "type": "number" + }, + "finenessGrade": { + "description": "绾ゅ害绛夌骇", + "type": "string" + }, + "finenessRegisterID": { + "description": "绾ゅ害鐧昏琛↖D", + "type": "integer" + }, + "finenessRoundingItems": { + "description": "绾ゅ害鍒楄〃", + "type": "array", + "items": { + "$ref": "#/definitions/models.FinenessRoundingItem" + } + }, + "id": { + "type": "integer" + }, + "position": { + "description": "FinenessCheckID uint ` + "`" + `gorm:\"not null;comment:绾ゅ害妫�楠岃〃ID\" json:\"finenessCheckID\"` + "`" + ` //绾ゅ害妫�楠岃〃ID", + "type": "integer" + }, + "purity": { + "description": "娲佸噣搴�", + "type": "number" + }, + "remark": { + "description": "澶囨敞", + "type": "string" + }, + "totalDeviation": { + "description": "鎬诲樊", + "type": "number" + }, + "twiceChange": { + "description": "浜屽害鍙樺寲", + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, "models.FinenessItem": { "type": "object", "properties": { @@ -807,7 +1109,20 @@ }, "workshopGroup": { "description": "杞︾粍", - "type": "string" + "type": "integer" + } + } + }, + "models.FinenessRoundingItem": { + "type": "object", + "properties": { + "fineness": { + "description": "绾ゅ害", + "type": "number" + }, + "quantity": { + "description": "鏁伴噺", + "type": "integer" } } }, @@ -955,7 +1270,7 @@ }, "workshopGroup": { "description": "杞︾粍", - "type": "string" + "type": "integer" } } }, @@ -1096,6 +1411,20 @@ } } }, + "response.FinenessCheckInfo": { + "type": "object", + "properties": { + "info": { + "$ref": "#/definitions/models.FinenessCheck" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/models.FinenessCheckItem" + } + } + } + }, "response.RankStandard": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 57c171c..535c5b4 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.FinenessCheck" + } + } + } + } + ] + } + } + } + }, + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "绾ゅ害妫�楠�" + ], + "summary": "绾ゅ害妫�楠屼慨鏀�", + "parameters": [ + { + "description": "瀛楀吀淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/models.FinenessCheck" + } + } + ], + "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/response.FinenessCheckInfo" + } + } + } + ] + } + } + } + }, + "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": { @@ -457,6 +616,13 @@ "parameters": [ { "type": "string", + "description": "token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", "name": "keyWord", "in": "query" }, @@ -576,6 +742,13 @@ "schema": { "$ref": "#/definitions/models.WorkshopManage" } + }, + { + "type": "string", + "description": "token", + "name": "Authorization", + "in": "header", + "required": true } ], "responses": { @@ -598,7 +771,7 @@ 3 ], "x-enum-comments": { - "AllCar": "鍏ㄨ溅", + "AllCar": "鍏ㄨ溅缁撴潫", "LeftHalfCar": "宸﹀崐杞�", "RightHalfCar": "鍙冲崐杞�" }, @@ -702,6 +875,135 @@ } } }, + "models.FinenessCheck": { + "type": "object", + "properties": { + "averageFineness": { + "description": "骞冲潎绾ゅ害", + "type": "number" + }, + "cleanliness": { + "description": "娓呮磥搴�", + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "deletedAt": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "deviation": { + "description": "鍋忓樊", + "type": "number" + }, + "finenessGrade": { + "description": "绾ゅ害绛夌骇", + "type": "string" + }, + "finenessRegister": { + "description": "绾ゅ害鐧昏", + "allOf": [ + { + "$ref": "#/definitions/models.FinenessRegister" + } + ] + }, + "finenessRegisterID": { + "description": "绾ゅ害鐧昏琛↖D", + "type": "integer" + }, + "id": { + "type": "integer" + }, + "inspector": { + "description": "妫�楠屽憳", + "type": "string" + }, + "marketProcessOrderNumber": { + "description": "搴勫彛宸ヨ壓鍗曠紪鍙�", + "type": "string" + }, + "measureFineness": { + "description": "鍏噺绾ゅ害", + "type": "number" + }, + "purity": { + "description": "娲佸噣搴�", + "type": "number" + }, + "totalDeviation": { + "description": "鎬诲樊", + "type": "number" + }, + "twiceChange": { + "description": "浜屽害鍙樺寲", + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "models.FinenessCheckItem": { + "type": "object", + "properties": { + "cleanliness": { + "description": "娓呮磥搴�", + "type": "number" + }, + "createdAt": { + "type": "string" + }, + "deletedAt": { + "$ref": "#/definitions/gorm.DeletedAt" + }, + "deviation": { + "description": "鍋忓樊", + "type": "number" + }, + "finenessGrade": { + "description": "绾ゅ害绛夌骇", + "type": "string" + }, + "finenessRegisterID": { + "description": "绾ゅ害鐧昏琛↖D", + "type": "integer" + }, + "finenessRoundingItems": { + "description": "绾ゅ害鍒楄〃", + "type": "array", + "items": { + "$ref": "#/definitions/models.FinenessRoundingItem" + } + }, + "id": { + "type": "integer" + }, + "position": { + "description": "FinenessCheckID uint `gorm:\"not null;comment:绾ゅ害妫�楠岃〃ID\" json:\"finenessCheckID\"` //绾ゅ害妫�楠岃〃ID", + "type": "integer" + }, + "purity": { + "description": "娲佸噣搴�", + "type": "number" + }, + "remark": { + "description": "澶囨敞", + "type": "string" + }, + "totalDeviation": { + "description": "鎬诲樊", + "type": "number" + }, + "twiceChange": { + "description": "浜屽害鍙樺寲", + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, "models.FinenessItem": { "type": "object", "properties": { @@ -795,7 +1097,20 @@ }, "workshopGroup": { "description": "杞︾粍", - "type": "string" + "type": "integer" + } + } + }, + "models.FinenessRoundingItem": { + "type": "object", + "properties": { + "fineness": { + "description": "绾ゅ害", + "type": "number" + }, + "quantity": { + "description": "鏁伴噺", + "type": "integer" } } }, @@ -943,7 +1258,7 @@ }, "workshopGroup": { "description": "杞︾粍", - "type": "string" + "type": "integer" } } }, @@ -1084,6 +1399,20 @@ } } }, + "response.FinenessCheckInfo": { + "type": "object", + "properties": { + "info": { + "$ref": "#/definitions/models.FinenessCheck" + }, + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/models.FinenessCheckItem" + } + } + } + }, "response.RankStandard": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 732df48..94be12b 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: @@ -82,6 +82,98 @@ updatedAt: type: string type: object + models.FinenessCheck: + properties: + averageFineness: + description: 骞冲潎绾ゅ害 + type: number + cleanliness: + description: 娓呮磥搴� + type: number + createdAt: + type: string + deletedAt: + $ref: '#/definitions/gorm.DeletedAt' + deviation: + description: 鍋忓樊 + type: number + finenessGrade: + description: 绾ゅ害绛夌骇 + type: string + finenessRegister: + allOf: + - $ref: '#/definitions/models.FinenessRegister' + description: 绾ゅ害鐧昏 + finenessRegisterID: + description: 绾ゅ害鐧昏琛↖D + type: integer + id: + type: integer + inspector: + description: 妫�楠屽憳 + type: string + marketProcessOrderNumber: + description: 搴勫彛宸ヨ壓鍗曠紪鍙� + type: string + measureFineness: + description: 鍏噺绾ゅ害 + type: number + purity: + description: 娲佸噣搴� + type: number + totalDeviation: + description: 鎬诲樊 + type: number + twiceChange: + description: 浜屽害鍙樺寲 + type: number + updatedAt: + type: string + type: object + models.FinenessCheckItem: + properties: + cleanliness: + description: 娓呮磥搴� + type: number + createdAt: + type: string + deletedAt: + $ref: '#/definitions/gorm.DeletedAt' + deviation: + description: 鍋忓樊 + type: number + finenessGrade: + description: 绾ゅ害绛夌骇 + type: string + finenessRegisterID: + description: 绾ゅ害鐧昏琛↖D + type: integer + finenessRoundingItems: + description: 绾ゅ害鍒楄〃 + items: + $ref: '#/definitions/models.FinenessRoundingItem' + type: array + id: + type: integer + position: + description: FinenessCheckID uint `gorm:"not null;comment:绾ゅ害妫�楠岃〃ID" + json:"finenessCheckID"` //绾ゅ害妫�楠岃〃ID + type: integer + purity: + description: 娲佸噣搴� + type: number + remark: + description: 澶囨敞 + type: string + totalDeviation: + description: 鎬诲樊 + type: number + twiceChange: + description: 浜屽害鍙樺寲 + type: number + updatedAt: + type: string + type: object models.FinenessItem: properties: createdAt: @@ -148,7 +240,16 @@ type: string workshopGroup: description: 杞︾粍 - type: string + type: integer + type: object + models.FinenessRoundingItem: + properties: + fineness: + description: 绾ゅ害 + type: number + quantity: + description: 鏁伴噺 + type: integer type: object models.RawSilkPriceStandard: properties: @@ -249,7 +350,7 @@ type: integer workshopGroup: description: 杞︾粍 - type: string + type: integer type: object request.DynamicsRank: properties: @@ -344,6 +445,15 @@ description: 绛夌骇鍊� type: number type: object + response.FinenessCheckInfo: + properties: + info: + $ref: '#/definitions/models.FinenessCheck' + items: + items: + $ref: '#/definitions/models.FinenessCheckItem' + type: array + type: object response.RankStandard: properties: checkItem: @@ -397,9 +507,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.FinenessCheck' + type: array + type: object + summary: 绾ゅ害妫�楠屽垪琛� + tags: + - 绾ゅ害妫�楠� + post: + parameters: + - description: 瀛楀吀淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/models.FinenessCheck' + 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/response.FinenessCheckInfo' + type: object + summary: 绾ゅ害妫�楠岃鎯� + tags: + - 绾ゅ害妫�楠� /api-jl/v1/fineness/register: get: parameters: + - in: query + name: keyword + type: string - description: 椤电爜 in: query name: page @@ -433,6 +635,11 @@ required: true schema: $ref: '#/definitions/request.AddFinenessRegister' + - description: token + in: header + name: Authorization + required: true + type: string produces: - application/json responses: @@ -673,6 +880,11 @@ /api-jl/v1/system/getWorkshopManageList: get: parameters: + - description: token + in: header + name: Authorization + required: true + type: string - in: query name: keyWord type: string @@ -748,6 +960,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..80e4217 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..a16a304 100644 --- a/router/router.go +++ b/router/router.go @@ -18,8 +18,8 @@ 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.JWTAuth()) + //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..863c71f 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) @@ -202,3 +202,12 @@ result = float32(math.Round(float64(result)*10) / 10) return result } + +func FinenessReCheck(finenessCheck *models.FinenessCheck) (err error) { + standardMap, err := GetSilkRankStandard() + if err != nil { + return err + } + finenessCheck.FinenessGrade = CalcFinenessGrade(finenessCheck.Deviation, finenessCheck.TotalDeviation, finenessCheck.Cleanliness, finenessCheck.Purity, finenessCheck.TwiceChange, standardMap) + return +} 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