| | |
| | | Name string `json:"name"` //名称 |
| | | IsDefault bool `json:"isDefault"` //是否可编辑 |
| | | } |
| | | |
| | | type AddWorkPositionRequest struct { |
| | | StartDate string `gorm:"type:varchar(255);not null;default:'';comment:开始日期" validate:"required"` //开始日期 |
| | | EndDate string `gorm:"type:varchar(255);not null;default:'';comment:结束日期" validate:"required"` //结束日期 |
| | | Workshop string `gorm:"type:varchar(255);not null;comment:车间" json:"workshop" validate:"required"` //车间 |
| | | WorkshopGroup int `gorm:"type:int(11);not null;default:0;comment:车组" json:"workshopGroup" validate:"required"` //车组 |
| | | StartWorkerPosition int `json:"startWorkerPosition" gorm:"type:int(11);comment:开始车号" validate:"required"` //开始车号 |
| | | EndWorkerPosition int `json:"endWorkerPosition" gorm:"type:int(11);comment:结束车号" validate:"required"` //结束车号 |
| | | WorkerId string `gorm:"type:varchar(255);not null;default:'';comment:工人ID" json:"workerId" validate:"required"` //工人ID |
| | | } |
| | | |
| | | type UpdateWorkerPositionRequest struct { |
| | | Id uint `json:"id"` |
| | | AddWorkPositionRequest |
| | | } |
| | | |
| | | type GetWorkerPositionList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
New file |
| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/spf13/cast" |
| | | "gorm.io/gorm" |
| | | "silkserver/controllers/request" |
| | | "silkserver/extend/code" |
| | | "silkserver/extend/util" |
| | | "silkserver/middleware" |
| | | "silkserver/models" |
| | | ) |
| | | |
| | | type WorkerPositionController struct { |
| | | } |
| | | |
| | | // CreateWorkerPositionInfo |
| | | // @Tags 机台管理 |
| | | // @Summary 创建机台信息 |
| | | // @Produce application/json |
| | | // @Param object body request.AddWorkPositionRequest true "参数" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/workerPosition/createWorkerPositionInfo [post] |
| | | func (slf WorkerPositionController) CreateWorkerPositionInfo(c *gin.Context) { |
| | | var params request.AddWorkPositionRequest |
| | | err := c.BindJSON(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | |
| | | //查询是否重复 |
| | | _, err = models.NewWorkerPositionSearch().SetWorkerID(params.WorkerId).First() |
| | | if err != gorm.ErrRecordNotFound { |
| | | util.ResponseFormat(c, code.RequestParamError, "请勿重复添加") |
| | | return |
| | | } |
| | | |
| | | record := &models.WorkerPosition{ |
| | | StartDate: params.StartDate, |
| | | EndDate: params.EndDate, |
| | | Workshop: params.Workshop, |
| | | WorkshopGroup: params.WorkshopGroup, |
| | | StartWorkerPosition: params.StartWorkerPosition, |
| | | EndWorkerPosition: params.EndWorkerPosition, |
| | | WorkerId: params.WorkerId, |
| | | } |
| | | |
| | | info := middleware.GetUserInfo(c) |
| | | if info != nil { |
| | | record.Creator = info.NickName |
| | | } |
| | | |
| | | err = models.NewWorkerPositionSearch().Create(record) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "创建失败, 请重试") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, "创建成功") |
| | | } |
| | | |
| | | // UpdateWorkerPositionInfo |
| | | // @Tags 机台管理 |
| | | // @Summary 更新机台信息 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateWorkerPositionRequest true "参数" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/workerPosition/updateWorkerPositionInfo [post] |
| | | func (slf WorkerPositionController) UpdateWorkerPositionInfo(c *gin.Context) { |
| | | var params request.UpdateWorkerPositionRequest |
| | | err := c.BindJSON(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if params.Id == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数缺失") |
| | | return |
| | | } |
| | | |
| | | record := &models.WorkerPosition{ |
| | | StartDate: params.StartDate, |
| | | EndDate: params.EndDate, |
| | | Workshop: params.Workshop, |
| | | WorkshopGroup: params.WorkshopGroup, |
| | | StartWorkerPosition: params.StartWorkerPosition, |
| | | EndWorkerPosition: params.EndWorkerPosition, |
| | | WorkerId: params.WorkerId, |
| | | } |
| | | |
| | | info := middleware.GetUserInfo(c) |
| | | if info != nil { |
| | | record.Creator = info.NickName |
| | | } |
| | | |
| | | err = models.NewWorkerPositionSearch().SetID(params.Id).Update(record) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "更新失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, "更新成功") |
| | | } |
| | | |
| | | // GetWorkerPositionList |
| | | // |
| | | // @Tags 机台管理 |
| | | // @Summary 获取机台信息列表 |
| | | // @Produce application/json |
| | | // @Param object body request.GetWorkerPositionList true "参数" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.ResponseList{data=[]models.WorkerPosition} "成功" |
| | | // @Router /api-jl/v1/workerPosition/getWorkerPositionList [post] |
| | | func (slf WorkerPositionController) GetWorkerPositionList(c *gin.Context) { |
| | | var params request.GetWorkerPositionList |
| | | err := c.BindJSON(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | WorkerPositions, total, err := models.NewWorkerPositionSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetPreload().Find() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查询失败") |
| | | return |
| | | } |
| | | util.ResponseFormatList(c, code.Success, WorkerPositions, total) |
| | | } |
| | | |
| | | // DeleteWorkerPositionInfo |
| | | // |
| | | // @Tags 机台管理 |
| | | // @Summary 删除机台信息 |
| | | // @Produce application/json |
| | | // @Param id path string true "id" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/workerPosition/deleteWorkerPositionInfo/{id} [delete] |
| | | func (slf WorkerPositionController) DeleteWorkerPositionInfo(c *gin.Context) { |
| | | id := c.Param("id") |
| | | if id == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "无效的id") |
| | | return |
| | | } |
| | | idInt := cast.ToUint(id) |
| | | if idInt == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "无效的id") |
| | | return |
| | | } |
| | | err := models.NewWorkerPositionSearch().SetID(idInt).Delete() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "删除失败") |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, "删除成功") |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/createWorkerPositionInfo": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "创建机台信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddWorkPositionRequest" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/deleteWorkerPositionInfo/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "删除机台信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/getWorkerPositionList": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "获取机台信息列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetWorkerPositionList" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.WorkerPosition" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/updateWorkerPositionInfo": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "更新机台信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateWorkerPositionRequest" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "definitions": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "worker": { |
| | | "description": "工人ID", |
| | | "description": "工人", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Worker" |
| | |
| | | "type": "string" |
| | | }, |
| | | "workTypeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "models.WorkerPosition": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createdAt": { |
| | | "type": "string" |
| | | }, |
| | | "creator": { |
| | | "type": "string" |
| | | }, |
| | | "deletedAt": { |
| | | "$ref": "#/definitions/gorm.DeletedAt" |
| | | }, |
| | | "endDate": { |
| | | "description": "结束日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkerPosition": { |
| | | "description": "结束车号", |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "车间", |
| | | "type": "string" |
| | | }, |
| | | "startDate": { |
| | | "description": "开始日期", |
| | | "type": "string" |
| | | }, |
| | | "startWorkerPosition": { |
| | | "description": "开始车号", |
| | | "type": "integer" |
| | | }, |
| | | "updatedAt": { |
| | | "type": "string" |
| | | }, |
| | | "worker": { |
| | | "description": "工人", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Worker" |
| | | } |
| | | ] |
| | | }, |
| | | "workerId": { |
| | | "description": "工人ID", |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "integer" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddWorkPositionRequest": { |
| | | "type": "object", |
| | | "required": [ |
| | | "endDate", |
| | | "endWorkerPosition", |
| | | "startDate", |
| | | "startWorkerPosition", |
| | | "workerId", |
| | | "workshop", |
| | | "workshopGroup" |
| | | ], |
| | | "properties": { |
| | | "endDate": { |
| | | "description": "结束日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkerPosition": { |
| | | "description": "结束车号", |
| | | "type": "integer" |
| | | }, |
| | | "startDate": { |
| | | "description": "开始日期", |
| | | "type": "string" |
| | | }, |
| | | "startWorkerPosition": { |
| | | "description": "开始车号", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "工人ID", |
| | | "type": "string" |
| | | }, |
| | | "workshop": { |
| | | "description": "车间", |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.ChangeYieldRegister": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | }, |
| | | "request.GetWorkerList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetWorkerPositionList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateWorkerPositionRequest": { |
| | | "type": "object", |
| | | "required": [ |
| | | "endDate", |
| | | "endWorkerPosition", |
| | | "startDate", |
| | | "startWorkerPosition", |
| | | "workerId", |
| | | "workshop", |
| | | "workshopGroup" |
| | | ], |
| | | "properties": { |
| | | "endDate": { |
| | | "description": "结束日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkerPosition": { |
| | | "description": "结束车号", |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "startDate": { |
| | | "description": "开始日期", |
| | | "type": "string" |
| | | }, |
| | | "startWorkerPosition": { |
| | | "description": "开始车号", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "工人ID", |
| | | "type": "string" |
| | | }, |
| | | "workshop": { |
| | | "description": "车间", |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.YieldRegisterCircleInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/createWorkerPositionInfo": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "创建机台信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.AddWorkPositionRequest" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/deleteWorkerPositionInfo/{id}": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "删除机台信息", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/getWorkerPositionList": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "获取机台信息列表", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.GetWorkerPositionList" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "array", |
| | | "items": { |
| | | "$ref": "#/definitions/models.WorkerPosition" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/workerPosition/updateWorkerPositionInfo": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "机台管理" |
| | | ], |
| | | "summary": "更新机台信息", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.UpdateWorkerPositionRequest" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "definitions": { |
| | |
| | | "type": "string" |
| | | }, |
| | | "worker": { |
| | | "description": "工人ID", |
| | | "description": "工人", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Worker" |
| | |
| | | "type": "string" |
| | | }, |
| | | "workTypeId": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "models.WorkerPosition": { |
| | | "type": "object", |
| | | "properties": { |
| | | "createdAt": { |
| | | "type": "string" |
| | | }, |
| | | "creator": { |
| | | "type": "string" |
| | | }, |
| | | "deletedAt": { |
| | | "$ref": "#/definitions/gorm.DeletedAt" |
| | | }, |
| | | "endDate": { |
| | | "description": "结束日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkerPosition": { |
| | | "description": "结束车号", |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "name": { |
| | | "description": "车间", |
| | | "type": "string" |
| | | }, |
| | | "startDate": { |
| | | "description": "开始日期", |
| | | "type": "string" |
| | | }, |
| | | "startWorkerPosition": { |
| | | "description": "开始车号", |
| | | "type": "integer" |
| | | }, |
| | | "updatedAt": { |
| | | "type": "string" |
| | | }, |
| | | "worker": { |
| | | "description": "工人", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/models.Worker" |
| | | } |
| | | ] |
| | | }, |
| | | "workerId": { |
| | | "description": "工人ID", |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "integer" |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.AddWorkPositionRequest": { |
| | | "type": "object", |
| | | "required": [ |
| | | "endDate", |
| | | "endWorkerPosition", |
| | | "startDate", |
| | | "startWorkerPosition", |
| | | "workerId", |
| | | "workshop", |
| | | "workshopGroup" |
| | | ], |
| | | "properties": { |
| | | "endDate": { |
| | | "description": "结束日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkerPosition": { |
| | | "description": "结束车号", |
| | | "type": "integer" |
| | | }, |
| | | "startDate": { |
| | | "description": "开始日期", |
| | | "type": "string" |
| | | }, |
| | | "startWorkerPosition": { |
| | | "description": "开始车号", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "工人ID", |
| | | "type": "string" |
| | | }, |
| | | "workshop": { |
| | | "description": "车间", |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.ChangeYieldRegister": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | }, |
| | | "request.GetWorkerList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetWorkerPositionList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.UpdateWorkerPositionRequest": { |
| | | "type": "object", |
| | | "required": [ |
| | | "endDate", |
| | | "endWorkerPosition", |
| | | "startDate", |
| | | "startWorkerPosition", |
| | | "workerId", |
| | | "workshop", |
| | | "workshopGroup" |
| | | ], |
| | | "properties": { |
| | | "endDate": { |
| | | "description": "结束日期", |
| | | "type": "string" |
| | | }, |
| | | "endWorkerPosition": { |
| | | "description": "结束车号", |
| | | "type": "integer" |
| | | }, |
| | | "id": { |
| | | "type": "integer" |
| | | }, |
| | | "startDate": { |
| | | "description": "开始日期", |
| | | "type": "string" |
| | | }, |
| | | "startWorkerPosition": { |
| | | "description": "开始车号", |
| | | "type": "integer" |
| | | }, |
| | | "workerId": { |
| | | "description": "工人ID", |
| | | "type": "string" |
| | | }, |
| | | "workshop": { |
| | | "description": "车间", |
| | | "type": "string" |
| | | }, |
| | | "workshopGroup": { |
| | | "description": "车组", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | | "request.YieldRegisterCircleInfo": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | worker: |
| | | allOf: |
| | | - $ref: '#/definitions/models.Worker' |
| | | description: 工人ID |
| | | description: 工人 |
| | | workerId: |
| | | description: 工人ID |
| | | type: string |
| | |
| | | workType: |
| | | type: string |
| | | workTypeId: |
| | | type: integer |
| | | type: object |
| | | models.WorkerPosition: |
| | | properties: |
| | | createdAt: |
| | | type: string |
| | | creator: |
| | | type: string |
| | | deletedAt: |
| | | $ref: '#/definitions/gorm.DeletedAt' |
| | | endDate: |
| | | description: 结束日期 |
| | | type: string |
| | | endWorkerPosition: |
| | | description: 结束车号 |
| | | type: integer |
| | | id: |
| | | type: integer |
| | | name: |
| | | description: 车间 |
| | | type: string |
| | | startDate: |
| | | description: 开始日期 |
| | | type: string |
| | | startWorkerPosition: |
| | | description: 开始车号 |
| | | type: integer |
| | | updatedAt: |
| | | type: string |
| | | worker: |
| | | allOf: |
| | | - $ref: '#/definitions/models.Worker' |
| | | description: 工人 |
| | | workerId: |
| | | description: 工人ID |
| | | type: string |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: integer |
| | | type: object |
| | | models.WorkshopManage: |
| | |
| | | description: 工人ID |
| | | type: string |
| | | type: object |
| | | request.AddWorkPositionRequest: |
| | | properties: |
| | | endDate: |
| | | description: 结束日期 |
| | | type: string |
| | | endWorkerPosition: |
| | | description: 结束车号 |
| | | type: integer |
| | | startDate: |
| | | description: 开始日期 |
| | | type: string |
| | | startWorkerPosition: |
| | | description: 开始车号 |
| | | type: integer |
| | | workerId: |
| | | description: 工人ID |
| | | type: string |
| | | workshop: |
| | | description: 车间 |
| | | type: string |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: integer |
| | | required: |
| | | - endDate |
| | | - endWorkerPosition |
| | | - startDate |
| | | - startWorkerPosition |
| | | - workerId |
| | | - workshop |
| | | - workshopGroup |
| | | type: object |
| | | request.ChangeYieldRegister: |
| | | properties: |
| | | createTime: |
| | |
| | | type: integer |
| | | type: object |
| | | request.GetWorkerList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.GetWorkerPositionList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | |
| | | workerId: |
| | | description: 工人ID |
| | | type: string |
| | | type: object |
| | | request.UpdateWorkerPositionRequest: |
| | | properties: |
| | | endDate: |
| | | description: 结束日期 |
| | | type: string |
| | | endWorkerPosition: |
| | | description: 结束车号 |
| | | type: integer |
| | | id: |
| | | type: integer |
| | | startDate: |
| | | description: 开始日期 |
| | | type: string |
| | | startWorkerPosition: |
| | | description: 开始车号 |
| | | type: integer |
| | | workerId: |
| | | description: 工人ID |
| | | type: string |
| | | workshop: |
| | | description: 车间 |
| | | type: string |
| | | workshopGroup: |
| | | description: 车组 |
| | | type: integer |
| | | required: |
| | | - endDate |
| | | - endWorkerPosition |
| | | - startDate |
| | | - startWorkerPosition |
| | | - workerId |
| | | - workshop |
| | | - workshopGroup |
| | | type: object |
| | | request.YieldRegisterCircleInfo: |
| | | properties: |
| | |
| | | summary: 更新人员信息 |
| | | tags: |
| | | - 员工管理/员工信息 |
| | | /api-jl/v1/workerPosition/createWorkerPositionInfo: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.AddWorkPositionRequest' |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 创建机台信息 |
| | | tags: |
| | | - 机台管理 |
| | | /api-jl/v1/workerPosition/deleteWorkerPositionInfo/{id}: |
| | | delete: |
| | | parameters: |
| | | - description: id |
| | | in: path |
| | | name: id |
| | | required: true |
| | | type: string |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 删除机台信息 |
| | | tags: |
| | | - 机台管理 |
| | | /api-jl/v1/workerPosition/getWorkerPositionList: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.GetWorkerPositionList' |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | items: |
| | | $ref: '#/definitions/models.WorkerPosition' |
| | | type: array |
| | | type: object |
| | | summary: 获取机台信息列表 |
| | | tags: |
| | | - 机台管理 |
| | | /api-jl/v1/workerPosition/updateWorkerPositionInfo: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.UpdateWorkerPositionRequest' |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 更新机台信息 |
| | | tags: |
| | | - 机台管理 |
| | | swagger: "2.0" |
| | |
| | | SalaryPlan{}, |
| | | Mentor{}, |
| | | AttendanceManage{}, |
| | | WorkerPosition{}, |
| | | ) |
| | | return err |
| | | } |
| | |
| | | Mentor struct { |
| | | gorm.Model |
| | | WorkerId string `gorm:"unique_index:worker_id_month;type:varchar(255);not null;default:'';comment:工人ID" json:"workerId"` //工人ID |
| | | Worker Worker `gorm:"foreignkey:WorkerId" json:"worker"` //工人ID |
| | | Worker Worker `gorm:"foreignkey:WorkerId" json:"worker"` //工人 |
| | | Creator string `gorm:"type:varchar(255);not null;default:'';comment:添加人" json:"creator"` |
| | | Month string `gorm:"unique_index:worker_id_month;type:varchar(255);not null;default:'';comment:月份" json:"month"` //月份 |
| | | Days int `gorm:"type:tinyint;not null;default:0;comment:天数" json:"days"` //天数 |
New file |
| | |
| | | package models |
| | | |
| | | import ( |
| | | "fmt" |
| | | "gorm.io/gorm" |
| | | "silkserver/pkg/mysqlx" |
| | | ) |
| | | |
| | | type ( |
| | | // WorkerPosition 机台管理 |
| | | WorkerPosition struct { |
| | | gorm.Model |
| | | StartDate string `gorm:"type:varchar(255);not null;default:'';comment:开始日期"` //开始日期 |
| | | EndDate string `gorm:"type:varchar(255);not null;default:'';comment:结束日期"` //结束日期 |
| | | Workshop string `gorm:"type:varchar(255);not null;comment:车间" json:"name"` //车间 |
| | | WorkshopGroup int `gorm:"type:int(11);not null;default:0;comment:车组" json:"workshopGroup"` //车组 |
| | | StartWorkerPosition int `json:"startWorkerPosition" gorm:"type:int(11);comment:开始车号"` //开始车号 |
| | | EndWorkerPosition int `json:"endWorkerPosition" gorm:"type:int(11);comment:结束车号"` //结束车号 |
| | | WorkerId string `gorm:"type:varchar(255);not null;default:'';comment:工人ID" json:"workerId"` //工人ID |
| | | Worker Worker `gorm:"foreignkey:WorkerId" json:"worker"` //工人 |
| | | Creator string `gorm:"type:varchar(255);not null;default:'';comment:添加人" json:"creator"` |
| | | } |
| | | WorkerPositionSearch struct { |
| | | WorkerPosition |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | | Orm *gorm.DB |
| | | Preload bool |
| | | Keyword string |
| | | } |
| | | ) |
| | | |
| | | func (slf *WorkerPosition) TableName() string { |
| | | return "silk_worker_position" |
| | | } |
| | | |
| | | func NewWorkerPositionSearch() *WorkerPositionSearch { |
| | | return &WorkerPositionSearch{Orm: mysqlx.GetDB()} |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetOrm(tx *gorm.DB) *WorkerPositionSearch { |
| | | slf.Orm = tx |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetPage(page, size int) *WorkerPositionSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetOrder(order string) *WorkerPositionSearch { |
| | | slf.Order = order |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetPreload() *WorkerPositionSearch { |
| | | slf.Preload = true |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetID(id uint) *WorkerPositionSearch { |
| | | slf.ID = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetWorkerID(id string) *WorkerPositionSearch { |
| | | slf.WorkerId = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetKeyword(keyword string) *WorkerPositionSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetWorkshop(workshop string) *WorkerPositionSearch { |
| | | slf.Workshop = workshop |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) SetWorkshopGroup(group int) *WorkerPositionSearch { |
| | | slf.WorkshopGroup = group |
| | | return slf |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Table(slf.TableName()) |
| | | |
| | | if slf.ID != 0 { |
| | | db = db.Where("id = ?", slf.ID) |
| | | } |
| | | |
| | | if slf.Order != "" { |
| | | db = db.Order(slf.Order) |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | kw := "%" + slf.Keyword + "%" |
| | | db = db.Joins("Worker").Where("silk_mentor.worker_id LIKE ? or Worker.name LIKE ?", kw, kw) |
| | | } |
| | | |
| | | if slf.Workshop != "" { |
| | | db = db.Where("workshop = ?", slf.Workshop) |
| | | } |
| | | |
| | | if slf.WorkshopGroup > 0 { |
| | | db = db.Where("workshop_group = ?", slf.WorkshopGroup) |
| | | } |
| | | |
| | | if slf.WorkerId != "" { |
| | | db = db.Where("worker_id = ?", slf.WorkerId) |
| | | } |
| | | |
| | | if slf.Preload { |
| | | db = db.Model(&WorkerPosition{}).Preload("Worker") |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | // Create 单条插入 |
| | | func (slf *WorkerPositionSearch) Create(record *WorkerPosition) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(record).Error; err != nil { |
| | | return fmt.Errorf("create err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | // CreateBatch 批量插入 |
| | | func (slf *WorkerPositionSearch) CreateBatch(records []*WorkerPosition) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Create(&records).Error; err != nil { |
| | | return fmt.Errorf("create batch err: %v, records: %+v", err, records) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) Save(record *WorkerPosition) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Omit("CreatedAt").Save(record).Error; err != nil { |
| | | return fmt.Errorf("save err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) Update(record *WorkerPosition) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Updates(record).Error; err != nil { |
| | | return fmt.Errorf("save err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) UpdateByMap(upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Updates(upMap).Error; err != nil { |
| | | return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) UpdateByQuery(query string, args []interface{}, upMap map[string]interface{}) error { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()).Where(query, args...) |
| | | ) |
| | | |
| | | if err := db.Updates(upMap).Error; err != nil { |
| | | return fmt.Errorf("update by query err: %v, query: %s, args: %+v, upMap: %+v", err, query, args, upMap) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) Delete() error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Unscoped().Delete(&WorkerPosition{}).Error; err != nil { |
| | | return err |
| | | } |
| | | |
| | | return nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) First() (*WorkerPosition, error) { |
| | | var ( |
| | | record = new(WorkerPosition) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.First(record).Error; err != nil { |
| | | return record, err |
| | | } |
| | | |
| | | return record, nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) Find() ([]*WorkerPosition, int64, error) { |
| | | var ( |
| | | records = make([]*WorkerPosition, 0) |
| | | total int64 |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return records, total, fmt.Errorf("find count err: %v", err) |
| | | } |
| | | if slf.PageNum*slf.PageSize > 0 { |
| | | db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) |
| | | } |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, total, fmt.Errorf("find records err: %v", err) |
| | | } |
| | | |
| | | return records, total, nil |
| | | } |
| | | |
| | | func (slf *WorkerPositionSearch) FindAll() ([]*WorkerPosition, error) { |
| | | var ( |
| | | records = make([]*WorkerPosition, 0) |
| | | db = slf.build() |
| | | ) |
| | | |
| | | if slf.PageNum*slf.PageSize > 0 { |
| | | db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) |
| | | } |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, fmt.Errorf("find records err: %v", err) |
| | | } |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | // FindByQuery 指定条件查询. |
| | | func (slf *WorkerPositionSearch) FindByQuery(query string, args []interface{}) ([]*WorkerPosition, int64, error) { |
| | | var ( |
| | | records = make([]*WorkerPosition, 0) |
| | | total int64 |
| | | db = slf.Orm.Table(slf.TableName()).Where(query, args...) |
| | | ) |
| | | |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return records, total, fmt.Errorf("find by query count err: %v", err) |
| | | } |
| | | if slf.PageNum*slf.PageSize > 0 { |
| | | db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) |
| | | } |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, total, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) |
| | | } |
| | | |
| | | return records, total, nil |
| | | } |
| | | |
| | | // FindByQueryNotTotal 指定条件查询&不查询总条数. |
| | | func (slf *WorkerPositionSearch) FindByQueryNotTotal(query string, args []interface{}) ([]*WorkerPosition, error) { |
| | | var ( |
| | | records = make([]*WorkerPosition, 0) |
| | | db = slf.Orm.Table(slf.TableName()).Where(query, args...) |
| | | ) |
| | | |
| | | if slf.PageNum*slf.PageSize > 0 { |
| | | db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize) |
| | | } |
| | | if err := db.Find(&records).Error; err != nil { |
| | | return records, fmt.Errorf("find by query records err: %v, query: %s, args: %+v", err, query, args) |
| | | } |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *WorkerPositionSearch) InitDefaultData() error { |
| | | return nil |
| | | } |
| | |
| | | mentorApi.DELETE("deleteMentorInfo/:id", mentorCtl.DeleteMentorInfo) //删除带徒信息 |
| | | } |
| | | |
| | | wpApi := r.Group(urlPrefix + "/workerPosition") |
| | | wpCtl := new(controllers.WorkerPositionController) |
| | | { |
| | | wpApi.POST("createWorkerPositionInfo", wpCtl.CreateWorkerPositionInfo) //创建机台信息 |
| | | wpApi.POST("updateWorkerPositionInfo", wpCtl.UpdateWorkerPositionInfo) //更新机台信息 |
| | | wpApi.POST("getWorkerPositionList", wpCtl.GetWorkerPositionList) //获取机台信息列表 |
| | | wpApi.DELETE("deleteWorkerPositionInfo/:id", wpCtl.DeleteWorkerPositionInfo) //删除机台信息 |
| | | } |
| | | |
| | | return r |
| | | } |