HR管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

841 lines
17 KiB

package personnelapi
import (
"encoding/json"
"errors"
"fmt"
"hr_server/models"
"hr_server/models/workgroup"
"hr_server/overall"
"hr_server/overall/overallhandle"
"strconv"
)
//用工关系转换
//1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职
//1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职
func EmptypeToInt(emp string) int {
switch emp {
case "临时工":
return 1
case "编外人员":
return 2
case "实习":
return 3
case "实习生":
return 3
case "试用员工":
return 4
case "待分配":
return 5
case "待岗":
return 6
case "临时调入":
return 7
case "正式员工":
return 8
case "长期病假":
return 9
case "停薪留职":
return 10
case "退休":
return 11
case "辞职":
return 12
case "批准辞职":
return 12
case "辞退":
return 13
case "离职":
return 14
default:
return 1
}
}
// 雇佣类型转换
// 雇佣类型(1:雇佣入职;2:再入职;3:返聘)
func hireTypeToInt(hir string) int {
switch hir {
case "雇佣入职":
return 1
case "再入职":
return 2
case "返聘":
return 3
default:
return 1
}
}
/*
婚姻状态
婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
*/
func maritalstatusToInt(name string) int {
switch name {
case "未婚":
return 1
case "已婚":
return 2
case "丧偶":
return 3
case "离异":
return 4
case "离婚":
return 4
default:
return 1
}
}
/*
星座
(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
*/
func consteToInt(emp string) int {
switch emp {
case "白羊座":
return 1
case "金牛座":
return 2
case "双子座":
return 3
case "巨蟹座":
return 4
case "狮子座":
return 5
case "处女座":
return 6
case "天枰座":
return 7
case "天秤座":
return 7
case "天蝎座":
return 8
case "射手座":
return 9
case "摩羯座":
return 10
case "水瓶座":
return 11
case "双鱼座":
return 12
default:
return 1
}
}
/*
政治面貌
(1:群众; 2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
*/
func politiToInt(emp string) int {
switch emp {
case "群众":
return 1
case "无党派":
return 2
case "台盟会员":
return 3
case "九三社员":
return 4
case "致公党员":
return 5
case "农工党员":
return 6
case "民进会员":
return 7
case "民建会员":
return 8
case "民盟盟员":
return 9
case "民革会员":
return 10
case "共青团员":
return 11
case "预备党员":
return 12
case "中共党员":
return 13
default:
return 1
}
}
/*
性别
(1:男性;2:女性;3:中性)
*/
func genderToInt(name string) int {
switch name {
case "男":
return 1
case "女":
return 2
case "中性":
return 3
case "男性":
return 1
case "女性":
return 2
default:
return 1
}
}
/*
健康状况
(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)
*/
func healthToInt(name string) int {
switch name {
case "良好":
return 1
case "一般":
return 2
case "较弱":
return 3
case "有生理缺陷":
return 4
case "残废":
return 5
default:
return 2
}
}
/*
健康状况
(1:主职;2:兼职)
*/
func assignTypeToInt(name string) int {
switch name {
case "主职":
return 1
default:
return 2
}
}
/*
变动类型
(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;17、新入职;)
*/
func changeTypeToInt(emp string) int {
switch emp {
case "预入职":
return 1
case "雇佣入职":
return 2
case "转正":
return 3
case "晋升":
return 4
case "升职":
return 4
case "降级":
return 5
case "降职":
return 5
case "职等调整":
return 6
case "调动调入":
return 7
case "跨公司调动调入":
return 8
case "借调":
return 9
case "平调":
return 10
case "兼职":
return 11
case "预离职":
return 12
case "离职":
return 13
case "批准辞职":
return 13
case "退休":
return 14
case "返聘":
return 15
case "员工初始化":
return 16
case "擅自离职":
return 17
case "即辞即走":
return 18
case "组织调整":
return 19
case "辞退":
return 20
case "跨公司借调调出":
return 21
case "跨公司借调调入":
return 22
case "培训期间离职":
return 23
case "合同到期":
return 24
case "实习结束":
return 25
case "新入职":
return 26
default:
return 1
}
}
func changeTypeToStr(emp int) string {
switch emp {
case 1:
return "预入职"
case 2:
return "雇佣入职"
case 3:
return "转正"
case 4:
return "升职"
case 5:
return "降职"
case 6:
return "职等调整"
case 7:
return "调动调入"
case 8:
return "跨公司调动调入"
case 9:
return "借调"
case 10:
return "平调"
case 11:
return "兼职"
case 12:
return "预离职"
case 13:
return "离职"
case 14:
return "退休"
case 15:
return "返聘"
case 16:
return "员工初始化"
case 17:
return "擅自离职"
case 18:
return "即辞即走"
case 19:
return "组织调整"
case 20:
return "辞退"
case 21:
return "跨公司借调调出"
case 22:
return "跨公司借调调入"
case 23:
return "培训期间离职"
case 24:
return "合同到期"
case 25:
return "实习结束"
case 26:
return "新入职"
default:
return "预入职"
}
}
/*
学历
(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函授专科;7:大学专科;8:函授本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)
*/
func ducationToInt(emp string) int {
switch emp {
case "初中及以下":
return 1
case "中专":
return 2
case "高中":
return 3
case "中技":
return 4
case "高技":
return 5
case "函授专科":
return 6
case "专科":
return 7
case "大专":
return 7
case "大学专科":
return 7
case "函授本科":
return 8
case "本科":
return 9
case "大学本科":
return 9
case "硕士研究生":
return 10
case "研究生":
return 10
case "博士研究生":
return 11
case "专家、教授":
return 12
default:
return 0
}
}
// 学位(0:无;1:学士;2:硕士;3:博士;4:工学学士;5:教育学学位)int
func hestacademicdegreeToInt(hir string) int {
switch hir {
case "学士":
return 1
case "硕士":
return 2
case "博士":
return 3
case "学士学位":
return 1
case "工学学士":
return 4
case "教育学学位":
return 5
default:
return 0
}
}
func EmptypeToStr(emp int) string {
switch emp {
case 1:
return "临时工"
case 2:
return "编外人员"
case 3:
return "实习&实习生"
case 4:
return "试用员工"
case 5:
return "待分配"
case 6:
return "待岗"
case 7:
return "临时调入"
case 8:
return "正式员工"
case 9:
return "长期病假"
case 10:
return "停薪留职"
case 11:
return "退休"
case 12:
return "辞职"
case 13:
return "辞退"
case 14:
return "离职"
default:
return "临时工"
}
}
// 雇佣类型(1:社会招聘;2:校园招聘;3:内部推荐)
func JoinJobChanel(hir string) int {
switch hir {
case "校园招聘":
return 2
case "内部推荐":
return 3
default:
return 1
}
}
// 学历类型
func EducationTypeStr(level string) int {
switch level {
case "全日制统招学历":
return 1
case "成人高考学历":
return 2
case "自学考试学历":
return 3
case "开放大学学历":
return 4
case "网络教育学历":
return 5
case "函授学历":
return 6
case "双一流院校":
return 7
case "“985”工程院校":
return 9
case "“211”工程院校":
return 8
case "公办本科院校":
return 10
case "民办本科院校":
return 11
case "公办专科院校":
return 12
case "民办专科院校":
return 13
case "高职院校":
return 14
case "中职院校":
return 15
case "公立中学":
return 16
case "私立中学":
return 17
default:
return 0
}
}
// 职位变动类型
func PositionChangeTypeStr(level string) int {
switch level {
case "平调":
return 2
case "降职":
return 3
case "升职":
return 4
default:
return 1
}
}
// 奖惩级别
func RewPunLevelStr(level string) int {
switch level {
case "部门级":
return 1
case "公司级":
return 2
case "县级":
return 3
case "市级":
return 4
case "省级":
return 5
case "国家级":
return 6
default:
return 0
}
}
func RewPunLevelClassStr(emp string) int {
switch emp {
case "年终评优":
return 1
case "表扬":
return 2
case "嘉奖":
return 3
case "记功":
return 4
case "记大功":
return 5
case "特别奖励":
return 6
case "批评":
return 7
case "警告":
return 8
case "记过":
return 9
case "记大过":
return 10
case "降级":
return 11
case "留用察看":
return 12
case "开除":
return 13
default:
return 0
}
}
func SchoolTypeStr(level string) int {
var typeName int
switch level {
case "私立中学":
typeName = 1
case "公立中学":
typeName = 2
case "高职院校":
typeName = 3
case "民办专科院校":
typeName = 4
case "公办专科院校":
typeName = 5
case "民办本科院校":
typeName = 6
case "公办本科院校":
typeName = 7
case "”211“工程院校":
typeName = 8
case "“211“工程院校":
typeName = 8
case "”985“工程院校":
typeName = 9
case "“985”工程院校":
typeName = 9
case "双一流院校":
typeName = 10
default:
typeName = 0
}
return typeName
}
/*
*
@ 作者: 秦东
@ 时间: 2025-01-16 16:26:39
@ 功能: 确定当前行政组织用哪一个轮询规则
*/
func CureeRunRules(orgId int64) (rules GenesInfo, cureeOrgId int64, err error) {
if orgId != 0 {
err = rules.GetCont(map[string]interface{}{"`orgId`": orgId})
if err != nil || rules.TypeId == 0 {
var supaerOrgId models.AdministrativeOrganization
supaerOrgId.GetCont(map[string]interface{}{"`id`": orgId}, "`superior`")
if supaerOrgId.Superior != 0 {
return CureeRunRules(supaerOrgId.Superior)
}
} else {
cureeOrgId = orgId
}
} else {
err = errors.New("没有相关设定")
}
return
}
/*
*
@ 作者: 秦东
@ 时间: 2025-01-30 13:38:44
@ 功能: 计算行政组织某一天执行得班组
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (g *GenesInfo) CountOrgTeamsIsDay(dats string) (teamIsDay []workgroup.TeamsRules, err error) {
if g.TypeId != 66813772706107392 {
teamAry, _ := g.GainChangBaiTeams(dats)
if len(teamAry) > 0 {
teamIsDay = append(teamIsDay, teamAry...)
}
}
//获取源点起始工作时间段
g.BegainTime = overallhandle.UnixTimeToDay(g.StartTime, 14)
g.TypeIdStr = strconv.FormatInt(g.TypeId, 10)
//获取倒班规则
var paiBanType workgroup.WorkTimeType
paiBanType.GetCont(map[string]interface{}{"`id`": g.TypeId}, " `name`")
g.TypeName = paiBanType.Name
//作息时间
var zuoXiTime []workgroup.WorkingTimePeriod
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = ?", g.TypeId).Order("`sort` ASC").Find(&zuoXiTime)
//轮询规则
var lunXunShiXu []workgroup.TeamsRules
overall.CONSTANT_DB_HR.Where("`ruleTypeId` = ?", g.TypeId).Find(&lunXunShiXu)
if len(zuoXiTime) < 1 || len(lunXunShiXu) < 1 {
return teamIsDay, errors.New("此行政组织还未设定班组轮询规则! *struct类型,却传入*")
}
var canyuTeams []int64
cycle := 1
for _, v := range lunXunShiXu {
cycle = v.Cycle
if !overallhandle.IsInTrue(v.TeamsId, canyuTeams) {
canyuTeams = append(canyuTeams, v.TeamsId)
}
}
teamsMap := make(map[int64][]workgroup.TeamsRules)
for _, v := range canyuTeams {
var teamRuleAry []workgroup.TeamsRules
for _, mv := range lunXunShiXu {
if v == mv.TeamsId {
teamRuleAry = append(teamRuleAry, mv)
}
}
teamsMap[v] = teamRuleAry
}
var wvTimeAll overallhandle.DateTimeTotimes
wvTimeAll.BaisStrToTime(dats)
fmt.Printf("daysApart------------->:%v\n%v\n%v\n", dats, wvTimeAll.AllTime, wvTimeAll)
var qiyuanTime overallhandle.DateTimeTotimes
qiyuanTime.BaisStrToTime(g.BegainTime)
// yearIntQy, _ := strconv.Atoi(qiyuanTime.Years)
// monthIntQy, _ := strconv.Atoi(qiyuanTime.Months)
// daysIntQy, _ := strconv.Atoi(qiyuanTime.Days)
// zhouJiQiyuan := overallhandle.ZellerFunction2Week(yearIntQy, monthIntQy, daysIntQy)
switch cycle {
case 2: //按周
yearInt, _ := strconv.Atoi(wvTimeAll.Years)
monthInt, _ := strconv.Atoi(wvTimeAll.Months)
daysInt, _ := strconv.Atoi(wvTimeAll.Days)
zhouJi := overallhandle.ZellerFunction2Week(yearInt, monthInt, daysInt)
key := 0
if zhouJi-1 > 0 {
if zhouJi-1 > len(lunXunShiXu) {
key = len(lunXunShiXu) - 1
} else {
key = zhouJi - 1
}
} else {
key = 0
}
banZuAry := lunXunShiXu[key]
teamIsDay = append(teamIsDay, banZuAry)
default:
daysApart := ((wvTimeAll.AllTime - qiyuanTime.AllTime) / 86400) + 1
// jsontime, _ := json.Marshal(g)
fmt.Printf("daysApart:%v\n%v\n%v\n%v\n", dats, daysApart, wvTimeAll.AllTime, qiyuanTime.AllTime)
if daysApart >= 0 {
for i, v := range teamsMap {
ruleLen := len(v)
var ruleStep int64 = 1
if daysApart > int64(ruleLen) {
ruleStep = int64(daysApart) % int64(ruleLen)
if ruleStep == 0 {
ruleStep = int64(ruleLen)
}
} else {
ruleStep = int64(daysApart)
}
for _, lv := range lunXunShiXu {
if lv.CycleSort == ruleStep && lv.TeamsId == i && lv.CycleWorkTime != 0 {
// cycleInfo = v
lvJson, _ := json.Marshal(lv)
fmt.Printf("\n\nlv---------i:%v----ruleStep:%v-------->%v\n\n", i, ruleStep, string(lvJson))
teamIsDay = append(teamIsDay, lv)
}
}
}
}
// daysApart, _ := overallhandle.CalculateYearDifference(g.StartTime, wvTimeAll.AllTime, 1)
// sjc := ((wvTimeAll.AllTime - g.StartTime) / 86400) + 1
// fmt.Printf("\n\n\n\n相差几天%v------------------->%v\n\n\n\n", daysApart, sjc)
// xiangcha := (7 - zhouJiQiyuan)
// daysApart = daysApart + float64(xiangcha)
// fmt.Printf("\n\n\n\n相差几天%v------------------->%v----------------->%v------------------->%v\n\n\n\n", daysApart, sjc, xiangcha, daysApart)
// daysApartInt64, _ := strconv.ParseInt(strconv.FormatFloat(daysApart, 'f', 0, 64), 10, 64)
// if daysApart >= 0 {
// for _, v := range teamsMap {
// ruleLen := len(v)
// var ruleStep int64 = 1
// if sjc > int64(ruleLen) {
// ruleStep = int64(sjc) % int64(ruleLen)
// if ruleStep == 0 {
// ruleStep = int64(ruleLen)
// }
// } else {
// ruleStep = int64(sjc)
// }
// guoDuVal := daysApartInt64 % int64(ruleLen)
// // dingwei, _ := strconv.ParseInt(strconv.FormatFloat(math.Ceil(guoDuVal), 'f', 0, 64), 10, 64)
// // fmt.Printf("\n\n\n\n相差几天------------>%v\n\n\n\n", dingwei)
// val, _ := json.Marshal(v)
// sort.Slice(v, func(i, j int) bool {
// return v[i].CycleSort < v[j].CycleSort
// })
// fmt.Printf("\n\n\n\n相差几天-----guoDuVal------->%v\n\n------->%v\n\n------->%v\n\n", ruleStep, guoDuVal, string(val))
// // keyVal := dingwei + 1
// keyVal := guoDuVal
// if keyVal < 0 {
// keyVal = 0
// }
// // if v.CycleSort == ruleStep{
// // }
// teamIsDay = append(teamIsDay, v[guoDuVal])
// }
// } else {
// daysApartInt64 = -daysApartInt64
// for _, v := range teamsMap {
// ruleLen := len(v)
// if ruleLen <= 0 {
// ruleLen = 1
// }
// guoDuVal := daysApartInt64 / int64(ruleLen)
// // dingwei, _ := strconv.ParseInt(strconv.FormatFloat(math.Ceil(guoDuVal), 'f', 0, 64), 10, 64)
// sort.Slice(v, func(i, j int) bool {
// return v[i].CycleSort > v[j].CycleSort
// })
// teamIsDay = append(teamIsDay, v[guoDuVal])
// }
// }
}
return teamIsDay, nil
}
/*
*
@ 作者: 秦东
@ 时间: 2025-04-03 11:20:37
@ 功能: 获取某天长白班人员
*/
func (g *GenesInfo) GainChangBaiTeams(dats string) (teamIsDay []workgroup.TeamsRules, err error) {
var zuoXiCbTime []workgroup.WorkingTimePeriod
overall.CONSTANT_DB_HR.Where("`state` = 1 AND `type_id` = 66813772706107392").Order("`sort` ASC").Find(&zuoXiCbTime)
//长白轮询规则
var lunXunShiXu []workgroup.TeamsRules
overall.CONSTANT_DB_HR.Where("`ruleTypeId` = 66813772706107392").Find(&lunXunShiXu)
var wvTimeAll overallhandle.DateTimeTotimes
wvTimeAll.BaisStrToTime(dats)
yearInt, _ := strconv.Atoi(wvTimeAll.Years)
monthInt, _ := strconv.Atoi(wvTimeAll.Months)
daysInt, _ := strconv.Atoi(wvTimeAll.Days)
zhouJi := overallhandle.ZellerFunction2Week(yearInt, monthInt, daysInt)
key := 0
if zhouJi-1 > 0 {
if zhouJi-1 > len(lunXunShiXu) {
key = len(lunXunShiXu) - 1
} else {
key = zhouJi - 1
}
} else {
key = 0
}
banZuAry := lunXunShiXu[key]
teamIsDay = append(teamIsDay, banZuAry)
return
}