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.
1416 lines
54 KiB
1416 lines
54 KiB
package personnelapi
|
|
|
|
import (
|
|
"fmt"
|
|
"hr_server/middleware/snowflake"
|
|
"hr_server/models"
|
|
"hr_server/overall"
|
|
"hr_server/overall/overallhandle"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
//金蝶人员信息对接
|
|
func (s *StaffApi) NewKingdee(c *gin.Context) {
|
|
var requestData addKingdeePersonnel
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Number == "" {
|
|
overallhandle.Result(1, requestData.Number, c, "工号不能为空!")
|
|
return
|
|
}
|
|
var manContent models.PersonArchives
|
|
manErr := manContent.GetCont(map[string]interface{}{"`number`": requestData.Number})
|
|
if manErr == nil {
|
|
//已经存在!进行变动操作
|
|
manErr = eidtAddManContJinDie(manContent, requestData)
|
|
} else {
|
|
//不存在!进行新增操作
|
|
var oldSchool models.WorkMan
|
|
oldSchool.GetCont(map[string]interface{}{"wm_number": requestData.Number})
|
|
manErr = newAddManContJinDie(oldSchool, requestData)
|
|
}
|
|
if manErr != nil {
|
|
overallhandle.Result(104, manErr, c)
|
|
return
|
|
}
|
|
overallhandle.Result(0, manErr, c)
|
|
}
|
|
|
|
//编辑员工
|
|
func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePersonnel) error {
|
|
eidtManCont := overallhandle.MapOut()
|
|
if manCont.Name != "" && manCont.Name != perArcInfo.Name {
|
|
eidtManCont["`name`"] = manCont.Name
|
|
}
|
|
if manCont.Icon != "" && manCont.Icon != perArcInfo.Icon {
|
|
eidtManCont["`icon`"] = manCont.Icon
|
|
}
|
|
if manCont.HireType != 0 && manCont.HireType != perArcInfo.HireClass {
|
|
eidtManCont["`hire_class`"] = manCont.HireType
|
|
}
|
|
if manCont.EmpType != 0 && manCont.EmpType != perArcInfo.EmpType {
|
|
eidtManCont["`emp_type`"] = manCont.EmpType
|
|
}
|
|
//人员变更记录
|
|
var manChangeRecord models.PersonnelChangeRecord
|
|
changeRecordTrue := false
|
|
//公司
|
|
if manCont.Company != "" {
|
|
var orgCompany models.AdministrativeOrganization
|
|
orgErr := orgCompany.GetCont(map[string]interface{}{"kingdeeid": manCont.Company}, "`id`")
|
|
if orgErr == nil {
|
|
if orgCompany.Id != perArcInfo.Company {
|
|
eidtManCont["`company`"] = orgCompany.Id
|
|
changeRecordTrue = true
|
|
}
|
|
manChangeRecord.Company = orgCompany.Id
|
|
}
|
|
}
|
|
//主部门
|
|
if manCont.MainDepartment != "" {
|
|
var orgMainDepart models.AdministrativeOrganization
|
|
orgErr := orgMainDepart.GetCont(map[string]interface{}{"kingdeeid": manCont.MainDepartment}, "`id`")
|
|
if orgErr == nil {
|
|
if orgMainDepart.Id != perArcInfo.Company {
|
|
eidtManCont["`maindeparment`"] = orgMainDepart.Id
|
|
changeRecordTrue = true
|
|
}
|
|
manChangeRecord.MainDepartment = orgMainDepart.Id
|
|
}
|
|
}
|
|
//部门
|
|
if len(manCont.Department) > 0 {
|
|
var departId []string
|
|
|
|
if manCont.MainDepartment != "" {
|
|
if overallhandle.IsInTrue[string](manCont.MainDepartment, manCont.Department) == false {
|
|
manCont.Department = append(manCont.Department, manCont.MainDepartment)
|
|
}
|
|
}
|
|
|
|
for _, dv := range manCont.Department {
|
|
var orgMainDepartAry models.AdministrativeOrganization
|
|
orgErr := orgMainDepartAry.GetCont(map[string]interface{}{"kingdeeid": dv}, "`id`")
|
|
if orgErr == nil {
|
|
orgIdStr := strconv.FormatInt(orgMainDepartAry.Id, 10)
|
|
if overallhandle.StringIsInMap(orgIdStr, departId) == false {
|
|
departId = append(departId, orgIdStr)
|
|
}
|
|
}
|
|
}
|
|
oldDepart := strings.Split(perArcInfo.Deparment, ",")
|
|
chaJiDepart := overallhandle.DifferenceSet[string](departId, oldDepart)
|
|
if len(chaJiDepart) > 0 {
|
|
departIdStr := strings.Join(departId, ",")
|
|
eidtManCont["`deparment`"] = departIdStr
|
|
manChangeRecord.Department = departIdStr
|
|
changeRecordTrue = true
|
|
}
|
|
|
|
}
|
|
//行政组织
|
|
if manCont.AdminOrg != "" {
|
|
var orgMainDepartAdmin models.AdministrativeOrganization
|
|
orgErr := orgMainDepartAdmin.GetCont(map[string]interface{}{"kingdeeid": manCont.AdminOrg}, "`id`")
|
|
if orgErr == nil {
|
|
if orgMainDepartAdmin.Id != perArcInfo.AdminOrg {
|
|
eidtManCont["`admin_org`"] = orgMainDepartAdmin.Id
|
|
changeRecordTrue = true
|
|
}
|
|
manChangeRecord.Adminorg = orgMainDepartAdmin.Id
|
|
}
|
|
}
|
|
//职位
|
|
if manCont.Position != "" {
|
|
var positionCont models.Position
|
|
positErr := positionCont.GetCont(map[string]interface{}{`kingdeeid`: manCont.Position}, "`id`")
|
|
if positErr == nil {
|
|
if positionCont.Id != perArcInfo.Position {
|
|
eidtManCont["`position`"] = positionCont.Id
|
|
changeRecordTrue = true
|
|
}
|
|
manChangeRecord.Position = positionCont.Id
|
|
}
|
|
}
|
|
//职务
|
|
if manCont.JobName != "" {
|
|
var dutiesCont models.DutiesClassLeve
|
|
dutiesErr := dutiesCont.GetCont(map[string]interface{}{"`d_king`": manCont.JobName}, "d_id")
|
|
if dutiesErr == nil {
|
|
|
|
if dutiesCont.Id != perArcInfo.Position {
|
|
eidtManCont["`job_id`"] = dutiesCont.Id
|
|
changeRecordTrue = true
|
|
}
|
|
|
|
if dutiesCont.ClassId != perArcInfo.JobClass {
|
|
eidtManCont["`job_class`"] = dutiesCont.ClassId
|
|
changeRecordTrue = true
|
|
}
|
|
manChangeRecord.JobId = dutiesCont.Id
|
|
manChangeRecord.JobClass = dutiesCont.ClassId
|
|
}
|
|
}
|
|
if manCont.PositionGrade != 0 {
|
|
if manCont.PositionGrade != perArcInfo.JobLeve {
|
|
eidtManCont["`job_leve`"] = manCont.PositionGrade
|
|
}
|
|
manChangeRecord.JobLevel = manCont.PositionGrade
|
|
changeRecordTrue = true
|
|
}
|
|
fmt.Printf("第一学历--->%v--->%v\n", changeRecordTrue, manChangeRecord)
|
|
if len(eidtManCont) > 0 {
|
|
var manMainCont models.PersonArchives
|
|
eidtErrMain := manMainCont.EiteCont(map[string]interface{}{"`id`": perArcInfo.Id}, eidtManCont)
|
|
if eidtErrMain != nil {
|
|
return eidtErrMain
|
|
} else {
|
|
if changeRecordTrue == true {
|
|
//写入变动记录
|
|
|
|
manChangeRecord.Type = manCont.HireType
|
|
manChangeRecord.Number = perArcInfo.Number
|
|
manChangeRecord.Time = time.Now().Unix()
|
|
manChangeRecord.Key = perArcInfo.Key
|
|
// rybdErr := overall.CONSTANT_DB_HR.Create(&manChangeRecord).Error
|
|
// jsonCont, _ := json.Marshal(manChangeRecord)
|
|
// fmt.Printf("第二学历--->%v--->%v\n", rybdErr, string(jsonCont))
|
|
}
|
|
//编辑人员附属信息
|
|
synPro.Add(1)
|
|
go editManAuxiliaryDataNew(perArcInfo.Key, manCont)
|
|
//编辑紧急联系人信息
|
|
synPro.Add(1)
|
|
go emergencyContactPersonNew(perArcInfo.Key, manCont)
|
|
//编辑员工家属信息
|
|
synPro.Add(1)
|
|
go eidtFamilyMembersNew(perArcInfo.Key, manCont.Number, manCont.MemberOfFamily)
|
|
//编辑员工教育经历
|
|
synPro.Add(1)
|
|
go educatExperKingdeeNew(perArcInfo.Key, manCont)
|
|
//编辑工作履历
|
|
synPro.Add(1)
|
|
go editWorkHistoryMan(perArcInfo.Key, manCont.Number, manCont.WorkHistoryList)
|
|
//编辑集团内工作履历
|
|
synPro.Add(1)
|
|
go editInsideWorkHistoryMan(perArcInfo.Key, manCont.InsideWorkHistory)
|
|
synPro.Wait()
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
//新增员工
|
|
func newAddManContJinDie(oldSchool models.WorkMan, manCont addKingdeePersonnel) error {
|
|
|
|
var manKeyNum int64 = 0
|
|
node, nodeErr := snowflake.NewWorker(1)
|
|
if nodeErr == nil {
|
|
manKeyNum = node.GetId()
|
|
} else {
|
|
manKeyNum = overallhandle.TableNumber()
|
|
}
|
|
if oldSchool.Key != 0 {
|
|
manKeyNum = oldSchool.Key
|
|
}
|
|
|
|
var manMainCont models.PersonArchives
|
|
manMainCont.Number = manCont.Number
|
|
manMainCont.Name = manCont.Name
|
|
manMainCont.Icon = manCont.Icon
|
|
manMainCont.HireClass = manCont.HireType
|
|
manMainCont.EmpType = manCont.EmpType
|
|
timeTady := time.Now().Unix()
|
|
manMainCont.Time = timeTady
|
|
manMainCont.EiteTime = timeTady
|
|
manMainCont.State = 1
|
|
|
|
if manCont.Company != "" {
|
|
var orgCompany models.AdministrativeOrganization
|
|
orgErr := orgCompany.GetCont(map[string]interface{}{"kingdeeid": manCont.Company}, "`id`")
|
|
if orgErr == nil {
|
|
manMainCont.Company = orgCompany.Id
|
|
}
|
|
}
|
|
if manCont.MainDepartment != "" {
|
|
var orgMainDepart models.AdministrativeOrganization
|
|
orgErr := orgMainDepart.GetCont(map[string]interface{}{"kingdeeid": manCont.MainDepartment}, "`id`")
|
|
if orgErr == nil {
|
|
manMainCont.MainDeparment = orgMainDepart.Id
|
|
}
|
|
}
|
|
if len(manCont.Department) > 0 {
|
|
var departId []string
|
|
if manCont.MainDepartment != "" {
|
|
if overallhandle.IsInTrue[string](manCont.MainDepartment, manCont.Department) == false {
|
|
manCont.Department = append(manCont.Department, manCont.MainDepartment)
|
|
}
|
|
}
|
|
for _, dv := range manCont.Department {
|
|
var orgMainDepartAry models.AdministrativeOrganization
|
|
orgErr := orgMainDepartAry.GetCont(map[string]interface{}{"kingdeeid": dv}, "`id`")
|
|
if orgErr == nil {
|
|
orgIdStr := strconv.FormatInt(orgMainDepartAry.Id, 10)
|
|
if overallhandle.StringIsInMap(orgIdStr, departId) == false {
|
|
departId = append(departId, orgIdStr)
|
|
}
|
|
}
|
|
}
|
|
departIdStr := strings.Join(departId, ",")
|
|
manMainCont.Deparment = departIdStr
|
|
}
|
|
if manCont.AdminOrg != "" {
|
|
var orgMainDepartAdmin models.AdministrativeOrganization
|
|
orgErr := orgMainDepartAdmin.GetCont(map[string]interface{}{"kingdeeid": manCont.AdminOrg}, "`id`")
|
|
if orgErr == nil {
|
|
manMainCont.AdminOrg = orgMainDepartAdmin.Id
|
|
}
|
|
}
|
|
|
|
//职位
|
|
if manCont.Position != "" {
|
|
var positionCont models.Position
|
|
positErr := positionCont.GetCont(map[string]interface{}{`kingdeeid`: manCont.Position}, "`id`")
|
|
if positErr == nil {
|
|
manMainCont.Position = positionCont.Id
|
|
}
|
|
}
|
|
//职务
|
|
if manCont.JobName != "" {
|
|
var dutiesCont models.DutiesClassLeve
|
|
dutiesErr := dutiesCont.GetCont(map[string]interface{}{"`d_king`": manCont.JobName}, "d_id", "c_id")
|
|
if dutiesErr == nil {
|
|
manMainCont.JobId = dutiesCont.Id
|
|
manMainCont.JobClass = dutiesCont.ClassId
|
|
}
|
|
}
|
|
if manCont.PositionGrade != 0 {
|
|
manMainCont.JobLeve = manCont.PositionGrade
|
|
}
|
|
|
|
//获取老人员主表内容
|
|
var oldPersonArchives models.Personnel
|
|
oldPersErr := overall.CONSTANT_DB_HR_Jin.Where(map[string]interface{}{"`number`": manCont.Number}).First(&oldPersonArchives).Error
|
|
if oldPersErr == nil {
|
|
if manCont.Icon == "" {
|
|
manMainCont.Icon = oldPersonArchives.Icon
|
|
}
|
|
if oldPersonArchives.Key != 0 {
|
|
manMainCont.Key = oldPersonArchives.Key
|
|
} else {
|
|
manMainCont.Key = manKeyNum
|
|
}
|
|
|
|
if oldPersonArchives.Wechat != "" {
|
|
manMainCont.Wechat = oldPersonArchives.Wechat
|
|
}
|
|
if oldPersonArchives.WorkWechat != "" {
|
|
manMainCont.WorkWechat = oldPersonArchives.WorkWechat
|
|
}
|
|
manMainCont.IsAdmin = oldPersonArchives.IsAdmin
|
|
manMainCont.Role = oldPersonArchives.Role
|
|
if oldPersonArchives.Password != "" {
|
|
manMainCont.Password = oldPersonArchives.Password
|
|
} else {
|
|
//密码加密
|
|
var passwordMd5 overallhandle.Md5Encryption
|
|
passwordMd5.Md5EncryptionInit(overall.CONSTANT_CONFIG.Appsetup.DefaultPassword)
|
|
manMainCont.Password = passwordMd5.Md5EncryptionAlgorithm()
|
|
}
|
|
} else {
|
|
manMainCont.Key = manKeyNum
|
|
if oldSchool.Password != "" {
|
|
manMainCont.Password = oldSchool.Password
|
|
} else {
|
|
//密码加密
|
|
var passwordMd5 overallhandle.Md5Encryption
|
|
passwordMd5.Md5EncryptionInit(overall.CONSTANT_CONFIG.Appsetup.DefaultPassword)
|
|
manMainCont.Password = passwordMd5.Md5EncryptionAlgorithm()
|
|
}
|
|
if oldSchool.WorkWechatId != "" {
|
|
manMainCont.WorkWechat = oldSchool.WorkWechatId
|
|
}
|
|
if oldSchool.WechatId != "" {
|
|
manMainCont.Wechat = oldSchool.WechatId
|
|
}
|
|
}
|
|
addManContErr := overall.CONSTANT_DB_HR.Create(&manMainCont).Error
|
|
if addManContErr != nil {
|
|
return addManContErr
|
|
} else {
|
|
//编辑人员附属信息
|
|
synPro.Add(1)
|
|
go editManAuxiliaryDataNew(manKeyNum, manCont)
|
|
//编辑紧急联系人信息
|
|
synPro.Add(1)
|
|
go emergencyContactPersonNew(manKeyNum, manCont)
|
|
//编辑员工家属信息
|
|
synPro.Add(1)
|
|
go eidtFamilyMembersNew(manKeyNum, manCont.Number, manCont.MemberOfFamily)
|
|
//编辑员工教育经历
|
|
synPro.Add(1)
|
|
go educatExperKingdeeNew(manKeyNum, manCont)
|
|
//编辑集团外工作履历
|
|
synPro.Add(1)
|
|
go editWorkHistoryMan(manKeyNum, manCont.Number, manCont.WorkHistoryList)
|
|
//编辑集团内工作履历
|
|
synPro.Add(1)
|
|
go editInsideWorkHistoryMan(manKeyNum, manCont.InsideWorkHistory)
|
|
synPro.Wait()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
//编辑人员附属信息
|
|
func editManAuxiliaryDataNew(manKeyNum int64, manCont addKingdeePersonnel) {
|
|
defer synPro.Done()
|
|
var manInfo models.PersonnelContent
|
|
manErr := manInfo.GetCont(map[string]interface{}{"`key`": manKeyNum})
|
|
if manErr == nil {
|
|
saveData := overallhandle.MapOut()
|
|
|
|
if manCont.Globalroaming != "" && manCont.Globalroaming != manInfo.Globalroaming {
|
|
saveData["globalroaming"] = manCont.Globalroaming
|
|
}
|
|
if manCont.Passportno != "" && manCont.Passportno != manInfo.Passportno {
|
|
saveData["passportno"] = manCont.Passportno
|
|
}
|
|
|
|
if manCont.IDCardNo != "" && manCont.IDCardNo != manInfo.Idcardno {
|
|
saveData["idcardno"] = manCont.IDCardNo
|
|
}
|
|
if manCont.IDCardStartTime != "" {
|
|
idCardStarTime, idCarErr := overallhandle.DateToTimeStamp(manCont.IDCardStartTime)
|
|
if idCarErr == false {
|
|
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.IDCardStartTime))
|
|
}
|
|
|
|
if idCardStarTime != manInfo.Idcardstartdate {
|
|
saveData["idcardstartdate"] = idCardStarTime
|
|
}
|
|
}
|
|
if manCont.IDCardEndTime != "" {
|
|
idCardEndTime, idCardEndTimeErr := overallhandle.DateToTimeStamp(manCont.IDCardEndTime)
|
|
if idCardEndTimeErr == false {
|
|
idCardEndTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.IDCardEndTime))
|
|
}
|
|
if idCardEndTime != manInfo.Idcardenddate {
|
|
saveData["idcardenddate"] = idCardEndTime
|
|
}
|
|
}
|
|
if manCont.IDCardAddress != "" && manCont.IDCardAddress != manInfo.Idcardaddress {
|
|
saveData["idcardaddress"] = manCont.IDCardAddress
|
|
}
|
|
if manCont.IDCardIsSued != "" && manCont.IDCardIsSued != manInfo.IdcardIssued {
|
|
saveData["idcardIssued"] = manCont.IDCardIsSued
|
|
}
|
|
if manCont.Mobilephone != "" && manCont.Mobilephone != manInfo.Mobilephone {
|
|
saveData["mobilephone"] = manCont.Mobilephone
|
|
}
|
|
if manCont.Email != "" && manCont.Email != manInfo.Email {
|
|
saveData["email"] = manCont.Email
|
|
}
|
|
if manCont.Gender != 0 && manCont.Gender != manInfo.Gender {
|
|
saveData["gender"] = manCont.Gender
|
|
}
|
|
if manCont.Birthday != "" {
|
|
brrthday, brrthdayErr := overallhandle.DateToTimeStamp(manCont.Birthday)
|
|
if brrthdayErr == false {
|
|
brrthday, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.Birthday))
|
|
}
|
|
if brrthday != manInfo.Birthday {
|
|
saveData["birthday"] = brrthday
|
|
}
|
|
}
|
|
if manCont.Nation != "" && manCont.Nation != manInfo.Myfolk {
|
|
saveData["myfolk"] = manCont.Nation
|
|
}
|
|
if manCont.NativePlace != "" && manCont.NativePlace != manInfo.Nativeplace {
|
|
saveData["nativeplace"] = manCont.NativePlace
|
|
}
|
|
if manCont.Health != 0 && manCont.Health != manInfo.Health {
|
|
saveData["health"] = manCont.Health
|
|
}
|
|
if manCont.Maritalstatus != 0 && manCont.Maritalstatus != manInfo.Maritalstatus {
|
|
saveData["maritalstatus"] = manCont.Maritalstatus
|
|
}
|
|
if manCont.CurrentResidence != "" && manCont.CurrentResidence != manInfo.Currentresidence {
|
|
saveData["currentresidence"] = manCont.CurrentResidence
|
|
}
|
|
if manCont.Constellation != 0 && manCont.Constellation != manInfo.Constellation {
|
|
saveData["constellationing"] = manCont.Constellation
|
|
}
|
|
if manCont.Iisdoubleworker != 0 && manCont.Iisdoubleworker != manInfo.Isdoubleworker {
|
|
saveData["isdoubleworker"] = manCont.Iisdoubleworker
|
|
// eidtDoubleWorker(manCont, manCont.Iisdoubleworker)
|
|
eidtDoubleWorkerNew(manKeyNum, manCont, manCont.Iisdoubleworker)
|
|
}
|
|
if manCont.Isveterans != 0 && manCont.Isveterans != manInfo.Isveterans {
|
|
saveData["isveterans"] = manCont.Isveterans
|
|
if manCont.Isveterans == 1 {
|
|
if manCont.Veteransnumber != "" && manCont.Veteransnumber != manInfo.Veteransnumber {
|
|
saveData["veteransnumber"] = manCont.Veteransnumber
|
|
}
|
|
} else {
|
|
saveData["veteransnumber"] = ""
|
|
}
|
|
}
|
|
if manCont.WorkingDate != "" {
|
|
workInData, workInDataErr := overallhandle.DateToTimeStamp(manCont.WorkingDate)
|
|
if workInDataErr == false {
|
|
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.WorkingDate))
|
|
}
|
|
|
|
if workInData != manInfo.Jobstartdate {
|
|
saveData["jobstartdate"] = workInData
|
|
}
|
|
}
|
|
if manCont.EntryDate != "" {
|
|
entryData, entryDataErr := overallhandle.DateToTimeStamp(manCont.EntryDate)
|
|
if entryDataErr == false {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.EntryDate))
|
|
}
|
|
if entryData != manInfo.Entrydate {
|
|
saveData["entrydate"] = entryData
|
|
}
|
|
}
|
|
if manCont.ProbationPeriod != 0 && manCont.ProbationPeriod != manInfo.Probationperiod {
|
|
saveData["probationperiod"] = manCont.ProbationPeriod
|
|
entryData := manInfo.Entrydate
|
|
if manCont.EntryDate != "" {
|
|
entryDataErr := false
|
|
entryData, entryDataErr = overallhandle.DateToTimeStamp(manCont.EntryDate)
|
|
if entryDataErr == false {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.EntryDate))
|
|
}
|
|
}
|
|
planformalData := overallhandle.GetFutureMonthTime(entryData, manCont.ProbationPeriod, 2)
|
|
saveData["planformaldate"] = planformalData
|
|
}
|
|
|
|
if manCont.ConfirmationDate != "" {
|
|
planformalData, planformalDataErr := overallhandle.DateToTimeStamp(manCont.ConfirmationDate)
|
|
if planformalDataErr == false {
|
|
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.ConfirmationDate))
|
|
}
|
|
saveData["planformaldate"] = planformalData
|
|
}
|
|
if manCont.PoliticalOutlook != 0 && manCont.PoliticalOutlook != manInfo.PoliticalOutlook {
|
|
saveData["political_outlook"] = manCont.PoliticalOutlook
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`time`"] = time.Now().Unix()
|
|
manInfo.EiteCont(map[string]interface{}{"`key`": manInfo.Key}, saveData)
|
|
}
|
|
} else {
|
|
manInfo.Key = manKeyNum
|
|
manInfo.Number = manCont.Number
|
|
manInfo.Passportno = manCont.Passportno
|
|
manInfo.Globalroaming = manCont.Globalroaming
|
|
manInfo.Idcardno = manCont.IDCardNo
|
|
idCardStarTime := time.Now().Unix()
|
|
if manCont.IDCardStartTime != "" {
|
|
idCardStarTimeErr := false
|
|
idCardStarTime, idCardStarTimeErr = overallhandle.DateToTimeStamp(manCont.IDCardStartTime)
|
|
if idCardStarTimeErr == false {
|
|
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.IDCardStartTime))
|
|
}
|
|
}
|
|
manInfo.Idcardstartdate = idCardStarTime //身份证有效期开始
|
|
idCardEndTime := time.Now().Unix()
|
|
if manCont.IDCardEndTime != "" {
|
|
idCardEndTimeErr := false
|
|
idCardEndTime, idCardEndTimeErr = overallhandle.DateToTimeStamp(manCont.IDCardEndTime)
|
|
if idCardEndTimeErr == false {
|
|
idCardEndTime, idCardEndTimeErr = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.IDCardEndTime))
|
|
}
|
|
}
|
|
manInfo.Idcardenddate = idCardEndTime //身份证有效期结束
|
|
manInfo.Idcardaddress = manCont.IDCardAddress //身份证地址
|
|
manInfo.IdcardIssued = manCont.IDCardIsSued //身份证签发机关
|
|
manInfo.Mobilephone = manCont.Mobilephone
|
|
manInfo.Email = manCont.Email
|
|
manInfo.Gender = manCont.Gender
|
|
|
|
brrthday, brrthdayErr := overallhandle.DateToTimeStamp(manCont.Birthday)
|
|
if brrthdayErr == false {
|
|
brrthday, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.Birthday))
|
|
}
|
|
manInfo.Birthday = brrthday
|
|
manInfo.Myfolk = manCont.Nation
|
|
manInfo.Nativeplace = manCont.NativePlace
|
|
manInfo.Health = manCont.Health
|
|
manInfo.Maritalstatus = manCont.Maritalstatus
|
|
manInfo.Currentresidence = manCont.CurrentResidence
|
|
manInfo.Time = time.Now().Unix()
|
|
manInfo.Constellation = manCont.Constellation
|
|
manInfo.Isdoubleworker = manCont.Iisdoubleworker
|
|
manInfo.Isveterans = manCont.Isveterans
|
|
manInfo.Veteransnumber = manCont.Veteransnumber
|
|
workInData := time.Now().Unix()
|
|
if manCont.WorkingDate != "" {
|
|
workInDataErr := false
|
|
workInData, workInDataErr = overallhandle.DateToTimeStamp(manCont.WorkingDate)
|
|
if workInDataErr == false {
|
|
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.WorkingDate))
|
|
}
|
|
}
|
|
manInfo.Jobstartdate = workInData
|
|
entryData := time.Now().Unix()
|
|
if manCont.EntryDate != "" {
|
|
entryDataErr := false
|
|
entryData, entryDataErr = overallhandle.DateToTimeStamp(manCont.EntryDate)
|
|
if entryDataErr == false {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.EntryDate))
|
|
}
|
|
}
|
|
manInfo.Entrydate = entryData
|
|
manInfo.Probationperiod = manCont.ProbationPeriod
|
|
planformalData := time.Now().Unix()
|
|
if manCont.ConfirmationDate != "" {
|
|
planformalDataErr := false
|
|
planformalData, planformalDataErr = overallhandle.DateToTimeStamp(manCont.ConfirmationDate)
|
|
if planformalDataErr == false {
|
|
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.ConfirmationDate))
|
|
}
|
|
|
|
} else {
|
|
planformalData = overallhandle.GetFutureMonthTime(entryData, manCont.ProbationPeriod, 2)
|
|
}
|
|
manInfo.Planformaldate = planformalData
|
|
manInfo.PoliticalOutlook = manCont.PoliticalOutlook
|
|
|
|
overall.CONSTANT_DB_HR.Create(&manInfo)
|
|
if manCont.Iisdoubleworker == 1 {
|
|
//编辑双职工
|
|
eidtDoubleWorkerNew(manKeyNum, manCont, 1)
|
|
}
|
|
}
|
|
}
|
|
|
|
//编辑双职工
|
|
func eidtDoubleWorkerNew(manKeyNum int64, manCont addKingdeePersonnel, state int) {
|
|
var doubleWorkCont models.DoubleWorker
|
|
dwErr := doubleWorkCont.GetCont(map[string]interface{}{"`key`": manKeyNum})
|
|
if dwErr == nil {
|
|
saveData := overallhandle.MapOut()
|
|
if manCont.SpouseName != "" && manCont.SpouseName != doubleWorkCont.Name {
|
|
saveData["`name`"] = manCont.SpouseName
|
|
}
|
|
if manCont.SpouseCompany != "" && manCont.SpouseCompany != doubleWorkCont.Company {
|
|
saveData["`company`"] = manCont.SpouseCompany
|
|
}
|
|
if manCont.SpouseDepartment != "" && manCont.SpouseDepartment != doubleWorkCont.Department {
|
|
saveData["`department`"] = manCont.SpouseDepartment
|
|
}
|
|
if manCont.SpousePosition != "" && manCont.SpousePosition != doubleWorkCont.Position {
|
|
saveData["`position`"] = manCont.SpousePosition
|
|
}
|
|
if manCont.SpouseTel != "" && manCont.SpouseTel != doubleWorkCont.Tel {
|
|
saveData["`tel`"] = manCont.SpouseTel
|
|
}
|
|
if state != 0 && state != doubleWorkCont.State {
|
|
saveData["`state`"] = state
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`time`"] = time.Now().Unix()
|
|
doubleWorkCont.EiteCont(map[string]interface{}{"`number`": manCont.Number}, saveData)
|
|
}
|
|
} else {
|
|
saveData := overallhandle.MapOut()
|
|
saveData["state"] = 2
|
|
doubleWorkCont.EiteCont(map[string]interface{}{"`number`": manCont.Number}, saveData)
|
|
doubleWorkCont.Key = manKeyNum
|
|
doubleWorkCont.Number = manCont.Number
|
|
doubleWorkCont.Name = manCont.SpouseName
|
|
doubleWorkCont.Tel = manCont.SpouseTel
|
|
doubleWorkCont.Company = manCont.SpouseCompany
|
|
doubleWorkCont.Department = manCont.SpouseDepartment
|
|
doubleWorkCont.Position = manCont.SpousePosition
|
|
doubleWorkCont.State = state
|
|
overall.CONSTANT_DB_HR.Create(&doubleWorkCont)
|
|
}
|
|
}
|
|
|
|
//编辑紧急联系人信息
|
|
func emergencyContactPersonNew(manKeyNum int64, manCont addKingdeePersonnel) {
|
|
defer synPro.Done()
|
|
var emeContPerAry []emergencyContact
|
|
if manCont.UrgentNameOne != "" || manCont.UrgentRelationshipOne != "" || manCont.UrgentMobilephoneOne != "" {
|
|
var emeContPerOne emergencyContact
|
|
emeContPerOne.Name = manCont.UrgentNameOne //姓名1
|
|
emeContPerOne.Relationship = manCont.UrgentRelationshipOne //与紧急联系人1
|
|
emeContPerOne.Mobilephone = manCont.UrgentMobilephoneOne //联系电话1
|
|
emeContPerAry = append(emeContPerAry, emeContPerOne)
|
|
}
|
|
if manCont.UrgentNameTwo != "" || manCont.UrgentRelationshipTwo != "" || manCont.UrgentMobilephoneTwo != "" {
|
|
var emeContPerTwo emergencyContact
|
|
emeContPerTwo.Name = manCont.UrgentNameTwo //姓名2
|
|
emeContPerTwo.Relationship = manCont.UrgentRelationshipTwo //与紧急联系人2
|
|
emeContPerTwo.Mobilephone = manCont.UrgentMobilephoneTwo //联系电话2
|
|
emeContPerAry = append(emeContPerAry, emeContPerTwo)
|
|
}
|
|
if len(emeContPerAry) > 0 {
|
|
|
|
var oldEmePersList []models.EmergencyContact
|
|
oldEmeErr := overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&oldEmePersList).Error
|
|
if oldEmeErr == nil {
|
|
var writeName []string
|
|
var allId []int64
|
|
var isEite []int64
|
|
for _, ev := range emeContPerAry {
|
|
for _, ov := range oldEmePersList {
|
|
if overallhandle.JudgeInMap(ov.Id, allId) == false {
|
|
allId = append(allId, ov.Id)
|
|
}
|
|
if ev.Name == ov.Name {
|
|
writeName = append(writeName, ev.Name)
|
|
if overallhandle.JudgeInMap(ov.Id, isEite) == false {
|
|
isEite = append(isEite, ov.Id)
|
|
}
|
|
eitdCont := overallhandle.MapOut()
|
|
if ev.Relationship != "" && ev.Relationship != ov.Relationship {
|
|
eitdCont["relationship"] = ev.Relationship
|
|
}
|
|
if ev.Mobilephone != "" && ev.Mobilephone != ov.Tel {
|
|
eitdCont["tel"] = ev.Mobilephone
|
|
}
|
|
if ov.State != 1 {
|
|
eitdCont["state"] = 1
|
|
}
|
|
if len(eitdCont) > 0 {
|
|
eitdCont["time"] = time.Now().Unix()
|
|
var oldEmePersCont models.EmergencyContact
|
|
oldEmePersCont.EiteCont(map[string]interface{}{"`id`": ov.Id}, eitdCont)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//判断两个紧急人员是否都写入
|
|
// if len(writeName) != 2 {
|
|
for _, sv := range emeContPerAry {
|
|
if overallhandle.StringIsInMap(sv.Name, writeName) == false {
|
|
var addEmeCont models.EmergencyContact
|
|
addEmeCont.Key = manKeyNum
|
|
addEmeCont.Number = manCont.Number
|
|
addEmeCont.Name = sv.Name
|
|
addEmeCont.Relationship = sv.Relationship
|
|
addEmeCont.Tel = sv.Mobilephone
|
|
addEmeCont.State = 1
|
|
addEmeCont.Time = time.Now().Unix()
|
|
overall.CONSTANT_DB_HR.Create(&addEmeCont)
|
|
}
|
|
}
|
|
// }
|
|
} else {
|
|
for _, insetv := range emeContPerAry {
|
|
var addEmeCont models.EmergencyContact
|
|
addEmeCont.Key = manKeyNum
|
|
addEmeCont.Number = manCont.Number
|
|
addEmeCont.Name = insetv.Name
|
|
addEmeCont.Relationship = insetv.Relationship
|
|
addEmeCont.Tel = insetv.Mobilephone
|
|
addEmeCont.State = 1
|
|
addEmeCont.Time = time.Now().Unix()
|
|
overall.CONSTANT_DB_HR.Create(&addEmeCont)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
//编辑员工家属
|
|
func eidtFamilyMembersNew(manKeyNum int64, num string, family []memberOfFamily) {
|
|
defer synPro.Done()
|
|
if len(family) > 0 && manKeyNum != 0 {
|
|
var familyAry []models.FamilyMembers
|
|
famErr := overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&familyAry).Error
|
|
if famErr == nil {
|
|
var writeName []string
|
|
var allId []int64
|
|
var isEite []int64
|
|
for _, fv := range family {
|
|
for _, fav := range familyAry {
|
|
if overallhandle.JudgeInMap(fav.Id, allId) == false {
|
|
allId = append(allId, fav.Id)
|
|
}
|
|
if fv.Name == fav.Name {
|
|
writeName = append(writeName, fv.Name)
|
|
if overallhandle.JudgeInMap(fav.Id, isEite) == false {
|
|
isEite = append(isEite, fav.Id)
|
|
}
|
|
eitdCont := overallhandle.MapOut()
|
|
if fv.Relationship != "" && fv.Relationship != fav.Relationship {
|
|
eitdCont["relation"] = fv.Relationship
|
|
}
|
|
if fv.Mobilephone != "" && fv.Mobilephone != fav.Tel {
|
|
eitdCont["tel"] = fv.Mobilephone
|
|
}
|
|
if fv.Company != "" && fv.Company != fav.Company {
|
|
eitdCont["company"] = fv.Company
|
|
}
|
|
if fv.Department != "" && fv.Department != fav.Deparment {
|
|
eitdCont["deparment"] = fv.Department
|
|
}
|
|
if fv.Position != "" && fv.Position != fav.Postnme {
|
|
eitdCont["postnme"] = fv.Position
|
|
}
|
|
if fv.PoliticalOutlook != 0 && fv.PoliticalOutlook != fav.PoliticalOutlook {
|
|
eitdCont["political_outlook"] = fv.PoliticalOutlook
|
|
}
|
|
if len(eitdCont) > 0 {
|
|
eitdCont["time"] = time.Now().Unix()
|
|
var oldFamilyCont models.FamilyMembers
|
|
oldFamilyCont.EiteCont(map[string]interface{}{"`id`": fav.Id}, eitdCont)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//新增不存在得家庭成员
|
|
for _, afv := range family {
|
|
if overallhandle.StringIsInMap(afv.Name, writeName) == false {
|
|
var addFamliyCont models.FamilyMembers
|
|
addFamliyCont.Key = manKeyNum
|
|
addFamliyCont.Number = num
|
|
addFamliyCont.Relationship = afv.Relationship //亲属关系"`
|
|
addFamliyCont.Name = afv.Name //姓名"`
|
|
addFamliyCont.Company = afv.Company //所在公司"`
|
|
addFamliyCont.Deparment = afv.Department //所在部门"`
|
|
addFamliyCont.Postnme = afv.Position //所在岗位"`
|
|
addFamliyCont.Tel = afv.Mobilephone //紧急联系人电话"`
|
|
addFamliyCont.PoliticalOutlook = afv.PoliticalOutlook //政治面貌
|
|
addFamliyCont.Time = time.Now().Unix() // 创建时间"`
|
|
overall.CONSTANT_DB_HR.Create(&addFamliyCont)
|
|
}
|
|
}
|
|
} else {
|
|
//新增家庭成员
|
|
for _, v := range family {
|
|
var addFamliyCont models.FamilyMembers
|
|
addFamliyCont.Key = manKeyNum
|
|
addFamliyCont.Number = num
|
|
addFamliyCont.Relationship = v.Relationship //亲属关系"`
|
|
addFamliyCont.Name = v.Name //姓名"`
|
|
addFamliyCont.Company = v.Company //所在公司"`
|
|
addFamliyCont.Deparment = v.Department //所在部门"`
|
|
addFamliyCont.Postnme = v.Position //所在岗位"`
|
|
addFamliyCont.Tel = v.Mobilephone //紧急联系人电话"`
|
|
addFamliyCont.PoliticalOutlook = v.PoliticalOutlook //政治面貌
|
|
addFamliyCont.Time = time.Now().Unix() // 创建时间"`
|
|
overall.CONSTANT_DB_HR.Create(&addFamliyCont)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//教育经历
|
|
func educatExperKingdeeNew(manKeyNum int64, manCont addKingdeePersonnel) {
|
|
defer synPro.Done()
|
|
if manCont.HighestGraduationSchool != "" {
|
|
//最高学历
|
|
var perEduContHig models.PersonnelEducation
|
|
highestGormDb := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Where("`key` = ? AND `graduation_school` = ? AND `subject` = ?", manKeyNum, manCont.HighestGraduationSchool, manCont.HighestSubject)
|
|
higErr := highestGormDb.First(&perEduContHig).Error
|
|
|
|
if higErr == nil {
|
|
eitdCont := overallhandle.MapOut()
|
|
if manCont.HighestEducation != 0 && manCont.HighestEducation != perEduContHig.Education {
|
|
eitdCont["education"] = manCont.HighestEducation
|
|
}
|
|
if manCont.HighestAcademicDegree != 0 && manCont.HighestAcademicDegree != perEduContHig.AcademicDegree {
|
|
eitdCont["academic_degree"] = manCont.HighestAcademicDegree
|
|
}
|
|
if manCont.HighestAdmissionTime != "" {
|
|
entranceTime, entranceTimeErr := overallhandle.DateToTimeStamp(manCont.HighestAdmissionTime)
|
|
if entranceTimeErr == false {
|
|
entranceTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestAdmissionTime))
|
|
}
|
|
if entranceTime != perEduContHig.AdmissionTime {
|
|
eitdCont["admission_time"] = entranceTime
|
|
}
|
|
}
|
|
if manCont.HighestGraduationTime != "" {
|
|
graduationTime, graduationTimeErr := overallhandle.DateToTimeStamp(manCont.HighestGraduationTime)
|
|
if graduationTimeErr == false {
|
|
graduationTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestGraduationTime))
|
|
}
|
|
if graduationTime != perEduContHig.GraduationTime {
|
|
eitdCont["graduation_time"] = graduationTime
|
|
}
|
|
}
|
|
if len(eitdCont) > 0 {
|
|
eitdCont["Time"] = time.Now().Unix()
|
|
eitdCont["level"] = 3
|
|
var oldFamilyCont models.PersonnelEducation
|
|
oldFamilyCont.EiteCont(map[string]interface{}{"`id`": perEduContHig.Id}, eitdCont)
|
|
}
|
|
} else {
|
|
var perEduContFirstIsTrue models.PersonnelEducation
|
|
highestGormDbIsTrue := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Where("`level` = 3 AND `key` = ?", manKeyNum).First(&perEduContFirstIsTrue).Error
|
|
if highestGormDbIsTrue == nil {
|
|
eitdCont := overallhandle.MapOut()
|
|
eitdCont["Time"] = time.Now().Unix()
|
|
eitdCont["level"] = 1
|
|
var oldFamilyCont models.PersonnelEducation
|
|
oldFamilyCont.EiteCont(map[string]interface{}{"`key`": manKeyNum, "level": 3}, eitdCont)
|
|
}
|
|
perEduContHig.Key = manKeyNum
|
|
perEduContHig.Number = manCont.Number // 员工工号
|
|
perEduContHig.Education = manCont.HighestEducation // 学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"`
|
|
perEduContHig.GraduationSchool = manCont.HighestGraduationSchool // 毕业学校"`
|
|
perEduContHig.Subject = manCont.HighestSubject // 专业"`
|
|
entranceTime := time.Now().Unix()
|
|
if manCont.HighestAdmissionTime != "" {
|
|
entranceTimeErr := false
|
|
entranceTime, entranceTimeErr = overallhandle.DateToTimeStamp(manCont.HighestAdmissionTime)
|
|
if entranceTimeErr == false {
|
|
entranceTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestAdmissionTime))
|
|
}
|
|
}
|
|
perEduContHig.AdmissionTime = entranceTime // 入学时间"`
|
|
graduationTime := time.Now().Unix()
|
|
if manCont.HighestGraduationTime != "" {
|
|
graduationTimeErr := false
|
|
graduationTime, graduationTimeErr = overallhandle.DateToTimeStamp(manCont.HighestGraduationTime)
|
|
if graduationTimeErr == false {
|
|
graduationTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestGraduationTime))
|
|
}
|
|
}
|
|
perEduContHig.GraduationTime = graduationTime // 毕业时间"`
|
|
perEduContHig.Time = time.Now().Unix() // 写入时间"`
|
|
perEduContHig.AcademicDegree = manCont.HighestAcademicDegree
|
|
perEduContHig.Level = 3 // 学历类型(1:普通;2:第一学历;3:最高学历)"`
|
|
overall.CONSTANT_DB_HR.Create(&perEduContHig)
|
|
}
|
|
}
|
|
//第一学历
|
|
if manCont.FirstGraduationSchool != "" {
|
|
//第一学历
|
|
var perEduContFirst models.PersonnelEducation
|
|
firsthestGormDb := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Where("`key` = ? AND graduation_school = ? AND subject = ?", manKeyNum, manCont.FirstGraduationSchool, manCont.FirstSubject)
|
|
higErr := firsthestGormDb.First(&perEduContFirst).Error
|
|
|
|
if higErr == nil {
|
|
eitdContFirst := overallhandle.MapOut()
|
|
if manCont.FirstEducation != 0 && manCont.FirstEducation != perEduContFirst.Education {
|
|
eitdContFirst["education"] = manCont.FirstEducation
|
|
}
|
|
if manCont.FirstAcademicDegree != 0 && manCont.FirstAcademicDegree != perEduContFirst.AcademicDegree {
|
|
eitdContFirst["academic_degree"] = manCont.FirstAcademicDegree
|
|
}
|
|
if manCont.FirstAdmissionTime != "" {
|
|
entranceTimeFirst, entranceTimeFirstErr := overallhandle.DateToTimeStamp(manCont.FirstAdmissionTime)
|
|
if entranceTimeFirstErr == false {
|
|
entranceTimeFirst, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.FirstAdmissionTime))
|
|
}
|
|
if entranceTimeFirst != perEduContFirst.AdmissionTime {
|
|
eitdContFirst["admission_time"] = entranceTimeFirst
|
|
}
|
|
}
|
|
if manCont.FirstGraduationTime != "" {
|
|
graduationTimeFirst, graduationTimeFirstErr := overallhandle.DateToTimeStamp(manCont.FirstGraduationTime)
|
|
if graduationTimeFirstErr == false {
|
|
graduationTimeFirst, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.FirstGraduationTime))
|
|
}
|
|
if graduationTimeFirst != perEduContFirst.GraduationTime {
|
|
eitdContFirst["graduation_time"] = graduationTimeFirst
|
|
}
|
|
}
|
|
if len(eitdContFirst) > 0 {
|
|
eitdContFirst["Time"] = time.Now().Unix()
|
|
eitdContFirst["level"] = 2
|
|
var oldFamilyContFirst models.PersonnelEducation
|
|
oldFamilyContFirst.EiteCont(map[string]interface{}{"`id`": perEduContFirst.Id}, eitdContFirst)
|
|
}
|
|
} else {
|
|
var perEduContFirstIsTrue models.PersonnelEducation
|
|
highestGormDbIsTrue := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Where("`level` = 1 AND `key` = ?", manKeyNum).First(&perEduContFirstIsTrue).Error
|
|
if highestGormDbIsTrue == nil {
|
|
eitdContFirst := overallhandle.MapOut()
|
|
eitdContFirst["Time"] = time.Now().Unix()
|
|
eitdContFirst["level"] = 1
|
|
var oldFamilyContFirst models.PersonnelEducation
|
|
oldFamilyContFirst.EiteCont(map[string]interface{}{"`key`": manKeyNum, "level": 2}, eitdContFirst)
|
|
}
|
|
perEduContFirst.Key = manKeyNum
|
|
perEduContFirst.Number = manCont.Number // 员工工号
|
|
perEduContFirst.Education = manCont.FirstEducation // 学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"`
|
|
perEduContFirst.GraduationSchool = manCont.FirstGraduationSchool // 毕业学校"`
|
|
perEduContFirst.Subject = manCont.FirstSubject // 专业"`
|
|
entranceTimeFirst := time.Now().Unix()
|
|
if manCont.HighestAdmissionTime != "" {
|
|
entranceTimeFirstErr := false
|
|
entranceTimeFirst, entranceTimeFirstErr = overallhandle.DateToTimeStamp(manCont.HighestAdmissionTime)
|
|
if entranceTimeFirstErr == false {
|
|
entranceTimeFirst, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestAdmissionTime))
|
|
}
|
|
}
|
|
perEduContFirst.AdmissionTime = entranceTimeFirst // 入学时间"`
|
|
graduationTimef := time.Now().Unix()
|
|
if manCont.HighestGraduationTime != "" {
|
|
graduationTimefErr := false
|
|
graduationTimef, _ = overallhandle.DateToTimeStamp(manCont.HighestGraduationTime)
|
|
if graduationTimefErr == false {
|
|
graduationTimef, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestGraduationTime))
|
|
}
|
|
}
|
|
perEduContFirst.GraduationTime = graduationTimef // 毕业时间"`
|
|
perEduContFirst.Time = time.Now().Unix() // 写入时间"`
|
|
perEduContFirst.AcademicDegree = manCont.FirstAcademicDegree
|
|
perEduContFirst.Level = 2 // 学历类型(1:普通;2:第一学历;3:最高学历)"`
|
|
overall.CONSTANT_DB_HR.Create(&perEduContFirst)
|
|
}
|
|
}
|
|
}
|
|
|
|
//编辑工作履历
|
|
func editWorkHistoryMan(manKeyNum int64, num string, workHistoryList []workHistoryAry) {
|
|
defer synPro.Done()
|
|
if len(workHistoryList) > 0 && manKeyNum != 0 {
|
|
var oldWork []models.WorkHistory
|
|
oldWorkErr := overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&oldWork).Error
|
|
if oldWorkErr == nil {
|
|
for _, wvs := range workHistoryList {
|
|
var whCont models.WorkHistory
|
|
isEidtErr := whCont.GetCont(map[string]interface{}{"`key`": manKeyNum, "`company`": wvs.Company, "`deparment`": wvs.Department, "`job`": wvs.Position}, "id", "entry_time", "leavedate", "witness", "witness_tel", "remarks")
|
|
if isEidtErr == nil {
|
|
saveDate := overallhandle.MapOut()
|
|
if wvs.EntryTime != "" { //入职时间"`
|
|
|
|
entryData, entryDataErr := overallhandle.DateToTimeStamp(wvs.EntryTime)
|
|
if entryDataErr == false {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", wvs.EntryTime))
|
|
}
|
|
if entryData != whCont.EntryTime {
|
|
saveDate["entry_time"] = entryData
|
|
}
|
|
}
|
|
if wvs.LeaveDate != "" { //离职日期"`
|
|
leaveTime, leaveTimeErr := overallhandle.DateToTimeStamp(wvs.LeaveDate)
|
|
if leaveTimeErr == false {
|
|
leaveTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", wvs.LeaveDate))
|
|
}
|
|
if leaveTime != whCont.Leavedate {
|
|
saveDate["leavedate"] = leaveTime
|
|
}
|
|
}
|
|
if wvs.Witness != "" && wvs.Witness != whCont.Witness {
|
|
saveDate["witness"] = wvs.Witness
|
|
}
|
|
if wvs.WitnessTel != "" && wvs.WitnessTel != whCont.WitnessTel {
|
|
saveDate["witness_tel"] = wvs.WitnessTel
|
|
}
|
|
if wvs.Remarks != "" && wvs.Remarks != whCont.Remarks {
|
|
saveDate["remarks"] = wvs.Remarks
|
|
}
|
|
if len(saveDate) > 0 {
|
|
saveDate["time"] = time.Now().Unix()
|
|
saveDate["state"] = 1
|
|
var eidtWorkHisCont models.WorkHistory
|
|
eidtWorkHisCont.EiteCont(map[string]interface{}{"`id`": whCont.Id}, saveDate)
|
|
}
|
|
} else {
|
|
var addWorkCont models.WorkHistory
|
|
addWorkCont.Number = num //工号"`
|
|
addWorkCont.Key = manKeyNum //身份识别"`
|
|
addWorkCont.Company = wvs.Company //公司"`
|
|
addWorkCont.Deparment = wvs.Department //部门"`
|
|
addWorkCont.Job = wvs.Position //职务"`
|
|
entryData := time.Now().Unix()
|
|
if wvs.EntryTime != "" {
|
|
entryDataErr := false
|
|
entryData, entryDataErr = overallhandle.DateToTimeStamp(wvs.EntryTime)
|
|
if entryDataErr == false {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", wvs.EntryTime))
|
|
}
|
|
}
|
|
addWorkCont.EntryTime = entryData //入职时间"`
|
|
leaveTime := time.Now().Unix()
|
|
if wvs.LeaveDate != "" {
|
|
leaveTimeErr := false
|
|
leaveTime, leaveTimeErr = overallhandle.DateToTimeStamp(wvs.LeaveDate)
|
|
if leaveTimeErr == false {
|
|
leaveTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", wvs.LeaveDate))
|
|
}
|
|
}
|
|
addWorkCont.Leavedate = leaveTime //离职日期"`
|
|
addWorkCont.Witness = wvs.Witness //证明人"`
|
|
addWorkCont.WitnessTel = wvs.WitnessTel //证明人电话"`
|
|
addWorkCont.Remarks = wvs.Remarks //备注"`
|
|
addWorkCont.Time = time.Now().Unix() //创建时间"`
|
|
addWorkCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
overall.CONSTANT_DB_HR.Create(&addWorkCont)
|
|
}
|
|
}
|
|
} else {
|
|
var addAllWork []models.WorkHistory
|
|
for _, v := range workHistoryList {
|
|
var addWorkCont models.WorkHistory
|
|
addWorkCont.Number = num //工号"`
|
|
addWorkCont.Key = manKeyNum //身份识别"`
|
|
addWorkCont.Company = v.Company //公司"`
|
|
addWorkCont.Deparment = v.Department //部门"`
|
|
addWorkCont.Job = v.Position //职务"`
|
|
entryData := time.Now().Unix()
|
|
if v.EntryTime != "" {
|
|
entryDataErr := false
|
|
entryData, entryDataErr = overallhandle.DateToTimeStamp(v.EntryTime)
|
|
if entryDataErr == false {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", v.EntryTime))
|
|
}
|
|
}
|
|
addWorkCont.EntryTime = entryData //入职时间"`
|
|
leaveTime := time.Now().Unix()
|
|
if v.LeaveDate != "" {
|
|
leaveTimeErr := false
|
|
leaveTime, leaveTimeErr = overallhandle.DateToTimeStamp(v.LeaveDate)
|
|
if leaveTimeErr == false {
|
|
leaveTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", v.LeaveDate))
|
|
}
|
|
}
|
|
addWorkCont.Leavedate = leaveTime //离职日期"`
|
|
addWorkCont.Witness = v.Witness //证明人"`
|
|
addWorkCont.WitnessTel = v.WitnessTel //证明人电话"`
|
|
addWorkCont.Remarks = v.Remarks //备注"`
|
|
addWorkCont.Time = time.Now().Unix() //创建时间"`
|
|
addWorkCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
addAllWork = append(addAllWork, addWorkCont)
|
|
}
|
|
if len(addAllWork) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&addAllWork)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//编辑集团内工作经历
|
|
func editInsideWorkHistoryMan(manKeyNum int64, contList []insideHistory) {
|
|
defer synPro.Done()
|
|
if len(contList) > 0 && manKeyNum > 0 {
|
|
//判断是否已经存在集团内工作履历
|
|
var insideWork []models.InsideWorkHistory
|
|
err := overall.CONSTANT_DB_HR.Model(&models.InsideWorkHistory{}).Select("`id`").Where("`key` = ?", manKeyNum).Find(&insideWork).Error
|
|
fmt.Printf("isErr---err---->%v\n", err)
|
|
var topGroup int64 = 0
|
|
var groupTopCont models.AdministrativeOrganization
|
|
groupTopCont.GetCont(map[string]interface{}{"superior": 0}, "id")
|
|
topGroup = groupTopCont.Id
|
|
|
|
if err == nil {
|
|
var iInt []int
|
|
for i, v := range contList {
|
|
var wssCont models.AdministrativeOrganization
|
|
wssCont.GetCont(map[string]interface{}{"kingdeeid": v.WorkshopSection}, "id")
|
|
var insiCont models.InsideWorkHistory
|
|
isErr := insiCont.GetCont(map[string]interface{}{"`key`": manKeyNum, "workshop_section": wssCont.Id})
|
|
fmt.Printf("isErr--1----->%v\n", isErr)
|
|
if isErr == nil {
|
|
iInt = append(iInt, i)
|
|
saveData := overallhandle.MapOut()
|
|
if v.Group != "" {
|
|
var groupCont models.AdministrativeOrganization
|
|
groupCont.GetCont(map[string]interface{}{"kingdeeid": v.Group}, "id")
|
|
if groupCont.Id != insiCont.Group {
|
|
saveData["group"] = groupCont.Id
|
|
}
|
|
}
|
|
if v.Company != "" {
|
|
var companyCont models.AdministrativeOrganization
|
|
companyCont.GetCont(map[string]interface{}{"kingdeeid": v.Company}, "id")
|
|
if companyCont.Id != insiCont.Company {
|
|
saveData["company"] = companyCont.Id
|
|
}
|
|
}
|
|
if v.Department != "" {
|
|
var departmentCont models.AdministrativeOrganization
|
|
departmentCont.GetCont(map[string]interface{}{"kingdeeid": v.Department}, "id")
|
|
if departmentCont.Id != insiCont.Department {
|
|
saveData["department"] = departmentCont.Id
|
|
}
|
|
}
|
|
if v.Workshop != "" {
|
|
var workshopCont models.AdministrativeOrganization
|
|
workshopCont.GetCont(map[string]interface{}{"kingdeeid": v.Workshop}, "id")
|
|
if workshopCont.Id != insiCont.WorkShop {
|
|
saveData["workshop"] = workshopCont.Id
|
|
}
|
|
}
|
|
if v.WorkshopSection != "" && wssCont.Id != insiCont.WorkshopSection {
|
|
saveData["workshop_section"] = wssCont.Id
|
|
}
|
|
if v.Position != "" {
|
|
var positionCont models.Position
|
|
positionCont.GetCont(map[string]interface{}{"kingdeeid": v.Position}, "id")
|
|
if positionCont.Id != insiCont.Position {
|
|
saveData["position"] = positionCont.Id
|
|
}
|
|
}
|
|
if v.GradePositions != 0 && insiCont.GradePositions != insiCont.GradePositions {
|
|
saveData["grade_positions"] = v.GradePositions
|
|
}
|
|
if v.StartTime != "" {
|
|
startTime, startTimeErr := overallhandle.DateToTimeStamp(v.StartTime)
|
|
if startTimeErr == false {
|
|
startTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.StartTime))
|
|
}
|
|
if startTime != insiCont.StartTime {
|
|
saveData["start_time"] = startTime
|
|
}
|
|
}
|
|
|
|
if v.StartTime != "" {
|
|
if v.EndTime != "至今" && v.EndTime != "2199-12-31 00:00:00" && v.EndTime != "2199-12-31" && v.EndTime != "7258003200" {
|
|
|
|
endTime, endTimeErr := overallhandle.DateToTimeStamp(v.EndTime)
|
|
if endTimeErr == false {
|
|
endTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EndTime))
|
|
}
|
|
if endTime != insiCont.EndTime {
|
|
saveData["end_time"] = endTime
|
|
saveData["state"] = 2
|
|
}
|
|
} else {
|
|
saveData["end_time"] = 0
|
|
saveData["state"] = 1
|
|
}
|
|
}
|
|
if v.ChangeType != 0 && v.ChangeType != insiCont.ChangeType {
|
|
saveData["end_time"] = v.ChangeType
|
|
}
|
|
if len(saveData) > 0 {
|
|
insiCont.EditCont(map[string]interface{}{"`id`": insiCont.Id}, saveData)
|
|
}
|
|
}
|
|
}
|
|
if len(iInt) < len(contList) {
|
|
var addData []models.InsideWorkHistory
|
|
for ii, vv := range contList {
|
|
if overallhandle.IsInTrue[int](ii, iInt) == false {
|
|
var cont models.InsideWorkHistory
|
|
cont.Key = manKeyNum //员工识别符"`
|
|
if vv.Group != "" {
|
|
var groupCont models.AdministrativeOrganization
|
|
groupErr := groupCont.GetCont(map[string]interface{}{"kingdeeid": vv.Group}, "id")
|
|
if groupErr == nil {
|
|
cont.Group = groupCont.Id //集团"`
|
|
} else {
|
|
cont.Group = topGroup //集团"`
|
|
}
|
|
} else {
|
|
cont.Group = topGroup //集团"`
|
|
}
|
|
if vv.Company != "" {
|
|
var companyCont models.AdministrativeOrganization
|
|
companyErr := companyCont.GetCont(map[string]interface{}{"kingdeeid": vv.Company}, "id")
|
|
if companyErr == nil {
|
|
cont.Company = companyCont.Id //部室"`
|
|
} else {
|
|
cont.Company = topGroup //部室"`
|
|
}
|
|
} else {
|
|
cont.Company = topGroup //部室"`
|
|
}
|
|
if vv.Department != "" {
|
|
var departCont models.AdministrativeOrganization
|
|
departErr := departCont.GetCont(map[string]interface{}{"kingdeeid": vv.Department}, "id")
|
|
if departErr == nil {
|
|
cont.Department = departCont.Id //部室"`
|
|
} else {
|
|
cont.Department = topGroup //部室"`
|
|
}
|
|
} else {
|
|
cont.Department = topGroup //部室"`
|
|
}
|
|
|
|
if vv.Workshop != "" {
|
|
var workShopCont models.AdministrativeOrganization
|
|
workShopErr := workShopCont.GetCont(map[string]interface{}{"kingdeeid": vv.Workshop}, "id")
|
|
if workShopErr == nil {
|
|
cont.WorkShop = workShopCont.Id //部室"`
|
|
} else {
|
|
cont.WorkShop = 0 //二级部门或车间"`
|
|
}
|
|
} else {
|
|
cont.WorkShop = 0 //二级部门或车间"`
|
|
}
|
|
|
|
if vv.WorkshopSection != "" {
|
|
var workShopSecCont models.AdministrativeOrganization
|
|
workShopSecErr := workShopSecCont.GetCont(map[string]interface{}{"kingdeeid": vv.WorkshopSection}, "id")
|
|
if workShopSecErr == nil {
|
|
cont.WorkshopSection = workShopSecCont.Id //工段"`
|
|
} else {
|
|
cont.WorkshopSection = 0 //工段"`
|
|
}
|
|
} else {
|
|
cont.WorkshopSection = 0 //工段"`
|
|
}
|
|
|
|
if vv.Position != "" {
|
|
var positionCont models.Position
|
|
positionErr := positionCont.GetCont(map[string]interface{}{"kingdeeid": vv.Position}, "id")
|
|
if positionErr == nil {
|
|
cont.Position = positionCont.Id //职位"`
|
|
} else {
|
|
cont.Position = 1 //职位"`
|
|
}
|
|
} else {
|
|
cont.Position = 1 //职位"`
|
|
}
|
|
|
|
cont.GradePositions = vv.GradePositions //职等"`
|
|
|
|
startTime := time.Now().Unix()
|
|
if vv.StartTime != "" {
|
|
startTimeErr := false
|
|
startTime, startTimeErr = overallhandle.DateToTimeStamp(vv.StartTime)
|
|
if startTimeErr == false {
|
|
startTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", vv.StartTime))
|
|
}
|
|
}
|
|
cont.StartTime = startTime //开始日期"`
|
|
cont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
if vv.EndTime != "" {
|
|
if vv.EndTime != "至今" && vv.EndTime != "2199-12-31 00:00:00" && vv.EndTime != "2199-12-31" && vv.EndTime != "7258003200" {
|
|
endTime, endTimeErr := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", vv.EndTime))
|
|
if endTimeErr == false {
|
|
endTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", vv.EndTime))
|
|
}
|
|
cont.EndTime = endTime
|
|
cont.State = 2
|
|
}
|
|
}
|
|
cont.Team = 1 //班组(1:长白;2:甲;3:乙;4:丙;5:丁)"`
|
|
changeTypes := vv.ChangeType
|
|
if changeTypes == 0 {
|
|
changeTypes = 1
|
|
}
|
|
cont.ChangeType = changeTypes //变动类型(1:预入职;2:雇佣入职;3:转正;4:职等调整;5:调动调入;6:借调;7:兼职;8:预离职;9:离职;10:退休;11:返聘;12:员工初始化;)"`
|
|
cont.Time = time.Now().Unix() //:创建时间"`
|
|
|
|
addData = append(addData, cont)
|
|
}
|
|
}
|
|
if len(addData) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&addData)
|
|
}
|
|
}
|
|
} else {
|
|
//不存在集团内部工作经历,进行新政
|
|
var addData []models.InsideWorkHistory
|
|
for _, v := range contList {
|
|
var cont models.InsideWorkHistory
|
|
cont.Key = manKeyNum //员工识别符"`
|
|
if v.Group != "" {
|
|
var groupCont models.AdministrativeOrganization
|
|
groupErr := groupCont.GetCont(map[string]interface{}{"kingdeeid": v.Group}, "id")
|
|
if groupErr == nil {
|
|
cont.Group = groupCont.Id //集团"`
|
|
} else {
|
|
cont.Group = topGroup //集团"`
|
|
}
|
|
} else {
|
|
cont.Group = topGroup //集团"`
|
|
}
|
|
if v.Company != "" {
|
|
var companyCont models.AdministrativeOrganization
|
|
companyErr := companyCont.GetCont(map[string]interface{}{"kingdeeid": v.Company}, "id")
|
|
if companyErr == nil {
|
|
cont.Company = companyCont.Id //部室"`
|
|
} else {
|
|
cont.Company = topGroup //部室"`
|
|
}
|
|
} else {
|
|
cont.Company = topGroup //部室"`
|
|
}
|
|
if v.Department != "" {
|
|
var departCont models.AdministrativeOrganization
|
|
departErr := departCont.GetCont(map[string]interface{}{"kingdeeid": v.Department}, "id")
|
|
if departErr == nil {
|
|
cont.Department = departCont.Id //部室"`
|
|
} else {
|
|
cont.Department = topGroup //部室"`
|
|
}
|
|
} else {
|
|
cont.Department = topGroup //部室"`
|
|
}
|
|
|
|
if v.Workshop != "" {
|
|
var workShopCont models.AdministrativeOrganization
|
|
workShopErr := workShopCont.GetCont(map[string]interface{}{"kingdeeid": v.Workshop}, "id")
|
|
if workShopErr == nil {
|
|
cont.WorkShop = workShopCont.Id //部室"`
|
|
} else {
|
|
cont.WorkShop = 0 //二级部门或车间"`
|
|
}
|
|
} else {
|
|
cont.WorkShop = 0 //二级部门或车间"`
|
|
}
|
|
|
|
if v.WorkshopSection != "" {
|
|
var workShopSecCont models.AdministrativeOrganization
|
|
workShopSecErr := workShopSecCont.GetCont(map[string]interface{}{"kingdeeid": v.WorkshopSection}, "id")
|
|
if workShopSecErr == nil {
|
|
cont.WorkshopSection = workShopSecCont.Id //工段"`
|
|
} else {
|
|
cont.WorkshopSection = 0 //工段"`
|
|
}
|
|
} else {
|
|
cont.WorkshopSection = 0 //工段"`
|
|
}
|
|
|
|
if v.Position != "" {
|
|
var positionCont models.Position
|
|
positionErr := positionCont.GetCont(map[string]interface{}{"kingdeeid": v.Position}, "id")
|
|
if positionErr == nil {
|
|
cont.Position = positionCont.Id //职位"`
|
|
} else {
|
|
cont.Position = 1 //职位"`
|
|
}
|
|
} else {
|
|
cont.Position = 1 //职位"`
|
|
}
|
|
|
|
cont.GradePositions = v.GradePositions //职等"`
|
|
|
|
startTime := time.Now().Unix()
|
|
if v.StartTime != "" {
|
|
startTimeErr := false
|
|
startTime, startTimeErr = overallhandle.DateToTimeStamp(v.StartTime)
|
|
if startTimeErr == false {
|
|
startTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.StartTime))
|
|
}
|
|
}
|
|
cont.StartTime = startTime //开始日期"`
|
|
|
|
cont.State = 1 //状态(1:启用;2:休眠;3:删除)"`
|
|
if v.EndTime != "" {
|
|
if v.EndTime != "至今" && v.EndTime != "2199-12-31 00:00:00" && v.EndTime != "2199-12-31" && v.EndTime != "7258003200" {
|
|
endTime, endTimeErr := overallhandle.DateToTimeStamp(v.EndTime)
|
|
if endTimeErr == false {
|
|
endTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EndTime))
|
|
}
|
|
cont.EndTime = endTime
|
|
cont.State = 2 //状态(1:启用;2:休眠;3:删除)"`
|
|
}
|
|
}
|
|
cont.Team = 1 //班组(1:长白;2:甲;3:乙;4:丙;5:丁)"`
|
|
changeTypes := v.ChangeType
|
|
if changeTypes == 0 {
|
|
changeTypes = 1
|
|
}
|
|
cont.ChangeType = changeTypes //变动类型(1:预入职;2:雇佣入职;3:转正;4:职等调整;5:调动调入;6:借调;7:兼职;8:预离职;9:离职;10:退休;11:返聘;12:员工初始化;)"`
|
|
cont.Time = time.Now().Unix() //:创建时间"`
|
|
|
|
addData = append(addData, cont)
|
|
}
|
|
if len(addData) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&addData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|