diff --git a/api/version1/inlet.go b/api/version1/inlet.go index 04ffb29..f002b88 100644 --- a/api/version1/inlet.go +++ b/api/version1/inlet.go @@ -5,6 +5,7 @@ import ( "hr_server/api/version1/permitpowerapi" "hr_server/api/version1/personnelapi" "hr_server/api/version1/shiyan" + "hr_server/api/version1/workrostering" ) type ApiInlet struct { @@ -12,6 +13,7 @@ type ApiInlet struct { PermitPowerApi permitpowerapi.PermitPowerApi StaffApi personnelapi.StaffApi ShiyanApi shiyan.ShiYan + RosteringApi workrostering.ApiModer } var AppApiInlet = new(ApiInlet) diff --git a/api/version1/personnelapi/staffarchives.go b/api/version1/personnelapi/staffarchives.go index d5b294a..eb48292 100644 --- a/api/version1/personnelapi/staffarchives.go +++ b/api/version1/personnelapi/staffarchives.go @@ -1315,10 +1315,10 @@ func (s *StaffApi) AddInsideHistory(c *gin.Context) { overallhandle.Result(1, requestData.Id, c, "行政组织不能为空") return } - if requestData.Position == "" { - overallhandle.Result(1, requestData.Id, c, "职位不能为空") - return - } + // if requestData.Position == "" { + // overallhandle.Result(1, requestData.Id, c, "岗位不能为空") + // return + // } if requestData.Team == "" { overallhandle.Result(1, requestData.Id, c, "班组不能为空") return @@ -1331,7 +1331,7 @@ func (s *StaffApi) AddInsideHistory(c *gin.Context) { requestData.ChangeType = 1 } if requestData.AssignType == 0 { - requestData.AssignType = 1 + requestData.AssignType = 2 } var insiderHistoryWork models.InsideWorkHistory idInt, _ := strconv.ParseInt(requestData.Id, 10, 64) @@ -1410,7 +1410,7 @@ func (s *StaffApi) EidtInsideHistoryWorkCont(c *gin.Context) { } if requestData.Team == "" { if requestData.Team != strconv.FormatInt(insiderHistoryWork.Team, 10) { - saveData["position"] = requestData.Team + saveData["team"] = requestData.Team } } if requestData.StartTime == "" { @@ -1442,6 +1442,14 @@ func (s *StaffApi) EidtInsideHistoryWorkCont(c *gin.Context) { if requestData.GradePositions != 0 && requestData.GradePositions != insiderHistoryWork.GradePositions { saveData["grade_positions"] = requestData.GradePositions } + + if requestData.JobId != "" { + jobIdInt, _ := strconv.ParseInt(requestData.JobId, 10, 64) + if jobIdInt != insiderHistoryWork.JobId { + saveData["jobid"] = jobIdInt + } + } + if len(saveData) > 0 { saveData["time"] = time.Now().Unix() eidtErr := insiderHistoryWork.EditCont(map[string]interface{}{"`id`": requestData.Id}, saveData) @@ -2344,6 +2352,7 @@ func (s *StaffApi) GetInsideWorkHistoryList(c *gin.Context) { if v.EndTime != 0 { endTimeStr = overallhandle.UnixTimeToDay(v.EndTime, 14) } + snedCont.Id = strconv.FormatInt(v.Id, 10) snedCont.EndTime = endTimeStr //结束时间 snedCont.AllOrgName = allOrgName //性质组织全称 snedCont.OrgId = orgId //行政组织ID @@ -2359,7 +2368,10 @@ func (s *StaffApi) GetInsideWorkHistoryList(c *gin.Context) { snedCont.ChangeType = v.ChangeType //调动类型 snedCont.ChangeTypeName = changeTypeToStr(v.ChangeType) snedCont.AssignType = v.AssignType //1、主职;2:兼职 - + var dutiesCont models.Duties + dutiesCont.GetCont(map[string]interface{}{"`id`": v.JobId}, "`name`") + snedCont.JobId = v.JobId + snedCont.JobName = dutiesCont.Name // snedCont.SuperiorPostName string //上级职务名称 // snedCont.SuperiorManName []string //上级人员 // snedCont.SubordinatesCount int //下属熟练 @@ -2406,3 +2418,344 @@ func getSuperiorPeopleAndSubMan(orgId, postId int64) (postName, manTitle string) } return } + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-03 15:08:17 +@ 功能: 判断是否已经存在主职 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (s *StaffApi) JudgePrincipalPosition(c *gin.Context) { + var requestData judgeMainPost + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.UserKey == "" { + overallhandle.Result(101, requestData, c) + return + } + // if requestData.OrgId == "" || requestData.PostId == "" || requestData.UserKey == "" { + // overallhandle.Result(101, requestData, c) + // return + // } + //获取所在部门 + // orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64) + // _, _, departmentId, _, _ := overallhandle.GetOrgStructure(orgIdInt) + //查找是否已经存在主部门 + var insideWorkHisCont models.InsideWorkHistory + err = insideWorkHisCont.GetCont(map[string]interface{}{"`key`": requestData.UserKey, "`assign_type`": 1}) + if err != nil { + overallhandle.Result(0, err, c) + return + } + overallhandle.Result(11111, err, c, "已经存在主职!是否替换!") +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-03 15:55:23 +@ 功能: 添加职工履历(新版) +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (s *StaffApi) AddInsideHistoryNew(c *gin.Context) { + var requestData eidtInsideHistoryWorkEs + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(101, err, c) + return + } + if requestData.Id == "" { + overallhandle.Result(1, requestData.Id, c, "员工标识符不能为空") + return + } + if requestData.OrgId == 0 { + overallhandle.Result(1, requestData.OrgId, c, "行政组织不能为空") + return + } + // if requestData.Position == "" { + // overallhandle.Result(1, requestData.Id, c, "岗位不能为空") + // return + // } + if requestData.Team == 0 { + overallhandle.Result(1, requestData.Team, c, "班组不能为空") + return + } + if requestData.StartTime == "" { + overallhandle.Result(1, requestData.StartTime, c, "就任此职位开始时间不能为空") + return + } + startTimeVal, timeErr := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.StartTime)) + if timeErr == false { + overallhandle.Result(1, requestData.StartTime, c, "就任此职位开始时间格式不正确") + return + } + if requestData.ChangeType == 0 { + requestData.ChangeType = 1 + } + if requestData.AssignType == 0 { + requestData.AssignType = 2 + } + idInt64, _ := strconv.ParseInt(requestData.Id, 10, 64) + //获取行政组织关系 + // orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64) + groupId, companyId, departmentId, sunDepartId, workShopId := overallhandle.GetOrgStructure(requestData.OrgId) + //判断该经历shi + if requestData.AssignType == 1 { + //判断是否已经存在主职 + var insideWorkHisCont models.InsideWorkHistory + err = insideWorkHisCont.GetCont(map[string]interface{}{"`key`": idInt64, "`assign_type`": 1}) + if err == nil { + //存在主职,将主职移除 + synPro.Add(1) + go handleMainZhi(idInt64, 2) + } + } + synPro.Wait() //等待执行完毕 + var insCont models.InsideWorkHistory + insCont.Key = idInt64 //员工识别符"` + insCont.Group = groupId //集团"` + insCont.Company = companyId //公司"` + insCont.Department = departmentId //部室"` + insCont.WorkShop = sunDepartId //二级部门或车间"` + insCont.WorkshopSection = workShopId //工段"` + // requestData.Position, _ := strconv.ParseInt(requestData.Position, 10, 64) + insCont.Position = requestData.Position //职位"` + // requestData.JobId, _ := strconv.ParseInt(requestData.JobId, 10, 64) + insCont.JobId = requestData.JobId + insCont.GradePositions = requestData.GradePositions //职等"` + insCont.StartTime = startTimeVal //开始日期"` + var endTimeVal int64 + if requestData.EndTime != "" { + endTimeVal, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EndTime)) + } else { + endTimeVal = 0 + } + insCont.EndTime = endTimeVal //结束日期"` + // teamId, _ := strconv.ParseInt(requestData.Team, 10, 64) + insCont.Team = requestData.Team //班组(1:长白;2:甲;3:乙;4:丙;5:丁)"` + insCont.ChangeType = requestData.ChangeType //变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"` + insCont.Time = time.Now().Unix() //创建时间"` + insCont.State = 1 //状态(1:启用;2:禁用;3:删除)"` + insCont.AssignType = requestData.AssignType //1、主职;2:兼职"` + err = overall.CONSTANT_DB_HR.Create(&insCont).Error + if err != nil { + overallhandle.Result(104, err, c) + return + } + //处理人员管理部门与主部门关系 + var userInfo models.PersonArchives + err = userInfo.GetCont(map[string]interface{}{"`key`": idInt64}, "`deparment`", "`admin_org`", "`deparment`", "`position`", "`job_id`", "`job_leve`", "`sun_main_deparment`", "`teamid`") + if err == nil { + //获取所有关联部门 + var departIdAry []int64 + err = overall.CONSTANT_DB_HR.Model(&models.InsideWorkHistory{}).Select("DISTINCT `department`").Where("`state` = 1 AND `key` = ?", idInt64).Find(&departIdAry).Error + saveUserInfo := overallhandle.MapOut() + if userInfo.Deparment == "" && len(departIdAry) > 0 { + var departIdStr []string + for _, v := range departIdAry { + departIdStr = append(departIdStr, strconv.FormatInt(v, 10)) + } + saveUserInfo["`deparment`"] = strings.Join(departIdStr, ",") + } + if requestData.AssignType == 1 { + if userInfo.AdminOrg != requestData.OrgId { + saveUserInfo["`company`"] = companyId + saveUserInfo["`maindeparment`"] = departmentId + saveUserInfo["`sun_main_deparment`"] = sunDepartId + saveUserInfo["`admin_org`"] = requestData.OrgId + saveUserInfo["`position`"] = requestData.Position + saveUserInfo["`job_id`"] = requestData.JobId + saveUserInfo["`job_leve`"] = requestData.GradePositions + //获取职务类型 + var dutiesCont models.Duties + dutiesCont.GetCont(map[string]interface{}{"`id`": requestData.JobId}, "`job_type`") + saveUserInfo["`job_class`"] = dutiesCont.JobType + saveUserInfo["`teamid`"] = requestData.Team + } + } + if len(saveUserInfo) > 0 { + saveUserInfo["`eite_time`"] = time.Now().Unix() + userInfo.EiteCont(map[string]interface{}{"`key`": idInt64}, saveUserInfo) + } + + } + + overallhandle.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-03 16:03:55 +@ 功能: 变更主职 +@ 参数 + + #userKey 员工Key + #assignType 1、主职;2:兼职 + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func handleMainZhi(userKey int64, assignType int) { + defer synPro.Done() + var insCont models.InsideWorkHistory + insCont.EditCont(map[string]interface{}{"`key`": userKey}, map[string]interface{}{"`assign_type`": assignType}) +} + +// 人员列表(对外) +func (s *StaffApi) ArchivesListWai(c *gin.Context) { + var requestData peopleList + c.ShouldBindJSON(&requestData) + if requestData.Page < 0 { + requestData.Page = 1 + } + if requestData.PageSize < 0 { + requestData.PageSize = 10 + } + // var staffList []models.ManCont + // var staffList []models.PersonArchives + gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("state = 1 AND `number` NOT LIKE ?", "%W%") + + if requestData.Number != "" { + gormDb = gormDb.Where("number LIKE ?", "%"+requestData.Number+"%") + } + if requestData.Name != "" { + gormDb = gormDb.Where("name LIKE ?", "%"+requestData.Name+"%") + } + if requestData.HireClass != 0 { + gormDb = gormDb.Where("hire_class = ?", requestData.HireClass) + } + if requestData.Company != 0 { + gormDb = gormDb.Where("company = ?", requestData.Company) + } + // if requestData.Deparment != "" { + // gormDb = gormDb.Where("FIND_IN_SET(?,`deparment`)", requestData.Deparment) + // } + if requestData.AdminOrg != 0 { + // var idAry []int64 + // idAry = overallhandle.GetDepartmentSun(requestData.AdminOrg, idAry) + // idAry = append(idAry, requestData.AdminOrg) + // gormDb = gormDb.Where("admin_org IN ?", idAry) + var sunAry overallhandle.AllSunList[int64] + sunAry.GetAllSunOrg(requestData.AdminOrg) + sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg) + gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList) + + } + if requestData.Position != 0 { + gormDb = gormDb.Where("position = ?", requestData.Position) + } + if requestData.EmpType != 0 { + gormDb = gormDb.Where("emp_type = ?", requestData.EmpType) + } else { + gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10) + } + if requestData.Role != "" { + gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role) + } + + var total int64 + totalErr := gormDb.Count(&total).Error + if totalErr != nil { + total = 0 + } + var idAry []int64 + // errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&staffList).Error + errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error + var positionAry []peopleManOutList + + var manContList []models.ManCont + errGorm = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Find(&manContList).Error + + for _, v := range manContList { + var staffInfo peopleManOutList + staffInfo.ManCont = v + var getSpur models.Position + getWhe := overallhandle.MapOut() + getWhe["id"] = v.Position + getSpur.GetCont(getWhe, "name", "person_in_charge") + staffInfo.PositionName = getSpur.Name + staffInfo.PersonInCharge = getSpur.PersonInCharge + staffInfo.KeyStr = strconv.FormatInt(v.Key, 10) + //公司 + if v.Company != 0 { + var getSpurDepart models.AdministrativeOrganization + getWheDepart := overallhandle.MapOut() + getWheDepart["id"] = v.Company + getSpurDepart.GetCont(getWheDepart, "name") + staffInfo.CompanyName = getSpurDepart.Name + } + //主部门 + if v.MainDeparment != 0 { + var getSpurDepartMain models.AdministrativeOrganization + getWheDepartMain := overallhandle.MapOut() + getWheDepartMain["id"] = v.MainDeparment + getSpurDepartMain.GetCont(getWheDepartMain, "name") + staffInfo.MainDeparmentName = getSpurDepartMain.Name + } + //二级著部门 + if v.SunMainDeparment != 0 { + var sunMainDepart models.AdministrativeOrganization + sunMainDepart.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`") + staffInfo.SunMainDeparmentName = sunMainDepart.Name + } + //获取部门 + // departmentAry := strings.Split(v.Deparment, ",") + // if len(departmentAry) > 0 { + // var departCont []getDepartmentInfo + // departErr := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("id,number,name").Where("`id` IN ?", departmentAry).Order("`organization_type` ASC").Find(&departCont).Error + + // if departErr == nil { + // var departNameAry []string + // for _, d_v := range departCont { + // departNameAry = append(departNameAry, d_v.Name) + // } + // if len(departNameAry) > 0 { + // staffInfo.DeparmentName = strings.Join(departNameAry, " ") + // } + // } + // } + var orgContTypeCont models.OrgContType + orgContTypeCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`", "`level`") + if orgContTypeCont.Level >= 6 { + staffInfo.WorkPostName = orgContTypeCont.Name + } + + positionAry = append(positionAry, staffInfo) + + } + if errGorm != nil { + overallhandle.Result(105, errGorm, c) + } else { + overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c) + } +} diff --git a/api/version1/personnelapi/type.go b/api/version1/personnelapi/type.go index 2412eb0..087e766 100644 --- a/api/version1/personnelapi/type.go +++ b/api/version1/personnelapi/type.go @@ -129,7 +129,8 @@ type addPersonnel struct { // 集团内部工作履历 type insideHistoryerMy struct { OrgId string `json:"orgid"` //行政组织 - Position string `json:"position"` //职位 + Position string `json:"position"` //岗位 + JobId string `json:"jobid"` //职务 GradePositions int64 `json:"gradepositions"` //职等 StartTime string `json:"starttime"` //开始日期 EndTime string `json:"endtime"` //结束日期 @@ -137,6 +138,17 @@ type insideHistoryerMy struct { AssignType int `json:"assigntype"` //1:主职,2:兼职 Team string `json:"team"` //班组 } +type insideHistoryerMyEs struct { + OrgId int64 `json:"orgid"` //行政组织 + Position int64 `json:"position"` //岗位 + JobId int64 `json:"jobid"` //职务 + GradePositions int64 `json:"gradepositions"` //职等 + StartTime string `json:"starttime"` //开始日期 + EndTime string `json:"endtime"` //结束日期 + ChangeType int `json:"changetype"` //变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;) + AssignType int `json:"assigntype"` //1:主职,2:兼职 + Team int64 `json:"team"` //班组 +} // 教育经历 type educationalExperience struct { @@ -334,7 +346,7 @@ type educatExp struct { type workHistoryAry struct { Company string `json:"company"` //公司 Department string `json:"department"` //部门 - Position string `json:"fposition"` //职务 + Position string `json:"position"` //职务 EntryTime string `json:"entrytime"` //入职时间 LeaveDate string `json:"leavedate"` //离职日期 Witness string `json:"witness"` //证明人 @@ -459,6 +471,11 @@ type eidtInsideHistoryWork struct { insideHistoryerMy } +type eidtInsideHistoryWorkEs struct { + Id string `json:"id"` + insideHistoryerMyEs +} + // 修改密码 type editPws struct { Id string `json:"id"` diff --git a/api/version1/personnelapi/types.go b/api/version1/personnelapi/types.go index 89e5ca4..b6309f5 100644 --- a/api/version1/personnelapi/types.go +++ b/api/version1/personnelapi/types.go @@ -150,6 +150,7 @@ type OutpersonCont struct { //输出集团内部工作经历 type outInsetWork struct { + Id string `json:"id"` // StartTime string `json:"starttimg"` //开始时间 EndTime string `json:"endtimg"` //结束时间 AllOrgName string `json:"allorgname"` //性质组织全称 @@ -165,6 +166,8 @@ type outInsetWork struct { SuperiorPostName string `json:"superiorpostname"` //上级职务名称 SuperiorManName []string `json:"superiormanname"` //上级人员 SubordinatesCount int `json:"subordinatescount"` //下属熟练 + JobId int64 `json:"jobid"` //职务 + JobName string `json:"jobname"` //职务名称 } //输出集团内部工作经历 @@ -219,3 +222,10 @@ type EditContData struct { Constellationing int `json:"constellationing"` //星座 Maritalstatus int `json:"maritalstatus"` //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异) int } + +//判断主职 +type judgeMainPost struct { + UserKey string `json:"userkey"` // + // OrgId string `json:"orgid"` //行政组织 + // PostId string `json:"postid"` //岗位 +} diff --git a/api/version1/workrostering/entry.go b/api/version1/workrostering/entry.go new file mode 100644 index 0000000..5bc9565 --- /dev/null +++ b/api/version1/workrostering/entry.go @@ -0,0 +1,17 @@ +package workrostering + +import ( + "hr_server/overall/overallhandle" + + "github.com/gin-gonic/gin" +) + +// 排班管理API +type ApiModer struct{} + +// 入口 +func (s *ApiModer) Index(c *gin.Context) { + outputCont := overallhandle.MapOut() + outputCont["index"] = "排班管理API" + overallhandle.Result(0, outputCont, c) +} diff --git a/api/version1/workrostering/structsetup.go b/api/version1/workrostering/structsetup.go new file mode 100644 index 0000000..18de999 --- /dev/null +++ b/api/version1/workrostering/structsetup.go @@ -0,0 +1,33 @@ +package workrostering + +//工作时间段列表查询 +type WorkTimeList struct { + Name string `json:"name"` //名称 +} + +//添加工作时间段 +type SetWorkTime struct { + Name string `json:"name"` //名称 + List []TemaTime `json:"list"` // 班次安排 +} + +//通用班次时间 +type TemaTime struct { + Title string `json:"title"` //班次名称 + StartTime string `json:"startTime"` //开始时间 + EndTime string `json:"endTime"` //结束时间 +} + +//输出工作时间段列表 +type SendWorkTime struct { + Id string `json:"id"` // + State int `json:"state"` // + States bool `json:"states"` // + SetWorkTime +} + +//编辑工作时间段内容 +type EditWorkTimeCont struct { + Id string `json:"id"` // + SetWorkTime +} diff --git a/api/version1/workrostering/teamtime.go b/api/version1/workrostering/teamtime.go new file mode 100644 index 0000000..212446f --- /dev/null +++ b/api/version1/workrostering/teamtime.go @@ -0,0 +1,324 @@ +package workrostering + +import ( + "hr_server/models/workgroup" + "hr_server/overall" + "hr_server/overall/overallhandle" + "strconv" + "time" + + "github.com/gin-gonic/gin" +) + +//工作时间设定 + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-13 18:38:21 +@ 功能: 获取工作时间列表 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiModer) TeamTimeList(c *gin.Context) { + var requestData WorkTimeList + c.ShouldBindJSON(&requestData) + var timeList []workgroup.WorkTimeType + gormDb := overall.CONSTANT_DB_HR.Model(&workgroup.WorkTimeType{}).Where("`state` IN (1,2)") + if requestData.Name != "" { + gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%") + } + err := gormDb.Find(&timeList).Error + if err != nil { + overallhandle.Result(107, err, c) + return + } + var sendList []SendWorkTime + for _, v := range timeList { + + var sendCont SendWorkTime + sendCont.Id = strconv.FormatInt(v.Id, 10) + sendCont.Name = v.Name + sendCont.State = v.State + if v.State == 1 { + sendCont.States = true + } else { + sendCont.States = false + } + var workTimeCont workgroup.WorkingTimePeriod + timeContList, _ := workTimeCont.ContMap(map[string]interface{}{`type_id`: v.Id}, "`name`", "`start_time`", "`end_time`") + for _, wv := range timeContList { + var teamContTime TemaTime + teamContTime.Title = wv.Name + teamContTime.StartTime = wv.StartTime + teamContTime.EndTime = wv.EndTime + sendCont.List = append(sendCont.List, teamContTime) + } + sendList = append(sendList, sendCont) + } + overallhandle.Result(0, sendList, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-13 17:29:07 +@ 功能: 添加工作时间设置 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiModer) AddTeamTime(c *gin.Context) { + var requestData SetWorkTime + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.Name == "" { + overallhandle.Result(101, requestData, c) + return + } + if len(requestData.List) < 1 { + overallhandle.Result(1, requestData, c, "没有划分工作时间段!") + return + } + isTrue := true + for _, v := range requestData.List { + if v.Title == "" || v.StartTime == "" || v.EndTime == "" { + isTrue = false + } + // beginTime := fmt.Sprintf("%v",) + } + if !isTrue { + overallhandle.Result(1, requestData, c, "您划分的工作时间段,有不符合规定的!请改正!") + return + } + key := overallhandle.OnlyOneNumber(5) + //工作时间段类型 + var workTimeType workgroup.WorkTimeType + //判断是否有同类型的安排 + err = workTimeType.GetCont(map[string]interface{}{"`name`": requestData.Name}, "`id`") + if err == nil { + overallhandle.Result(1, requestData, c, "该名称已经存在!请不要重复添加!") + return + } + workTimeType.Id = key + workTimeType.Name = requestData.Name //type:string comment:类型名称 version:2022-11-13 16:57 + workTimeType.State = 1 //类型:(1:启用;2:禁用;3:删除) version:2022-11-13 16:57 + workTimeType.Time = time.Now().Unix() + //工作时段 + var workTimeList []workgroup.WorkingTimePeriod + for _, lv := range requestData.List { + var workTimeCont workgroup.WorkingTimePeriod + workTimeCont.Name = lv.Title //type:string comment:工作时间段名称 version:2022-11-13 16:59 + workTimeCont.Time = time.Now().Unix() //type:int64 comment:编辑时间;0 version:2022-11-13 16:59 + workTimeCont.TypeId = key //type:int64 comment:类型 version:2022-11-13 16:59 + workTimeCont.StartTime = lv.StartTime //type:string comment:开始时间 version:2022-11-13 16:59 + workTimeCont.EndTime = lv.EndTime //type:string comment:结束时间 version:2022-11-13 16:59 + workTimeList = append(workTimeList, workTimeCont) + } + err = overall.CONSTANT_DB_HR.Create(&workTimeType).Error + if err != nil { + overallhandle.Result(104, requestData, c) + return + } + WriteWorkTime(key, workTimeList) + overallhandle.Result(0, requestData, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-13 18:06:08 +@ 功能: 写入工作时段 +@ 参数 + + #key 类型ID + #workTimeList 时段列表 + +@ 返回值 + + #err 返回状态 + +@ 方法原型 + + # WriteWorkTime(key int64, workTimeList []workgroup.WorkingTimePeriod) (err error) +*/ +func WriteWorkTime(key int64, workTimeList []workgroup.WorkingTimePeriod) (err error) { + var workTimeCont workgroup.WorkingTimePeriod + workTimeCont.DelCont(map[string]interface{}{"`type_id`": key}) + err = overall.CONSTANT_DB_HR.Create(&workTimeList).Error + return +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-14 08:14:45 +@ 功能: 编辑状态 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiModer) EditWorkTimeState(c *gin.Context) { + var requestData overallhandle.EditState + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.Id == "" { + overallhandle.Result(101, err, c) + return + } + if requestData.State == 0 { + requestData.State = 2 + } + if requestData.Constrain == 0 { + requestData.Constrain = 2 + } + wher := overallhandle.MapOut() + wher["id"] = requestData.Id + var oldCont workgroup.WorkTimeType + err = oldCont.GetCont(wher) + if err != nil { + overallhandle.Result(107, err, c) + return + } + + if requestData.State != oldCont.State { + editCont := overallhandle.MapOut() + if requestData.State < 3 { + editCont["state"] = requestData.State + editCont["time"] = time.Now().Unix() + err = oldCont.EiteCont(wher, editCont) + if err != nil { + overallhandle.Result(106, err, c) + return + } + } else { + if requestData.Constrain != 1 { + editCont["state"] = requestData.State + editCont["time"] = time.Now().Unix() + err = oldCont.EiteCont(wher, editCont) + if err != nil { + overallhandle.Result(108, err, c) + return + } + } else { + var workTimeLists workgroup.WorkingTimePeriod + workTimeLists.DelCont(map[string]interface{}{"`type_id`": requestData.Id}) + err = oldCont.DelCont(wher) + if err != nil { + overallhandle.Result(108, err, c) + return + } + } + } + } + overallhandle.Result(0, err, c) +} + +/* +* +@ 作者: 秦东 +@ 时间: 2022-12-14 09:20:07 +@ 功能: 编辑时间段 +@ 参数 + + # + +@ 返回值 + + # + +@ 方法原型 + + # +*/ +func (a *ApiModer) EditWorkTimeCont(c *gin.Context) { + var requestData EditWorkTimeCont + err := c.ShouldBindJSON(&requestData) + if err != nil { + overallhandle.Result(100, err, c) + return + } + if requestData.Id == "" { + overallhandle.Result(101, requestData, c) + return + } + if requestData.Name == "" { + overallhandle.Result(101, requestData, c) + return + } + if len(requestData.List) < 1 { + overallhandle.Result(1, requestData, c, "没有划分工作时间段!") + return + } + isTrue := true + for _, v := range requestData.List { + if v.Title == "" || v.StartTime == "" || v.EndTime == "" { + isTrue = false + } + // beginTime := fmt.Sprintf("%v",) + } + if !isTrue { + overallhandle.Result(1, requestData, c, "您划分的工作时间段,有不符合规定的!请改正!") + return + } + wher := overallhandle.MapOut() + wher["id"] = requestData.Id + var oldCont workgroup.WorkTimeType + err = oldCont.GetCont(wher) + if err != nil { + overallhandle.Result(107, err, c) + return + } + editCont := overallhandle.MapOut() + editCont["name"] = requestData.Name + editCont["time"] = time.Now().Unix() + err = oldCont.EiteCont(wher, editCont) + if err != nil { + overallhandle.Result(106, err, c) + return + } + //工作时段 + var workTimeList []workgroup.WorkingTimePeriod + for _, lv := range requestData.List { + var workTimeCont workgroup.WorkingTimePeriod + workTimeCont.Name = lv.Title //type:string comment:工作时间段名称 version:2022-11-13 16:59 + workTimeCont.Time = time.Now().Unix() //type:int64 comment:编辑时间;0 version:2022-11-13 16:59 + workTimeCont.TypeId = oldCont.Id //type:int64 comment:类型 version:2022-11-13 16:59 + workTimeCont.StartTime = lv.StartTime //type:string comment:开始时间 version:2022-11-13 16:59 + workTimeCont.EndTime = lv.EndTime //type:string comment:结束时间 version:2022-11-13 16:59 + workTimeList = append(workTimeList, workTimeCont) + } + WriteWorkTime(oldCont.Id, workTimeList) + overallhandle.Result(0, err, c) +} diff --git a/apirouter/inlet.go b/apirouter/inlet.go index b0a68a1..be7e4bd 100644 --- a/apirouter/inlet.go +++ b/apirouter/inlet.go @@ -7,6 +7,7 @@ import ( "hr_server/apirouter/permit" "hr_server/apirouter/personnel" "hr_server/apirouter/shiyanrouter" + "hr_server/apirouter/workteamapi" ) //路由入口 @@ -20,6 +21,7 @@ type RouterGroup struct { ShiyanApiRRouter shiyanrouter.ShiyanApiRouter EmpowerApiRouter empowerrote.EmpowerApiRouter KingdeeApiRouter dockingjindie.DockingJindieApiRouter + RosteringApiRouter workteamapi.ApiRouter //排班相关管理 } var RouterGroupInlet = new(RouterGroup) diff --git a/apirouter/personnel/people.go b/apirouter/personnel/people.go index 3b77a67..994130d 100644 --- a/apirouter/personnel/people.go +++ b/apirouter/personnel/people.go @@ -65,6 +65,10 @@ func (p *PersonnelRoute) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("edit_man_org_cont", apiHandle.EditManOrgCont) //编辑人员行政组织 EditManMainCont apiRouter.POST("edit_manmain_cont", apiHandle.EditManMainCont) //编辑人员主题信息 + apiRouter.POST("judge_prin_position", apiHandle.JudgePrincipalPosition) //判断是否已经存在主职 + + apiRouter.POST("addinsidehistorynew", apiHandle.AddInsideHistoryNew) //添加集团工作履历(新版) + } } @@ -78,7 +82,7 @@ func (p *PersonnelRouteKingdee) InitRouterGroup(route *gin.RouterGroup) { apiRouter.POST("stafflist", apiHandle.StaffList) //人员列表 apiRouter.POST("addstaff", apiHandle.AddStaff) //添加人员档案 apiRouter.POST("allocationofrights", apiHandle.AllocationOfRights) //分配权限 - apiRouter.POST("archiveslist", apiHandle.ArchivesList) //人员列表(新) + apiRouter.POST("archiveslist", apiHandle.ArchivesListWai) //人员列表(新) apiRouter.POST("archivescont", apiHandle.ArchivesCon) //个人档案 apiRouter.POST("kingdeehr", apiHandle.NewKingdee) //对接金蝶HR系统 apiRouter.POST("editpassword", apiHandle.EditPassWord) //修改密码 diff --git a/apirouter/workteamapi/apigroupurl.go b/apirouter/workteamapi/apigroupurl.go new file mode 100644 index 0000000..226d21c --- /dev/null +++ b/apirouter/workteamapi/apigroupurl.go @@ -0,0 +1,23 @@ +package workteamapi + +import ( + "hr_server/api/version1" + + "github.com/gin-gonic/gin" +) + +// 员工档案 +func (a *ApiRouter) InitRouterGroup(route *gin.RouterGroup) { + apiRouter := route.Group("rostering") + var apiHandle = version1.AppApiInlet.RosteringApi + { + apiRouter.GET("", apiHandle.Index) //入口 + apiRouter.POST("", apiHandle.Index) //入口 + + apiRouter.POST("team_time_list", apiHandle.TeamTimeList) //获取工作时间列表 + apiRouter.POST("add_team_time", apiHandle.AddTeamTime) //添加工作时间段设定 + apiRouter.POST("edit_work_time_state", apiHandle.EditWorkTimeState) //编辑工作时间段状态 + apiRouter.POST("edit_work_time_cont", apiHandle.EditWorkTimeCont) //编辑工作时间段内容 + + } +} diff --git a/apirouter/workteamapi/entry.go b/apirouter/workteamapi/entry.go new file mode 100644 index 0000000..2417d82 --- /dev/null +++ b/apirouter/workteamapi/entry.go @@ -0,0 +1,4 @@ +package workteamapi + +//排班相关操作 +type ApiRouter struct{} diff --git a/initialization/route/route_entry.go b/initialization/route/route_entry.go index ff4c804..3751616 100644 --- a/initialization/route/route_entry.go +++ b/initialization/route/route_entry.go @@ -40,6 +40,9 @@ func InitialRouter() *gin.Engine { staffApi := apirouter.RouterGroupInlet.PersonnelRoute staffApiFuben := apirouter.RouterGroupInlet.PersonnelRouteKingdee + //排班相关操作 + rosteringApi := apirouter.RouterGroupInlet.RosteringApiRouter + //金蝶对接接口 jinDieDockingApi := apirouter.RouterGroupInlet.KingdeeApiRouter //人员 organizationApiKingdee := apirouter.RouterGroupInlet.OrganizationApiOpen //组织架构 @@ -52,6 +55,8 @@ func InitialRouter() *gin.Engine { staffApi.InitRouterGroup(appLoadRouterGroup) //人员档案 + rosteringApi.InitRouterGroup(appLoadRouterGroup) //排班相关操作 + } //身份验证 diff --git a/models/inside_work_history.go b/models/inside_work_history.go index 9aeca53..35bc7df 100644 --- a/models/inside_work_history.go +++ b/models/inside_work_history.go @@ -5,7 +5,7 @@ import ( "strings" ) -//集团内部工作经历 +// 集团内部工作经历 type InsideWorkHistory struct { Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` Key int64 `json:"key" gorm:"column:key;type:bigint(20) unsigned;default:0;not null;comment:员工识别符"` @@ -23,19 +23,20 @@ type InsideWorkHistory struct { Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` AssignType int `json:"assigntype" gorm:"column:assign_type;type:int(1) unsigned;default:1;not null;comment:1、主职;2:兼职"` + JobId int64 `json:"jobid" gorm:"column:jobid;type:bigint(20) unsigned;default:0;not null;comment:职务"` } func (InsideWorkHistory *InsideWorkHistory) TableName() string { return "inside_work_history" } -//编辑集团内部工作经历内容 +// 编辑集团内部工作经历内容 func (cont *InsideWorkHistory) EditCont(whereMap map[string]interface{}, saveData map[string]interface{}) (err error) { err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error return } -//获取详细内容 +// 获取详细内容 func (cont *InsideWorkHistory) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_HR.Model(&cont) if len(field) > 0 { diff --git a/models/workgroup/work_time_type.go b/models/workgroup/work_time_type.go new file mode 100644 index 0000000..4878751 --- /dev/null +++ b/models/workgroup/work_time_type.go @@ -0,0 +1,59 @@ +package workgroup + +//工作时间段类型 +import ( + "hr_server/overall" + "strings" +) + +type WorkTimeType struct { + Id int64 `gorm:"primaryKey;column:id" json:"Id"` //type:int64 comment: version:2022-11-13 16:57 + Name string `gorm:"column:name" json:"Name"` //type:string comment:类型名称 version:2022-11-13 16:57 + State int `gorm:"column:state" json:"State"` //type:*int comment:类型:(1:启用;2:禁用;3:删除) version:2022-11-13 16:57 + Time int64 `gorm:"column:time" json:"Time"` //type:int64 comment: version:2022-11-13 16:57 +} + +func (WorkTimeType *WorkTimeType) TableName() string { + return "work_time_type" +} + +// 编辑内容 +func (cont *WorkTimeType) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *WorkTimeType) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *WorkTimeType) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *WorkTimeType) ContMap(whereMap interface{}, field ...string) (countAry []WorkTimeType, err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *WorkTimeType) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error + return +} diff --git a/models/workgroup/working_time_period.go b/models/workgroup/working_time_period.go new file mode 100644 index 0000000..7ccbc5c --- /dev/null +++ b/models/workgroup/working_time_period.go @@ -0,0 +1,61 @@ +package workgroup + +import ( + "hr_server/overall" + "strings" +) + +// 工作时间段 +type WorkingTimePeriod struct { + Id int64 `gorm:"primaryKey;column:id" json:"Id"` //type:int64 comment: version:2022-11-13 16:59 + Name string `gorm:"column:name" json:"Name"` //type:string comment:工作时间段名称 version:2022-11-13 16:59 + Time int64 `gorm:"column:time" json:"Time"` //type:int64 comment:编辑时间;0 version:2022-11-13 16:59 + TypeId int64 `gorm:"column:type_id" json:"TypeId"` //type:int64 comment:类型 version:2022-11-13 16:59 + StartTime string `gorm:"column:start_time" json:"StartTime"` //type:string comment:开始时间 version:2022-11-13 16:59 + EndTime string `gorm:"column:end_time" json:"EndTime"` //type:string comment:结束时间 version:2022-11-13 16:59 +} + +func (WorkingTimePeriod *WorkingTimePeriod) TableName() string { + return "working_time_period" +} + +// 编辑内容 +func (cont *WorkingTimePeriod) EiteCont(whereMap interface{}, saveData interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error + return +} + +// 获取内容 +func (cont *WorkingTimePeriod) GetCont(whereMap interface{}, field ...string) (err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + gormDb = gormDb.Where(whereMap) + err = gormDb.First(&cont).Error + return +} + +// 根据条件获取总数 +func (cont *WorkingTimePeriod) CountCont(whereMap interface{}) (countId int64) { + overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId) + return +} + +// 读取全部信息 +func (cont *WorkingTimePeriod) ContMap(whereMap interface{}, field ...string) (countAry []WorkingTimePeriod, err error) { + gormDb := overall.CONSTANT_DB_HR.Model(&cont) + if len(field) > 0 { + fieldStr := strings.Join(field, ",") + gormDb = gormDb.Select(fieldStr) + } + err = gormDb.Where(whereMap).Find(&countAry).Error + return +} + +// 删除内容 +func (cont *WorkingTimePeriod) DelCont(whereMap interface{}) (err error) { + err = overall.CONSTANT_DB_HR.Where(whereMap).Delete(&cont).Error + return +} diff --git a/overall/overallhandle/format_output.go b/overall/overallhandle/format_output.go index 0263c18..2376e89 100644 --- a/overall/overallhandle/format_output.go +++ b/overall/overallhandle/format_output.go @@ -14,7 +14,12 @@ func Result(code int, data interface{}, c *gin.Context, msgAry ...string) { } if len(msgAry) > 0 { for _, v := range msgAry { - msg = fmt.Sprintf("%v。%v", msg, v) + if msg != "" { + msg = fmt.Sprintf("%v。%v", msg, v) + } else { + msg = fmt.Sprintf("%v", v) + } + } } c.JSON(http.StatusOK, Reply{code, msg, data}) //输出json格式数据 diff --git a/overall/overallhandle/type.go b/overall/overallhandle/type.go index dea3698..8a84efc 100644 --- a/overall/overallhandle/type.go +++ b/overall/overallhandle/type.go @@ -67,3 +67,10 @@ type GenericityVariable interface { type AllSunList[T GenericityVariable] struct { SunList []T `json:"sunlist"` } + +//通用编辑状态 +type EditState struct { + Id string `json:"id"` //id + State int `json:"state"` //状态 + Constrain int `json:"constrain"` //强制执行 1:是;2:否 +}