@ -23,78 +23,133 @@ func (s *StaffApi) StaffList(c *gin.Context) {
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" )
// 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")
var personnelModels [ ] models . ManCont
gormDb := overall . CONSTANT_DB_HR . Model ( & models . ManCont { } )
if requestData . Number != "" {
gormDb = gormDb . Where ( "p.number LIKE ?" , "%" + requestData . Number + "%" )
gormDb = gormDb . Where ( "`number` LIKE ?" , "%" + requestData . Number + "%" )
}
if requestData . Name != "" {
gormDb = gormDb . Where ( "p.name LIKE ?" , "%" + requestData . Name + "%" )
gormDb = gormDb . Where ( "`name` LIKE ?" , "%" + requestData . Name + "%" )
}
if requestData . HireClass != 0 {
gormDb = gormDb . Where ( "p.hire_class = ?" , requestData . HireClass )
gormDb = gormDb . Where ( "`hire_class` = ?" , requestData . HireClass )
}
if requestData . Company != 0 {
gormDb = gormDb . Where ( "p.company = ?" , requestData . Company )
gormDb = gormDb . Where ( "`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 )
gormDb = gormDb . Where ( "`admin_org` = ?" , requestData . AdminOrg )
}
if requestData . Position != 0 {
gormDb = gormDb . Where ( "p.position = ?" , requestData . Position )
gormDb = gormDb . Where ( "`position` = ?" , requestData . Position )
}
if requestData . EmpType != 0 {
gormDb = gormDb . Where ( "p.emp_type = ?" , requestData . EmpType )
gormDb = gormDb . Where ( "`emp_type` = ?" , requestData . EmpType )
} else {
gormDb = gormDb . Where ( "p.emp_type IN ?" , overall . EmployeeStatusIng )
gormDb = gormDb . Where ( "`emp_type` IN ?" , overall . EmployeeStatusIng )
}
if requestData . Role != "" {
gormDb = gormDb . Where ( "FIND_IN_SET(?,p. `role`)" , requestData . Role )
gormDb = gormDb . Where ( "FIND_IN_SET(?,`role`)" , requestData . Role )
}
gormDb = gormDb . Where ( "p.state = 1" )
gormDb = gormDb . Where ( "`state` = 1" )
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
fmt . Printf ( "%v\n" , positionAry )
for i , v := range positionAry {
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 , " " )
}
}
}
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
// fmt.Printf("%v\n", positionAry)
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, " ")
// }
// }
// }
}
if errGorm != nil {
@ -1294,7 +1349,6 @@ func doubleWorkerStaffNoXiecheng(manKeyNum int64, numStr string, dobleMan []Doub
}
//
func workInsideHistoryLog ( manKeyNum int64 , num string , workHistoryList [ ] insideHistoryerMy ) {
defer synPro . Done ( )
if len ( workHistoryList ) > 0 && manKeyNum != 0 {