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.

802 lines
16 KiB

3 years ago
package personnelapi
8 months ago
import (
"encoding/json"
"errors"
"fmt"
"hr_server/models"
"hr_server/models/workgroup"
"hr_server/overall"
"hr_server/overall/overallhandle"
"strconv"
)
3 years ago
//用工关系转换
//1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职
3 years ago
//1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职
func EmptypeToInt(emp string) int {
3 years ago
switch emp {
3 years ago
case "临时工":
3 years ago
return 1
3 years ago
case "编外人员":
3 years ago
return 2
3 years ago
case "实习":
3 years ago
return 3
3 years ago
case "实习生":
return 3
case "试用员工":
3 years ago
return 4
3 years ago
case "待分配":
3 years ago
return 5
3 years ago
case "待岗":
3 years ago
return 6
3 years ago
case "临时调入":
3 years ago
return 7
3 years ago
case "正式员工":
3 years ago
return 8
3 years ago
case "长期病假":
return 9
case "停薪留职":
return 10
case "退休":
return 11
case "辞职":
return 12
case "批准辞职":
return 12
3 years ago
case "辞退":
return 13
case "离职":
return 14
3 years ago
default:
return 1
}
}
8 months ago
// 雇佣类型转换
// 雇佣类型(1:雇佣入职;2:再入职;3:返聘)
3 years ago
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
3 years ago
case "离婚":
return 4
3 years ago
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
8 months ago
case "天秤座":
return 7
3 years ago
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新入职
3 years ago
*/
func changeTypeToInt(emp string) int {
switch emp {
case "预入职":
return 1
case "雇佣入职":
return 2
case "转正":
return 3
case "晋升":
return 4
case "升职":
return 4
3 years ago
case "降级":
return 5
case "降职":
return 5
3 years ago
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
3 years ago
case "退休":
return 14
case "返聘":
return 15
case "员工初始化":
return 16
2 years ago
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
3 years ago
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 "员工初始化"
2 years ago
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 "预入职"
}
}
3 years ago
/*
学历
3 years ago
(1初中及以下2中专3高中4中技5高技6函授专科7大学专科8函授本科9大学本科10硕士研究生11博士研究生12专家教授)
3 years ago
*/
func ducationToInt(emp string) int {
switch emp {
case "初中及以下":
return 1
case "中专":
return 2
case "高中":
return 3
case "中技":
return 4
case "高技":
return 5
3 years ago
case "函授专科":
3 years ago
return 6
case "专科":
return 7
case "大专":
return 7
3 years ago
case "大学专科":
return 7
3 years ago
case "函授本科":
3 years ago
return 8
case "本科":
return 9
3 years ago
case "大学本科":
return 9
case "硕士研究生":
return 10
case "研究生":
return 10
3 years ago
case "博士研究生":
return 11
case "专家、教授":
return 12
default:
8 months ago
return 0
3 years ago
}
}
8 months ago
// 学位(0:无;1:学士;2:硕士;3:博士;4:工学学士;5:教育学学位)int
3 years ago
func hestacademicdegreeToInt(hir string) int {
switch hir {
case "学士":
return 1
case "硕士":
return 2
case "博士":
return 3
3 years ago
case "学士学位":
return 1
case "工学学士":
return 4
case "教育学学位":
return 5
3 years ago
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 "临时工"
}
}
8 months ago
// 雇佣类型(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
8 months ago
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
8 months ago
case "“211“工程院校":
typeName = 8
8 months ago
case "”985“工程院校":
typeName = 9
case "“985”工程院校":
typeName = 9
case "双一流院校":
typeName = 10
default:
typeName = 0
}
return typeName
}
8 months ago
/*
*
@ 作者: 秦东
@ 时间: 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) {
//获取源点起始工作时间段
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
}