25 changed files with 873 additions and 33 deletions
@ -0,0 +1,442 @@ |
|||||
|
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") |
||||
|
if requestData.Number != "" { |
||||
|
gormDb = gormDb.Where("p.number LIKE ?", "%"+requestData.Number+"%") |
||||
|
} |
||||
|
if requestData.Name != "" { |
||||
|
gormDb = gormDb.Where("p.name LIKE ?", "%"+requestData.Name+"%") |
||||
|
} |
||||
|
if requestData.HireClass != 0 { |
||||
|
gormDb = gormDb.Where("p.hire_class = ?", requestData.HireClass) |
||||
|
} |
||||
|
if requestData.Company != 0 { |
||||
|
gormDb = gormDb.Where("p.company = ?", requestData.Company) |
||||
|
} |
||||
|
if requestData.Deparment != "" { |
||||
|
gormDb = gormDb.Where("FIND_IN_SET(?,p.`deparment`)", requestData.Deparment) |
||||
|
} |
||||
|
if requestData.AdminOrg != 0 { |
||||
|
gormDb = gormDb.Where("p.admin_org = ?", requestData.AdminOrg) |
||||
|
} |
||||
|
if requestData.Position != 0 { |
||||
|
gormDb = gormDb.Where("p.position = ?", requestData.Position) |
||||
|
} |
||||
|
if requestData.EmpType != 0 { |
||||
|
gormDb = gormDb.Where("p.emp_type = ?", requestData.EmpType) |
||||
|
} else { |
||||
|
gormDb = gormDb.Where("p.emp_type IN ?", overall.EmployeeStatusIng) |
||||
|
} |
||||
|
if requestData.Role != "" { |
||||
|
gormDb = gormDb.Where("FIND_IN_SET(?,p.`role`)", requestData.Role) |
||||
|
} |
||||
|
|
||||
|
var total int64 |
||||
|
totalErr := gormDb.Count(&total).Error |
||||
|
if totalErr != nil { |
||||
|
total = 0 |
||||
|
} |
||||
|
var positionAry []peopleOutList |
||||
|
errGorm := gormDb.Order("p.company ASC,p.deparment ASC,p.admin_org ASC,p.position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&positionAry).Error |
||||
|
for i, v := range positionAry { |
||||
|
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) |
||||
|
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, " ") |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
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.Company == 0 { |
||||
|
requestData.Company = 1 |
||||
|
} |
||||
|
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 requestData.SpouseName == "" { |
||||
|
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶姓名!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.SpouseCompany == "" { |
||||
|
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶所在公司!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.SpouseDepartment == "" { |
||||
|
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶所在部门!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.SpousePosition == "" { |
||||
|
overallhandle.Result(1, requestData.SpouseName, c, "请输入配偶所在岗位!") |
||||
|
return |
||||
|
} |
||||
|
if requestData.SpouseTel == "" { |
||||
|
overallhandle.Result(1, requestData.SpouseName, 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.Password = overall.CONSTANT_CONFIG.Appsetup.DefaultPassword |
||||
|
} |
||||
|
|
||||
|
//员工档案主
|
||||
|
var staffInfo models.Personnel |
||||
|
//判断工号是存在
|
||||
|
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.HireClass = requestData.HireType |
||||
|
staffInfo.Position = requestData.Position |
||||
|
//获取职务信息
|
||||
|
jobCont, jobErr := getJobInfo(requestData.Position) |
||||
|
if jobErr == nil { |
||||
|
staffInfo.PositionLevel = jobCont.Dutid |
||||
|
staffInfo.JobClass = jobCont.Jobid |
||||
|
} |
||||
|
staffInfo.AdminOrg = requestData.AdminOrg |
||||
|
staffInfo.Company = requestData.Company |
||||
|
staffInfo.EmpType = requestData.EmpType |
||||
|
staffInfo.Deparment = strings.Join(requestData.Department, ",") |
||||
|
staffInfo.Time = time.Now().Unix() |
||||
|
staffInfo.EiteTime = time.Now().Unix() |
||||
|
staffInfo.PositionGrade = requestData.PositionGrade |
||||
|
staffInfo.Icon = requestData.Icon |
||||
|
// staffInfo.Password = requestData.Password
|
||||
|
var md5JiaMi overallhandle.Md5Encryption |
||||
|
md5JiaMi.Md5EncryptionInit(requestData.Password) |
||||
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
||||
|
staffInfo.Password = md5Token |
||||
|
|
||||
|
peopleMasterErr := overall.CONSTANT_DB_HR.Create(&staffInfo).Error |
||||
|
if peopleMasterErr != nil { |
||||
|
overallhandle.Result(104, staffInfo, c) |
||||
|
return |
||||
|
} |
||||
|
//员工档案附表
|
||||
|
synPro.Add(1) |
||||
|
go staffInfoCont(requestData) |
||||
|
|
||||
|
//双职工
|
||||
|
if requestData.Iisdoubleworker == 1 { |
||||
|
synPro.Add(1) |
||||
|
go doubleWorkerStaff(requestData) |
||||
|
} |
||||
|
//人员变动记录
|
||||
|
synPro.Add(1) |
||||
|
go peopleGaiDong(staffInfo) |
||||
|
//教育经历
|
||||
|
if len(requestData.EducationalExperience) > 0 { |
||||
|
synPro.Add(1) |
||||
|
go eduExperience(requestData.Number, requestData.EducationalExperience) |
||||
|
} |
||||
|
//紧急联系人
|
||||
|
if len(requestData.EmergencyContact) > 0 { |
||||
|
synPro.Add(1) |
||||
|
go emeContact(requestData.Number, requestData.EmergencyContact) |
||||
|
|
||||
|
} |
||||
|
//家庭成员
|
||||
|
if len(requestData.MemberOfFamily) > 0 { |
||||
|
synPro.Add(1) |
||||
|
go familyPeople(requestData.Number, requestData.MemberOfFamily) |
||||
|
} |
||||
|
synPro.Wait() |
||||
|
overallhandle.Result(0, staffInfo, c) |
||||
|
} |
||||
|
|
||||
|
//获取职务相关属性
|
||||
|
func getJobInfo(jobId int64) (cont jobAttber, err error) { |
||||
|
var positionInfo models.Position |
||||
|
// err = overall.CONSTANT_DB_HR.Table(fmt.Sprintf("%s p", positionInfo.TableName())).Select("p.id,p.number,p.name,p.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 = p.duties").Joins("left join job_class as j on j.id = d.job_type").Where("`p`.`id` = ?", jobId).First(&cont).Error
|
||||
|
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(contData addPersonnel) { |
||||
|
defer synPro.Done() |
||||
|
var staffAttribute models.PersonnelContent |
||||
|
staffAttribute.Number = contData.Number |
||||
|
staffAttribute.Idcardno = contData.IDCardNo |
||||
|
staffAttribute.Mobilephone = contData.Mobilephone |
||||
|
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 |
||||
|
staffAttribute.Health = contData.Health |
||||
|
staffAttribute.Maritalstatus = contData.Maritalstatus |
||||
|
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(contData addPersonnel) { |
||||
|
defer synPro.Done() |
||||
|
var doublePeople models.DoubleWorker |
||||
|
doublePeople.Number = contData.Number |
||||
|
doublePeople.Name = contData.SpouseName |
||||
|
doublePeople.Company = contData.SpouseCompany |
||||
|
doublePeople.Department = contData.SpouseDepartment |
||||
|
doublePeople.Position = contData.SpousePosition |
||||
|
doublePeople.Tel = contData.SpouseTel |
||||
|
doublePeople.Time = time.Now().Unix() |
||||
|
overall.CONSTANT_DB_HR.Create(&doublePeople) |
||||
|
} |
||||
|
|
||||
|
//人员变动记录
|
||||
|
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.JobGrade = 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(number string, eduExpAry []educationalExperience) { |
||||
|
defer synPro.Done() |
||||
|
var leaExp []models.PersonnelEducation |
||||
|
maxLevel := 1 |
||||
|
for eei, eev := range eduExpAry { |
||||
|
if maxLevel < eev.Education { |
||||
|
maxLevel = eev.Education |
||||
|
} |
||||
|
var leaExpInfo models.PersonnelEducation |
||||
|
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(number string, contAry []emergencyContact) { |
||||
|
defer synPro.Done() |
||||
|
var emerContAry []models.EmergencyContact |
||||
|
for _, emev := range contAry { |
||||
|
var emerInfo models.EmergencyContact |
||||
|
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(number string, contAry []memberOfFamily) { |
||||
|
defer synPro.Done() |
||||
|
var familyAry []models.FamilyMembers |
||||
|
for _, fv := range contAry { |
||||
|
var familyInfo models.FamilyMembers |
||||
|
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) |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,137 @@ |
|||||
|
package personnelapi |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/models" |
||||
|
"hr_server/overall/overallhandle" |
||||
|
"sync" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//协程
|
||||
|
var synPro = sync.WaitGroup{} |
||||
|
|
||||
|
//人员API
|
||||
|
type StaffApi struct{} |
||||
|
|
||||
|
//入口
|
||||
|
func (s *StaffApi) Index(c *gin.Context) { |
||||
|
outputCont := overallhandle.MapOut() |
||||
|
outputCont["index"] = "人员档案API" |
||||
|
overallhandle.Result(0, outputCont, c) |
||||
|
} |
||||
|
|
||||
|
//人员列表查询
|
||||
|
type peopleList struct { |
||||
|
overallhandle.PageTurning |
||||
|
Number string `json:"number"` //工号
|
||||
|
Name string `json:"name"` //name
|
||||
|
HireClass int `json:"hireclass"` //雇佣类型
|
||||
|
Company int64 `json:"company"` //公司
|
||||
|
Deparment string `json:"deparment"` //部门
|
||||
|
AdminOrg int64 `json:"adminorg"` //所属行政组织
|
||||
|
Position int64 `json:"position"` //职位
|
||||
|
EmpType int `json:"emptype"` //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)
|
||||
|
Role string `json:"role"` |
||||
|
} |
||||
|
|
||||
|
//人员列表输出
|
||||
|
type peopleOutList struct { |
||||
|
models.Personnel |
||||
|
Mobilephone string `json:"mobilephone" gorm:"column:mobilephone;type:varchar(50) unsigned;default:'';not null;comment:手机号码"` |
||||
|
Gender int `json:"gender" gorm:"column:type;gender:tinyint(1) unsigned;default:1;not null;comment:性别(1:男性;2:女性;3:中性)"` |
||||
|
Isdoubleworker int `json:"isdoubleworker" gorm:"column:type;isdoubleworker:tinyint(1) unsigned;default:1;not null;comment:是否双职工(1:是;2:否)"` |
||||
|
Isveterans int `json:"isveterans" gorm:"column:type;isveterans:tinyint(1) unsigned;default:1;not null;comment:是否为退役军人(1:是;2:否)"` |
||||
|
Entrydate int64 `json:"entrydate" gorm:"column:entrydate;type:bigint(20) unsigned;default:0;not null;comment:入职日期"` |
||||
|
Probationperiod int64 `json:"probationperiod" gorm:"column:probationperiod;type:int(5) unsigned;default:0;not null;comment:试用期"` |
||||
|
Planformaldate int64 `json:"planformaldate" gorm:"column:planformaldate;type:bigint(20) unsigned;default:0;not null;comment:预计转正日期"` |
||||
|
CompanyName string `json:"companyname"` //公司名称
|
||||
|
DeparmentName string `json:"deparmentname"` //部门名称
|
||||
|
PositionName string `json:"positionname"` //职位
|
||||
|
} |
||||
|
|
||||
|
//获取部门细腻些
|
||||
|
type getDepartmentInfo struct { |
||||
|
Id int64 `json:"id"` //id
|
||||
|
Number string `json:"number"` //行政编码
|
||||
|
Name string `json:"name"` //组织名称
|
||||
|
} |
||||
|
|
||||
|
//添加员工参数
|
||||
|
type addPersonnel struct { |
||||
|
Number string `json:"number"` //工号1
|
||||
|
Password string `json:"password"` //密码1
|
||||
|
Name string `json:"name"` //姓名1
|
||||
|
Gender int `json:"gender"` //性别
|
||||
|
Icon string `json:"icon"` //头像
|
||||
|
HireType int `json:"hiretype"` //1雇佣类型(1:雇佣入职;2:再入职;3:返聘)
|
||||
|
Mobilephone string `json:"mobilephone"` //联系电话
|
||||
|
IDCardNo string `json:"idcardno"` //身份证号码
|
||||
|
PoliticalOutlook int `json:"politicaloutlook"` //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
|
||||
|
Company int64 `json:"company"` //公司
|
||||
|
Department []string `json:"department"` //分厂(部室)
|
||||
|
AdminOrg int64 `json:"adminorg"` //工段
|
||||
|
Position int64 `json:"position"` //职位(岗位)1
|
||||
|
EmpType int `json:"emptype"` //用工关系(1:实习生;2:待分配;3:试用员工;4:正式员工;5:停薪留职;6:退休;7:辞退;8:离职)
|
||||
|
PositionGrade int64 `json:"positiongrade"` //入职等级
|
||||
|
Nation string `json:"nation"` //民族
|
||||
|
Birthday string `json:"birthday"` //生日
|
||||
|
WorkingDate string `json:"workingdate"` //参加工作日期
|
||||
|
EntryDate string `json:"entrydate"` //入职日期
|
||||
|
ProbationPeriod int `json:"probationperiod"` //试用期(月)
|
||||
|
ConfirmationDate string `json:"confirmationdate"` //转正日期
|
||||
|
NativePlace string `json:"nativeplace"` //籍贯
|
||||
|
CurrentResidence string `json:"currentresidence"` //现居地
|
||||
|
Constellation int `json:"constellation"` //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
|
||||
|
Health int `json:"health"` //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废
|
||||
|
Maritalstatus int `json:"maritalstatus"` //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
|
||||
|
Iisdoubleworker int `json:"isdoubleworker"` //是否双职工(1:是;2:否)
|
||||
|
Isveterans int `json:"isveterans"` //是否为退役军人(1:是;2:否)
|
||||
|
Veteransnumber string `json:"veteransnumber"` //退役证编号
|
||||
|
EducationalExperience []educationalExperience `json:"educationalexperience"` //教育经历
|
||||
|
EmergencyContact []emergencyContact `json:"emergencycontact"` //紧急联系人
|
||||
|
MemberOfFamily []memberOfFamily `json:"memberoffamily"` //家庭成员
|
||||
|
SpouseName string `json:"spousename"` //配偶姓名
|
||||
|
SpouseCompany string `json:"spousecompany"` //配偶所在公司
|
||||
|
SpouseDepartment string `json:"spousedepartment"` //配偶所在部门
|
||||
|
SpousePosition string `json:"spouseposition"` //配偶所在岗位
|
||||
|
SpouseTel string `json:"spousetel"` //配偶联系方式
|
||||
|
} |
||||
|
|
||||
|
//教育经历
|
||||
|
type educationalExperience struct { |
||||
|
AdmissionTime string `json:"admissiontime"` //入学时间
|
||||
|
GraduationTime string `json:"graduationtime"` //毕业时间
|
||||
|
Education int `json:"education"` //学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)
|
||||
|
Subject string `json:"subject"` //专业
|
||||
|
GraduationSchool string `json:"graduationschool"` //毕业学校
|
||||
|
} |
||||
|
|
||||
|
//紧急联系人
|
||||
|
type emergencyContact struct { |
||||
|
Name string `json:"name"` //姓名
|
||||
|
Relationship string `json:"relationship"` //与紧急联系人
|
||||
|
Mobilephone string `json:"mobilephone"` //联系电话
|
||||
|
} |
||||
|
|
||||
|
//家庭成员
|
||||
|
type memberOfFamily struct { |
||||
|
emergencyContact |
||||
|
Company string `json:"company"` //公司
|
||||
|
Department string `json:"department"` //分厂(部室)
|
||||
|
Position string `json:"position"` //职位(岗位)
|
||||
|
PoliticalOutlook int `json:"politicaloutlook"` //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
|
||||
|
} |
||||
|
|
||||
|
//职务相关
|
||||
|
type jobAttber 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(255) unsigned;default:'';not null;comment:编号"` |
||||
|
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:名称"` |
||||
|
PersonInCharge int `json:"personincharge" gorm:"column:person_in_charge;type:tinyint(1) unsigned;default:0;not null;comment:是否为本部门负责人"` |
||||
|
Dutid int64 `json:"dutid" gorm:"column:dutid;type:bigint(20) unsigned;default:0;not null;comment:职务Id"` |
||||
|
Dutname string `json:"dutname" gorm:"column:dutname;type:varchar(255) unsigned;default:'';not null;comment:职务名称"` |
||||
|
DutNumber string `json:"dutnumber" gorm:"column:dutnumber;type:varchar(255) unsigned;default:'';not null;comment:职务编号"` |
||||
|
Jobid int64 `json:"jobid" gorm:"column:jobid;type:bigint(20) unsigned;default:0;not null;comment:职务分类Id"` |
||||
|
JobName string `json:"jobname" gorm:"column:jobname;type:varchar(255) unsigned;default:'';not null;comment:职务分类名称"` |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
package shiyan |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"hr_server/overall/overallhandle" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
func (s *ShiYan) ShiyanCont(c *gin.Context) { |
||||
|
var requestData Jieshou |
||||
|
c.ShouldBindJSON(&requestData) |
||||
|
if requestData.Time == "" { |
||||
|
requestData.Time = overallhandle.UnixTimeToDay(time.Now().Unix(), 11) |
||||
|
} |
||||
|
entryData, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.Time)) |
||||
|
planformalData := overallhandle.GetFutureMonthTime(entryData, requestData.ProbationPeriod, 2) |
||||
|
|
||||
|
timeStr := overallhandle.UnixTimeToDay(planformalData, 11) |
||||
|
out := overallhandle.MapOut() |
||||
|
out["time"] = requestData.Time |
||||
|
out["entryData"] = entryData |
||||
|
out["timeStr"] = timeStr |
||||
|
overallhandle.Result(0, out, c) |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package shiyan |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/overall/overallhandle" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//人员API
|
||||
|
type ShiYan struct{} |
||||
|
|
||||
|
//入口
|
||||
|
func (s *ShiYan) Index(c *gin.Context) { |
||||
|
outputCont := overallhandle.MapOut() |
||||
|
outputCont["index"] = "实验API" |
||||
|
overallhandle.Result(0, outputCont, c) |
||||
|
} |
||||
|
|
||||
|
type Jieshou struct { |
||||
|
Time string `json:"time"` |
||||
|
ProbationPeriod int `json:"probationperiod"` //试用期(月)
|
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package personnel |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/api/version1" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//员工档案
|
||||
|
func (p *PersonnelRoute) InitRouterGroup(route *gin.RouterGroup) { |
||||
|
apiRouter := route.Group("staff") |
||||
|
var apiHandle = version1.AppApiInlet.StaffApi |
||||
|
{ |
||||
|
apiRouter.GET("", apiHandle.Index) //入口
|
||||
|
apiRouter.POST("", apiHandle.Index) //入口
|
||||
|
apiRouter.POST("stafflist", apiHandle.StaffList) //人员列表
|
||||
|
apiRouter.POST("addstaff", apiHandle.AddStaff) //添加人员档案
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
package personnel |
||||
|
|
||||
|
//人员管理方面
|
||||
|
type PersonnelRoute struct{} |
||||
@ -0,0 +1,18 @@ |
|||||
|
package shiyanrouter |
||||
|
|
||||
|
import ( |
||||
|
"hr_server/api/version1" |
||||
|
|
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
//组织架构
|
||||
|
func (p *ShiyanApiRouter) InitRouterGroup(route *gin.RouterGroup) { |
||||
|
apiRouter := route.Group("shiyan") |
||||
|
var apiHandle = version1.AppApiInlet.ShiyanApi |
||||
|
{ |
||||
|
apiRouter.GET("", apiHandle.Index) //入口
|
||||
|
apiRouter.POST("", apiHandle.Index) //入口
|
||||
|
apiRouter.POST("shiyan", apiHandle.ShiyanCont) //人员列表
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
package shiyanrouter |
||||
|
|
||||
|
type ShiyanApiRouter struct{} |
||||
@ -0,0 +1,21 @@ |
|||||
|
{ |
||||
|
"group":[ |
||||
|
{ |
||||
|
"old":3, |
||||
|
"new":2 |
||||
|
} |
||||
|
], |
||||
|
"department":[ |
||||
|
{ |
||||
|
"newgroup":2, |
||||
|
"old":1, |
||||
|
"new":14 |
||||
|
}, |
||||
|
{ |
||||
|
"newgroup":2, |
||||
|
"old":2, |
||||
|
"new":13 |
||||
|
} |
||||
|
], |
||||
|
"workshopsection":[] |
||||
|
} |
||||
Binary file not shown.
@ -0,0 +1,24 @@ |
|||||
|
package models |
||||
|
|
||||
|
import "hr_server/overall" |
||||
|
|
||||
|
//紧急联系人
|
||||
|
type DoubleWorker struct { |
||||
|
Number string `json:"number" gorm:"primaryKey;column:number;type:varchar(30) unsigned;not null;comment:员工工号;index"` |
||||
|
Name string `json:"name" gorm:"column:name;type:varchar(255) unsigned;default:'';not null;comment:姓名"` |
||||
|
Company string `json:"company" gorm:"column:company;type:varchar(255) unsigned;default:'';not null;comment:所在公司"` |
||||
|
Department string `json:"department" gorm:"column:department;type:varchar(255) unsigned;default:'';not null;comment:所在部门"` |
||||
|
Position string `json:"position" gorm:"column:position;type:varchar(255) unsigned;default:'';not null;comment:所在岗位"` |
||||
|
Tel string `json:"tel" gorm:"column:tel;type:varchar(255) unsigned;default:'';not null;comment:联系方式"` |
||||
|
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
||||
|
} |
||||
|
|
||||
|
func (DoubleWorker *DoubleWorker) TableName() string { |
||||
|
return "double_worker" |
||||
|
} |
||||
|
|
||||
|
//编辑职务分类内容
|
||||
|
func (DoubleWorker *DoubleWorker) EiteCont(whereMap interface{}, saveData interface{}) (err error) { |
||||
|
err = overall.CONSTANT_DB_HR.Model(&DoubleWorker).Where(whereMap).Updates(saveData).Error |
||||
|
return |
||||
|
} |
||||
Loading…
Reference in new issue