| | |
| | | package request |
| | | |
| | | import ( |
| | | "github.com/shopspring/decimal" |
| | | "silkserver/constvar" |
| | | ) |
| | | |
| | | type PayrollProductionCar struct { |
| | | PageInfo |
| | | Cycle string `json:"cycle" form:"cycle"` // 统计周期(年-月-日) |
| | |
| | | WorkTypeCode string `json:"workTypeCode" form:"workTypeCode"` // 工种编码 |
| | | Keyword string `json:"keyword" form:"keyword"` // 关键字 |
| | | } |
| | | |
| | | type UpdatePayrollConstitute struct { |
| | | Cycle string `json:"cycle" ` //月份 |
| | | WorkerID string `json:"workerID" ` //员工ID |
| | | WorkTypeID uint `json:"workTypeID" ` //工种ID |
| | | WorkTypeCode constvar.JobType `json:"workTypeCode" ` //工种代码 |
| | | Amount decimal.Decimal `json:"amount" ` //金额 |
| | | } |
| | | |
| | | type PayrollConstitute struct { |
| | | PageInfo |
| | | Cycle string `json:"cycle" form:"cycle"` // 统计周期按月查询(年-月) |
| | | WorkerID string `json:"workerID" form:"workerID"` // 员工ID |
| | | WorkTypeID int `json:"workTypeID" form:"workTypeID"` // 工种ID |
| | | WorkTypeCode string `json:"workTypeCode" form:"workTypeCode"` // 工种编码 |
| | | Keyword string `json:"keyword" form:"keyword"` // 关键字 |
| | | } |
| | | |
| | | type SavePayrollConstitute struct { |
| | | Cycle string `json:"cycle" from:"cycle"` //周期(月份) |
| | | WorkerID string `json:"workerId" from:"workerId"` //员工ID |
| | | WorkTypeID uint `json:"workTypeID" from:"workTypeID"` //工种ID |
| | | WorkTypeCode constvar.JobType `json:"workTypeCode" from:"workTypeCode"` //工种代码 |
| | | WorkTypeName string `json:"workTypeName" from:"workTypeName"` //工种名称 |
| | | SalaryPlanId uint `json:"salaryPlanId" from:"salaryPlanId"` //薪资方案ID |
| | | Amount decimal.Decimal `json:"amount" from:"amount"` // 金额 |
| | | } |
New file |
| | |
| | | package response |
| | | |
| | | type PayrollSalaryPlan struct { |
| | | // 人员信息 |
| | | // |
| | | } |
| | |
| | | package controllers |
| | | |
| | | import ( |
| | | "fmt" |
| | | "github.com/gin-gonic/gin" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "silkserver/constvar" |
| | | "silkserver/controllers/request" |
| | |
| | | "silkserver/extend/util" |
| | | "silkserver/middleware" |
| | | "silkserver/models" |
| | | "silkserver/pkg/structx" |
| | | "silkserver/pkg/timex" |
| | | "strconv" |
| | | "time" |
| | |
| | | |
| | | util.ResponseFormatList(c, code.Success, list, total) |
| | | } |
| | | |
| | | // SavePayrollConstitute |
| | | // |
| | | // @Tags 员工薪资/薪酬方案 |
| | | // @Summary 薪酬数额调整 |
| | | // @Produce application/json |
| | | // @Param object body request.SavePayrollConstitute true "参数" |
| | | // @Param Authorization header string true "token" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-jl/v1/salary/savePayrollConstitute [post] |
| | | func (slf SalaryPlanController) SavePayrollConstitute(c *gin.Context) { |
| | | var params request.SavePayrollConstitute |
| | | var constitute models.PayrollConstitute |
| | | err := c.BindJSON(¶ms) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | err = structx.AssignTo(params, &constitute) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "数据转换失败") |
| | | return |
| | | } |
| | | if len(constitute.Cycle) < 7 { |
| | | util.ResponseFormat(c, code.RequestParamError, "周期参数为空或格式错误") |
| | | } |
| | | if len(constitute.WorkerID) == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "员工ID参数为空") |
| | | } |
| | | if constitute.SalaryPlanId == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "薪资方案ID参数为空") |
| | | } |
| | | |
| | | info := middleware.GetUserInfo(c) |
| | | if info == nil || info.NickName == "" { |
| | | util.ResponseFormat(c, code.RequestParamError, "用户未登录") |
| | | } |
| | | constitute.CreatedBy = info.NickName |
| | | |
| | | if payrollConstitute, err := models.NewPayrollConstituteSearch().SetCycle(params.Cycle).SetWorkerID(params.WorkerID).SetSalaryPlanId(params.SalaryPlanId).First(); err != nil && payrollConstitute != nil { |
| | | constitute.ID = payrollConstitute.ID |
| | | constitute.CreatedAt = payrollConstitute.CreatedAt |
| | | } |
| | | |
| | | if constitute.ID > 0 { |
| | | err = models.NewPayrollConstituteSearch().Save(&constitute) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "保存失败") |
| | | return |
| | | } |
| | | } else { |
| | | err = models.NewPayrollConstituteSearch().Create(&constitute) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "保存失败") |
| | | return |
| | | } |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "保存成功") |
| | | } |
| | | |
| | | // GetPayrollConstituteList |
| | | // |
| | | // @Tags 员工薪资/薪酬方案 |
| | | // @Summary 获取人员每月的薪资列表 |
| | | // @Produce application/json |
| | | // @Param Authorization header string true "token" |
| | | // @Param object query request.PayrollConstitute true "查询参数" |
| | | // @Success 200 {object} util.ResponseList{data=map[string]interface{}} "成功" |
| | | // @Router /api-jl/v1/salary/getPayrollConstituteList [get] |
| | | func (slf SalaryPlanController) GetPayrollConstituteList(c *gin.Context) { |
| | | |
| | | var params request.PayrollConstitute |
| | | if err := c.ShouldBindQuery(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if len(params.Cycle) == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "请检查查询周期。格式:Cycle(yyyy-MM-dd)") |
| | | return |
| | | } |
| | | |
| | | groupList, err := models.NewPayrollConstituteSearch().ConstituteGroup(&models.ConstituteGroup{Cycle: params.Cycle}) |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找工资分类失败") |
| | | return |
| | | } |
| | | groupMap := make(map[string][]*models.ConstituteGroup, 0) |
| | | for _, group := range groupList { |
| | | if _, ok := groupMap[group.WorkerID]; ok { |
| | | groupMap[group.WorkerID] = append(groupMap[group.WorkerID], group) |
| | | } else { |
| | | groupMap[group.WorkerID] = []*models.ConstituteGroup{group} |
| | | } |
| | | } |
| | | |
| | | // 员工信息 |
| | | workers, err := models.NewWorkerSearch().FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找用户失败") |
| | | } |
| | | workerMap := make(map[string]*models.Worker) |
| | | for _, worker := range workers { |
| | | workerMap[worker.ID] = worker |
| | | } |
| | | |
| | | // 工资方案 |
| | | salaryPlans, err := models.NewSalaryPlanSearch().FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找薪资方案失败") |
| | | } |
| | | salaryPlanMap := make(map[uint]*models.SalaryPlan) |
| | | for _, plan := range salaryPlans { |
| | | salaryPlanMap[plan.ID] = plan |
| | | } |
| | | |
| | | // 工资单项 |
| | | constituteList, err := models.NewPayrollConstituteSearch().SetCycle(params.Cycle).SetWorkerID(params.WorkerID).SetWorkTypeID(uint(params.WorkTypeID)).SetWorkTypeCode(params.WorkTypeCode).FindNotTotal() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "查找工资单项失败") |
| | | return |
| | | } |
| | | constituteMap := make(map[string]*models.PayrollConstitute) |
| | | for _, v := range constituteList { |
| | | key := fmt.Sprintf("%v%v%v", v.Cycle, v.WorkerID, v.SalaryPlanId) |
| | | constituteMap[key] = v |
| | | } |
| | | |
| | | var list []map[string]interface{} |
| | | for workerId, group := range groupMap { |
| | | result := make(map[string]interface{}) |
| | | result["cycle"] = params.Cycle |
| | | if _, ok := workerMap[workerId]; ok { // 人员信息 |
| | | result["worker"] = workerMap[workerId] |
| | | } |
| | | amount := decimal.NewFromInt(0) |
| | | constituteList := make([]map[string]interface{}, 0) |
| | | for _, v := range group { |
| | | temp := make(map[string]interface{}) |
| | | if _, ok := salaryPlanMap[v.SalaryPlanId]; ok { |
| | | temp["salaryPlan"] = salaryPlanMap[v.SalaryPlanId] |
| | | } |
| | | |
| | | key := fmt.Sprintf("%v%v%v", v.Cycle, v.WorkerID, v.SalaryPlanId) |
| | | if _, ok := constituteMap[key]; ok { |
| | | temp["amount"] = constituteMap[key].Amount |
| | | amount = amount.Add(constituteMap[key].Amount) |
| | | } |
| | | constituteList = append(constituteList, temp) |
| | | } |
| | | result["amount"] = amount // 应发工资 |
| | | result["list"] = constituteList // 工资详情 |
| | | |
| | | list = append(list, result) |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, list) |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/getPayrollConstituteList": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "员工薪资/薪酬方案" |
| | | ], |
| | | "summary": "获取人员每月的薪资列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "统计周期按月查询(年-月)", |
| | | "name": "cycle", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "工种编码", |
| | | "name": "workTypeCode", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "工种ID", |
| | | "name": "workTypeID", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "员工ID", |
| | | "name": "workerID", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/getPayrollProductionCarList": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/savePayrollConstitute": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "员工薪资/薪酬方案" |
| | | ], |
| | | "summary": "薪酬数额调整", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SavePayrollConstitute" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/saveSalaryPlan": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5 |
| | | 4 |
| | | ], |
| | | "type": "integer", |
| | | "x-enum-comments": { |
| | | "DictTypeColor": "颜色", |
| | | "DictTypeMarket": "庄口", |
| | | "DictTypeSpec": "规格", |
| | | "DictTypeSubsidy": "补贴", |
| | | "DictTypeWorkshop": "车间" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "DictTypeMarket", |
| | | "DictTypeWorkshop", |
| | | "DictTypeColor", |
| | | "DictTypeSpec", |
| | | "DictTypeSubsidy" |
| | | "DictTypeSpec" |
| | | ], |
| | | "description": "字典类型", |
| | | "name": "dictType", |
| | |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5 |
| | | 4 |
| | | ], |
| | | "x-enum-comments": { |
| | | "DictTypeColor": "颜色", |
| | | "DictTypeMarket": "庄口", |
| | | "DictTypeSpec": "规格", |
| | | "DictTypeSubsidy": "补贴", |
| | | "DictTypeWorkshop": "车间" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "DictTypeMarket", |
| | | "DictTypeWorkshop", |
| | | "DictTypeColor", |
| | | "DictTypeSpec", |
| | | "DictTypeSubsidy" |
| | | "DictTypeSpec" |
| | | ] |
| | | }, |
| | | "constvar.FileTemplateCategory": { |
| | |
| | | "cleaner", |
| | | "machine_cleaner", |
| | | "all-powerful", |
| | | "monitor" |
| | | "monitor", |
| | | "test", |
| | | "other" |
| | | ], |
| | | "x-enum-comments": { |
| | | "JobTypeAllPowerful": "全能机动", |
| | |
| | | "JobTypeMachineCleaner": "感知器清洗工", |
| | | "JobTypeMaintenance": "保全工", |
| | | "JobTypeMonitor": "班长", |
| | | "JobTypeOther": "其它", |
| | | "JobTypeScoop": "舀茧工", |
| | | "JobTypeTest": "测试", |
| | | "JobTypeTransport": "送茧工", |
| | | "JobTypeWeavers": "挡车工" |
| | | }, |
| | |
| | | "JobTypeCleaner", |
| | | "JobTypeMachineCleaner", |
| | | "JobTypeAllPowerful", |
| | | "JobTypeMonitor" |
| | | "JobTypeMonitor", |
| | | "JobTypeTest", |
| | | "JobTypeOther" |
| | | ] |
| | | }, |
| | | "constvar.MiniDictType": { |
| | |
| | | "models.PayrollProductionCar": { |
| | | "type": "object", |
| | | "properties": { |
| | | "badSilkAvgQuantity": { |
| | | "description": "野纤平均数量", |
| | | "type": "number" |
| | | }, |
| | | "badSilkQuantity": { |
| | | "description": "野纤数量", |
| | | "type": "number" |
| | |
| | | "description": "规格", |
| | | "type": "string" |
| | | }, |
| | | "workshopId": { |
| | | "type": "integer" |
| | | }, |
| | | "workshopNumber": { |
| | | "description": "车间编号", |
| | | "type": "string" |
| | |
| | | "silkTotalAvgAmount": { |
| | | "description": "丝量人平均总价", |
| | | "type": "number" |
| | | }, |
| | | "workshopId": { |
| | | "type": "integer" |
| | | }, |
| | | "workshopName": { |
| | | "description": "车间名称", |
| | |
| | | "shopName": { |
| | | "type": "string" |
| | | }, |
| | | "shopNumber": { |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "$ref": "#/definitions/constvar.WorkerStatus" |
| | | }, |
| | |
| | | }, |
| | | "vehicleSpeed": { |
| | | "type": "number" |
| | | }, |
| | | "workshopId": { |
| | | "type": "integer" |
| | | }, |
| | | "workshopName": { |
| | | "description": "车间名", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SavePayrollConstitute": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "金额", |
| | | "type": "number" |
| | | }, |
| | | "cycle": { |
| | | "description": "周期(月份)", |
| | | "type": "string" |
| | | }, |
| | | "salaryPlanId": { |
| | | "description": "薪资方案ID", |
| | | "type": "integer" |
| | | }, |
| | | "workTypeCode": { |
| | | "description": "工种代码", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.JobType" |
| | | } |
| | | ] |
| | | }, |
| | | "workTypeID": { |
| | | "description": "工种ID", |
| | | "type": "integer" |
| | | }, |
| | | "workTypeName": { |
| | | "description": "工种名称", |
| | | "type": "string" |
| | | }, |
| | | "workerId": { |
| | | "description": "员工ID", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.SaveRankStandard": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/getPayrollConstituteList": { |
| | | "get": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "员工薪资/薪酬方案" |
| | | ], |
| | | "summary": "获取人员每月的薪资列表", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "统计周期按月查询(年-月)", |
| | | "name": "cycle", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "关键字", |
| | | "name": "keyword", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "页码", |
| | | "name": "page", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "每页大小", |
| | | "name": "pageSize", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "工种编码", |
| | | "name": "workTypeCode", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "integer", |
| | | "description": "工种ID", |
| | | "name": "workTypeID", |
| | | "in": "query" |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "员工ID", |
| | | "name": "workerID", |
| | | "in": "query" |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/util.ResponseList" |
| | | }, |
| | | { |
| | | "type": "object", |
| | | "properties": { |
| | | "data": { |
| | | "type": "object", |
| | | "additionalProperties": true |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/getPayrollProductionCarList": { |
| | | "get": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/savePayrollConstitute": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "员工薪资/薪酬方案" |
| | | ], |
| | | "summary": "薪酬数额调整", |
| | | "parameters": [ |
| | | { |
| | | "description": "参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.SavePayrollConstitute" |
| | | } |
| | | }, |
| | | { |
| | | "type": "string", |
| | | "description": "token", |
| | | "name": "Authorization", |
| | | "in": "header", |
| | | "required": true |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-jl/v1/salary/saveSalaryPlan": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5 |
| | | 4 |
| | | ], |
| | | "type": "integer", |
| | | "x-enum-comments": { |
| | | "DictTypeColor": "颜色", |
| | | "DictTypeMarket": "庄口", |
| | | "DictTypeSpec": "规格", |
| | | "DictTypeSubsidy": "补贴", |
| | | "DictTypeWorkshop": "车间" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "DictTypeMarket", |
| | | "DictTypeWorkshop", |
| | | "DictTypeColor", |
| | | "DictTypeSpec", |
| | | "DictTypeSubsidy" |
| | | "DictTypeSpec" |
| | | ], |
| | | "description": "字典类型", |
| | | "name": "dictType", |
| | |
| | | 1, |
| | | 2, |
| | | 3, |
| | | 4, |
| | | 5 |
| | | 4 |
| | | ], |
| | | "x-enum-comments": { |
| | | "DictTypeColor": "颜色", |
| | | "DictTypeMarket": "庄口", |
| | | "DictTypeSpec": "规格", |
| | | "DictTypeSubsidy": "补贴", |
| | | "DictTypeWorkshop": "车间" |
| | | }, |
| | | "x-enum-varnames": [ |
| | | "DictTypeMarket", |
| | | "DictTypeWorkshop", |
| | | "DictTypeColor", |
| | | "DictTypeSpec", |
| | | "DictTypeSubsidy" |
| | | "DictTypeSpec" |
| | | ] |
| | | }, |
| | | "constvar.FileTemplateCategory": { |
| | |
| | | "cleaner", |
| | | "machine_cleaner", |
| | | "all-powerful", |
| | | "monitor" |
| | | "monitor", |
| | | "test", |
| | | "other" |
| | | ], |
| | | "x-enum-comments": { |
| | | "JobTypeAllPowerful": "全能机动", |
| | |
| | | "JobTypeMachineCleaner": "感知器清洗工", |
| | | "JobTypeMaintenance": "保全工", |
| | | "JobTypeMonitor": "班长", |
| | | "JobTypeOther": "其它", |
| | | "JobTypeScoop": "舀茧工", |
| | | "JobTypeTest": "测试", |
| | | "JobTypeTransport": "送茧工", |
| | | "JobTypeWeavers": "挡车工" |
| | | }, |
| | |
| | | "JobTypeCleaner", |
| | | "JobTypeMachineCleaner", |
| | | "JobTypeAllPowerful", |
| | | "JobTypeMonitor" |
| | | "JobTypeMonitor", |
| | | "JobTypeTest", |
| | | "JobTypeOther" |
| | | ] |
| | | }, |
| | | "constvar.MiniDictType": { |
| | |
| | | "models.PayrollProductionCar": { |
| | | "type": "object", |
| | | "properties": { |
| | | "badSilkAvgQuantity": { |
| | | "description": "野纤平均数量", |
| | | "type": "number" |
| | | }, |
| | | "badSilkQuantity": { |
| | | "description": "野纤数量", |
| | | "type": "number" |
| | |
| | | "description": "规格", |
| | | "type": "string" |
| | | }, |
| | | "workshopId": { |
| | | "type": "integer" |
| | | }, |
| | | "workshopNumber": { |
| | | "description": "车间编号", |
| | | "type": "string" |
| | |
| | | "silkTotalAvgAmount": { |
| | | "description": "丝量人平均总价", |
| | | "type": "number" |
| | | }, |
| | | "workshopId": { |
| | | "type": "integer" |
| | | }, |
| | | "workshopName": { |
| | | "description": "车间名称", |
| | |
| | | "shopName": { |
| | | "type": "string" |
| | | }, |
| | | "shopNumber": { |
| | | "type": "string" |
| | | }, |
| | | "status": { |
| | | "$ref": "#/definitions/constvar.WorkerStatus" |
| | | }, |
| | |
| | | }, |
| | | "vehicleSpeed": { |
| | | "type": "number" |
| | | }, |
| | | "workshopId": { |
| | | "type": "integer" |
| | | }, |
| | | "workshopName": { |
| | | "description": "车间名", |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.SavePayrollConstitute": { |
| | | "type": "object", |
| | | "properties": { |
| | | "amount": { |
| | | "description": "金额", |
| | | "type": "number" |
| | | }, |
| | | "cycle": { |
| | | "description": "周期(月份)", |
| | | "type": "string" |
| | | }, |
| | | "salaryPlanId": { |
| | | "description": "薪资方案ID", |
| | | "type": "integer" |
| | | }, |
| | | "workTypeCode": { |
| | | "description": "工种代码", |
| | | "allOf": [ |
| | | { |
| | | "$ref": "#/definitions/constvar.JobType" |
| | | } |
| | | ] |
| | | }, |
| | | "workTypeID": { |
| | | "description": "工种ID", |
| | | "type": "integer" |
| | | }, |
| | | "workTypeName": { |
| | | "description": "工种名称", |
| | | "type": "string" |
| | | }, |
| | | "workerId": { |
| | | "description": "员工ID", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.SaveRankStandard": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | type: integer |
| | | x-enum-comments: |
| | | DictTypeColor: 颜色 |
| | | DictTypeMarket: 庄口 |
| | | DictTypeSpec: 规格 |
| | | DictTypeSubsidy: 补贴 |
| | | DictTypeWorkshop: 车间 |
| | | x-enum-varnames: |
| | | - DictTypeMarket |
| | | - DictTypeWorkshop |
| | | - DictTypeColor |
| | | - DictTypeSpec |
| | | - DictTypeSubsidy |
| | | constvar.FileTemplateCategory: |
| | | enum: |
| | | - 1 |
| | |
| | | - machine_cleaner |
| | | - all-powerful |
| | | - monitor |
| | | - test |
| | | - other |
| | | type: string |
| | | x-enum-comments: |
| | | JobTypeAllPowerful: 全能机动 |
| | |
| | | JobTypeMachineCleaner: 感知器清洗工 |
| | | JobTypeMaintenance: 保全工 |
| | | JobTypeMonitor: 班长 |
| | | JobTypeOther: 其它 |
| | | JobTypeScoop: 舀茧工 |
| | | JobTypeTest: 测试 |
| | | JobTypeTransport: 送茧工 |
| | | JobTypeWeavers: 挡车工 |
| | | x-enum-varnames: |
| | |
| | | - JobTypeMachineCleaner |
| | | - JobTypeAllPowerful |
| | | - JobTypeMonitor |
| | | - JobTypeTest |
| | | - JobTypeOther |
| | | constvar.MiniDictType: |
| | | enum: |
| | | - 1 |
| | |
| | | type: object |
| | | models.PayrollProductionCar: |
| | | properties: |
| | | badSilkAvgQuantity: |
| | | description: 野纤平均数量 |
| | | type: number |
| | | badSilkQuantity: |
| | | description: 野纤数量 |
| | | type: number |
| | |
| | | spec: |
| | | description: 规格 |
| | | type: string |
| | | workshopId: |
| | | type: integer |
| | | workshopNumber: |
| | | description: 车间编号 |
| | | type: string |
| | |
| | | silkTotalAvgAmount: |
| | | description: 丝量人平均总价 |
| | | type: number |
| | | workshopId: |
| | | type: integer |
| | | workshopName: |
| | | description: 车间名称 |
| | | type: string |
| | |
| | | type: string |
| | | shopName: |
| | | type: string |
| | | shopNumber: |
| | | type: string |
| | | status: |
| | | $ref: '#/definitions/constvar.WorkerStatus' |
| | | workType: |
| | |
| | | type: string |
| | | vehicleSpeed: |
| | | type: number |
| | | workshopId: |
| | | type: integer |
| | | workshopName: |
| | | description: 车间名 |
| | | type: string |
| | |
| | | type: boolean |
| | | name: |
| | | description: 名称 |
| | | type: string |
| | | type: object |
| | | request.SavePayrollConstitute: |
| | | properties: |
| | | amount: |
| | | description: 金额 |
| | | type: number |
| | | cycle: |
| | | description: 周期(月份) |
| | | type: string |
| | | salaryPlanId: |
| | | description: 薪资方案ID |
| | | type: integer |
| | | workTypeCode: |
| | | allOf: |
| | | - $ref: '#/definitions/constvar.JobType' |
| | | description: 工种代码 |
| | | workTypeID: |
| | | description: 工种ID |
| | | type: integer |
| | | workTypeName: |
| | | description: 工种名称 |
| | | type: string |
| | | workerId: |
| | | description: 员工ID |
| | | type: string |
| | | type: object |
| | | request.SaveRankStandard: |
| | |
| | | summary: 删除薪酬方案 |
| | | tags: |
| | | - 员工薪资/薪酬方案 |
| | | /api-jl/v1/salary/getPayrollConstituteList: |
| | | get: |
| | | parameters: |
| | | - description: token |
| | | in: header |
| | | name: Authorization |
| | | required: true |
| | | type: string |
| | | - description: 统计周期按月查询(年-月) |
| | | in: query |
| | | name: cycle |
| | | type: string |
| | | - description: 关键字 |
| | | in: query |
| | | name: keyword |
| | | type: string |
| | | - description: 页码 |
| | | in: query |
| | | name: page |
| | | type: integer |
| | | - description: 每页大小 |
| | | in: query |
| | | name: pageSize |
| | | type: integer |
| | | - description: 工种编码 |
| | | in: query |
| | | name: workTypeCode |
| | | type: string |
| | | - description: 工种ID |
| | | in: query |
| | | name: workTypeID |
| | | type: integer |
| | | - description: 员工ID |
| | | in: query |
| | | name: workerID |
| | | type: string |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | allOf: |
| | | - $ref: '#/definitions/util.ResponseList' |
| | | - properties: |
| | | data: |
| | | additionalProperties: true |
| | | type: object |
| | | type: object |
| | | summary: 获取人员每月的薪资列表 |
| | | tags: |
| | | - 员工薪资/薪酬方案 |
| | | /api-jl/v1/salary/getPayrollProductionCarList: |
| | | get: |
| | | parameters: |
| | |
| | | summary: 获取薪资类型列表 |
| | | tags: |
| | | - 员工薪资/薪酬方案 |
| | | /api-jl/v1/salary/savePayrollConstitute: |
| | | post: |
| | | parameters: |
| | | - description: 参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.SavePayrollConstitute' |
| | | - 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/salary/saveSalaryPlan: |
| | | post: |
| | | parameters: |
| | |
| | | - 2 |
| | | - 3 |
| | | - 4 |
| | | - 5 |
| | | in: query |
| | | name: dictType |
| | | type: integer |
| | |
| | | DictTypeColor: 颜色 |
| | | DictTypeMarket: 庄口 |
| | | DictTypeSpec: 规格 |
| | | DictTypeSubsidy: 补贴 |
| | | DictTypeWorkshop: 车间 |
| | | x-enum-varnames: |
| | | - DictTypeMarket |
| | | - DictTypeWorkshop |
| | | - DictTypeColor |
| | | - DictTypeSpec |
| | | - DictTypeSubsidy |
| | | - description: 搜索关键字 |
| | | in: query |
| | | name: keyword |
| | |
| | | "fmt" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "math/rand" |
| | | "silkserver/constvar" |
| | | "silkserver/pkg/mysqlx" |
| | | ) |
| | | |
| | | type ( |
| | | // PayrollConstitute 其它补贴、奖惩 |
| | | // PayrollConstitute 薪资分类项 |
| | | PayrollConstitute struct { |
| | | BaseModelInt |
| | | Cycle string `json:"cycle" gorm:"index;size:20;not null;comment:统计周期(yyyy-MM)"` //月份 |
| | |
| | | WorkTypeID uint `json:"workTypeID" gorm:"type:bigint(20);not null;comment:工种ID"` //工种ID |
| | | WorkType WorkTypeManage `json:"workType" gorm:"foreignKey:WorkTypeID;references:ID"` //工种ID |
| | | WorkTypeCode constvar.JobType `json:"workTypeCode" gorm:"size:255;not null;comment:工种代码"` //工种代码 |
| | | WorkTypeName string `json:"workTypeName" gorm:"size:255;not null;comment:工种名称"` //工种名称 |
| | | WorkTypeName string `json:"workTypeName" gorm:"size:255;comment:工种名称"` //工种名称 |
| | | SalaryPlanId uint `json:"salaryPlanId" gorm:"type:bigint(20);not null;comment:薪资方案ID"` //薪资方案ID |
| | | SalaryPlan SalaryPlan `json:"subsidyTypeName" gorm:"foreignKey:SalaryPlanId;references:ID"` //薪资方案 |
| | | SalaryFormula string `json:"salaryFormula" gorm:"size:255;not null;comment:薪资方案(翻译)"` //薪资方案 |
| | | SalaryFormula string `json:"salaryFormula" gorm:"size:255;comment:薪资方案(翻译)"` //薪资方案 |
| | | Amount decimal.Decimal `json:"amount" gorm:"type:decimal(12,4);comment:金额"` // 金额 |
| | | CreatedBy string `json:"createdBy" gorm:"size:255;not null;comment:添加者"` // 添加者(auto,用户id) |
| | | } |
| | |
| | | PayrollConstituteSearch struct { |
| | | PayrollConstitute |
| | | Monthly string |
| | | Keyword string |
| | | |
| | | Order string |
| | | PageNum int |
| | | PageSize int |
| | |
| | | return "silk_payroll_constitute" |
| | | } |
| | | |
| | | // NewPayrollConstituteSearch 其它补贴 |
| | | // NewPayrollConstituteSearch 薪资分类项 |
| | | func NewPayrollConstituteSearch() *PayrollConstituteSearch { |
| | | return &PayrollConstituteSearch{Orm: mysqlx.GetDB()} |
| | | } |
| | |
| | | return slf |
| | | } |
| | | |
| | | func (slf *PayrollConstituteSearch) SetWorkTypeCode(workTypeCode string) *PayrollConstituteSearch { |
| | | slf.WorkTypeCode = constvar.JobType(workTypeCode) |
| | | return slf |
| | | } |
| | | |
| | | func (slf *PayrollConstituteSearch) SetSalaryPlanId(salaryPlanId uint) *PayrollConstituteSearch { |
| | | slf.SalaryPlanId = salaryPlanId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *PayrollConstituteSearch) SetWorkerID(workerID string) *PayrollConstituteSearch { |
| | | slf.WorkerID = workerID |
| | | return slf |
| | |
| | | db = db.Where("work_type_id = ?", slf.WorkTypeID) |
| | | } |
| | | |
| | | if slf.WorkerID != "" { |
| | | db = db.Where("worker_id = ?", slf.WorkerID) |
| | | if slf.WorkTypeCode != "" { |
| | | db = db.Where("work_type_code = ?", slf.WorkTypeCode) |
| | | } |
| | | |
| | | if slf.WorkerID != "" { |
| | | db = db.Where("worker_id = ?", slf.WorkerID) |
| | | } |
| | | |
| | | if slf.SalaryPlanId > 0 { |
| | | db = db.Where("salary_plan_id = ?", slf.SalaryPlanId) |
| | | } |
| | | |
| | | if slf.CreatedBy != "" { |
| | | db = db.Where("created_by = ?", slf.SalaryPlanId) |
| | | db = db.Where("created_by = ?", slf.CreatedBy) |
| | | } |
| | | |
| | | if slf.Keyword != "" { |
| | | key := "%" + slf.Keyword + "%" |
| | | db = db.Where("work_type_name like ?", key) |
| | | } |
| | | |
| | | db.Where("1 = 1") |
| | |
| | | |
| | | return records, nil |
| | | } |
| | | |
| | | type ConstituteGroup struct { |
| | | Cycle string `json:"cycle"` //月份 |
| | | WorkerID string `json:"workerId"` //员工ID |
| | | WorkTypeCode constvar.JobType `json:"workTypeCode"` //工种代码 |
| | | SalaryPlanId uint `json:"salaryPlanId"` //薪资方案ID |
| | | } |
| | | |
| | | // ConstituteGroup 本月统计了工资的人员 |
| | | func (slf *PayrollConstituteSearch) ConstituteGroup(cg *ConstituteGroup) ([]*ConstituteGroup, error) { |
| | | var ( |
| | | records = make([]*ConstituteGroup, 0) |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | ) |
| | | db.Select("cycle,worker_id,work_type_code,salary_plan_id") |
| | | db.Where("cycle = ?", cg.Cycle) |
| | | if cg.WorkerID != "" { |
| | | db.Where("worker_id = ?", cg.WorkerID) |
| | | } |
| | | if cg.WorkTypeCode != "" { |
| | | db.Where("work_type_code = ?", cg.WorkTypeCode) |
| | | } |
| | | if cg.SalaryPlanId > 0 { |
| | | db.Where("salary_plan_id = ?", cg.SalaryPlanId) |
| | | } |
| | | db.Group("cycle,worker_id,work_type_code,salary_plan_id") |
| | | |
| | | return records, db.Find(&records).Error |
| | | } |
| | | |
| | | // InitDefaultData 初始化数据 |
| | | func (slf *PayrollConstituteSearch) InitDefaultData() error { |
| | | var ( |
| | | db = slf.Orm.Table(slf.TableName()) |
| | | total int64 = 0 |
| | | ) |
| | | date := "2024-06" |
| | | if err := db.Where("cycle = ?", date).Count(&total).Error; err != nil { |
| | | return err |
| | | } |
| | | if total != 0 { |
| | | return nil |
| | | } |
| | | data := make([]*PayrollConstitute, 0) |
| | | workers, _ := NewWorkerSearch().FindNotTotal() |
| | | for _, record := range workers { |
| | | r := rand.Intn(10) |
| | | data = append(data, &PayrollConstitute{ |
| | | Cycle: date, |
| | | WorkerID: record.ID, |
| | | WorkTypeID: uint(r + 1), |
| | | WorkTypeCode: constvar.JobTypeArr[r], |
| | | WorkTypeName: constvar.JobTypeMap[constvar.JobTypeArr[r]], |
| | | SalaryPlanId: 7, |
| | | Amount: decimal.NewFromInt32(int32(r * 100)), |
| | | CreatedBy: "auto", |
| | | }) |
| | | } |
| | | err := slf.CreateBatch(data) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | |
| | | return nil |
| | | } |
| | |
| | | salaryApi.GET("getPayrollProductionCarList", salaryPlanController.GetPayrollProductionCarList) //获取车台每天的产量列表 |
| | | salaryApi.GET("getPayrollProductionGroupList", salaryPlanController.GetPayrollProductionGroupList) //获取小组每天的产量列表 |
| | | salaryApi.GET("getPayrollSalaryPlanList", salaryPlanController.GetPayrollSalaryPlanList) //获取人员每月的薪资列表 |
| | | salaryApi.POST("savePayrollConstitute", salaryPlanController.SavePayrollConstitute) //薪酬数额调整 |
| | | salaryApi.GET("getPayrollConstituteList", salaryPlanController.GetPayrollConstituteList) //获取人员每月的薪资列表 |
| | | } |
| | | |
| | | //考勤管理 |
| | |
| | | |
| | | // 根据方案计算各工种薪资 |
| | | func salaryCalculate(parameter *SalaryParameter, salaryPlan *models.SalaryPlan) (string, decimal.Decimal) { |
| | | formula := strings.ReplaceAll(salaryPlan.SalaryFormula, " ", "") |
| | | formula := strings.ReplaceAll(salaryPlan.SalaryFormula, ",", "") |
| | | formula = strings.ReplaceAll(salaryPlan.SalaryFormula, " ", "") |
| | | //var SplitFixedField = []string{"日产丝量", "生丝单价", "桶数", "野纤数量", "野纤单价", "同组挡车工月平均工资", "同组车头工工资", "出勤天数"} |
| | | formula = strings.Replace(formula, "日产丝量*生丝单价", parameter.SilkTotalAmount.String(), -1) |
| | | formula = strings.Replace(formula, "野纤数量*野纤单价", parameter.BadSilkTotalAmount.String(), -1) |
| | |
| | | formula = strings.Replace(formula, "同组车头工工资", parameter.GroupCarHeadAvgAmount.String(), -1) |
| | | formula = strings.Replace(formula, "出勤天数", parameter.JobDays.String(), -1) |
| | | |
| | | logx.Debugf("salary formula: %v", formula) |
| | | |
| | | result, err := calculator.ParseAndExec(formula) |
| | | if err != nil { |
| | | logx.Errorf("%s : %v", formula, err) |