22 changed files with 1300 additions and 27 deletions
@ -0,0 +1,824 @@ |
|||||
|
package personnelapi |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"hr_server/models" |
||||
|
"hr_server/overall" |
||||
|
"hr_server/overall/overallhandle" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//金蝶人员信息对接
|
||||
|
func (s *StaffApi) Kingdee(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 = eidtAddManCont(manContent, requestData) |
||||
|
} else { |
||||
|
//不存在!进行新增操作
|
||||
|
manErr = newAddManCont(requestData) |
||||
|
} |
||||
|
if manErr != nil { |
||||
|
overallhandle.Result(104, manErr, c) |
||||
|
return |
||||
|
} |
||||
|
overallhandle.Result(0, manErr, c) |
||||
|
} |
||||
|
|
||||
|
//编辑员工
|
||||
|
func eidtAddManCont(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 |
||||
|
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() |
||||
|
|
||||
|
// rybdErr := overall.CONSTANT_DB_HR.Create(&manChangeRecord).Error
|
||||
|
// jsonCont, _ := json.Marshal(manChangeRecord)
|
||||
|
// fmt.Printf("第二学历--->%v--->%v\n", rybdErr, string(jsonCont))
|
||||
|
} |
||||
|
//编辑人员附属信息
|
||||
|
synPro.Add(1) |
||||
|
go editManAuxiliaryData(manCont) |
||||
|
//编辑紧急联系人信息
|
||||
|
synPro.Add(1) |
||||
|
go emergencyContactPerson(manCont) |
||||
|
//编辑员工家属信息
|
||||
|
synPro.Add(1) |
||||
|
go eidtFamilyMembers(manCont.Number, manCont.MemberOfFamily) |
||||
|
//编辑员工教育经历
|
||||
|
synPro.Add(1) |
||||
|
go educatExperKingdee(manCont) |
||||
|
synPro.Wait() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
//新增员工
|
||||
|
func newAddManCont(manCont addKingdeePersonnel) error { |
||||
|
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 |
||||
|
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") |
||||
|
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 = overallhandle.TableNumber() |
||||
|
} |
||||
|
|
||||
|
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 = overallhandle.TableNumber() |
||||
|
//密码加密
|
||||
|
var passwordMd5 overallhandle.Md5Encryption |
||||
|
passwordMd5.Md5EncryptionInit(overall.CONSTANT_CONFIG.Appsetup.DefaultPassword) |
||||
|
manMainCont.Password = passwordMd5.Md5EncryptionAlgorithm() |
||||
|
} |
||||
|
addManContErr := overall.CONSTANT_DB_HR.Create(&manMainCont).Error |
||||
|
if addManContErr != nil { |
||||
|
return addManContErr |
||||
|
} else { |
||||
|
//编辑人员附属信息
|
||||
|
synPro.Add(1) |
||||
|
go editManAuxiliaryData(manCont) |
||||
|
//编辑紧急联系人信息
|
||||
|
synPro.Add(1) |
||||
|
go emergencyContactPerson(manCont) |
||||
|
//编辑员工家属信息
|
||||
|
synPro.Add(1) |
||||
|
go eidtFamilyMembers(manCont.Number, manCont.MemberOfFamily) |
||||
|
//编辑员工教育经历
|
||||
|
synPro.Add(1) |
||||
|
go educatExperKingdee(manCont) |
||||
|
synPro.Wait() |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
//编辑人员附属信息
|
||||
|
func editManAuxiliaryData(manCont addKingdeePersonnel) { |
||||
|
defer synPro.Done() |
||||
|
var manInfo models.PersonnelContent |
||||
|
manErr := manInfo.GetCont(map[string]interface{}{"`number`": manCont.Number}) |
||||
|
if manErr == nil { |
||||
|
saveData := overallhandle.MapOut() |
||||
|
if manCont.IDCardNo != "" && manCont.IDCardNo != manInfo.Idcardno { |
||||
|
saveData["idcardno"] = manCont.IDCardNo |
||||
|
} |
||||
|
if manCont.IDCardStartTime != "" { |
||||
|
idCardStarTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.IDCardStartTime)) |
||||
|
if idCardStarTime != manInfo.Idcardstartdate { |
||||
|
saveData["idcardstartdate"] = idCardStarTime |
||||
|
} |
||||
|
} |
||||
|
if manCont.IDCardEndTime != "" { |
||||
|
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, _ := 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) |
||||
|
} |
||||
|
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, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.WorkingDate)) |
||||
|
if workInData != manInfo.Jobstartdate { |
||||
|
saveData["jobstartdate"] = workInData |
||||
|
} |
||||
|
} |
||||
|
if manCont.EntryDate != "" { |
||||
|
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 != "" { |
||||
|
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, _ := 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{}{"`number`": manCont.Number}, saveData) |
||||
|
} |
||||
|
} else { |
||||
|
manInfo.Number = manCont.Number |
||||
|
manInfo.Idcardno = manCont.IDCardNo |
||||
|
idCardStarTime := time.Now().Unix() |
||||
|
if manCont.IDCardStartTime != "" { |
||||
|
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.IDCardStartTime)) |
||||
|
} |
||||
|
manInfo.Idcardstartdate = idCardStarTime //身份证有效期开始
|
||||
|
idCardEndTime := time.Now().Unix() |
||||
|
if manCont.IDCardEndTime != "" { |
||||
|
idCardEndTime, _ = 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, _ := 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 != "" { |
||||
|
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.WorkingDate)) |
||||
|
} |
||||
|
manInfo.Jobstartdate = workInData |
||||
|
entryData := time.Now().Unix() |
||||
|
if manCont.EntryDate != "" { |
||||
|
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 != "" { |
||||
|
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 { |
||||
|
//编辑双职工
|
||||
|
eidtDoubleWorker(manCont, 1) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
//编辑双职工
|
||||
|
func eidtDoubleWorker(manCont addKingdeePersonnel, state int) { |
||||
|
var doubleWorkCont models.DoubleWorker |
||||
|
dwErr := doubleWorkCont.GetCont(map[string]interface{}{"`number`": manCont.Number}) |
||||
|
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.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 emergencyContactPerson(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("`number` = ?", manCont.Number).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.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.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 eidtFamilyMembers(num string, family []memberOfFamily) { |
||||
|
defer synPro.Done() |
||||
|
if len(family) > 0 && num != "" { |
||||
|
var familyAry []models.FamilyMembers |
||||
|
famErr := overall.CONSTANT_DB_HR.Where("`number` = ?", num).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.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.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 educatExperKingdee(manCont addKingdeePersonnel) { |
||||
|
defer synPro.Done() |
||||
|
if manCont.HighestGraduationSchool != "" { |
||||
|
//最高学历
|
||||
|
var perEduContHig models.PersonnelEducation |
||||
|
highestGormDb := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Where("number = ? AND graduation_school = ? AND subject = ?", manCont.Number, 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, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestAdmissionTime)) |
||||
|
if entranceTime != perEduContHig.AdmissionTime { |
||||
|
eitdCont["admission_time"] = entranceTime |
||||
|
} |
||||
|
} |
||||
|
if manCont.HighestGraduationTime != "" { |
||||
|
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("number = ?", manCont.Number).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{}{"`number`": manCont.Number, "level": 3}, eitdCont) |
||||
|
} |
||||
|
|
||||
|
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 != "" { |
||||
|
entranceTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestAdmissionTime)) |
||||
|
} |
||||
|
perEduContHig.AdmissionTime = entranceTime // 入学时间"`
|
||||
|
graduationTime := time.Now().Unix() |
||||
|
if manCont.HighestGraduationTime != "" { |
||||
|
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("number = ? AND graduation_school = ? AND subject = ?", manCont.Number, 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, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.FirstAdmissionTime)) |
||||
|
if entranceTimeFirst != perEduContFirst.AdmissionTime { |
||||
|
eitdContFirst["admission_time"] = entranceTimeFirst |
||||
|
} |
||||
|
} |
||||
|
if manCont.FirstGraduationTime != "" { |
||||
|
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"] = 3 |
||||
|
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("number = ?", manCont.Number).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{}{"`number`": manCont.Number, "level": 1}, eitdContFirst) |
||||
|
} |
||||
|
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 != "" { |
||||
|
entranceTimeFirst, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", manCont.HighestAdmissionTime)) |
||||
|
} |
||||
|
perEduContFirst.AdmissionTime = entranceTimeFirst // 入学时间"`
|
||||
|
graduationTimef := time.Now().Unix() |
||||
|
if manCont.HighestGraduationTime != "" { |
||||
|
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) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,37 @@ |
|||||
|
package models |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
//职务信息及类别、等级视图
|
||||
|
type DutiesClassLeve struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:d_id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
Name string `json:"name" gorm:"column:d_name;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` |
||||
|
Weight int64 `json:"weight" gorm:"column:d_weight;type:bigint(20) unsigned;default:1;not null;comment:权重"` |
||||
|
Number string `json:"number" gorm:"column:d_num;type:varchar(50) unsigned;default:'';not null;comment:编码"` |
||||
|
State int `json:"state" gorm:"column:d_state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
||||
|
KingdeeId string `json:"kingdeeid" gorm:"column:d_king;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"` |
||||
|
ClassId int64 `json:"classid" gorm:"primaryKey;column:c_id;type:bigint(20) unsigned;not null;comment:Id;index"` //职务分类Id
|
||||
|
ClassName string `json:"classname" gorm:"column:c_name;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"` |
||||
|
// LeveId int64 `json:"leveid" gorm:"primaryKey;column:l_id;type:bigint(20) unsigned;not null;comment:Id;index"` //职务等级Id
|
||||
|
// LeveNumber string `json:"levenumber" gorm:"column:l_num;type:varchar(50) unsigned;default:'';not null;comment:等级编号"`
|
||||
|
// LeveName string `json:"levename" gorm:"column:l_name;type:varchar(255) unsigned;default:'';not null;comment:等级名称"`
|
||||
|
} |
||||
|
|
||||
|
func (DutiesClassLeve *DutiesClassLeve) TableName() string { |
||||
|
return "duties_class_leve" |
||||
|
} |
||||
|
|
||||
|
//获取详细内容
|
||||
|
func (cont *DutiesClassLeve) 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 |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
package models |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
//职务信息及类别、等级视图
|
||||
|
type OrgContType struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"` |
||||
|
Number string `json:"number" gorm:"column:number;type:varchar(50) unsigned;default:'';not null;comment:行政编码"` |
||||
|
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:组织名称"` |
||||
|
Superior int64 `json:"superior" gorm:"column:superior;type:bigint(20) unsigned;default:0;not null;comment:上级ID"` |
||||
|
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
||||
|
TypeName string `json:"typename" gorm:"column:typename;type:varchar(255) unsigned;default:'';not null;comment:类型名称"` |
||||
|
Level int64 `json:"level" gorm:"column:level;type:int(5) unsigned;default:1;not null;comment:级别"` |
||||
|
} |
||||
|
|
||||
|
func (OrgContType *OrgContType) TableName() string { |
||||
|
return "org_cont_type" |
||||
|
} |
||||
|
|
||||
|
//获取详细内容
|
||||
|
func (cont *OrgContType) 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 |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
package models |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/overall" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
//员工档案(主)
|
||||
|
type PersonArchives struct { |
||||
|
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:ID"` |
||||
|
Number string `json:"number" gorm:"column:number;type:varchar(30) unsigned;not null;comment:员工工号"` |
||||
|
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
||||
|
Icon string `json:"icon" gorm:"column:icon;type:varchar(255) unsigned;default:'';not null;comment:头像"` |
||||
|
HireClass int `json:"hireclass" gorm:"column:hire_class;type:tinyint(1) unsigned;default:1;not null;comment:雇佣类型(1:雇佣入职;2:再入职;)"` |
||||
|
EmpType int `json:"emptype" gorm:"column:emp_type;type:tinyint(1) unsigned;default:1;not null;comment:用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)"` |
||||
|
Company int64 `json:"company" gorm:"column:company;type:bigint(20) unsigned;default:0;not null;comment:入职公司"` |
||||
|
MainDeparment int64 `json:"maindeparment" gorm:"column:maindeparment;type:bigint(20) unsigned;default:0;not null;comment:主部门"` |
||||
|
Deparment string `json:"deparment" gorm:"column:deparment;type:text;comment:部门"` |
||||
|
AdminOrg int64 `json:"adminorg" gorm:"column:admin_org;type:bigint(20) unsigned;default:0;not null;comment:所属行政组织"` |
||||
|
Position int64 `json:"position" gorm:"column:position;type:bigint(20) unsigned;default:0;not null;comment:职位"` |
||||
|
JobClass int64 `json:"jobclass" gorm:"column:job_class;type:bigint(20) unsigned;default:2;not null;comment:职务分类"` |
||||
|
JobId int64 `json:"jobid" gorm:"column:job_id;type:bigint(20) unsigned;default:0;not null;comment:职务"` |
||||
|
JobLeve int64 `json:"jobleve" gorm:"column:job_leve;type:bigint(20) unsigned;default:0;not null;comment:职务等级"` |
||||
|
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:写入时间"` |
||||
|
EiteTime int64 `json:"eitetime" gorm:"column:eite_time;type:bigint(20) unsigned;default:0;not null;comment:编辑时间"` |
||||
|
Wechat string `json:"wechat" gorm:"column:wechat;type:varchar(255) unsigned;default:'';not null;comment:微信UserId"` |
||||
|
WorkWechat string `json:"workwechat" gorm:"column:work_wechat;type:varchar(255) unsigned;default:'';not null;comment:企业微信UserId"` |
||||
|
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)` |
||||
|
Key int64 `json:"key" gorm:"column:key;type:bigint(50) unsigned;default:0;not null;comment:key"` |
||||
|
IsAdmin int `json:"isadmin" gorm:"column:is_admin;type:tinyint(1) unsigned;default:1;not null;comment:是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管` |
||||
|
Password string `json:"password" gorm:"column:password;type:varchar(255) unsigned;default:'';not null;comment:密码"` |
||||
|
Role string `json:"role" gorm:"column:role;type:longtext;comment:角色"` |
||||
|
} |
||||
|
|
||||
|
func (PersonArchives *PersonArchives) TableName() string { |
||||
|
return "person_archives" |
||||
|
} |
||||
|
|
||||
|
//编辑员工档案
|
||||
|
func (PersonArchives *PersonArchives) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_HR.Model(&PersonArchives).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
//获取员工档案
|
||||
|
func (cont *PersonArchives) 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 |
||||
|
} |
||||
Loading…
Reference in new issue