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.
1939 lines
67 KiB
1939 lines
67 KiB
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) StaffList(c *gin.Context) {
|
|
var requestData peopleList
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Page < 0 {
|
|
requestData.Page = 1
|
|
}
|
|
if requestData.PageSize < 0 {
|
|
requestData.PageSize = 10
|
|
}
|
|
// gormDb := overall.CONSTANT_DB_HR.Model(&models.JobClass{}).Select("").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type")
|
|
// var personnelModels models.Personnel
|
|
// gormDb := overall.CONSTANT_DB_HR.Table(fmt.Sprintf("%s p", personnelModels.TableName())).Select("p.*,pc.mobilephone,pc.gender,pc.isdoubleworker,pc.isveterans,pc.entrydate,pc.probationperiod,pc.planformaldate").Joins("left join personnel_content as pc on pc.number = p.number")
|
|
|
|
//SELECT * FROM `man_cont` WHERE `position` = 727 AND `emp_type` IN (1,2,3,4,5,6,7,8,9,10) AND `state` = 1 ORDER BY `company` ASC,`maindeparment` ASC,`admin_org` ASC,`position` ASC LIMIT 20
|
|
|
|
// sqlStrList := "SELECT * FROM `man_cont`"
|
|
// sqlStrCount := "SELECT count(*) FROM `man_cont`"
|
|
|
|
sqlStr := "WHERE `state` = 1"
|
|
|
|
var personnelModels []models.ManCont
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.ManCont{})
|
|
if requestData.Number != "" {
|
|
gormDb = gormDb.Where("`number` LIKE ?", "%"+requestData.Number+"%")
|
|
sqlStr = fmt.Sprintf("%v AND `number` LIKE %v", sqlStr, requestData.Number)
|
|
}
|
|
if requestData.Name != "" {
|
|
gormDb = gormDb.Where("`name` LIKE ?", "%"+requestData.Name+"%")
|
|
sqlStr = fmt.Sprintf("%v AND `name` LIKE %v", sqlStr, requestData.Name)
|
|
}
|
|
if requestData.HireClass != 0 {
|
|
gormDb = gormDb.Where("`hire_class` = ?", requestData.HireClass)
|
|
sqlStr = fmt.Sprintf("%v AND `hire_class` = %v", sqlStr, requestData.HireClass)
|
|
}
|
|
if requestData.Company != 0 {
|
|
gormDb = gormDb.Where("`company` = ?", requestData.Company)
|
|
sqlStr = fmt.Sprintf("%v AND `company` = %v", sqlStr, requestData.Company)
|
|
}
|
|
if requestData.Deparment != "" {
|
|
gormDb = gormDb.Where("FIND_IN_SET(?,p.`deparment`)", requestData.Deparment)
|
|
sqlStr = fmt.Sprintf("%v AND `maindeparment` = %v", sqlStr, requestData.Deparment)
|
|
}
|
|
if requestData.AdminOrg != 0 {
|
|
gormDb = gormDb.Where("`admin_org` = ?", requestData.AdminOrg)
|
|
sqlStr = fmt.Sprintf("%v AND `admin_org` = %v", sqlStr, requestData.AdminOrg)
|
|
}
|
|
if requestData.Position != 0 {
|
|
gormDb = gormDb.Where("`position` = ?", requestData.Position)
|
|
sqlStr = fmt.Sprintf("%v AND `position` = %v", sqlStr, requestData.Position)
|
|
}
|
|
if requestData.EmpType != 0 {
|
|
gormDb = gormDb.Where("`emp_type` = ?", requestData.EmpType)
|
|
sqlStr = fmt.Sprintf("%v AND `emp_type` = %v", sqlStr, requestData.EmpType)
|
|
} else {
|
|
// gormDb = gormDb.Where("`emp_type` IN ?", overall.EmployeeStatusIng)
|
|
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 1, 10)
|
|
if len(overall.EmployeeStatusIng) > 0 {
|
|
var empId []string
|
|
for i := 0; i < len(overall.EmployeeStatusIng); i++ {
|
|
overEmpId := strconv.Itoa(overall.EmployeeStatusIng[i])
|
|
if overallhandle.IsInTrue[string](overEmpId, empId) == false {
|
|
empId = append(empId, overEmpId)
|
|
}
|
|
}
|
|
sqlStr = fmt.Sprintf("%v AND `emp_type` IN (%v)", sqlStr, strings.Join(empId, ","))
|
|
}
|
|
|
|
}
|
|
if requestData.Role != "" {
|
|
gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role)
|
|
sqlStr = fmt.Sprintf("%v AND FIND_IN_SET(%v,`role`)", sqlStr, requestData.Role)
|
|
}
|
|
gormDb = gormDb.Where("`state` = 1")
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
var positionAry []peopleOutList
|
|
errGorm := gormDb.Order("`company` ASC,`maindeparment` ASC,`admin_org` ASC,`position` ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&personnelModels).Error
|
|
|
|
//原生查询
|
|
// selectSqlStr := fmt.Sprintf("%v %v", sqlStrList, sqlStr)
|
|
// selectSqlStrCount := fmt.Sprintf("%v %v", sqlStrCount, sqlStr)
|
|
// errGorm := overall.CONSTANT_DB_HR.Raw(selectSqlStr).Scan(&personnelModels).Error
|
|
// totalErr := overall.CONSTANT_DB_HR.Raw(selectSqlStrCount).Scan(&total).Error
|
|
// if totalErr != nil {
|
|
// total = 0
|
|
// }
|
|
// fmt.Printf("personnelModels-------------------->%v---------------->%v---------------->%v\n", total, totalErr, personnelModels)
|
|
for _, v := range personnelModels {
|
|
var manInCont peopleOutList
|
|
manInCont.Id = v.Id
|
|
manInCont.Number = v.Number //员工工号"`
|
|
manInCont.Name = v.Name //姓名"`
|
|
manInCont.Icon = v.Icon //头像"`
|
|
manInCont.HireClass = v.HireClass //雇佣类型(1:雇佣入职;2:再入职;)"`
|
|
manInCont.EmpType = v.EmpType // 用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)"`
|
|
manInCont.Company = v.Company //入职公司"`
|
|
manInCont.MainDeparment = v.MainDeparment //主部门"`
|
|
manInCont.SunMainDeparment = v.SunMainDeparment //二级主部门"`
|
|
manInCont.Deparment = v.Deparment //部门"`
|
|
manInCont.AdminOrg = v.AdminOrg //所属行政组织"`
|
|
manInCont.TeamId = v.TeamId //班组"`
|
|
manInCont.Position = v.Position //职位"`
|
|
manInCont.JobClass = v.JobClass //职务分类"`
|
|
manInCont.JobId = v.JobId //职务"`
|
|
manInCont.JobLeve = v.JobLeve //职务等级"`
|
|
manInCont.Time = v.Time //写入时间"`
|
|
manInCont.EiteTime = v.EiteTime //编辑时间"`
|
|
manInCont.Wechat = v.Wechat //微信UserId"`
|
|
manInCont.WorkWechat = v.WorkWechat //企业微信UserId"`
|
|
manInCont.State = v.State //状态(1:启用;2:禁用;3:删除)`
|
|
manInCont.Key = v.Key //key"`
|
|
manInCont.IsAdmin = v.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管`
|
|
manInCont.Password = v.Password //密码"`
|
|
manInCont.Role = v.Role //角色"`
|
|
manInCont.Idcardno = v.Idcardno //身份证号"`
|
|
manInCont.Passportno = v.Passportno //护照号码"`
|
|
manInCont.Globalroaming = v.Globalroaming //国际区号"`
|
|
manInCont.Mobilephone = v.Mobilephone //手机号码"`
|
|
manInCont.Email = v.Email //电子邮件"`
|
|
manInCont.Gender = v.Gender //性别(1:男性;2:女性;3:中性)"`
|
|
manInCont.Birthday = v.Birthday //debirthday"`
|
|
manInCont.Myfolk = v.Myfolk //民族"`
|
|
manInCont.Nativeplace = v.Nativeplace //籍贯"`
|
|
manInCont.Idcardstartdate = v.Idcardstartdate //身份证有效期开始"`
|
|
manInCont.Idcardenddate = v.Idcardenddate //身份证有效期结束"`
|
|
manInCont.Idcardaddress = v.Idcardaddress //身份证地址"`
|
|
manInCont.IdcardIssued = v.IdcardIssued //身份证签发机关"`
|
|
manInCont.Health = v.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)"`
|
|
manInCont.Maritalstatus = v.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)"`
|
|
manInCont.Internaltelephone = v.Internaltelephone //内线电话"`
|
|
manInCont.Currentresidence = v.Currentresidence //现居住地址"`
|
|
manInCont.Constellation = v.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)"`
|
|
manInCont.Isdoubleworker = v.Isdoubleworker //是否双职工(1:是;2:否)"`
|
|
manInCont.Isveterans = v.Isveterans //是否为退役军人(1:是;2:否)"`
|
|
manInCont.Veteransnumber = v.Veteransnumber //退役证编号"`
|
|
manInCont.Jobstartdate = v.Jobstartdate //参加工作日期"`
|
|
manInCont.Entrydate = v.Entrydate //入职日期"`
|
|
manInCont.Probationperiod = v.Probationperiod //试用期"`
|
|
manInCont.Planformaldate = v.Planformaldate //预计转正日期"`
|
|
manInCont.PoliticalOutlook = v.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)"`
|
|
|
|
// positionAry[i].KeyStr = strconv.FormatInt(positionAry[i].Key, 10)
|
|
|
|
// var getSpur models.Position
|
|
// getWhe := overallhandle.MapOut()
|
|
// getWhe["id"] = v.Position
|
|
// getSpur.GetCont(getWhe, "name")
|
|
// positionAry[i].PositionName = getSpur.Name
|
|
|
|
// var getSpurDepart models.AdministrativeOrganization
|
|
// getWheDepart := overallhandle.MapOut()
|
|
// getWheDepart["id"] = v.Company
|
|
// getSpurDepart.GetCont(getWheDepart, "name")
|
|
// positionAry[i].CompanyName = getSpurDepart.Name
|
|
|
|
// //获取部门
|
|
// departmentAry := strings.Split(v.Deparment, ",")
|
|
// if len(departmentAry) > 0 {
|
|
// var departCont []getDepartmentInfo
|
|
// departErr := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("id,number,name").Where("`id` IN ?", departmentAry).Order("`organization_type` ASC").Find(&departCont).Error
|
|
|
|
// if departErr == nil {
|
|
// var departNameAry []string
|
|
// for _, d_v := range departCont {
|
|
// departNameAry = append(departNameAry, d_v.Name)
|
|
// }
|
|
// if len(departNameAry) > 0 {
|
|
// positionAry[i].DeparmentName = strings.Join(departNameAry, " ")
|
|
// }
|
|
// }
|
|
// }
|
|
positionAry = append(positionAry, manInCont)
|
|
}
|
|
if errGorm != nil {
|
|
overallhandle.Result(105, errGorm, c)
|
|
} else {
|
|
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
|
|
}
|
|
}
|
|
|
|
// 添加员工
|
|
func (s *StaffApi) AddStaff(c *gin.Context) {
|
|
var requestData addPersonnel
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Number == "" {
|
|
overallhandle.Result(1, requestData.Number, c, "工号不能为空!")
|
|
return
|
|
}
|
|
if requestData.Name == "" {
|
|
overallhandle.Result(1, requestData.Name, c, "姓名不能为空!")
|
|
return
|
|
}
|
|
if requestData.Gender == 0 {
|
|
requestData.Gender = 1
|
|
}
|
|
if requestData.HireType == 0 {
|
|
requestData.HireType = 1
|
|
}
|
|
if requestData.PoliticalOutlook == 0 {
|
|
requestData.PoliticalOutlook = 1
|
|
}
|
|
if requestData.AdminOrg == 0 {
|
|
overallhandle.Result(1, requestData.Position, c, "请选择员工归属行政组织!")
|
|
return
|
|
}
|
|
// if len(requestData.Department) < 1 {
|
|
// overallhandle.Result(1, requestData.Department, c, "请您选择该员工归属哪个分厂(部室)!")
|
|
// return
|
|
// }
|
|
if requestData.Position == 0 {
|
|
overallhandle.Result(1, requestData.Position, c, "请分配员工职位(岗位)!")
|
|
return
|
|
}
|
|
if requestData.EmpType == 0 {
|
|
requestData.EmpType = 2
|
|
}
|
|
if requestData.PositionGrade == 0 {
|
|
overallhandle.Result(1, requestData.PositionGrade, c, "请分配员入职等级!")
|
|
return
|
|
}
|
|
if requestData.ProbationPeriod == 0 {
|
|
requestData.ProbationPeriod = 3
|
|
}
|
|
if requestData.Constellation == 0 {
|
|
requestData.Constellation = 1
|
|
}
|
|
if requestData.Health == 0 {
|
|
requestData.Health = 2
|
|
}
|
|
if requestData.Maritalstatus == 0 {
|
|
requestData.Maritalstatus = 1
|
|
}
|
|
if requestData.Iisdoubleworker == 0 {
|
|
requestData.Iisdoubleworker = 2
|
|
} else {
|
|
if requestData.Iisdoubleworker == 1 {
|
|
if len(requestData.DoubleWorkerList) < 0 {
|
|
overallhandle.Result(1, requestData.DoubleWorkerList, c, "请输入配偶信息!")
|
|
return
|
|
}
|
|
|
|
}
|
|
}
|
|
if requestData.Isveterans == 0 {
|
|
requestData.Isveterans = 2
|
|
} else {
|
|
if requestData.Isveterans == 1 && requestData.Veteransnumber == "" {
|
|
overallhandle.Result(1, requestData.Veteransnumber, c, "请输入退役证编号!")
|
|
return
|
|
}
|
|
}
|
|
if requestData.Password == "" && requestData.EmpType != 9 {
|
|
requestData.Password = overall.CONSTANT_CONFIG.Appsetup.DefaultPassword
|
|
}
|
|
|
|
//员工档案主
|
|
var staffInfo models.PersonArchives
|
|
//判断工号是存在
|
|
whereAry := overallhandle.MapOut()
|
|
whereAry["number"] = requestData.Number
|
|
if judgeNoErr := staffInfo.GetCont(whereAry, "number"); judgeNoErr == nil {
|
|
overallhandle.Result(1, requestData, c, "该工号已经被使用!请不要重复使用!")
|
|
return
|
|
}
|
|
|
|
staffInfo.Number = requestData.Number
|
|
staffInfo.Name = requestData.Name
|
|
staffInfo.Icon = requestData.Icon
|
|
staffInfo.HireClass = requestData.HireType
|
|
staffInfo.EmpType = requestData.EmpType
|
|
|
|
// mainDepartmentId, _ := strconv.ParseInt(requestData.MainDepartment, 10, 64)
|
|
|
|
_, companyId, departmentId, sunDepartId, _ := overallhandle.GetOrgStructure(requestData.AdminOrg)
|
|
|
|
staffInfo.Company = companyId
|
|
|
|
staffInfo.MainDeparment = departmentId
|
|
staffInfo.SunMainDeparment = sunDepartId
|
|
// staffInfo.Deparment = strings.Join(requestData.Department, ",")
|
|
staffInfo.AdminOrg = requestData.AdminOrg
|
|
teamIdInt, _ := strconv.ParseInt(requestData.Team, 10, 64)
|
|
staffInfo.TeamId = teamIdInt
|
|
|
|
staffInfo.Position = requestData.Position
|
|
//获取职务信息
|
|
var postDuitesCont models.PostDutiesJob
|
|
jobErr := postDuitesCont.GetCont(map[string]interface{}{"id": requestData.Position}, "duties")
|
|
// jobCont, jobErr := getJobInfo(requestData.Position)
|
|
if jobErr == nil {
|
|
staffInfo.JobClass = postDuitesCont.JobType
|
|
staffInfo.JobId = postDuitesCont.Duties
|
|
}
|
|
staffInfo.JobLeve = requestData.PositionGrade
|
|
|
|
staffInfo.Time = time.Now().Unix()
|
|
staffInfo.EiteTime = time.Now().Unix()
|
|
staffInfo.State = 1
|
|
|
|
// staffInfo.Password = requestData.Password
|
|
if requestData.Password != "" {
|
|
var md5JiaMi overallhandle.Md5Encryption
|
|
md5JiaMi.Md5EncryptionInit(requestData.Password)
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
staffInfo.Password = md5Token
|
|
}
|
|
|
|
manKeyNum := overallhandle.TableNumber()
|
|
|
|
staffInfo.Key = manKeyNum
|
|
staffInfo.IsAdmin = 1
|
|
staffInfo.Role = ""
|
|
peopleMasterErr := overall.CONSTANT_DB_HR.Create(&staffInfo).Error
|
|
if peopleMasterErr != nil {
|
|
overallhandle.Result(104, staffInfo, c)
|
|
return
|
|
}
|
|
|
|
//员工档案附表
|
|
synPro.Add(1)
|
|
go staffInfoCont(manKeyNum, requestData)
|
|
|
|
//双职工
|
|
if requestData.Iisdoubleworker == 1 {
|
|
synPro.Add(1)
|
|
go doubleWorkerStaff(manKeyNum, requestData.Number, requestData.DoubleWorkerList)
|
|
}
|
|
//人员变动记录
|
|
// synPro.Add(1)
|
|
// go peopleGaiDong(staffInfo)
|
|
//教育经历
|
|
if len(requestData.EducationalExperience) > 0 {
|
|
synPro.Add(1)
|
|
go eduExperience(manKeyNum, requestData.Number, requestData.EducationalExperience)
|
|
}
|
|
//紧急联系人
|
|
if len(requestData.EmergencyContact) > 0 {
|
|
synPro.Add(1)
|
|
go emeContact(manKeyNum, requestData.Number, requestData.EmergencyContact)
|
|
|
|
}
|
|
//家庭成员
|
|
if len(requestData.MemberOfFamily) > 0 {
|
|
synPro.Add(1)
|
|
go familyPeople(manKeyNum, requestData.Number, requestData.MemberOfFamily)
|
|
}
|
|
//工作履历
|
|
if len(requestData.WorkHistoryList) > 0 {
|
|
synPro.Add(1)
|
|
go workHistoryLog(manKeyNum, requestData.Number, requestData.WorkHistoryList)
|
|
}
|
|
//公司内部工作履历
|
|
if len(requestData.InsideWorkHistory) > 0 {
|
|
synPro.Add(1)
|
|
go workInsideHistoryLog(manKeyNum, requestData.Number, requestData.InsideWorkHistory)
|
|
}
|
|
synPro.Wait()
|
|
overallhandle.Result(0, staffInfo, c)
|
|
}
|
|
|
|
// 获取职务相关属性
|
|
func getJobInfo(jobId int64) (cont jobAttber, err error) {
|
|
var positionInfo models.Position
|
|
err = overall.CONSTANT_DB_HR.Model(&positionInfo).Select("position.id,position.number,position.name,position.person_in_charge,d.id as dutid,d.name as dutname,d.number as dutnumber,j.id as jobid,j.name as jobname").Joins("left join duties as d on d.id = position.duties").Joins("left join job_class as j on j.id = d.job_type").Where("`position`.`id` = ?", jobId).First(&cont).Error
|
|
return
|
|
}
|
|
|
|
// 员工档案详情
|
|
func staffInfoCont(manKeyNum int64, contData addPersonnel) {
|
|
defer synPro.Done()
|
|
var staffAttribute models.PersonnelContent
|
|
contErr := staffAttribute.GetCont(map[string]interface{}{"`key`": manKeyNum})
|
|
if contErr == nil {
|
|
saveData := overallhandle.MapOut()
|
|
if contData.Passportno != "" && contData.Passportno != staffAttribute.Passportno {
|
|
saveData["passportno"] = contData.Passportno
|
|
}
|
|
if contData.Globalroaming != "" && contData.Globalroaming != staffAttribute.Globalroaming {
|
|
saveData["globalroaming"] = contData.Globalroaming
|
|
}
|
|
if contData.IDCardNo != "" && contData.IDCardNo != staffAttribute.Idcardno {
|
|
saveData["idcardno"] = contData.IDCardNo
|
|
}
|
|
if contData.IDCardStartTime != "" {
|
|
idCardStarTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardStartTime))
|
|
if idCardStarTime != staffAttribute.Idcardstartdate {
|
|
saveData["idcardstartdate"] = idCardStarTime
|
|
}
|
|
}
|
|
if contData.IDCardEndTime != "" {
|
|
idCardEndTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardEndTime))
|
|
if idCardEndTime != staffAttribute.Idcardenddate {
|
|
saveData["idcardenddate"] = idCardEndTime
|
|
}
|
|
}
|
|
if contData.IDCardAddress != "" && contData.IDCardAddress != staffAttribute.Idcardaddress {
|
|
saveData["idcardaddress"] = contData.IDCardAddress
|
|
}
|
|
if contData.IDCardIsSued != "" && contData.IDCardIsSued != staffAttribute.IdcardIssued {
|
|
saveData["idcardIssued"] = contData.IDCardIsSued
|
|
}
|
|
if contData.Mobilephone != "" && contData.Mobilephone != staffAttribute.Mobilephone {
|
|
saveData["mobilephone"] = contData.Mobilephone
|
|
}
|
|
if contData.Email != "" && contData.Email != staffAttribute.Email {
|
|
saveData["email"] = contData.Email
|
|
}
|
|
if contData.Gender != 0 && contData.Gender != staffAttribute.Gender {
|
|
saveData["gender"] = contData.Gender
|
|
}
|
|
if contData.Birthday != "" {
|
|
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.Birthday))
|
|
if brrthday != staffAttribute.Birthday {
|
|
saveData["birthday"] = brrthday
|
|
}
|
|
}
|
|
if contData.Nation != "" && contData.Nation != staffAttribute.Myfolk {
|
|
saveData["myfolk"] = contData.Nation
|
|
}
|
|
if contData.NativePlace != "" && contData.NativePlace != staffAttribute.Nativeplace {
|
|
saveData["nativeplace"] = contData.NativePlace
|
|
}
|
|
if contData.Health != 0 && contData.Health != staffAttribute.Health {
|
|
saveData["health"] = contData.Health
|
|
}
|
|
if contData.Maritalstatus != 0 && contData.Maritalstatus != staffAttribute.Maritalstatus {
|
|
saveData["maritalstatus"] = contData.Maritalstatus
|
|
}
|
|
if contData.CurrentResidence != "" && contData.CurrentResidence != staffAttribute.Currentresidence {
|
|
saveData["currentresidence"] = contData.CurrentResidence
|
|
}
|
|
if contData.Constellation != 0 && contData.Constellation != staffAttribute.Constellation {
|
|
saveData["constellationing"] = contData.Constellation
|
|
}
|
|
if contData.Iisdoubleworker != 0 && contData.Iisdoubleworker != staffAttribute.Isdoubleworker {
|
|
saveData["isdoubleworker"] = contData.Iisdoubleworker
|
|
// eidtDoubleWorker(contData, contData.Iisdoubleworker)
|
|
doubleWorkerStaff(manKeyNum, staffAttribute.Number, contData.DoubleWorkerList)
|
|
}
|
|
if contData.Isveterans != 0 && contData.Isveterans != staffAttribute.Isveterans {
|
|
saveData["isveterans"] = contData.Isveterans
|
|
if contData.Isveterans == 1 {
|
|
if contData.Veteransnumber != "" && contData.Veteransnumber != staffAttribute.Veteransnumber {
|
|
saveData["veteransnumber"] = contData.Veteransnumber
|
|
}
|
|
} else {
|
|
saveData["veteransnumber"] = ""
|
|
}
|
|
}
|
|
if contData.WorkingDate != "" {
|
|
workInData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.WorkingDate))
|
|
if workInData != staffAttribute.Jobstartdate {
|
|
saveData["jobstartdate"] = workInData
|
|
}
|
|
}
|
|
if contData.EntryDate != "" {
|
|
entryData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
|
|
if entryData != staffAttribute.Entrydate {
|
|
saveData["entrydate"] = entryData
|
|
}
|
|
}
|
|
if contData.ProbationPeriod != 0 && contData.ProbationPeriod != staffAttribute.Probationperiod {
|
|
saveData["probationperiod"] = contData.ProbationPeriod
|
|
entryData := staffAttribute.Entrydate
|
|
if contData.EntryDate != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
|
|
}
|
|
planformalData := overallhandle.GetFutureMonthTime(entryData, contData.ProbationPeriod, 2)
|
|
saveData["planformaldate"] = planformalData
|
|
}
|
|
|
|
if contData.ConfirmationDate != "" {
|
|
planformalData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.ConfirmationDate))
|
|
saveData["planformaldate"] = planformalData
|
|
}
|
|
if contData.PoliticalOutlook != 0 && contData.PoliticalOutlook != staffAttribute.PoliticalOutlook {
|
|
saveData["political_outlook"] = contData.PoliticalOutlook
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`time`"] = time.Now().Unix()
|
|
staffAttribute.EiteCont(map[string]interface{}{"`key`": staffAttribute.Key}, saveData)
|
|
}
|
|
} else {
|
|
staffAttribute.Key = manKeyNum
|
|
staffAttribute.Number = contData.Number
|
|
staffAttribute.Passportno = contData.Passportno
|
|
staffAttribute.Globalroaming = contData.Globalroaming
|
|
staffAttribute.Idcardno = contData.IDCardNo
|
|
staffAttribute.Mobilephone = contData.Mobilephone
|
|
staffAttribute.Email = contData.Email
|
|
staffAttribute.Gender = contData.Gender
|
|
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.Birthday))
|
|
staffAttribute.Birthday = brrthday
|
|
staffAttribute.Myfolk = contData.Nation
|
|
staffAttribute.Nativeplace = contData.NativePlace
|
|
|
|
idCardStarTime := time.Now().Unix()
|
|
if contData.IDCardStartTime != "" {
|
|
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardStartTime))
|
|
}
|
|
staffAttribute.Idcardstartdate = idCardStarTime //身份证有效期开始
|
|
idCardEndTime := time.Now().Unix()
|
|
if contData.IDCardEndTime != "" {
|
|
idCardEndTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardEndTime))
|
|
}
|
|
staffAttribute.Idcardenddate = idCardEndTime //身份证有效期结束
|
|
staffAttribute.Idcardaddress = contData.IDCardAddress //身份证地址
|
|
staffAttribute.IdcardIssued = contData.IDCardIsSued //身份证签发机关
|
|
staffAttribute.Health = contData.Health
|
|
staffAttribute.Maritalstatus = contData.Maritalstatus
|
|
staffAttribute.Internaltelephone = ""
|
|
staffAttribute.Currentresidence = contData.CurrentResidence
|
|
staffAttribute.Time = time.Now().Unix()
|
|
staffAttribute.Constellation = contData.Constellation
|
|
staffAttribute.Isdoubleworker = contData.Iisdoubleworker
|
|
staffAttribute.Isveterans = contData.Isveterans
|
|
staffAttribute.Veteransnumber = contData.Veteransnumber
|
|
workInData := time.Now().Unix()
|
|
if contData.WorkingDate != "" {
|
|
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.WorkingDate))
|
|
}
|
|
staffAttribute.Jobstartdate = workInData
|
|
entryData := time.Now().Unix()
|
|
if contData.EntryDate != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
|
|
}
|
|
staffAttribute.Entrydate = entryData
|
|
staffAttribute.Probationperiod = contData.ProbationPeriod
|
|
planformalData := time.Now().Unix()
|
|
if contData.ConfirmationDate != "" {
|
|
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.ConfirmationDate))
|
|
} else {
|
|
planformalData = overallhandle.GetFutureMonthTime(entryData, contData.ProbationPeriod, 2)
|
|
}
|
|
staffAttribute.Planformaldate = planformalData
|
|
staffAttribute.PoliticalOutlook = contData.PoliticalOutlook
|
|
|
|
overall.CONSTANT_DB_HR.Create(&staffAttribute)
|
|
}
|
|
|
|
}
|
|
|
|
// 双职工
|
|
func doubleWorkerStaff(manKeyNum int64, numStr string, dobleMan []DoubleWorkerInFo) {
|
|
defer synPro.Done()
|
|
|
|
var dwManAry []models.DoubleWorker
|
|
dwManAryErr := overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&dwManAry).Error
|
|
if dwManAryErr == nil {
|
|
var eidtIint []int
|
|
for i, v := range dobleMan {
|
|
var dwManInfo models.DoubleWorker
|
|
dwInFoErr := dwManInfo.GetCont(map[string]interface{}{"`key`": manKeyNum, "`name`": v.Name})
|
|
if dwInFoErr == nil {
|
|
eidtIint = append(eidtIint, i)
|
|
saveData := overallhandle.MapOut()
|
|
if v.Number != "" && v.Number != dwManInfo.Number {
|
|
saveData["number"] = v.Number
|
|
}
|
|
if v.Company != "" && v.Company != dwManInfo.Company {
|
|
saveData["company"] = v.Company
|
|
}
|
|
if v.Department != "" && v.Department != dwManInfo.Department {
|
|
saveData["department"] = v.Department
|
|
}
|
|
if v.Position != "" && v.Position != dwManInfo.Position {
|
|
saveData["position"] = v.Position
|
|
}
|
|
if v.Mobilephone != "" && v.Mobilephone != dwManInfo.Tel {
|
|
saveData["tel"] = v.Mobilephone
|
|
}
|
|
if dwManInfo.State != 1 {
|
|
saveData["state"] = 1
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`time`"] = time.Now().Unix()
|
|
dwManInfo.EiteCont(map[string]interface{}{"`id`": dwManInfo.Id}, saveData)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
var doublePeopleInset []models.DoubleWorker
|
|
if len(dobleMan) > 0 {
|
|
for _, v := range dobleMan {
|
|
var doublePeople models.DoubleWorker
|
|
doublePeople.Key = manKeyNum
|
|
doublePeople.Number = v.Number
|
|
doublePeople.Name = v.Name
|
|
doublePeople.Company = v.Company
|
|
doublePeople.Department = v.Department
|
|
doublePeople.Position = v.Position
|
|
doublePeople.Tel = v.Mobilephone
|
|
doublePeople.Time = time.Now().Unix()
|
|
|
|
doublePeopleInset = append(doublePeopleInset, doublePeople)
|
|
}
|
|
}
|
|
if len(doublePeopleInset) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&doublePeopleInset)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 人员变动记录
|
|
func peopleGaiDong(contData models.Personnel) {
|
|
defer synPro.Done()
|
|
var pcrInfo models.PersonnelChangeRecord
|
|
pcrInfo.Number = contData.Number
|
|
pcrInfo.Type = contData.HireClass
|
|
reason := ""
|
|
switch contData.HireClass {
|
|
case 1:
|
|
reason = "雇佣入职"
|
|
case 2:
|
|
reason = "再入职"
|
|
case 3:
|
|
reason = "职位分配"
|
|
case 4:
|
|
reason = "转正"
|
|
case 5:
|
|
reason = "停薪留职"
|
|
case 6:
|
|
reason = "退休"
|
|
case 7:
|
|
reason = "辞退"
|
|
case 8:
|
|
reason = "离职"
|
|
default:
|
|
reason = ""
|
|
}
|
|
pcrInfo.Reason = reason
|
|
pcrInfo.Position = contData.Position
|
|
// pcrInfo.JobLevel = strconv.FormatInt(contData.PositionLevel, 10)
|
|
// pcrInfo.JobLevel = contData.PositionLevel
|
|
pcrInfo.JobLevel = contData.PositionGrade
|
|
pcrInfo.Company = contData.Company
|
|
pcrInfo.Department = contData.Deparment
|
|
pcrInfo.Adminorg = contData.AdminOrg
|
|
pcrInfo.Time = time.Now().Unix()
|
|
overall.CONSTANT_DB_HR.Create(&pcrInfo)
|
|
}
|
|
|
|
// 教育经历
|
|
func eduExperience(manKeyNum int64, number string, eduExpAry []educationalExperience) {
|
|
defer synPro.Done()
|
|
|
|
var oldEduExp []models.PersonnelEducation
|
|
oldEduExpErr := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Select("`id`,`graduation_school`,`subject`,`education`").Where("`key` = ?", manKeyNum).Find(&oldEduExp).Error
|
|
|
|
if oldEduExpErr == nil {
|
|
var eduExpAryI []int
|
|
for i, v := range eduExpAry {
|
|
for _, ov := range oldEduExp {
|
|
if v.GraduationSchool == ov.GraduationSchool && v.Subject == ov.Subject && v.Education == ov.Education {
|
|
eduExpAryI = append(eduExpAryI, i)
|
|
eidtCont := overallhandle.MapOut()
|
|
if v.AdmissionTime != "" {
|
|
insetTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.AdmissionTime))
|
|
if ov.AdmissionTime != insetTime {
|
|
eidtCont["admission_time"] = insetTime
|
|
}
|
|
}
|
|
if v.GraduationTime != "" {
|
|
insetEndTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.GraduationTime))
|
|
if ov.GraduationTime != insetEndTime {
|
|
eidtCont["graduation_time"] = insetEndTime
|
|
}
|
|
}
|
|
if v.AcademicDegree != strconv.Itoa(ov.AcademicDegree) {
|
|
acdInt, _ := strconv.Atoi(v.AcademicDegree)
|
|
eidtCont["graduation_time"] = acdInt
|
|
}
|
|
if v.Level != strconv.Itoa(ov.Level) {
|
|
acdLeveInt, _ := strconv.Atoi(v.Level)
|
|
eidtCont["level"] = acdLeveInt
|
|
}
|
|
if ov.State != 1 {
|
|
eidtCont["state"] = 1
|
|
}
|
|
if len(eidtCont) > 0 {
|
|
eidtCont["time"] = time.Now().Unix()
|
|
var eidtPerEduCont models.PersonnelEducation
|
|
eidtPerEduCont.EiteCont(map[string]interface{}{"`id`": ov.Id}, eidtCont)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(eduExpAryI) < len(eduExpAry) {
|
|
var leaAddExp []models.PersonnelEducation
|
|
for ei, ev := range eduExpAry {
|
|
if overallhandle.IsInTrue[int](ei, eduExpAryI) == false {
|
|
var leaExpInfo models.PersonnelEducation
|
|
leaExpInfo.Key = manKeyNum
|
|
leaExpInfo.Number = number
|
|
leaExpInfo.Education = ev.Education
|
|
leaExpInfo.GraduationSchool = ev.GraduationSchool
|
|
leaExpInfo.Subject = ev.Subject
|
|
admissionTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", ev.AdmissionTime))
|
|
leaExpInfo.AdmissionTime = admissionTime
|
|
graduationTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", ev.GraduationTime))
|
|
leaExpInfo.GraduationTime = graduationTime
|
|
leaExpInfo.Time = time.Now().Unix()
|
|
if ev.AcademicDegree != "" {
|
|
acdInt, _ := strconv.Atoi(ev.AcademicDegree)
|
|
leaExpInfo.Level = acdInt
|
|
}
|
|
leaExpInfo.State = 1
|
|
leaAddExp = append(leaAddExp, leaExpInfo)
|
|
}
|
|
}
|
|
if len(leaAddExp) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&leaAddExp)
|
|
}
|
|
}
|
|
|
|
} else {
|
|
//不存在教育经历,进行新增
|
|
var leaExp []models.PersonnelEducation
|
|
maxLevel := 1
|
|
for eei, eev := range eduExpAry {
|
|
if maxLevel < eev.Education {
|
|
maxLevel = eev.Education
|
|
}
|
|
var leaExpInfo models.PersonnelEducation
|
|
leaExpInfo.Key = manKeyNum
|
|
leaExpInfo.Number = number
|
|
leaExpInfo.Education = eev.Education
|
|
leaExpInfo.GraduationSchool = eev.GraduationSchool
|
|
leaExpInfo.Subject = eev.Subject
|
|
admissionTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", eev.AdmissionTime))
|
|
leaExpInfo.AdmissionTime = admissionTime
|
|
graduationTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", eev.GraduationTime))
|
|
leaExpInfo.GraduationTime = graduationTime
|
|
leaExpInfo.Time = time.Now().Unix()
|
|
if eei == 0 {
|
|
leaExpInfo.Level = 2
|
|
}
|
|
leaExp = append(leaExp, leaExpInfo)
|
|
}
|
|
//设定最高学历
|
|
if len(leaExp) > 1 {
|
|
for mei, maxEdv := range leaExp {
|
|
if maxEdv.Education != 2 && maxEdv.Education == maxLevel {
|
|
leaExp[mei].Level = 3
|
|
}
|
|
}
|
|
}
|
|
if len(leaExp) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&leaExp)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 紧急联系人
|
|
func emeContact(manKeyNum int64, number string, contAry []emergencyContact) {
|
|
defer synPro.Done()
|
|
|
|
var emerContList []models.EmergencyContact
|
|
emerContErr := overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&emerContList).Error
|
|
if emerContErr == nil {
|
|
var eidtIint []int
|
|
for i, v := range contAry {
|
|
for _, emv := range emerContList {
|
|
if v.Name == emv.Name {
|
|
eidtIint = append(eidtIint, i)
|
|
saveData := overallhandle.MapOut()
|
|
if v.Relationship != "" && v.Relationship != emv.Relationship {
|
|
saveData["relationship"] = v.Relationship
|
|
}
|
|
if v.Mobilephone != "" && v.Mobilephone != emv.Tel {
|
|
saveData["tel"] = v.Mobilephone
|
|
}
|
|
if emv.State != 1 {
|
|
saveData["state"] = 1
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["time"] = time.Now().Unix()
|
|
var eidtEmerData models.EmergencyContact
|
|
eidtEmerData.EiteCont(map[string]interface{}{"`id`": emv.Id}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(eidtIint) < len(contAry) {
|
|
var emerContAry []models.EmergencyContact
|
|
for ci, cv := range contAry {
|
|
if overallhandle.IsInTrue[int](ci, eidtIint) == false {
|
|
var emerInfo models.EmergencyContact
|
|
emerInfo.Key = manKeyNum
|
|
emerInfo.Number = number
|
|
emerInfo.Name = cv.Name
|
|
emerInfo.Relationship = cv.Relationship
|
|
emerInfo.Tel = cv.Mobilephone
|
|
emerInfo.Time = time.Now().Unix()
|
|
emerInfo.State = 1
|
|
emerContAry = append(emerContAry, emerInfo)
|
|
}
|
|
}
|
|
if len(emerContAry) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&emerContAry)
|
|
}
|
|
}
|
|
} else {
|
|
var emerContAry []models.EmergencyContact
|
|
for _, emev := range contAry {
|
|
var emerInfo models.EmergencyContact
|
|
emerInfo.Key = manKeyNum
|
|
emerInfo.Number = number
|
|
emerInfo.Name = emev.Name
|
|
emerInfo.Relationship = emev.Relationship
|
|
emerInfo.Tel = emev.Mobilephone
|
|
emerInfo.Time = time.Now().Unix()
|
|
emerInfo.State = 1
|
|
emerContAry = append(emerContAry, emerInfo)
|
|
}
|
|
if len(emerContAry) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&emerContAry)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 家庭成员
|
|
func familyPeople(manKeyNum int64, number string, contAry []memberOfFamily) {
|
|
defer synPro.Done()
|
|
var familyList []models.FamilyMembers
|
|
fllErr := overall.CONSTANT_DB_HR.Where("key = ?", manKeyNum).Find(&familyList).Error
|
|
if fllErr == nil {
|
|
var eidtIint []int
|
|
for i, v := range contAry {
|
|
for _, fv := range familyList {
|
|
if v.Name == fv.Name {
|
|
eidtIint = append(eidtIint, i)
|
|
saveData := overallhandle.MapOut()
|
|
if v.Relationship != "" && v.Relationship != fv.Relationship {
|
|
saveData["relation"] = v.Relationship
|
|
}
|
|
if v.Mobilephone != "" && v.Mobilephone != fv.Tel {
|
|
saveData["tel"] = v.Mobilephone
|
|
}
|
|
if v.Company != "" && v.Company != fv.Company {
|
|
saveData["company"] = v.Company
|
|
}
|
|
if v.Department != "" && v.Department != fv.Deparment {
|
|
saveData["deparment"] = v.Department
|
|
}
|
|
if v.Position != "" && v.Position != fv.Postnme {
|
|
saveData["postnme"] = v.Position
|
|
}
|
|
if v.PoliticalOutlook != 0 && v.PoliticalOutlook != fv.PoliticalOutlook {
|
|
saveData["political_outlook"] = v.PoliticalOutlook
|
|
}
|
|
if fv.State != 1 {
|
|
saveData["state"] = 1
|
|
}
|
|
if len(saveData) > 0 {
|
|
var eidtContInfo models.FamilyMembers
|
|
eidtContInfo.EiteCont(map[string]interface{}{"`id`": fv.Id}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(eidtIint) < len(contAry) {
|
|
var familyAry []models.FamilyMembers
|
|
for ci, cv := range contAry {
|
|
if overallhandle.IsInTrue[int](ci, eidtIint) == false {
|
|
var familyInfo models.FamilyMembers
|
|
familyInfo.Key = manKeyNum
|
|
familyInfo.Number = number
|
|
familyInfo.Relationship = cv.Relationship
|
|
familyInfo.Name = cv.Name
|
|
familyInfo.Company = cv.Company
|
|
familyInfo.Deparment = cv.Department
|
|
familyInfo.Postnme = cv.Position
|
|
familyInfo.Tel = cv.Mobilephone
|
|
familyInfo.PoliticalOutlook = cv.PoliticalOutlook
|
|
familyInfo.Time = time.Now().Unix()
|
|
familyAry = append(familyAry, familyInfo)
|
|
}
|
|
}
|
|
if len(familyAry) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&familyAry)
|
|
}
|
|
}
|
|
} else {
|
|
var familyAry []models.FamilyMembers
|
|
for _, fv := range contAry {
|
|
var familyInfo models.FamilyMembers
|
|
familyInfo.Key = manKeyNum
|
|
familyInfo.Number = number
|
|
familyInfo.Relationship = fv.Relationship
|
|
familyInfo.Name = fv.Name
|
|
familyInfo.Company = fv.Company
|
|
familyInfo.Deparment = fv.Department
|
|
familyInfo.Postnme = fv.Position
|
|
familyInfo.Tel = fv.Mobilephone
|
|
familyInfo.PoliticalOutlook = fv.PoliticalOutlook
|
|
familyInfo.Time = time.Now().Unix()
|
|
familyAry = append(familyAry, familyInfo)
|
|
}
|
|
if len(familyAry) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&familyAry)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// 分配权限
|
|
func (s *StaffApi) AllocationOfRights(c *gin.Context) {
|
|
var requestData allocationOfRightsToRole
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
overallhandle.Result(1, requestData.Id, c, "数据格式错误!")
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
overallhandle.Result(1, requestData.Id, c, "ID不能为空!")
|
|
return
|
|
}
|
|
if requestData.RoleId == "" {
|
|
overallhandle.Result(1, requestData.RoleId, c, "请选择角色!")
|
|
return
|
|
}
|
|
var setUserRole models.Personnel
|
|
judgeIsTrueWhere := overallhandle.MapOut()
|
|
judgeIsTrueWhere["id"] = requestData.Id
|
|
getUserErr := setUserRole.GetCont(judgeIsTrueWhere, "role")
|
|
if getUserErr != nil {
|
|
overallhandle.Result(105, getUserErr, c)
|
|
return
|
|
}
|
|
if setUserRole.Role != "" {
|
|
roleAry := strings.Split(setUserRole.Role, ",")
|
|
|
|
if overallhandle.StringIsInMap(requestData.RoleId, roleAry) == false {
|
|
roleAry = append(roleAry, requestData.RoleId)
|
|
saveData := overallhandle.MapOut()
|
|
saveData["eite_time"] = time.Now().Unix()
|
|
saveData["role"] = strings.Join(roleAry, ",")
|
|
saveErr := setUserRole.EiteCont(judgeIsTrueWhere, saveData)
|
|
if saveErr != nil {
|
|
overallhandle.Result(106, saveErr, c)
|
|
return
|
|
}
|
|
overallhandle.Result(0, setUserRole, c)
|
|
} else {
|
|
overallhandle.Result(0, setUserRole, c)
|
|
}
|
|
} else {
|
|
saveData := overallhandle.MapOut()
|
|
saveData["eite_time"] = time.Now().Unix()
|
|
saveData["role"] = requestData.RoleId
|
|
saveErr := setUserRole.EiteCont(judgeIsTrueWhere, saveData)
|
|
if saveErr != nil {
|
|
overallhandle.Result(106, saveErr, c)
|
|
return
|
|
}
|
|
overallhandle.Result(0, setUserRole, c)
|
|
}
|
|
}
|
|
|
|
// 工作履历
|
|
func workHistoryLog(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, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", wvs.EntryTime))
|
|
if entryData != whCont.EntryTime {
|
|
saveDate["entry_time"] = entryData
|
|
}
|
|
}
|
|
if wvs.LeaveDate != "" { //离职日期"`
|
|
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 != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", wvs.EntryTime))
|
|
}
|
|
addWorkCont.EntryTime = entryData //入职时间"`
|
|
leaveTime := time.Now().Unix()
|
|
if wvs.LeaveDate != "" {
|
|
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 != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 12:00:00", v.EntryTime))
|
|
}
|
|
addWorkCont.EntryTime = entryData //入职时间"`
|
|
leaveTime := time.Now().Unix()
|
|
if v.LeaveDate != "" {
|
|
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 (s *StaffApi) EidtStaffCont(c *gin.Context) {
|
|
var requestData eitePersonnel
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Id == "" {
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
return
|
|
}
|
|
var staffCont models.PersonArchives
|
|
err := staffCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`key`", "`number`")
|
|
if err != nil {
|
|
overallhandle.Result(105, err, c)
|
|
return
|
|
}
|
|
saveData := overallhandle.MapOut()
|
|
if requestData.Name != "" {
|
|
saveData["name"] = requestData.Name
|
|
}
|
|
if requestData.Icon != "" {
|
|
saveData["icon"] = requestData.Icon
|
|
}
|
|
if requestData.HireType != 0 {
|
|
saveData["hire_class"] = requestData.HireType
|
|
}
|
|
if requestData.EmpType != 0 {
|
|
saveData["emp_type"] = requestData.EmpType
|
|
}
|
|
if requestData.Company != 0 {
|
|
saveData["company"] = requestData.Company
|
|
}
|
|
if requestData.MainDepartment != 0 {
|
|
saveData["maindeparment"] = requestData.MainDepartment
|
|
}
|
|
if len(requestData.Department) > 0 {
|
|
mainDepart := strconv.FormatInt(requestData.MainDepartment, 10)
|
|
if overallhandle.IsInTrue[string](mainDepart, requestData.Department) == false {
|
|
requestData.Department = append(requestData.Department, mainDepart)
|
|
}
|
|
saveData["deparment"] = strings.Join(requestData.Department, ",")
|
|
}
|
|
if requestData.AdminOrg != 0 {
|
|
saveData["admin_org"] = requestData.AdminOrg
|
|
}
|
|
if requestData.Position != 0 {
|
|
saveData["position"] = requestData.Position
|
|
}
|
|
// if requestData.Iisdoubleworker != 0 {
|
|
// saveData["job_id"] = requestData.Iisdoubleworker
|
|
// }
|
|
|
|
//获取职务信息
|
|
var postDuitesCont models.PostDutiesJob
|
|
jobErr := postDuitesCont.GetCont(map[string]interface{}{"id": requestData.Position}, "duties")
|
|
// jobCont, jobErr := getJobInfo(requestData.Position)
|
|
if jobErr == nil {
|
|
saveData["job_id"] = postDuitesCont.Duties
|
|
saveData["job_class"] = postDuitesCont.JobType
|
|
}
|
|
if requestData.PositionGrade != 0 {
|
|
saveData["job_leve"] = requestData.PositionGrade
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["eite_time"] = time.Now().Unix()
|
|
saveErr := staffCont.EiteCont(map[string]interface{}{"`id`": staffCont.Id}, saveData)
|
|
if saveErr == nil {
|
|
//员工档案附表
|
|
staffInfoContEidt(staffCont.Key, staffCont.Number, requestData)
|
|
overallhandle.Result(0, saveErr, c)
|
|
} else {
|
|
overallhandle.Result(106, saveErr, c)
|
|
}
|
|
} else {
|
|
overallhandle.Result(0, err, c)
|
|
}
|
|
|
|
}
|
|
|
|
// 员工档案详情
|
|
func staffInfoContEidt(manKeyNum int64, num string, contData eitePersonnel) {
|
|
|
|
var staffAttribute models.PersonnelContent
|
|
contErr := staffAttribute.GetCont(map[string]interface{}{"`key`": manKeyNum})
|
|
if contErr == nil {
|
|
saveData := overallhandle.MapOut()
|
|
if contData.Passportno != "" && contData.Passportno != staffAttribute.Passportno {
|
|
saveData["passportno"] = contData.Passportno
|
|
}
|
|
if contData.Globalroaming != "" && contData.Globalroaming != staffAttribute.Globalroaming {
|
|
saveData["globalroaming"] = contData.Globalroaming
|
|
}
|
|
if contData.IDCardNo != "" && contData.IDCardNo != staffAttribute.Idcardno {
|
|
saveData["idcardno"] = contData.IDCardNo
|
|
}
|
|
if contData.IDCardStartTime != "" {
|
|
idCardStarTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardStartTime))
|
|
if idCardStarTime != staffAttribute.Idcardstartdate {
|
|
saveData["idcardstartdate"] = idCardStarTime
|
|
}
|
|
}
|
|
if contData.IDCardEndTime != "" {
|
|
idCardEndTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardEndTime))
|
|
if idCardEndTime != staffAttribute.Idcardenddate {
|
|
saveData["idcardenddate"] = idCardEndTime
|
|
}
|
|
}
|
|
if contData.IDCardAddress != "" && contData.IDCardAddress != staffAttribute.Idcardaddress {
|
|
saveData["idcardaddress"] = contData.IDCardAddress
|
|
}
|
|
if contData.IDCardIsSued != "" && contData.IDCardIsSued != staffAttribute.IdcardIssued {
|
|
saveData["idcardIssued"] = contData.IDCardIsSued
|
|
}
|
|
if contData.Mobilephone != "" && contData.Mobilephone != staffAttribute.Mobilephone {
|
|
saveData["mobilephone"] = contData.Mobilephone
|
|
}
|
|
if contData.Email != "" && contData.Email != staffAttribute.Email {
|
|
saveData["email"] = contData.Email
|
|
}
|
|
if contData.Gender != 0 && contData.Gender != staffAttribute.Gender {
|
|
saveData["gender"] = contData.Gender
|
|
}
|
|
if contData.Birthday != "" {
|
|
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.Birthday))
|
|
if brrthday != staffAttribute.Birthday {
|
|
saveData["birthday"] = brrthday
|
|
}
|
|
}
|
|
if contData.Nation != "" && contData.Nation != staffAttribute.Myfolk {
|
|
saveData["myfolk"] = contData.Nation
|
|
}
|
|
if contData.NativePlace != "" && contData.NativePlace != staffAttribute.Nativeplace {
|
|
saveData["nativeplace"] = contData.NativePlace
|
|
}
|
|
if contData.Health != 0 && contData.Health != staffAttribute.Health {
|
|
saveData["health"] = contData.Health
|
|
}
|
|
if contData.Maritalstatus != 0 && contData.Maritalstatus != staffAttribute.Maritalstatus {
|
|
saveData["maritalstatus"] = contData.Maritalstatus
|
|
}
|
|
if contData.CurrentResidence != "" && contData.CurrentResidence != staffAttribute.Currentresidence {
|
|
saveData["currentresidence"] = contData.CurrentResidence
|
|
}
|
|
if contData.Constellation != 0 && contData.Constellation != staffAttribute.Constellation {
|
|
saveData["constellationing"] = contData.Constellation
|
|
}
|
|
if contData.Iisdoubleworker != 0 && contData.Iisdoubleworker != staffAttribute.Isdoubleworker {
|
|
saveData["isdoubleworker"] = contData.Iisdoubleworker
|
|
// eidtDoubleWorker(contData, contData.Iisdoubleworker)
|
|
doubleWorkerStaffNoXiecheng(manKeyNum, staffAttribute.Number, contData.DoubleWorkerList)
|
|
}
|
|
if contData.Isveterans != 0 && contData.Isveterans != staffAttribute.Isveterans {
|
|
saveData["isveterans"] = contData.Isveterans
|
|
if contData.Isveterans == 1 {
|
|
if contData.Veteransnumber != "" && contData.Veteransnumber != staffAttribute.Veteransnumber {
|
|
saveData["veteransnumber"] = contData.Veteransnumber
|
|
}
|
|
} else {
|
|
saveData["veteransnumber"] = ""
|
|
}
|
|
}
|
|
if contData.WorkingDate != "" {
|
|
workInData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.WorkingDate))
|
|
if workInData != staffAttribute.Jobstartdate {
|
|
saveData["jobstartdate"] = workInData
|
|
}
|
|
}
|
|
if contData.EntryDate != "" {
|
|
entryData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
|
|
if entryData != staffAttribute.Entrydate {
|
|
saveData["entrydate"] = entryData
|
|
}
|
|
}
|
|
if contData.ProbationPeriod != 0 && contData.ProbationPeriod != staffAttribute.Probationperiod {
|
|
saveData["probationperiod"] = contData.ProbationPeriod
|
|
entryData := staffAttribute.Entrydate
|
|
if contData.EntryDate != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
|
|
}
|
|
planformalData := overallhandle.GetFutureMonthTime(entryData, contData.ProbationPeriod, 2)
|
|
saveData["planformaldate"] = planformalData
|
|
}
|
|
|
|
if contData.ConfirmationDate != "" {
|
|
planformalData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.ConfirmationDate))
|
|
saveData["planformaldate"] = planformalData
|
|
}
|
|
if contData.PoliticalOutlook != 0 && contData.PoliticalOutlook != staffAttribute.PoliticalOutlook {
|
|
saveData["political_outlook"] = contData.PoliticalOutlook
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`time`"] = time.Now().Unix()
|
|
staffAttribute.EiteCont(map[string]interface{}{"`key`": staffAttribute.Key}, saveData)
|
|
}
|
|
} else {
|
|
staffAttribute.Key = manKeyNum
|
|
staffAttribute.Number = num
|
|
staffAttribute.Passportno = contData.Passportno
|
|
staffAttribute.Globalroaming = contData.Globalroaming
|
|
staffAttribute.Idcardno = contData.IDCardNo
|
|
staffAttribute.Mobilephone = contData.Mobilephone
|
|
staffAttribute.Email = contData.Email
|
|
staffAttribute.Gender = contData.Gender
|
|
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.Birthday))
|
|
staffAttribute.Birthday = brrthday
|
|
staffAttribute.Myfolk = contData.Nation
|
|
staffAttribute.Nativeplace = contData.NativePlace
|
|
|
|
idCardStarTime := time.Now().Unix()
|
|
if contData.IDCardStartTime != "" {
|
|
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardStartTime))
|
|
}
|
|
staffAttribute.Idcardstartdate = idCardStarTime //身份证有效期开始
|
|
idCardEndTime := time.Now().Unix()
|
|
if contData.IDCardEndTime != "" {
|
|
idCardEndTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.IDCardEndTime))
|
|
}
|
|
staffAttribute.Idcardenddate = idCardEndTime //身份证有效期结束
|
|
staffAttribute.Idcardaddress = contData.IDCardAddress //身份证地址
|
|
staffAttribute.IdcardIssued = contData.IDCardIsSued //身份证签发机关
|
|
staffAttribute.Health = contData.Health
|
|
staffAttribute.Maritalstatus = contData.Maritalstatus
|
|
staffAttribute.Internaltelephone = ""
|
|
staffAttribute.Currentresidence = contData.CurrentResidence
|
|
staffAttribute.Time = time.Now().Unix()
|
|
staffAttribute.Constellation = contData.Constellation
|
|
staffAttribute.Isdoubleworker = contData.Iisdoubleworker
|
|
staffAttribute.Isveterans = contData.Isveterans
|
|
staffAttribute.Veteransnumber = contData.Veteransnumber
|
|
workInData := time.Now().Unix()
|
|
if contData.WorkingDate != "" {
|
|
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.WorkingDate))
|
|
}
|
|
staffAttribute.Jobstartdate = workInData
|
|
entryData := time.Now().Unix()
|
|
if contData.EntryDate != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.EntryDate))
|
|
}
|
|
staffAttribute.Entrydate = entryData
|
|
staffAttribute.Probationperiod = contData.ProbationPeriod
|
|
planformalData := time.Now().Unix()
|
|
if contData.ConfirmationDate != "" {
|
|
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", contData.ConfirmationDate))
|
|
} else {
|
|
planformalData = overallhandle.GetFutureMonthTime(entryData, contData.ProbationPeriod, 2)
|
|
}
|
|
staffAttribute.Planformaldate = planformalData
|
|
staffAttribute.PoliticalOutlook = contData.PoliticalOutlook
|
|
|
|
overall.CONSTANT_DB_HR.Create(&staffAttribute)
|
|
}
|
|
|
|
}
|
|
|
|
// 双职工
|
|
func doubleWorkerStaffNoXiecheng(manKeyNum int64, numStr string, dobleMan []DoubleWorkerInFo) {
|
|
|
|
var dwManAry []models.DoubleWorker
|
|
dwManAryErr := overall.CONSTANT_DB_HR.Where("`key` = ?", manKeyNum).Find(&dwManAry).Error
|
|
if dwManAryErr == nil {
|
|
var eidtIint []int
|
|
for i, v := range dobleMan {
|
|
var dwManInfo models.DoubleWorker
|
|
dwInFoErr := dwManInfo.GetCont(map[string]interface{}{"`key`": manKeyNum, "`name`": v.Name})
|
|
if dwInFoErr == nil {
|
|
eidtIint = append(eidtIint, i)
|
|
saveData := overallhandle.MapOut()
|
|
if v.Company != "" && v.Company != dwManInfo.Company {
|
|
saveData["company"] = v.Company
|
|
}
|
|
if v.Department != "" && v.Department != dwManInfo.Department {
|
|
saveData["department"] = v.Department
|
|
}
|
|
if v.Position != "" && v.Position != dwManInfo.Position {
|
|
saveData["position"] = v.Position
|
|
}
|
|
if v.Mobilephone != "" && v.Mobilephone != dwManInfo.Tel {
|
|
saveData["tel"] = v.Mobilephone
|
|
}
|
|
if dwManInfo.State != 1 {
|
|
saveData["state"] = 1
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`time`"] = time.Now().Unix()
|
|
dwManInfo.EiteCont(map[string]interface{}{"`id`": dwManInfo.Id}, saveData)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
var doublePeopleInset []models.DoubleWorker
|
|
if len(dobleMan) > 0 {
|
|
for _, v := range dobleMan {
|
|
var doublePeople models.DoubleWorker
|
|
doublePeople.Key = manKeyNum
|
|
doublePeople.Number = numStr
|
|
doublePeople.Name = v.Name
|
|
doublePeople.Company = v.Company
|
|
doublePeople.Department = v.Department
|
|
doublePeople.Position = v.Position
|
|
doublePeople.Tel = v.Mobilephone
|
|
doublePeople.Time = time.Now().Unix()
|
|
|
|
doublePeopleInset = append(doublePeopleInset, doublePeople)
|
|
}
|
|
}
|
|
if len(doublePeopleInset) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&doublePeopleInset)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
func workInsideHistoryLog(manKeyNum int64, num string, workHistoryList []insideHistoryerMy) {
|
|
defer synPro.Done()
|
|
if len(workHistoryList) > 0 && manKeyNum != 0 {
|
|
var insetConr []models.InsideWorkHistory
|
|
for _, v := range workHistoryList {
|
|
var insetInfor models.InsideWorkHistory
|
|
orgIdInt, _ := strconv.ParseInt(v.OrgId, 10, 64)
|
|
groupId, companyId, departmentId, sunDepartId, workShopId := overallhandle.GetOrgStructure(orgIdInt)
|
|
|
|
insetInfor.Group = groupId
|
|
insetInfor.Company = companyId
|
|
insetInfor.Department = departmentId
|
|
insetInfor.WorkShop = sunDepartId
|
|
insetInfor.WorkshopSection = workShopId
|
|
positionIdInt, _ := strconv.ParseInt(v.Position, 10, 64)
|
|
insetInfor.Position = positionIdInt
|
|
insetInfor.GradePositions = v.GradePositions
|
|
startTimeInt, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.StartTime))
|
|
insetInfor.StartTime = startTimeInt
|
|
if v.EndTime != "" {
|
|
endTimeInt, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EndTime))
|
|
insetInfor.EndTime = endTimeInt
|
|
}
|
|
|
|
teamIdInt, _ := strconv.ParseInt(v.Team, 10, 64)
|
|
insetInfor.Team = teamIdInt
|
|
insetInfor.ChangeType = v.ChangeType
|
|
insetInfor.AssignType = v.AssignType
|
|
insetInfor.Time = time.Now().Unix()
|
|
insetInfor.State = 1
|
|
insetConr = append(insetConr, insetInfor)
|
|
}
|
|
if len(insetConr) > 0 {
|
|
overall.CONSTANT_DB_HR.Create(&insetConr)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 修改密码
|
|
func (s *StaffApi) EditPassWord(c *gin.Context) {
|
|
var requestData editPws
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
overallhandle.Result(1, err, c, "数据格式不正确!")
|
|
return
|
|
}
|
|
if requestData.Id == "" {
|
|
overallhandle.Result(1, err, c, "未知用户ID")
|
|
return
|
|
}
|
|
if requestData.Pwd == "" {
|
|
overallhandle.Result(1, err, c, "请输入密码!")
|
|
return
|
|
}
|
|
if requestData.Pwdes == "" {
|
|
overallhandle.Result(1, err, c, "请确认密码")
|
|
return
|
|
}
|
|
if requestData.Pwd != requestData.Pwdes {
|
|
overallhandle.Result(1, err, c, "您两次输入的密码不一致!")
|
|
return
|
|
}
|
|
//员工档案主
|
|
var staffInfo models.PersonArchives
|
|
//判断工号是存在
|
|
whereAry := overallhandle.MapOut()
|
|
whereAry["`key`"] = requestData.Id
|
|
if judgeNoErr := staffInfo.GetCont(whereAry, "`key`"); judgeNoErr != nil {
|
|
overallhandle.Result(107, requestData, c)
|
|
return
|
|
}
|
|
//密码加密
|
|
var passwordMd5 overallhandle.Md5Encryption
|
|
passwordMd5.Md5EncryptionInit(requestData.Pwdes)
|
|
passwordMd5Str := passwordMd5.Md5EncryptionAlgorithm()
|
|
saveDate := overallhandle.MapOut()
|
|
saveDate["`password`"] = passwordMd5Str
|
|
saveDate["`eite_time`"] = time.Now().Unix()
|
|
err = staffInfo.EiteCont(whereAry, saveDate)
|
|
if err != nil {
|
|
overallhandle.Result(1, err, c, "修改失败!")
|
|
return
|
|
}
|
|
overallhandle.Result(0, err, c, "修改成功!")
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-11-26 13:36:23
|
|
@ 功能: 添加员工信息
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (s *StaffApi) AddPeopleCont(c *gin.Context) {
|
|
var requestData AddNewPeopleCont
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.Number == "" {
|
|
overallhandle.Result(1, requestData.Number, c, "工号不能为空!")
|
|
return
|
|
}
|
|
if requestData.Name == "" {
|
|
overallhandle.Result(1, requestData.Name, c, "姓名不能为空!")
|
|
return
|
|
}
|
|
if requestData.Icon == "" {
|
|
overallhandle.Result(1, requestData.Name, c, "请上传员工照片")
|
|
return
|
|
}
|
|
if requestData.Gender == 0 {
|
|
requestData.Gender = 1
|
|
}
|
|
if requestData.HireType == 0 {
|
|
requestData.HireType = 1
|
|
}
|
|
if requestData.EmpType == 0 {
|
|
requestData.HireType = 3
|
|
}
|
|
if requestData.AdminOrg == 0 {
|
|
overallhandle.Result(1, requestData.AdminOrg, c, "请选择员工归属行政组织!")
|
|
return
|
|
}
|
|
if requestData.Position == 0 {
|
|
overallhandle.Result(1, requestData.Position, c, "请选择人员职务!")
|
|
return
|
|
}
|
|
if requestData.TeamId == 0 {
|
|
overallhandle.Result(1, requestData.TeamId, c, "请选择人员归属班组!")
|
|
return
|
|
}
|
|
if requestData.PositionGrade == 0 {
|
|
requestData.PositionGrade = 3
|
|
return
|
|
}
|
|
if requestData.Mobilephone == "" {
|
|
overallhandle.Result(1, requestData.Mobilephone, c, "请输入人员手机号!")
|
|
return
|
|
}
|
|
if requestData.Health == 0 {
|
|
requestData.Health = 2
|
|
return
|
|
}
|
|
if requestData.EntryDate == "" {
|
|
overallhandle.Result(1, requestData.EntryDate, c, "请输入人员入职日期!")
|
|
return
|
|
}
|
|
if requestData.ProbationPeriod == 0 {
|
|
requestData.ProbationPeriod = 3
|
|
return
|
|
}
|
|
if requestData.IDCardNo == "" {
|
|
overallhandle.Result(1, requestData.IDCardNo, c, "请输入员工身份证号码!")
|
|
return
|
|
}
|
|
if requestData.PoliticalOutlook == 0 {
|
|
requestData.PoliticalOutlook = 1 //政治面貌
|
|
}
|
|
if requestData.HireType == 0 {
|
|
requestData.HireType = 1
|
|
}
|
|
// if requestData.JobId == 0 {
|
|
// requestData.JobId = 1
|
|
// }
|
|
if requestData.Maritalstatus == 0 {
|
|
requestData.Maritalstatus = 1
|
|
}
|
|
if requestData.Constellation == 0 {
|
|
requestData.Constellation = 1
|
|
}
|
|
if requestData.Isveterans == 0 {
|
|
requestData.Isveterans = 2
|
|
}
|
|
|
|
//员工档案主
|
|
var staffInfo models.PersonArchives
|
|
//判断工号是存在
|
|
whereAry := overallhandle.MapOut()
|
|
whereAry["number"] = requestData.Number
|
|
if judgeNoErr := staffInfo.GetCont(whereAry, "number"); judgeNoErr == nil {
|
|
overallhandle.Result(1, requestData, c, "该工号已经被使用!请不要重复使用!")
|
|
return
|
|
}
|
|
|
|
isMeKey := overallhandle.OnlyOneNumber(3) //获取唯一编号
|
|
|
|
setTime := time.Now().Unix()
|
|
staffInfo.Number = requestData.Number
|
|
staffInfo.Name = requestData.Name
|
|
staffInfo.Icon = requestData.Icon
|
|
staffInfo.HireClass = requestData.HireType
|
|
staffInfo.EmpType = requestData.EmpType
|
|
//获取相关行政组织
|
|
_, companyId, departmentId, sunDepartId, _ := overallhandle.GetOrgStructure(requestData.AdminOrg)
|
|
staffInfo.Company = companyId //公司
|
|
staffInfo.MainDeparment = departmentId //主部门
|
|
staffInfo.SunMainDeparment = sunDepartId //二级部门
|
|
staffInfo.AdminOrg = requestData.AdminOrg //行政组织
|
|
staffInfo.TeamId = requestData.TeamId //班组
|
|
staffInfo.Position = requestData.Position
|
|
//获取职务及职务分类
|
|
if requestData.JobId == 0 {
|
|
var postDuitesCont models.PostDutiesJob
|
|
postDuitesCont.GetCont(map[string]interface{}{"id": requestData.Position}, "`duties`", "`job_type`")
|
|
staffInfo.JobClass = postDuitesCont.JobType
|
|
staffInfo.JobId = postDuitesCont.Duties
|
|
} else {
|
|
var dutiesCont models.Duties
|
|
dutiesCont.GetCont(map[string]interface{}{"id": requestData.JobId}, "`job_type`")
|
|
staffInfo.JobClass = dutiesCont.JobType
|
|
staffInfo.JobId = requestData.JobId
|
|
}
|
|
staffInfo.JobLeve = requestData.PositionGrade //入职等级
|
|
staffInfo.Time = setTime
|
|
staffInfo.EiteTime = setTime
|
|
staffInfo.State = 1
|
|
staffInfo.Key = isMeKey
|
|
staffInfo.WorkWechat = requestData.WeorWechat
|
|
|
|
//员工资料副表
|
|
var peopleContEs models.PersonnelContent
|
|
|
|
peopleContEs.Key = isMeKey
|
|
peopleContEs.Number = requestData.Number
|
|
peopleContEs.Passportno = requestData.Passportno
|
|
peopleContEs.Globalroaming = requestData.Globalroaming
|
|
peopleContEs.Idcardno = requestData.IDCardNo
|
|
peopleContEs.Mobilephone = requestData.Mobilephone
|
|
peopleContEs.Gender = requestData.Gender
|
|
brrthday, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.Birthday))
|
|
peopleContEs.Birthday = brrthday
|
|
peopleContEs.Myfolk = requestData.Nation
|
|
peopleContEs.Nativeplace = requestData.NativePlace
|
|
|
|
idCardStarTime := time.Now().Unix()
|
|
if requestData.IdCardStartDate != "" {
|
|
idCardStarTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.IdCardStartDate))
|
|
}
|
|
peopleContEs.Idcardstartdate = idCardStarTime //身份证有效期开始
|
|
idCardEndTime := time.Now().Unix()
|
|
if requestData.IdCardEndDate != "" {
|
|
idCardEndTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.IdCardEndDate))
|
|
}
|
|
peopleContEs.Idcardenddate = idCardEndTime //身份证有效期结束
|
|
|
|
peopleContEs.Health = requestData.Health
|
|
peopleContEs.Maritalstatus = requestData.Maritalstatus
|
|
peopleContEs.Internaltelephone = ""
|
|
peopleContEs.Currentresidence = requestData.CurrentResidence
|
|
peopleContEs.Time = setTime
|
|
peopleContEs.Constellation = requestData.Constellation
|
|
peopleContEs.Isveterans = requestData.Isveterans
|
|
peopleContEs.Veteransnumber = requestData.Veteransnumber
|
|
|
|
workInData := setTime
|
|
if requestData.WorkingDate != "" {
|
|
workInData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.WorkingDate))
|
|
}
|
|
peopleContEs.Jobstartdate = workInData
|
|
entryData := setTime
|
|
if requestData.EntryDate != "" {
|
|
entryData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EntryDate))
|
|
}
|
|
peopleContEs.Entrydate = entryData
|
|
peopleContEs.Probationperiod = requestData.ProbationPeriod
|
|
planformalData := setTime
|
|
if requestData.ConfirmationDate != "" {
|
|
planformalData, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.ConfirmationDate))
|
|
} else {
|
|
planformalData = overallhandle.GetFutureMonthTime(entryData, requestData.ProbationPeriod, 2)
|
|
}
|
|
peopleContEs.Planformaldate = planformalData
|
|
peopleContEs.PoliticalOutlook = requestData.PoliticalOutlook
|
|
|
|
//开启事务
|
|
gromDbBeginAffair := overall.CONSTANT_DB_HR.Begin()
|
|
gromDbBeginAffair.SavePoint("CallBackBegin")
|
|
mainPeopenContErr := gromDbBeginAffair.Create(&staffInfo).Error
|
|
mainPeopenContEsErr := gromDbBeginAffair.Create(&peopleContEs).Error
|
|
fmt.Printf("开启事务%v----------%v\n", mainPeopenContErr, mainPeopenContEsErr)
|
|
if mainPeopenContErr == nil && mainPeopenContEsErr == nil {
|
|
addErr := gromDbBeginAffair.Commit().Error
|
|
overallhandle.Result(0, addErr, c)
|
|
} else {
|
|
gromDbBeginAffair.RollbackTo("CallBackBegin")
|
|
addErr := gromDbBeginAffair.Rollback().Error
|
|
overallhandle.Result(104, addErr, c)
|
|
}
|
|
// addErr := overall.CONSTANT_DB_HR.Transaction(func(tx *gorm.DB) error {
|
|
// mainPeopenContErr := tx.Create(&staffInfo).Error
|
|
// if mainPeopenContErr != nil {
|
|
// return mainPeopenContErr
|
|
// }
|
|
// mainPeopenContEsErr := tx.Create(&peopleContEs).Error
|
|
// if mainPeopenContEsErr != nil {
|
|
// return mainPeopenContEsErr
|
|
// }
|
|
// return nil
|
|
// })
|
|
// if addErr != nil {
|
|
// overallhandle.Result(104, addErr, c)
|
|
// } else {
|
|
// overallhandle.Result(0, addErr, c)
|
|
// }
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2022-11-30 09:29:27
|
|
@ 功能: 计算资料完整度
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (s *StaffApi) GetPeopleDataIntegrity(c *gin.Context) {
|
|
var requestData overallhandle.GetId
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.IdStr == "" && requestData.Id == 0 {
|
|
overallhandle.Result(101, requestData, c)
|
|
return
|
|
}
|
|
if requestData.IdStr != "" {
|
|
idInt, idErr := strconv.ParseInt(requestData.IdStr, 10, 64)
|
|
if idErr == nil {
|
|
requestData.Id = idInt
|
|
}
|
|
}
|
|
|
|
var scoreVal float64
|
|
|
|
//计算主表
|
|
var mainTable models.PersonArchives
|
|
err := mainTable.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
wher := map[string]interface{}{"`key`": mainTable.Key}
|
|
if err == nil {
|
|
var mainScore float64
|
|
if mainTable.Number != "" {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.Name != "" {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.Icon != "" {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.HireClass != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.EmpType != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.AdminOrg != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.Position != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.JobId != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.JobClass != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.JobLeve != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.Wechat != "" || mainTable.WorkWechat != "" {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainTable.TeamId != 0 {
|
|
mainScore = mainScore + 1
|
|
}
|
|
if mainScore == 12 {
|
|
scoreVal = scoreVal + 30
|
|
} else {
|
|
scoreVal = scoreVal + (mainScore/12)*30
|
|
fmt.Printf("main----121--->%v-------->%v\n", mainScore, mainScore/12)
|
|
|
|
}
|
|
fmt.Printf("main----12--->%v-------->%v\n", mainScore, scoreVal)
|
|
}
|
|
|
|
//人员补充资料
|
|
var manContTable models.PersonnelContent
|
|
err = manContTable.GetCont(wher)
|
|
if err == nil {
|
|
var mainScoreEs float64
|
|
if manContTable.Idcardno != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Mobilephone != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Email != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Gender != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Birthday != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Myfolk != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Nativeplace != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Idcardstartdate != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Idcardenddate != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Idcardaddress != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.IdcardIssued != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Health != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Maritalstatus != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Currentresidence != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Constellation != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
|
|
if manContTable.Isveterans == 1 {
|
|
if manContTable.Veteransnumber != "" {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
}
|
|
if manContTable.Jobstartdate != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Entrydate != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Probationperiod != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.Planformaldate != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if manContTable.PoliticalOutlook != 0 {
|
|
mainScoreEs = mainScoreEs + 1
|
|
}
|
|
if mainScoreEs == 21 {
|
|
scoreVal = scoreVal + 30
|
|
} else {
|
|
scoreVal = scoreVal + (mainScoreEs/21)*30
|
|
}
|
|
}
|
|
//判断是否有紧急联系人
|
|
var emeContAct models.EmergencyContact
|
|
err = emeContAct.GetCont(wher, "`id`")
|
|
if err == nil {
|
|
scoreVal = scoreVal + 10
|
|
}
|
|
//判断是否有家庭成员
|
|
var familyMemCont models.FamilyMembers
|
|
err = familyMemCont.GetCont(wher, "`id`")
|
|
if err == nil {
|
|
scoreVal = scoreVal + 10
|
|
}
|
|
//判断是否有教育经历
|
|
var perEducationCont models.PersonnelEducation
|
|
err = perEducationCont.GetCont(wher, "`id`")
|
|
if err == nil {
|
|
scoreVal = scoreVal + 10
|
|
}
|
|
//判断是否有工作经历
|
|
var workHistory models.WorkHistory
|
|
err = workHistory.GetCont(wher, "`id`")
|
|
if err == nil {
|
|
scoreVal = scoreVal + 10
|
|
}
|
|
fmt.Printf("scoreVal------->%v\n", scoreVal)
|
|
scoreVal = overallhandle.DecimalEs(scoreVal, 2)
|
|
overallhandle.Result(0, scoreVal, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2023-06-19 16:47:32
|
|
@ 功能: 修改用户头像
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (s *StaffApi) EditPeopleIcon(c *gin.Context) {
|
|
var requestData editUSerIcons
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
overallhandle.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Id == 0 {
|
|
overallhandle.Result(1, err, c, "未知参数")
|
|
return
|
|
}
|
|
why := overallhandle.MapOut()
|
|
why["`id`"] = requestData.Id
|
|
var oldCont models.PersonArchives
|
|
err = oldCont.GetCont(why, "`id`")
|
|
if err != nil {
|
|
overallhandle.Result(107, err, c)
|
|
return
|
|
}
|
|
editCont := overallhandle.MapOut()
|
|
editCont["icon"] = requestData.IconPath
|
|
editCont["eite_time"] = time.Now().Unix()
|
|
err = oldCont.EiteCont(why, editCont)
|
|
if err != nil {
|
|
overallhandle.Result(106, err, c)
|
|
return
|
|
}
|
|
overallhandle.Result(0, err, c)
|
|
}
|
|
|