|
|
|
|
package personnelapi
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
datacenter "hr_server/api/version1/dataCenter"
|
|
|
|
|
"hr_server/grocerystore"
|
|
|
|
|
"hr_server/models"
|
|
|
|
|
"hr_server/models/appPlatform"
|
|
|
|
|
"hr_server/models/customerForm"
|
|
|
|
|
personalitycolor "hr_server/models/personalityColor"
|
|
|
|
|
"hr_server/models/workgroup"
|
|
|
|
|
"hr_server/overall"
|
|
|
|
|
"hr_server/overall/overallhandle"
|
|
|
|
|
"regexp"
|
|
|
|
|
"sort"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 人员列表
|
|
|
|
|
func (s *StaffApi) ArchivesList(c *gin.Context) {
|
|
|
|
|
var requestData peopleList
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Page < 0 {
|
|
|
|
|
requestData.Page = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.PageSize < 0 {
|
|
|
|
|
requestData.PageSize = 10
|
|
|
|
|
}
|
|
|
|
|
// var staffList []models.ManCont
|
|
|
|
|
// var staffList []models.PersonArchives
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("state = 1")
|
|
|
|
|
|
|
|
|
|
if requestData.Number != "" {
|
|
|
|
|
gormDb = gormDb.Where("number LIKE ?", "%"+requestData.Number+"%")
|
|
|
|
|
}
|
|
|
|
|
if requestData.Name != "" {
|
|
|
|
|
gormDb = gormDb.Where("name LIKE ?", "%"+requestData.Name+"%")
|
|
|
|
|
}
|
|
|
|
|
if requestData.HireClass != 0 {
|
|
|
|
|
gormDb = gormDb.Where("hire_class = ?", requestData.HireClass)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Company != 0 {
|
|
|
|
|
gormDb = gormDb.Where("company = ?", requestData.Company)
|
|
|
|
|
}
|
|
|
|
|
// if requestData.Deparment != "" {
|
|
|
|
|
// gormDb = gormDb.Where("FIND_IN_SET(?,`deparment`)", requestData.Deparment)
|
|
|
|
|
// }
|
|
|
|
|
if requestData.AdminOrg != 0 {
|
|
|
|
|
// var idAry []int64
|
|
|
|
|
// idAry = overallhandle.GetDepartmentSun(requestData.AdminOrg, idAry)
|
|
|
|
|
// idAry = append(idAry, requestData.AdminOrg)
|
|
|
|
|
// gormDb = gormDb.Where("admin_org IN ?", idAry)
|
|
|
|
|
var sunAry overallhandle.AllSunList[int64]
|
|
|
|
|
sunAry.GetAllSunOrg(requestData.AdminOrg)
|
|
|
|
|
sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg)
|
|
|
|
|
gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position != 0 {
|
|
|
|
|
gormDb = gormDb.Where("position = ?", requestData.Position)
|
|
|
|
|
}
|
|
|
|
|
if len(requestData.EmpType) > 0 {
|
|
|
|
|
gormDb = gormDb.Where("emp_type IN ?", requestData.EmpType)
|
|
|
|
|
} else {
|
|
|
|
|
gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Role != "" {
|
|
|
|
|
gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("`teamid` = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
var idAry []int64
|
|
|
|
|
// errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&staffList).Error
|
|
|
|
|
errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error
|
|
|
|
|
var positionAry []peopleManOutList
|
|
|
|
|
|
|
|
|
|
var manContList []models.ManCont
|
|
|
|
|
errGorm = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Find(&manContList).Error
|
|
|
|
|
|
|
|
|
|
for _, v := range manContList {
|
|
|
|
|
var staffInfo peopleManOutList
|
|
|
|
|
staffInfo.ManCont = v
|
|
|
|
|
if v.IconPhoto != "" {
|
|
|
|
|
staffInfo.Icon = v.IconPhoto
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getSpur models.Position
|
|
|
|
|
getWhe := overallhandle.MapOut()
|
|
|
|
|
getWhe["id"] = v.Position
|
|
|
|
|
getSpur.GetCont(getWhe, "name", "person_in_charge")
|
|
|
|
|
staffInfo.PositionName = getSpur.Name
|
|
|
|
|
// staffInfo.PersonInCharge = getSpur.PersonInCharge
|
|
|
|
|
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
|
|
|
|
|
//公司
|
|
|
|
|
if v.Company != 0 {
|
|
|
|
|
var getSpurDepart models.AdministrativeOrganization
|
|
|
|
|
getWheDepart := overallhandle.MapOut()
|
|
|
|
|
getWheDepart["id"] = v.Company
|
|
|
|
|
getSpurDepart.GetCont(getWheDepart, "name")
|
|
|
|
|
staffInfo.CompanyName = getSpurDepart.Name
|
|
|
|
|
}
|
|
|
|
|
//主部门
|
|
|
|
|
if v.MainDeparment != 0 {
|
|
|
|
|
var getSpurDepartMain models.AdministrativeOrganization
|
|
|
|
|
getWheDepartMain := overallhandle.MapOut()
|
|
|
|
|
getWheDepartMain["id"] = v.MainDeparment
|
|
|
|
|
getSpurDepartMain.GetCont(getWheDepartMain, "name")
|
|
|
|
|
staffInfo.MainDeparmentName = getSpurDepartMain.Name
|
|
|
|
|
}
|
|
|
|
|
//二级著部门
|
|
|
|
|
if v.SunMainDeparment != 0 {
|
|
|
|
|
var sunMainDepart models.AdministrativeOrganization
|
|
|
|
|
sunMainDepart.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`")
|
|
|
|
|
staffInfo.SunMainDeparmentName = sunMainDepart.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 {
|
|
|
|
|
// staffInfo.DeparmentName = strings.Join(departNameAry, " ")
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
var orgContTypeCont models.OrgContType
|
|
|
|
|
orgContTypeCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`", "`level`")
|
|
|
|
|
if orgContTypeCont.Level >= 6 {
|
|
|
|
|
staffInfo.WorkPostName = orgContTypeCont.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if requestData.AdminOrg == v.AdminOrg && v.PersonInCharge == 1 {
|
|
|
|
|
// staffInfo.PersonInCharge = 1
|
|
|
|
|
// } else {
|
|
|
|
|
// staffInfo.PersonInCharge = 2
|
|
|
|
|
// }
|
|
|
|
|
staffInfo.PersonInCharge = 2
|
|
|
|
|
if v.PersonInCharge == 1 {
|
|
|
|
|
orgResList := strings.Split(v.ResponsibleDepartment, ",")
|
|
|
|
|
if len(orgResList) > 0 {
|
|
|
|
|
orgIdStr := strconv.FormatInt(requestData.AdminOrg, 10)
|
|
|
|
|
if overallhandle.IsInTrue[string](orgIdStr, orgResList) == true {
|
|
|
|
|
staffInfo.PersonInCharge = 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
positionAry = append(positionAry, staffInfo)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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) ArchivesCon(c *gin.Context) {
|
|
|
|
|
var requestData IdOrNumber
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
myId := overallhandle.TypeToInterface(requestData.Id)
|
|
|
|
|
if requestData.Number == "" && myId == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var satffCont models.ManCont
|
|
|
|
|
if myId != "" {
|
|
|
|
|
staffErr := satffCont.GetCont(map[string]interface{}{"`id`": myId})
|
|
|
|
|
if staffErr != nil {
|
|
|
|
|
overallhandle.Result(105, staffErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
} else if requestData.Number != "" {
|
|
|
|
|
staffErr := satffCont.GetCont(map[string]interface{}{"`number`": requestData.Number})
|
|
|
|
|
if staffErr != nil {
|
|
|
|
|
overallhandle.Result(105, staffErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var staffCenter staffArchivesCont
|
|
|
|
|
staffCenter.ManCont = satffCont
|
|
|
|
|
staffCenter.IdStr = strconv.FormatInt(satffCont.Id, 10)
|
|
|
|
|
if satffCont.Birthday != 0 {
|
|
|
|
|
staffCenter.BirthdayTime = overallhandle.UnixTimeToDay(satffCont.Birthday, 14) //生日
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Idcardstartdate != 0 {
|
|
|
|
|
staffCenter.IdCardStartTimeData = overallhandle.UnixTimeToDay(satffCont.Idcardstartdate, 14) //身份证有效期开始时间
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Idcardenddate != 0 {
|
|
|
|
|
staffCenter.IdCardEndTimeData = overallhandle.UnixTimeToDay(satffCont.Idcardenddate, 14) //身份证有效期结束时间
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Entrydate != 0 {
|
|
|
|
|
staffCenter.EntrydateTime = overallhandle.UnixTimeToDay(satffCont.Entrydate, 14) //入职日期
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Planformaldate != 0 {
|
|
|
|
|
staffCenter.PlanformaldateTime = overallhandle.UnixTimeToDay(satffCont.Planformaldate, 14) //预计转正日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Jobstartdate != 0 {
|
|
|
|
|
staffCenter.JobstartdateStr = overallhandle.UnixTimeToDay(satffCont.Jobstartdate, 14) //参加工作日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Entrydate != 0 {
|
|
|
|
|
staffCenter.EntrydateStr = overallhandle.UnixTimeToDay(satffCont.Entrydate, 14) //入职日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Company != 0 {
|
|
|
|
|
var groupInfos models.AdministrativeOrganization
|
|
|
|
|
groupInfos.GetCont(map[string]interface{}{"`id`": satffCont.Company}, "`name`")
|
|
|
|
|
staffCenter.CompanyName = groupInfos.Name
|
|
|
|
|
}
|
|
|
|
|
if satffCont.MainDeparment != 0 {
|
|
|
|
|
var demperMainInfos models.AdministrativeOrganization
|
|
|
|
|
demperMainInfos.GetCont(map[string]interface{}{"`id`": satffCont.MainDeparment}, "`name`")
|
|
|
|
|
staffCenter.MainDeparmentName = demperMainInfos.Name
|
|
|
|
|
}
|
|
|
|
|
if satffCont.AdminOrg != 0 {
|
|
|
|
|
var adminOrg models.AdministrativeOrganization
|
|
|
|
|
adminOrg.GetCont(map[string]interface{}{"`id`": satffCont.AdminOrg}, "`name`")
|
|
|
|
|
staffCenter.AdminOrgName = adminOrg.Name
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Position != 0 {
|
|
|
|
|
var postisInfo models.Position
|
|
|
|
|
postisInfo.GetCont(map[string]interface{}{"`id`": satffCont.Position}, "`name`", "`person_in_charge`")
|
|
|
|
|
staffCenter.PositionName = postisInfo.Name
|
|
|
|
|
staffCenter.PersonInCharge = postisInfo.PersonInCharge
|
|
|
|
|
}
|
|
|
|
|
if satffCont.JobClass != 0 {
|
|
|
|
|
var jobsInfo models.JobClass
|
|
|
|
|
jobsInfo.GetCont(map[string]interface{}{"`id`": satffCont.JobClass}, "`name`")
|
|
|
|
|
staffCenter.JobClassName = jobsInfo.Name
|
|
|
|
|
}
|
|
|
|
|
if satffCont.JobId != 0 {
|
|
|
|
|
var dutiresInfo models.Duties
|
|
|
|
|
dutiresInfo.GetCont(map[string]interface{}{"`id`": satffCont.JobId}, "`name`")
|
|
|
|
|
staffCenter.JobIdName = dutiresInfo.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffCenter.PoliticalOutlookName = overallhandle.PolitiToString(satffCont.PoliticalOutlook)
|
|
|
|
|
//获取双职工信息
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go func() {
|
|
|
|
|
staffCenter.DoubleWorkerList = getDoubleWorkerCont(satffCont.Key) //双职工
|
|
|
|
|
}()
|
|
|
|
|
//紧急联系人
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go func() {
|
|
|
|
|
staffCenter.EmergencyContact = getEmercyCallMan(satffCont.Key) //紧急联系人
|
|
|
|
|
}()
|
|
|
|
|
//家庭成员
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go func() {
|
|
|
|
|
staffCenter.MemberOfFamily = getMemberOfFamily(satffCont.Key) //家庭成员
|
|
|
|
|
}()
|
|
|
|
|
//教育经历
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go func() {
|
|
|
|
|
staffCenter.EducationalExperience = getEducationalExperience(satffCont.Key) //教育经历
|
|
|
|
|
}()
|
|
|
|
|
//工作履历
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go func() {
|
|
|
|
|
staffCenter.WorkHistoryList = getWorkHistoryList(satffCont.Key) //工作履历
|
|
|
|
|
}()
|
|
|
|
|
//集团内工作履历
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go func() {
|
|
|
|
|
staffCenter.InsideWorkHistory = getGroupWorkHistoryList(satffCont.Key) //工作履历
|
|
|
|
|
}()
|
|
|
|
|
synPro.Wait()
|
|
|
|
|
overallhandle.Result(0, staffCenter, c)
|
|
|
|
|
// return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取双职工信息
|
|
|
|
|
func getDoubleWorkerCont(key int64) (doubleworkerlist []DoubleWorkerCont) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var dowWorkMan []models.DoubleWorker
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Select("`id`", "`number`", "`name`", "`company`", "`department`", "`position`", "`tel`").Where("`state` = 1 AND `key` = ?", key).Find(&dowWorkMan).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
|
|
|
|
|
for _, v := range dowWorkMan {
|
|
|
|
|
var dwManCont DoubleWorkerCont
|
|
|
|
|
dwManCont.Id = strconv.FormatInt(v.Id, 10)
|
|
|
|
|
dwManCont.Number = v.Number //工号
|
|
|
|
|
dwManCont.Name = v.Name //姓名
|
|
|
|
|
dwManCont.Company = v.Company //公司
|
|
|
|
|
dwManCont.Department = v.Department //分厂(部室)
|
|
|
|
|
dwManCont.Position = v.Position //职位(岗位)
|
|
|
|
|
dwManCont.Mobilephone = v.Tel //联系电话
|
|
|
|
|
doubleworkerlist = append(doubleworkerlist, dwManCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 紧急联系人
|
|
|
|
|
func getEmercyCallMan(key int64) (callMan []emergencyContact) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var dowWorkMan []models.EmergencyContact
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Select("`id`", "`name`", "`relationship`", "`tel`").Where("`state` = 1 AND `key` = ?", key).Find(&dowWorkMan).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
|
|
|
|
|
for _, v := range dowWorkMan {
|
|
|
|
|
var dwManCont emergencyContact //
|
|
|
|
|
dwManCont.Id = strconv.FormatInt(v.Id, 10)
|
|
|
|
|
dwManCont.Name = v.Name //姓名
|
|
|
|
|
dwManCont.Relationship = v.Relationship //与紧急联系人
|
|
|
|
|
dwManCont.Mobilephone = v.Tel //联系电话
|
|
|
|
|
callMan = append(callMan, dwManCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取家庭成员
|
|
|
|
|
func getMemberOfFamily(key int64) (callMan []memberOfFamily) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var dowWorkMan []models.FamilyMembers
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Select("`id`", "`name`", "`relation`", "`company`", "`deparment`", "`postnme`", "`tel`,`political_outlook`").Where("`state` = 1 AND `key` = ?", key).Find(&dowWorkMan).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
for _, v := range dowWorkMan {
|
|
|
|
|
var dwManCont memberOfFamily //工号
|
|
|
|
|
dwManCont.Name = v.Name //姓名
|
|
|
|
|
dwManCont.Relationship = v.Relationship //与紧急联系人
|
|
|
|
|
dwManCont.Mobilephone = v.Tel //联系电话
|
|
|
|
|
dwManCont.Company = v.Company //公司
|
|
|
|
|
dwManCont.Department = v.Deparment //分厂(部室)
|
|
|
|
|
dwManCont.Position = v.Postnme //职位(岗位)
|
|
|
|
|
dwManCont.PoliticalOutlook = v.PoliticalOutlook //政治面貌
|
|
|
|
|
dwManCont.IdStr = strconv.FormatInt(v.Id, 10)
|
|
|
|
|
callMan = append(callMan, dwManCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取教育经历
|
|
|
|
|
func getEducationalExperience(key int64) (callMan []educatExp) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var dowWorkMan []models.PersonnelEducation
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Select("`id`", "`education`", "`graduation_school`", "`subject`", "`admission_time`", "`graduation_time`", "`level`,`academic_degree`").Where("`state` = 1 AND `key` = ?", key).Find(&dowWorkMan).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
for _, v := range dowWorkMan {
|
|
|
|
|
var dwManCont educatExp //
|
|
|
|
|
dwManCont.GraduationSchool = v.GraduationSchool //毕业学校
|
|
|
|
|
dwManCont.Subject = v.Subject //专业
|
|
|
|
|
dwManCont.Education = v.Education //学历
|
|
|
|
|
if v.AdmissionTime != 0 {
|
|
|
|
|
dwManCont.AdmissionTime = overallhandle.UnixTimeToDay(v.AdmissionTime, 14) //入学时间
|
|
|
|
|
}
|
|
|
|
|
if v.GraduationTime != 0 {
|
|
|
|
|
dwManCont.GraduationTime = overallhandle.UnixTimeToDay(v.GraduationTime, 14) //毕业时间
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dwManCont.AcademicDegree = getXueWei(v.AcademicDegree) //学位
|
|
|
|
|
dwManCont.AcademicDegreeId = v.AcademicDegree
|
|
|
|
|
dwManCont.Level = getXueWeiClass(v.Level)
|
|
|
|
|
dwManCont.LevelId = v.Level //学历类型
|
|
|
|
|
dwManCont.Id = strconv.FormatInt(v.Id, 10)
|
|
|
|
|
callMan = append(callMan, dwManCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 学位
|
|
|
|
|
func getXueWei(id int) string {
|
|
|
|
|
switch id {
|
|
|
|
|
case 1:
|
|
|
|
|
return "无"
|
|
|
|
|
case 2:
|
|
|
|
|
return "学士"
|
|
|
|
|
case 3:
|
|
|
|
|
return "硕士"
|
|
|
|
|
case 4:
|
|
|
|
|
return "博士"
|
|
|
|
|
default:
|
|
|
|
|
return "无"
|
|
|
|
|
}
|
|
|
|
|
return "无"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 学历类型
|
|
|
|
|
func getXueWeiClass(id int) string {
|
|
|
|
|
switch id {
|
|
|
|
|
case 2:
|
|
|
|
|
return "第一学历"
|
|
|
|
|
case 3:
|
|
|
|
|
return "最高学历"
|
|
|
|
|
default:
|
|
|
|
|
return "普通"
|
|
|
|
|
}
|
|
|
|
|
return "普通"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 工作履历
|
|
|
|
|
func getWorkHistoryList(key int64) (workHisList []workHistoryAry) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var workHisContList []models.WorkHistory
|
|
|
|
|
workHisContListErr := overall.CONSTANT_DB_HR.Where("`state` = 1 AND `key` = ?", key).Order("entry_time desc").Find(&workHisContList).Error
|
|
|
|
|
if workHisContListErr == nil {
|
|
|
|
|
for _, v := range workHisContList {
|
|
|
|
|
var workCont workHistoryAry
|
|
|
|
|
workCont.Company = v.Company //公司
|
|
|
|
|
workCont.Department = v.Deparment //部门
|
|
|
|
|
workCont.Position = v.Job //职务
|
|
|
|
|
if v.EntryTime != 0 {
|
|
|
|
|
workCont.EntryTime = overallhandle.UnixTimeToDay(v.EntryTime, 14) //入职时间
|
|
|
|
|
}
|
|
|
|
|
if v.Leavedate != 0 {
|
|
|
|
|
workCont.LeaveDate = overallhandle.UnixTimeToDay(v.Leavedate, 14) //离职日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workCont.Witness = v.Witness //证明人
|
|
|
|
|
workCont.WitnessTel = v.WitnessTel //证明人电话
|
|
|
|
|
workCont.Remarks = v.Remarks //备注
|
|
|
|
|
workCont.WorkCont = v.WorkCont //
|
|
|
|
|
workCont.SuperiorPosition = v.SuperiorPosition //
|
|
|
|
|
workCont.MinionNumber = strconv.Itoa(v.MinionNumber) //
|
|
|
|
|
workHisList = append(workHisList, workCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加双职工
|
|
|
|
|
func (s *StaffApi) AddDoubleWorkerApi(c *gin.Context) {
|
|
|
|
|
var requestData DoubleWorkerCont
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// overallhandle.Result(100, err, c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c, "参数错误")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Name == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Name, c, "请输入姓名")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Mobilephone == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Mobilephone, c, "请输入联系方式")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var manCont models.PersonArchives
|
|
|
|
|
manCont.GetCont(map[string]interface{}{"`key`": requestData.Id}, "`number`")
|
|
|
|
|
var doubleWorkInfo models.DoubleWorker
|
|
|
|
|
doubleWorkInfo.Number = manCont.Number
|
|
|
|
|
doubleWorkInfo.Name = requestData.Name
|
|
|
|
|
doubleWorkInfo.Company = requestData.Company
|
|
|
|
|
doubleWorkInfo.Department = requestData.Department
|
|
|
|
|
doubleWorkInfo.Position = requestData.Position
|
|
|
|
|
doubleWorkInfo.Tel = requestData.Mobilephone
|
|
|
|
|
doubleWorkInfo.Time = time.Now().Unix()
|
|
|
|
|
doubleWorkInfo.State = 1
|
|
|
|
|
keyInt, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
doubleWorkInfo.Key = keyInt
|
|
|
|
|
addErr := overall.CONSTANT_DB_HR.Create(&doubleWorkInfo).Error
|
|
|
|
|
if addErr != nil {
|
|
|
|
|
overallhandle.Result(104, addErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
overallhandle.Result(0, addErr, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑双职工
|
|
|
|
|
func (s *StaffApi) EidtDoubleWorkerApi(c *gin.Context) {
|
|
|
|
|
var requestData DoubleWorkerCont
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// overallhandle.Result(100, err, c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.DoubleWorker
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
if requestData.Name != "" && requestData.Name != doubleWorkCont.Name {
|
|
|
|
|
saveData["name"] = requestData.Name
|
|
|
|
|
}
|
|
|
|
|
if requestData.Company != "" && requestData.Company != doubleWorkCont.Company {
|
|
|
|
|
saveData["company"] = requestData.Company
|
|
|
|
|
}
|
|
|
|
|
if requestData.Department != "" && requestData.Department != doubleWorkCont.Department {
|
|
|
|
|
saveData["department"] = requestData.Department
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position != "" && requestData.Position != doubleWorkCont.Position {
|
|
|
|
|
saveData["position"] = requestData.Position
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.Mobilephone != "" && requestData.Mobilephone != doubleWorkCont.Tel {
|
|
|
|
|
saveData["tel"] = requestData.Mobilephone
|
|
|
|
|
}
|
|
|
|
|
if len(saveData) > 0 {
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
var eidtCont models.DoubleWorker
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑双职工状态
|
|
|
|
|
func (s *StaffApi) EidtDoubleWorkerState(c *gin.Context) {
|
|
|
|
|
var requestData eidtWorkState
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.DoubleWorker
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.State == 0 {
|
|
|
|
|
requestData.State = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.IsDel <= 1 {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.DoubleWorker
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.State == 3 {
|
|
|
|
|
delErr := overall.CONSTANT_DB_HR.Where(map[string]interface{}{"`id`": requestData.Id}).Delete(&models.DoubleWorker{}).Error
|
|
|
|
|
if delErr == nil {
|
|
|
|
|
overallhandle.Result(0, delErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(108, delErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.DoubleWorker
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加紧急联系人
|
|
|
|
|
func (s *StaffApi) AddEmercyCall(c *gin.Context) {
|
|
|
|
|
var requestData addEmergencyContact
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" || len(requestData.List) <= 0 {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
keyInt, keyErr := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
if keyErr != nil {
|
|
|
|
|
overallhandle.Result(100, keyErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var manCont models.PersonArchives
|
|
|
|
|
manErr := manCont.GetCont(map[string]interface{}{"`key`": keyInt}, "`number`")
|
|
|
|
|
if manErr != nil {
|
|
|
|
|
overallhandle.Result(107, manErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var emerContList []models.EmergencyContact
|
|
|
|
|
isWrite := 1
|
|
|
|
|
for _, v := range requestData.List {
|
|
|
|
|
if v.Name != "" && v.Mobilephone != "" {
|
|
|
|
|
var emerContCont models.EmergencyContact
|
|
|
|
|
emerContCont.Number = manCont.Number //员工工号;index"`
|
|
|
|
|
emerContCont.Name = v.Name //紧急联系人姓名"`
|
|
|
|
|
emerContCont.Relationship = v.Relationship //与紧急联系人关系"`
|
|
|
|
|
emerContCont.Tel = v.Mobilephone //紧急联系人电话"`
|
|
|
|
|
emerContCont.Time = time.Now().Unix() //创建时间"`
|
|
|
|
|
emerContCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
emerContCont.Key = keyInt //
|
|
|
|
|
emerContList = append(emerContList, emerContCont)
|
|
|
|
|
} else {
|
|
|
|
|
isWrite = 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isWrite != 1 {
|
|
|
|
|
overallhandle.Result(100, requestData.List, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(emerContList) <= 0 {
|
|
|
|
|
overallhandle.Result(1, emerContList, c, "没有要添加的数据!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
addErr := overall.CONSTANT_DB_HR.Create(&emerContList).Error
|
|
|
|
|
if addErr != nil {
|
|
|
|
|
overallhandle.Result(104, requestData.List, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, addErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑紧急联系人
|
|
|
|
|
func (s *StaffApi) EditEmercyCall(c *gin.Context) {
|
|
|
|
|
var requestData emergencyContact
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var enerCont models.EmergencyContact
|
|
|
|
|
err := enerCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`name`", "`relationship`", "`tel`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(105, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
if requestData.Name != "" && requestData.Name != enerCont.Name {
|
|
|
|
|
saveData["name"] = requestData.Name
|
|
|
|
|
}
|
|
|
|
|
if requestData.Relationship != "" && requestData.Relationship != enerCont.Relationship {
|
|
|
|
|
saveData["relationship"] = requestData.Relationship
|
|
|
|
|
}
|
|
|
|
|
if requestData.Mobilephone != "" && requestData.Mobilephone != enerCont.Tel {
|
|
|
|
|
saveData["tel"] = requestData.Mobilephone
|
|
|
|
|
}
|
|
|
|
|
if len(saveData) > 0 {
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
eidtErr := enerCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr != nil {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑紧急联系人
|
|
|
|
|
func (s *StaffApi) EditEmercyCallState(c *gin.Context) {
|
|
|
|
|
var requestData eidtWorkState
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.EmergencyContact
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.State == 0 {
|
|
|
|
|
requestData.State = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.IsDel <= 1 {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.EmergencyContact
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.State == 3 {
|
|
|
|
|
delErr := overall.CONSTANT_DB_HR.Where(map[string]interface{}{"`id`": requestData.Id}).Delete(&models.EmergencyContact{}).Error
|
|
|
|
|
if delErr == nil {
|
|
|
|
|
overallhandle.Result(0, delErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(108, delErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.EmergencyContact
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加家庭成员
|
|
|
|
|
func (s *StaffApi) AddFamilyMembers(c *gin.Context) {
|
|
|
|
|
var requestData addFamilyPeople
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(101, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" || len(requestData.List) <= 0 {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
keyInt, keyErr := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
if keyErr != nil {
|
|
|
|
|
overallhandle.Result(100, keyErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var manCont models.PersonArchives
|
|
|
|
|
manErr := manCont.GetCont(map[string]interface{}{"`key`": keyInt}, "`number`")
|
|
|
|
|
if manErr != nil {
|
|
|
|
|
overallhandle.Result(107, manErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var emerContList []models.FamilyMembers
|
|
|
|
|
isWrite := 1
|
|
|
|
|
for _, v := range requestData.List {
|
|
|
|
|
if v.Name != "" && v.Mobilephone != "" {
|
|
|
|
|
var emerContCont models.FamilyMembers
|
|
|
|
|
emerContCont.Number = manCont.Number
|
|
|
|
|
emerContCont.Relationship = v.Relationship //与家属关系"`
|
|
|
|
|
emerContCont.Name = v.Name //家属姓名"`
|
|
|
|
|
emerContCont.Company = v.Company
|
|
|
|
|
emerContCont.Deparment = v.Department
|
|
|
|
|
emerContCont.Postnme = v.Position
|
|
|
|
|
emerContCont.Tel = v.Mobilephone //家属电话"`
|
|
|
|
|
poloutlook := v.PoliticalOutlook
|
|
|
|
|
if poloutlook == 0 {
|
|
|
|
|
poloutlook = 1
|
|
|
|
|
}
|
|
|
|
|
emerContCont.PoliticalOutlook = poloutlook
|
|
|
|
|
emerContCont.Time = time.Now().Unix() //创建时间"`
|
|
|
|
|
emerContCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
emerContCont.Key = keyInt //
|
|
|
|
|
emerContList = append(emerContList, emerContCont)
|
|
|
|
|
} else {
|
|
|
|
|
isWrite = 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isWrite != 1 {
|
|
|
|
|
overallhandle.Result(100, requestData.List, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(emerContList) <= 0 {
|
|
|
|
|
overallhandle.Result(1, emerContList, c, "没有要添加的数据!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
addErr := overall.CONSTANT_DB_HR.Create(&emerContList).Error
|
|
|
|
|
if addErr != nil {
|
|
|
|
|
overallhandle.Result(104, requestData.List, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, addErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑家属信息
|
|
|
|
|
func (s *StaffApi) EditFamilyMembers(c *gin.Context) {
|
|
|
|
|
var requestData memberOfFamily
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var enerCont models.FamilyMembers
|
|
|
|
|
err := enerCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(105, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
if requestData.Name != "" && requestData.Name != enerCont.Name {
|
|
|
|
|
saveData["name"] = requestData.Name
|
|
|
|
|
}
|
|
|
|
|
if requestData.Relationship != "" && requestData.Relationship != enerCont.Relationship {
|
|
|
|
|
saveData["relation"] = requestData.Relationship
|
|
|
|
|
}
|
|
|
|
|
if requestData.Mobilephone != "" && requestData.Mobilephone != enerCont.Tel {
|
|
|
|
|
saveData["tel"] = requestData.Mobilephone
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.Company != "" && requestData.Company != enerCont.Company {
|
|
|
|
|
saveData["company"] = requestData.Company
|
|
|
|
|
}
|
|
|
|
|
if requestData.Department != "" && requestData.Department != enerCont.Deparment {
|
|
|
|
|
saveData["deparment"] = requestData.Department
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position != "" && requestData.Position != enerCont.Postnme {
|
|
|
|
|
saveData["postnme"] = requestData.Position
|
|
|
|
|
}
|
|
|
|
|
if requestData.PoliticalOutlook != 0 && requestData.PoliticalOutlook != enerCont.PoliticalOutlook {
|
|
|
|
|
saveData["political_outlook"] = requestData.PoliticalOutlook
|
|
|
|
|
}
|
|
|
|
|
if len(saveData) > 0 {
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
eidtErr := enerCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr != nil {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑家属状态
|
|
|
|
|
func (s *StaffApi) EditFamilyMembersSatte(c *gin.Context) {
|
|
|
|
|
var requestData eidtWorkState
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.FamilyMembers
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.State == 0 {
|
|
|
|
|
requestData.State = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.IsDel <= 1 {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.FamilyMembers
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.State == 3 {
|
|
|
|
|
delErr := overall.CONSTANT_DB_HR.Where(map[string]interface{}{"`id`": requestData.Id}).Delete(&models.FamilyMembers{}).Error
|
|
|
|
|
if delErr == nil {
|
|
|
|
|
overallhandle.Result(0, delErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(108, delErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.FamilyMembers
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加教育经历
|
|
|
|
|
func (s *StaffApi) AddEducationalExperience(c *gin.Context) {
|
|
|
|
|
var requestData addExpToSchool
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
// err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// overallhandle.Result(101, err, c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if requestData.Id == "" || len(requestData.List) <= 0 {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
keyInt, keyErr := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
if keyErr != nil {
|
|
|
|
|
overallhandle.Result(100, keyErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var manCont models.PersonArchives
|
|
|
|
|
manErr := manCont.GetCont(map[string]interface{}{"`key`": keyInt}, "`number`")
|
|
|
|
|
if manErr != nil {
|
|
|
|
|
overallhandle.Result(107, manErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var emerContList []models.PersonnelEducation
|
|
|
|
|
isWrite := 1
|
|
|
|
|
for _, v := range requestData.List {
|
|
|
|
|
if v.GraduationSchool != "" && v.Subject != "" {
|
|
|
|
|
var emerContCont models.PersonnelEducation
|
|
|
|
|
emerContCont.Number = manCont.Number
|
|
|
|
|
eduCation := v.Education
|
|
|
|
|
if eduCation == 0 {
|
|
|
|
|
eduCation = 1
|
|
|
|
|
}
|
|
|
|
|
emerContCont.Education = eduCation
|
|
|
|
|
emerContCont.EducationCn = overallhandle.DucationToInt(eduCation)
|
|
|
|
|
emerContCont.GraduationSchool = v.GraduationSchool
|
|
|
|
|
emerContCont.Subject = v.Subject
|
|
|
|
|
entranceTimeFirst := time.Now().Unix()
|
|
|
|
|
if v.AdmissionTime != "" {
|
|
|
|
|
entranceTimeFirst, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.AdmissionTime))
|
|
|
|
|
}
|
|
|
|
|
emerContCont.AdmissionTime = entranceTimeFirst // 入学时间"`
|
|
|
|
|
graduationTimef := time.Now().Unix()
|
|
|
|
|
if v.GraduationTime != "" {
|
|
|
|
|
graduationTimef, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.GraduationTime))
|
|
|
|
|
}
|
|
|
|
|
emerContCont.GraduationTime = graduationTimef // 毕业时间"`
|
|
|
|
|
emerContCont.Time = time.Now().Unix() // 写入时间"`
|
|
|
|
|
acaLeve, _ := strconv.Atoi(v.AcademicDegree)
|
|
|
|
|
if acaLeve == 0 {
|
|
|
|
|
acaLeve = 1
|
|
|
|
|
}
|
|
|
|
|
emerContCont.AcademicDegree = acaLeve
|
|
|
|
|
switch acaLeve {
|
|
|
|
|
case 2:
|
|
|
|
|
emerContCont.AcademicDegreeCn = "学士"
|
|
|
|
|
case 3:
|
|
|
|
|
emerContCont.AcademicDegreeCn = "硕士"
|
|
|
|
|
case 4:
|
|
|
|
|
emerContCont.AcademicDegreeCn = "博士"
|
|
|
|
|
case 5:
|
|
|
|
|
emerContCont.AcademicDegreeCn = "教育学学位"
|
|
|
|
|
default:
|
|
|
|
|
emerContCont.AcademicDegreeCn = "无"
|
|
|
|
|
}
|
|
|
|
|
emerContCont.Time = time.Now().Unix() //创建时间"`
|
|
|
|
|
emerContCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
emerContCont.Key = keyInt //
|
|
|
|
|
switch v.Level {
|
|
|
|
|
case "2":
|
|
|
|
|
var editPerCont models.PersonnelEducation
|
|
|
|
|
editPerCont.EiteCont(map[string]interface{}{"`key`": keyInt, "`level`": 2}, map[string]interface{}{"`level`": 1})
|
|
|
|
|
emerContCont.Level = 2
|
|
|
|
|
case "3":
|
|
|
|
|
var editPerCont models.PersonnelEducation
|
|
|
|
|
editPerCont.EiteCont(map[string]interface{}{"`key`": keyInt, "`level`": 3}, map[string]interface{}{"`level`": 1})
|
|
|
|
|
emerContCont.Level = 3
|
|
|
|
|
default:
|
|
|
|
|
emerContCont.Level = 1
|
|
|
|
|
}
|
|
|
|
|
emerContList = append(emerContList, emerContCont)
|
|
|
|
|
} else {
|
|
|
|
|
isWrite = 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isWrite != 1 {
|
|
|
|
|
overallhandle.Result(100, requestData.List, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(emerContList) <= 0 {
|
|
|
|
|
overallhandle.Result(1, emerContList, c, "没有要添加的数据!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
addErr := overall.CONSTANT_DB_HR.Create(&emerContList).Error
|
|
|
|
|
if addErr != nil {
|
|
|
|
|
overallhandle.Result(104, requestData.List, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, addErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑教育经历
|
|
|
|
|
func (s *StaffApi) EditEducationalExperience(c *gin.Context) {
|
|
|
|
|
var requestData editExpToSchool
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var enerCont models.PersonnelEducation
|
|
|
|
|
err := enerCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(105, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
if requestData.GraduationSchool != "" && requestData.GraduationSchool != enerCont.GraduationSchool {
|
|
|
|
|
saveData["graduation_school"] = requestData.GraduationSchool
|
|
|
|
|
}
|
|
|
|
|
if requestData.Subject != "" && requestData.Subject != enerCont.Subject {
|
|
|
|
|
saveData["subject"] = requestData.Subject
|
|
|
|
|
}
|
|
|
|
|
if requestData.Education != 0 && requestData.Education != enerCont.Education {
|
|
|
|
|
saveData["education"] = requestData.Education
|
|
|
|
|
saveData["education_cn"] = overallhandle.DucationToInt(requestData.Education)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.AdmissionTime != "" {
|
|
|
|
|
admissionTimeInt, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.AdmissionTime))
|
|
|
|
|
if admissionTimeInt != enerCont.AdmissionTime {
|
|
|
|
|
saveData["admission_time"] = admissionTimeInt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if requestData.GraduationTime != "" {
|
|
|
|
|
graduationTimeInt, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.GraduationTime))
|
|
|
|
|
if graduationTimeInt != enerCont.GraduationTime {
|
|
|
|
|
saveData["graduation_time"] = graduationTimeInt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if requestData.AcademicDegree != "" {
|
|
|
|
|
acaLeve, _ := strconv.Atoi(requestData.AcademicDegree)
|
|
|
|
|
if acaLeve != enerCont.AcademicDegree {
|
|
|
|
|
saveData["academic_degree"] = acaLeve
|
|
|
|
|
switch acaLeve {
|
|
|
|
|
case 2:
|
|
|
|
|
saveData["academic_degree_cn"] = "学士"
|
|
|
|
|
case 3:
|
|
|
|
|
saveData["academic_degree_cn"] = "硕士"
|
|
|
|
|
case 4:
|
|
|
|
|
saveData["academic_degree_cn"] = "博士"
|
|
|
|
|
case 5:
|
|
|
|
|
saveData["academic_degree_cn"] = "教育学学位"
|
|
|
|
|
default:
|
|
|
|
|
saveData["academic_degree_cn"] = "无"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.Level != "" {
|
|
|
|
|
levelInt, _ := strconv.Atoi(requestData.Level)
|
|
|
|
|
if levelInt != enerCont.Level {
|
|
|
|
|
switch levelInt {
|
|
|
|
|
case 2:
|
|
|
|
|
var editPerCont models.PersonnelEducation
|
|
|
|
|
editPerCont.EiteCont(map[string]interface{}{"`key`": enerCont.Key, "`level`": 2}, map[string]interface{}{"`level`": 1})
|
|
|
|
|
saveData["level"] = 2
|
|
|
|
|
case 3:
|
|
|
|
|
var editPerCont models.PersonnelEducation
|
|
|
|
|
editPerCont.EiteCont(map[string]interface{}{"`key`": enerCont.Key, "`level`": 3}, map[string]interface{}{"`level`": 1})
|
|
|
|
|
saveData["level"] = 3
|
|
|
|
|
default:
|
|
|
|
|
saveData["level"] = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(saveData) > 0 {
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
eidtErr := enerCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr != nil {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑教育经历状态
|
|
|
|
|
func (s *StaffApi) EditEduExpState(c *gin.Context) {
|
|
|
|
|
var requestData eidtWorkState
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.PersonnelEducation
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.State == 0 {
|
|
|
|
|
requestData.State = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.IsDel <= 1 {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.PersonnelEducation
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.State == 3 {
|
|
|
|
|
delErr := overall.CONSTANT_DB_HR.Where(map[string]interface{}{"`id`": requestData.Id}).Delete(&models.PersonnelEducation{}).Error
|
|
|
|
|
if delErr == nil {
|
|
|
|
|
overallhandle.Result(0, delErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(108, delErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.PersonnelEducation
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加工作履历
|
|
|
|
|
func (s *StaffApi) AddWorkHistoryCont(c *gin.Context) {
|
|
|
|
|
var requestData addWorkHistory
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
// err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
// if err != nil {
|
|
|
|
|
// overallhandle.Result(101, err, c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if requestData.Id == "" || len(requestData.List) <= 0 {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
keyInt, keyErr := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
if keyErr != nil {
|
|
|
|
|
overallhandle.Result(100, keyErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var manCont models.PersonArchives
|
|
|
|
|
manErr := manCont.GetCont(map[string]interface{}{"`key`": keyInt}, "`number`")
|
|
|
|
|
if manErr != nil {
|
|
|
|
|
overallhandle.Result(107, manErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var emerContList []models.WorkHistory
|
|
|
|
|
isWrite := 1
|
|
|
|
|
for _, v := range requestData.List {
|
|
|
|
|
if v.Company != "" && v.Department != "" {
|
|
|
|
|
var emerContCont models.WorkHistory
|
|
|
|
|
emerContCont.Number = manCont.Number
|
|
|
|
|
emerContCont.Key = keyInt
|
|
|
|
|
|
|
|
|
|
emerContCont.Company = v.Company //公司"`
|
|
|
|
|
emerContCont.Deparment = v.Department //部门"`
|
|
|
|
|
emerContCont.Job = v.Position //职务"`
|
|
|
|
|
joinTime := time.Now().Unix()
|
|
|
|
|
if v.EntryTime != "" {
|
|
|
|
|
joinTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.EntryTime))
|
|
|
|
|
}
|
|
|
|
|
emerContCont.EntryTime = joinTime //入职时间"`
|
|
|
|
|
outTime := time.Now().Unix()
|
|
|
|
|
if v.LeaveDate != "" {
|
|
|
|
|
outTime, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", v.LeaveDate))
|
|
|
|
|
}
|
|
|
|
|
emerContCont.Leavedate = outTime //离职日期"`
|
|
|
|
|
emerContCont.Witness = v.Witness //证明人"`
|
|
|
|
|
emerContCont.WitnessTel = v.WitnessTel //证明人电话"`
|
|
|
|
|
emerContCont.Remarks = v.Remarks //备注"`
|
|
|
|
|
emerContCont.Time = time.Now().Unix() //创建时间"`
|
|
|
|
|
emerContCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
|
|
|
|
|
emerContList = append(emerContList, emerContCont)
|
|
|
|
|
} else {
|
|
|
|
|
isWrite = 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isWrite != 1 {
|
|
|
|
|
overallhandle.Result(100, requestData.List, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(emerContList) <= 0 {
|
|
|
|
|
overallhandle.Result(1, emerContList, c, "没有要添加的数据!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
addErr := overall.CONSTANT_DB_HR.Create(&emerContList).Error
|
|
|
|
|
if addErr != nil {
|
|
|
|
|
overallhandle.Result(104, requestData.List, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, addErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑工作履历
|
|
|
|
|
func (s *StaffApi) EditWorkHistoryCont(c *gin.Context) {
|
|
|
|
|
var requestData editWorkHistory
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var enerCont models.WorkHistory
|
|
|
|
|
err := enerCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(105, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
if requestData.Company != "" && requestData.Company != enerCont.Company {
|
|
|
|
|
saveData["company"] = requestData.Company
|
|
|
|
|
}
|
|
|
|
|
if requestData.Department != "" && requestData.Department != enerCont.Deparment {
|
|
|
|
|
saveData["deparment"] = requestData.Department
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position != "" && requestData.Position != enerCont.Job {
|
|
|
|
|
saveData["job"] = requestData.Position
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.EntryTime != "" {
|
|
|
|
|
EntryTimeInt, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EntryTime))
|
|
|
|
|
if EntryTimeInt != enerCont.EntryTime {
|
|
|
|
|
saveData["entry_time"] = EntryTimeInt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if requestData.LeaveDate != "" {
|
|
|
|
|
LeaveDateInt, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.LeaveDate))
|
|
|
|
|
if LeaveDateInt != enerCont.Leavedate {
|
|
|
|
|
saveData["leavedate"] = LeaveDateInt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.Witness != "" && requestData.Witness != enerCont.Witness {
|
|
|
|
|
saveData["witness"] = requestData.Witness
|
|
|
|
|
}
|
|
|
|
|
if requestData.WitnessTel != "" && requestData.WitnessTel != enerCont.WitnessTel {
|
|
|
|
|
saveData["witness_tel"] = requestData.WitnessTel
|
|
|
|
|
}
|
|
|
|
|
if requestData.Remarks != "" && requestData.Remarks != enerCont.Remarks {
|
|
|
|
|
saveData["remarks"] = requestData.Remarks
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(saveData) > 0 {
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
eidtErr := enerCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr != nil {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑工作履历状态
|
|
|
|
|
func (s *StaffApi) EditWorkHistoryState(c *gin.Context) {
|
|
|
|
|
var requestData eidtWorkState
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.WorkHistory
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.State == 0 {
|
|
|
|
|
requestData.State = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.IsDel <= 1 {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.WorkHistory
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.State == 3 {
|
|
|
|
|
delErr := overall.CONSTANT_DB_HR.Where(map[string]interface{}{"`id`": requestData.Id}).Delete(&models.WorkHistory{}).Error
|
|
|
|
|
if delErr == nil {
|
|
|
|
|
overallhandle.Result(0, delErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(108, delErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.WorkHistory
|
|
|
|
|
eidtErr := eidtCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 集团内部工作履历
|
|
|
|
|
func getGroupWorkHistoryList(key int64) (workHisList []insideHistory) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var workHisContList []models.InsideWorkHistory
|
|
|
|
|
workHisContListErr := overall.CONSTANT_DB_HR.Where("`state` IN ? AND `key` = ?", []int{1, 2}, key).Order("start_time desc").Find(&workHisContList).Error
|
|
|
|
|
if workHisContListErr == nil {
|
|
|
|
|
for _, v := range workHisContList {
|
|
|
|
|
var workCont insideHistory
|
|
|
|
|
workCont.Bdlx = v.Bdlx
|
|
|
|
|
workCont.Gsmc = v.Gsmc
|
|
|
|
|
workCont.Yjbm = v.Yjbm
|
|
|
|
|
workCont.Ejbm = v.Ejbm
|
|
|
|
|
workCont.Gongduan = v.Gongduan
|
|
|
|
|
workCont.Dengji = v.Dengji
|
|
|
|
|
workCont.Zhiwei = v.Zhiwei
|
|
|
|
|
if v.Group != 0 {
|
|
|
|
|
var groupInfo models.AdministrativeOrganization
|
|
|
|
|
groupInfo.GetCont(map[string]interface{}{"`id`": v.Group}, "`name`")
|
|
|
|
|
workCont.Group = groupInfo.Name //集团
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v.Company != 0 {
|
|
|
|
|
var companyInfo models.AdministrativeOrganization
|
|
|
|
|
companyInfo.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`")
|
|
|
|
|
workCont.Company = companyInfo.Name //公司
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v.Department != 0 {
|
|
|
|
|
var deparment models.AdministrativeOrganization
|
|
|
|
|
deparment.GetCont(map[string]interface{}{"`id`": v.Department}, "`name`")
|
|
|
|
|
workCont.Department = deparment.Name //部门
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v.WorkShop != 0 {
|
|
|
|
|
var workshop models.AdministrativeOrganization
|
|
|
|
|
workshop.GetCont(map[string]interface{}{"`id`": v.WorkShop}, "`name`")
|
|
|
|
|
workCont.Workshop = workshop.Name //二级部门或车间
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if v.WorkshopSection != 0 {
|
|
|
|
|
var workshopsetdsas models.AdministrativeOrganization
|
|
|
|
|
workshopsetdsas.GetCont(map[string]interface{}{"`id`": v.WorkshopSection}, "`name`")
|
|
|
|
|
workCont.WorkshopSection = workshopsetdsas.Name //二级部门或车间
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var positCont models.Position
|
|
|
|
|
if v.Position != 0 {
|
|
|
|
|
positCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`", "`superior`")
|
|
|
|
|
workCont.Position = positCont.Name //职务
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workCont.GradePositions = v.GradePositions //职等
|
|
|
|
|
if v.StartTime != 0 {
|
|
|
|
|
workCont.StartTime = overallhandle.UnixTimeToDay(v.StartTime, 14) //开始日期
|
|
|
|
|
}
|
|
|
|
|
if v.EndTime != 0 {
|
|
|
|
|
workCont.EndTime = overallhandle.UnixTimeToDay(v.EndTime, 14) //结束日期
|
|
|
|
|
} else {
|
|
|
|
|
workCont.EndTime = "至今"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workCont.ChangeType = v.ChangeType //
|
|
|
|
|
workCont.WorkCont = v.WorkCont
|
|
|
|
|
if v.SuperiorPosition != "" {
|
|
|
|
|
workCont.SuperiorPosition = v.SuperiorPosition
|
|
|
|
|
} else {
|
|
|
|
|
if positCont.Superior != 0 {
|
|
|
|
|
var positContSuper models.Position
|
|
|
|
|
positContSuper.GetCont(map[string]interface{}{"`id`": positCont.Superior}, "`name`")
|
|
|
|
|
workCont.SuperiorPosition = positContSuper.Name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取
|
|
|
|
|
if v.Subordinates == 0 {
|
|
|
|
|
var mySunAllPost GainAllId
|
|
|
|
|
mySunAllPost.GetAllContId(v.Position)
|
|
|
|
|
if len(mySunAllPost.Id) > 0 {
|
|
|
|
|
var allPeople int64
|
|
|
|
|
overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Where("`position` IN ? AND emp_type < 11", mySunAllPost.Id).Count(&allPeople)
|
|
|
|
|
if allPeople == 0 {
|
|
|
|
|
workCont.MinionNumber = ""
|
|
|
|
|
} else {
|
|
|
|
|
workCont.MinionNumber = strconv.FormatInt(allPeople, 10)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
workCont.MinionNumber = strconv.Itoa(v.Subordinates)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workHisList = append(workHisList, workCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取所有下属职务
|
|
|
|
|
func (g *GainAllId) GetAllContId(id int64) {
|
|
|
|
|
if id != 0 {
|
|
|
|
|
var postIdList []int64
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Model(&models.Position{}).Select("`id`").Where("`state` = 1 AND `superior` = ?", id).Find(&postIdList)
|
|
|
|
|
if err == nil {
|
|
|
|
|
|
|
|
|
|
for _, v := range postIdList {
|
|
|
|
|
if v != 0 {
|
|
|
|
|
if !overallhandle.IsInTrue[int64](v, g.Id) {
|
|
|
|
|
g.Id = append(g.Id, v)
|
|
|
|
|
}
|
|
|
|
|
g.GetAllContId(v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加工作履历
|
|
|
|
|
func (s *StaffApi) AddInsideHistory(c *gin.Context) {
|
|
|
|
|
var requestData eidtInsideHistoryWork
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(101, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.Id, c, "员工标识符不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.OrgId == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.Id, c, "行政组织不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// if requestData.Position == "" {
|
|
|
|
|
// overallhandle.Result(1, requestData.Id, c, "岗位不能为空")
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if requestData.Team == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.Id, c, "班组不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.StartTime == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.Id, c, "就任此职位开始时间不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.ChangeType == 0 {
|
|
|
|
|
requestData.ChangeType = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.AssignType == 0 {
|
|
|
|
|
requestData.AssignType = 2
|
|
|
|
|
}
|
|
|
|
|
var insiderHistoryWork models.InsideWorkHistory
|
|
|
|
|
idInt, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
insiderHistoryWork.Key = idInt
|
|
|
|
|
orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64)
|
|
|
|
|
insiderHistoryWork.Group, insiderHistoryWork.Company, insiderHistoryWork.Department, insiderHistoryWork.WorkShop, insiderHistoryWork.WorkshopSection = overallhandle.GetOrgStructure(orgIdInt)
|
|
|
|
|
positionInt, _ := strconv.ParseInt(requestData.Position, 10, 64)
|
|
|
|
|
insiderHistoryWork.Position = positionInt
|
|
|
|
|
insiderHistoryWork.GradePositions = requestData.GradePositions
|
|
|
|
|
startTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.StartTime))
|
|
|
|
|
insiderHistoryWork.StartTime = startTime
|
|
|
|
|
if requestData.EndTime != "" && requestData.EndTime != "0" && requestData.EndTime != "至今" {
|
|
|
|
|
endTime, endErr := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EndTime))
|
|
|
|
|
if endErr == true {
|
|
|
|
|
insiderHistoryWork.EndTime = endTime
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
teamIdInt, _ := strconv.ParseInt(requestData.Team, 10, 64)
|
|
|
|
|
insiderHistoryWork.Team = teamIdInt
|
|
|
|
|
insiderHistoryWork.ChangeType = requestData.ChangeType
|
|
|
|
|
insiderHistoryWork.Time = time.Now().Unix()
|
|
|
|
|
insiderHistoryWork.State = 1
|
|
|
|
|
insiderHistoryWork.AssignType = requestData.AssignType
|
|
|
|
|
jobIdInt, _ := strconv.ParseInt(requestData.JobId, 10, 64)
|
|
|
|
|
insiderHistoryWork.JobId = jobIdInt
|
|
|
|
|
addErr := overall.CONSTANT_DB_HR.Create(&insiderHistoryWork).Error
|
|
|
|
|
if addErr != nil {
|
|
|
|
|
overallhandle.Result(104, addErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, addErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑集团内部工作
|
|
|
|
|
func (s *StaffApi) EidtInsideHistoryWorkCont(c *gin.Context) {
|
|
|
|
|
var requestData eidtInsideHistoryWork
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(101, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.Id, c, "ID不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var insiderHistoryWork models.InsideWorkHistory
|
|
|
|
|
getErr := insiderHistoryWork.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if getErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
if requestData.OrgId == "" {
|
|
|
|
|
orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64)
|
|
|
|
|
groupId, companyId, departmentId, sunDepartId, workId := overallhandle.GetOrgStructure(orgIdInt)
|
|
|
|
|
if groupId != insiderHistoryWork.Group {
|
|
|
|
|
saveData["group"] = groupId
|
|
|
|
|
}
|
|
|
|
|
if companyId != insiderHistoryWork.Company {
|
|
|
|
|
saveData["company"] = groupId
|
|
|
|
|
}
|
|
|
|
|
if departmentId != insiderHistoryWork.Department {
|
|
|
|
|
saveData["department"] = groupId
|
|
|
|
|
}
|
|
|
|
|
if sunDepartId != insiderHistoryWork.WorkShop {
|
|
|
|
|
saveData["workshop"] = groupId
|
|
|
|
|
}
|
|
|
|
|
if workId != insiderHistoryWork.WorkshopSection {
|
|
|
|
|
saveData["workshop_section"] = groupId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position == "" {
|
|
|
|
|
positionInt, _ := strconv.ParseInt(requestData.Position, 10, 64)
|
|
|
|
|
if positionInt != insiderHistoryWork.Position {
|
|
|
|
|
saveData["position"] = positionInt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.Team == "" {
|
|
|
|
|
if requestData.Team != strconv.FormatInt(insiderHistoryWork.Team, 10) {
|
|
|
|
|
saveData["team"] = requestData.Team
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.StartTime == "" {
|
|
|
|
|
startTime, _ := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.StartTime))
|
|
|
|
|
if startTime != insiderHistoryWork.StartTime {
|
|
|
|
|
saveData["start_time"] = startTime
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.ChangeType != 0 {
|
|
|
|
|
if requestData.ChangeType != insiderHistoryWork.ChangeType {
|
|
|
|
|
saveData["change_type"] = requestData.ChangeType
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.AssignType != 0 {
|
|
|
|
|
if requestData.AssignType != insiderHistoryWork.AssignType {
|
|
|
|
|
saveData["assign_type"] = requestData.AssignType
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.EndTime != "" && requestData.EndTime != "0" && requestData.EndTime != "至今" {
|
|
|
|
|
endTime, endErr := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EndTime))
|
|
|
|
|
if endErr == true {
|
|
|
|
|
if endTime != insiderHistoryWork.EndTime {
|
|
|
|
|
saveData["end_time"] = endTime
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData["end_time"] = 0
|
|
|
|
|
}
|
|
|
|
|
if requestData.GradePositions != 0 && requestData.GradePositions != insiderHistoryWork.GradePositions {
|
|
|
|
|
saveData["grade_positions"] = requestData.GradePositions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if requestData.JobId != "" {
|
|
|
|
|
jobIdInt, _ := strconv.ParseInt(requestData.JobId, 10, 64)
|
|
|
|
|
if jobIdInt != insiderHistoryWork.JobId {
|
|
|
|
|
saveData["jobid"] = jobIdInt
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(saveData) > 0 {
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
eidtErr := insiderHistoryWork.EditCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, eidtErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, getErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 编辑或删除集团内工作记录
|
|
|
|
|
func (s *StaffApi) EditOrDelInsideWorkHistoryState(c *gin.Context) {
|
|
|
|
|
var requestData eidtWorkState
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var doubleWorkCont models.InsideWorkHistory
|
|
|
|
|
wErr := doubleWorkCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if wErr != nil {
|
|
|
|
|
overallhandle.Result(107, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.State == 0 {
|
|
|
|
|
requestData.State = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.IsDel <= 1 {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.InsideWorkHistory
|
|
|
|
|
eidtErr := eidtCont.EditCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.State == 3 {
|
|
|
|
|
delErr := overall.CONSTANT_DB_HR.Where(map[string]interface{}{"`id`": requestData.Id}).Delete(&models.InsideWorkHistory{}).Error
|
|
|
|
|
if delErr == nil {
|
|
|
|
|
overallhandle.Result(0, delErr, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(108, delErr, c)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["time"] = time.Now().Unix()
|
|
|
|
|
saveData["state"] = requestData.State
|
|
|
|
|
var eidtCont models.InsideWorkHistory
|
|
|
|
|
eidtErr := eidtCont.EditCont(map[string]interface{}{"`id`": requestData.Id}, saveData)
|
|
|
|
|
if eidtErr == nil {
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(106, eidtErr, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 集团内部工作经历列表
|
|
|
|
|
func (s *StaffApi) InsideWorkHistoryList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.InsideWorkView
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.InsideWorkView{}).Where("`state` IN (1,2) AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("end_time asc").Order("start_time desc").Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, insideWorkHistoryList, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 工作履历列表
|
|
|
|
|
func (s *StaffApi) WorkHistoryList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.WorkHistory
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.WorkHistory{}).Where("`state` IN (1,2) AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("`entry_time` desc").Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
} else {
|
|
|
|
|
var sendDataList []outWorkHistory
|
|
|
|
|
for _, w := range insideWorkHistoryList {
|
|
|
|
|
var sendCont outWorkHistory
|
|
|
|
|
sendCont.Id = w.Id //
|
|
|
|
|
sendCont.Number = w.Number // 工号"`
|
|
|
|
|
sendCont.Key = w.Key // 身份识别"`
|
|
|
|
|
sendCont.Company = w.Company // 公司"`
|
|
|
|
|
sendCont.Deparment = w.Deparment // 部门"`
|
|
|
|
|
sendCont.Job = w.Job // 职务"`
|
|
|
|
|
sendCont.EntryTime = w.EntryTime // 入职时间"`
|
|
|
|
|
sendCont.Leavedate = w.Leavedate // 离职日期"`
|
|
|
|
|
sendCont.Witness = w.Witness // 证明人"`
|
|
|
|
|
sendCont.WitnessTel = w.WitnessTel // 证明人电话"`
|
|
|
|
|
sendCont.Remarks = w.Remarks // 备注"`
|
|
|
|
|
sendCont.Time = w.Time // 创建时间"`
|
|
|
|
|
sendCont.State = w.State // 状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
sendCont.StartTime = overallhandle.UnixTimeToDay(w.EntryTime, 14) //开始时间
|
|
|
|
|
endTimeStr := "至今"
|
|
|
|
|
if w.Leavedate != 0 {
|
|
|
|
|
endTimeStr = overallhandle.UnixTimeToDay(w.Leavedate, 14)
|
|
|
|
|
}
|
|
|
|
|
sendCont.EndTime = endTimeStr //结束时间
|
|
|
|
|
sendDataList = append(sendDataList, sendCont)
|
|
|
|
|
}
|
|
|
|
|
overallhandle.Result(0, sendDataList, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 教育经历列表
|
|
|
|
|
func (s *StaffApi) PersonnelEducationList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.PersonnelEducation
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonnelEducation{}).Where("`state` IN (1,2) AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
} else {
|
|
|
|
|
var list []OutpersonCont
|
|
|
|
|
for _, v := range insideWorkHistoryList {
|
|
|
|
|
var cont OutpersonCont
|
|
|
|
|
cont.Id = v.Id //ID"`
|
|
|
|
|
cont.Number = v.Number //员工工号"`
|
|
|
|
|
cont.Education = v.Education // 学历(1:初中及以下;2:中专;3:高中;4:中技;5:高技;6:函数专科;7:大学专科;8:函数本科;9:大学本科;10:硕士研究生;11:博士研究生;12:专家、教授)"`
|
|
|
|
|
cont.GraduationSchool = v.GraduationSchool //毕业学校"`
|
|
|
|
|
cont.Subject = v.Subject //专业"`
|
|
|
|
|
cont.AdmissionTime = v.AdmissionTime //入学时间"`
|
|
|
|
|
cont.GraduationTime = v.GraduationTime //毕业时间"`
|
|
|
|
|
cont.Time = v.Time //写入时间"`
|
|
|
|
|
cont.Level = v.Level // 学历类型(1:普通;2:第一学历;3:最高学历)"`
|
|
|
|
|
cont.AcademicDegree = v.AcademicDegree // 学位(1:无;2:学士;3:硕士;4:博士)"`
|
|
|
|
|
cont.Key = v.Key //key"`
|
|
|
|
|
cont.State = v.State // 状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
cont.AcademicDegreeCn = v.AcademicDegreeCn //学位中文说明"`
|
|
|
|
|
cont.EducationCn = v.EducationCn //学历中文说明"`
|
|
|
|
|
if v.AdmissionTime != 0 {
|
|
|
|
|
cont.AdmissionTimeStr = overallhandle.UnixTimeToDay(v.AdmissionTime, 14)
|
|
|
|
|
}
|
|
|
|
|
if v.GraduationTime != 0 {
|
|
|
|
|
cont.GraduationTimeStr = overallhandle.UnixTimeToDay(v.GraduationTime, 14)
|
|
|
|
|
} else {
|
|
|
|
|
cont.GraduationTimeStr = "至今"
|
|
|
|
|
}
|
|
|
|
|
// xueXiaoType := overallhandle.EducationTypeAll(int64(v.SchoolType))
|
|
|
|
|
if v.YuanXiaoLeiXing != "" {
|
|
|
|
|
cont.YuanXiaoLeiXing = v.YuanXiaoLeiXing
|
|
|
|
|
} else {
|
|
|
|
|
cont.YuanXiaoLeiXing = overallhandle.EducationTypeAll(int64(v.SchoolType))
|
|
|
|
|
}
|
|
|
|
|
cont.CollegeFaction = v.CollegeFaction
|
|
|
|
|
if v.XueLiLeixing != "" {
|
|
|
|
|
cont.XueLiLeixing = v.XueLiLeixing
|
|
|
|
|
} else {
|
|
|
|
|
cont.XueLiLeixing = overallhandle.EducationTypeAll(int64(v.EducationType))
|
|
|
|
|
}
|
|
|
|
|
list = append(list, cont)
|
|
|
|
|
}
|
|
|
|
|
overallhandle.Result(0, list, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 家庭成员列表
|
|
|
|
|
func (s *StaffApi) FamilyMemBersList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.FamilyMembers
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.FamilyMembers{}).Where("`state` IN (1,2) AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
for i, v := range insideWorkHistoryList {
|
|
|
|
|
insideWorkHistoryList[i].PoliticalOutlookCn = overallhandle.PolitiToString(v.PoliticalOutlook)
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, insideWorkHistoryList, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 紧急联系人列表
|
|
|
|
|
func (s *StaffApi) EmergencyContactList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.EmergencyContact
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.EmergencyContact{}).Where("`state` IN (1,2) AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, insideWorkHistoryList, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 双职工列表
|
|
|
|
|
func (s *StaffApi) DoubleWorkerList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.DoubleWorker
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.DoubleWorker{}).Where("`state` IN (1,2) AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(0, insideWorkHistoryList, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-10-19 09:40:32
|
|
|
|
|
@ 功能: 根据微信或企业微信UserId获取人员信息
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#OpenId 微信或企业微信UserId
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) WeChatGiveUsCont(c *gin.Context) {
|
|
|
|
|
var requestData weChatUserId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(100, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.OpenId == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var userCont models.ManCont
|
|
|
|
|
staffErr := overall.CONSTANT_DB_HR.Where("`wechat` = ? OR `work_wechat` = ?", requestData.OpenId, requestData.OpenId).First(&userCont).Error
|
|
|
|
|
if staffErr != nil {
|
|
|
|
|
overallhandle.Result(105, staffErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
switch userCont.State {
|
|
|
|
|
case 2:
|
|
|
|
|
overallhandle.Result(0, staffErr, c, "该账号已经被禁用!不可进行操作!")
|
|
|
|
|
return
|
|
|
|
|
case 3:
|
|
|
|
|
overallhandle.Result(0, staffErr, c, "该账号已经被离开企业!不可进行操作!")
|
|
|
|
|
return
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
if userCont.EmpType >= 11 {
|
|
|
|
|
overallhandle.Result(0, staffErr, c, "该账号已经被离开企业!不可进行操作!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
userAgent := overall.CONSTANT_CONFIG.Appsetup.AppKey
|
|
|
|
|
var md5JiaMi overallhandle.Md5Encryption
|
|
|
|
|
md5JiaMi.Md5EncryptionInit(userAgent)
|
|
|
|
|
md5Token := md5JiaMi.Md5EncryptionAlgorithm()
|
|
|
|
|
|
|
|
|
|
var md5JiaMiNumber overallhandle.Md5Encryption
|
|
|
|
|
// md5JiaMiNumber.Md5EncryptionInit(userCont.Number + uuIdValStr)
|
|
|
|
|
md5JiaMiNumber.Md5EncryptionInit(userCont.Number)
|
|
|
|
|
userKeyCode := md5JiaMiNumber.Md5EncryptionAlgorithm()
|
|
|
|
|
|
|
|
|
|
// sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token + uuIdValStr
|
|
|
|
|
sha1Str := userKeyCode + userCont.Number + userCont.Password + md5Token
|
|
|
|
|
sha1Token := overallhandle.Sha1Encryption(sha1Str)
|
|
|
|
|
fmt.Printf("token=========>\n%v\n---->%v\n---->%v\n---->%v\n---->%v\n---->%v\n", userKeyCode, userCont.Number, userCont.Password, md5Token, sha1Token, userAgent)
|
|
|
|
|
|
|
|
|
|
//返回值
|
|
|
|
|
saveData := overallhandle.MapOut()
|
|
|
|
|
saveData["key"] = userKeyCode
|
|
|
|
|
saveData["token"] = sha1Token
|
|
|
|
|
saveData["userinfo"] = userCont
|
|
|
|
|
menuoper, jurisdiction := getRoleSeat(userCont.Role)
|
|
|
|
|
writeRedisData := map[string]interface{}{
|
|
|
|
|
"userkey": userKeyCode,
|
|
|
|
|
"key": userCont.Key,
|
|
|
|
|
"usernumber": userCont.Number,
|
|
|
|
|
"userpwd": userCont.Password,
|
|
|
|
|
"usertoken": sha1Token,
|
|
|
|
|
"jurisdiction": jurisdiction,
|
|
|
|
|
"menuOper": menuoper,
|
|
|
|
|
"wand": 118,
|
|
|
|
|
}
|
|
|
|
|
//API Token数据
|
|
|
|
|
redisFileKey := fmt.Sprintf("ScanCode:Authentication:LoginApi_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userKeyCode)
|
|
|
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
|
|
|
|
|
redisClient.SetRedisTime(10800)
|
|
|
|
|
redisClient.HashMsetAdd(redisFileKey, writeRedisData)
|
|
|
|
|
|
|
|
|
|
groupId, companyId, departmentId, sunDepartId, workShopId := overallhandle.GetOrgStructure(userCont.AdminOrg)
|
|
|
|
|
fmt.Printf("groupId----->%v\ncompanyId----->%v\ndepartmentId----->%v\nsunDepartId----->%v\nworkShopId----->%v\n", groupId, companyId, departmentId, sunDepartId, workShopId)
|
|
|
|
|
var sunmaindeparment int64
|
|
|
|
|
|
|
|
|
|
if companyId != sunDepartId {
|
|
|
|
|
sunmaindeparment = sunDepartId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//缓存写入个人信息
|
|
|
|
|
redisMyContKey := fmt.Sprintf("ScanCode:Authentication:UserCont_%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, userCont.Number)
|
|
|
|
|
myCont := overallhandle.MapOut()
|
|
|
|
|
myCont["id"] = userCont.Id
|
|
|
|
|
myCont["number"] = userCont.Number //员工工号
|
|
|
|
|
myCont["name"] = userCont.Name //姓名
|
|
|
|
|
myCont["icon"] = userCont.Icon //头像
|
|
|
|
|
myCont["hireclass"] = userCont.HireClass //雇佣类型(1:雇佣入职;2:再入职;)
|
|
|
|
|
myCont["emptype"] = userCont.EmpType //用工关系(1:临时工 , 2:编外人员 ;3:实习&实习生;4:试用员工;5:待分配;6:待岗;7:临时调入;8:正式员工;9:长期病假;10:停薪留职;11:退休;12:辞职;13:辞退;14:离职)
|
|
|
|
|
myCont["company"] = userCont.Company //入职公司
|
|
|
|
|
// myCont["maindeparment"] = userCont.MainDeparment //主部门
|
|
|
|
|
// myCont["sunmaindeparment"] = userCont.SunMainDeparment //二级主部门
|
|
|
|
|
myCont["maindeparment"] = companyId //主部门
|
|
|
|
|
myCont["sunmaindeparment"] = sunmaindeparment //二级主部门
|
|
|
|
|
|
|
|
|
|
myCont["deparment"] = userCont.Deparment //部门
|
|
|
|
|
myCont["adminorg"] = userCont.AdminOrg //所属行政组织
|
|
|
|
|
myCont["teamid"] = userCont.TeamId //班组
|
|
|
|
|
myCont["position"] = userCont.Position //职位
|
|
|
|
|
myCont["jobclass"] = userCont.JobClass //职务分类
|
|
|
|
|
myCont["jobid"] = userCont.JobId //职务
|
|
|
|
|
myCont["jobleve"] = userCont.JobLeve //职务等级
|
|
|
|
|
myCont["wechat"] = userCont.Wechat //微信UserId
|
|
|
|
|
myCont["workwechat"] = userCont.WorkWechat //企业微信UserId
|
|
|
|
|
myCont["state"] = userCont.State //状态(1:启用;2:禁用;3:删除)
|
|
|
|
|
myCont["key"] = userCont.Key //key
|
|
|
|
|
myCont["isadmin"] = userCont.IsAdmin //是否为管理员(1:不是;2:分公司;3:集团管理员;4:超级管
|
|
|
|
|
myCont["password"] = userCont.Password //密码
|
|
|
|
|
myCont["role"] = userCont.Role //角色
|
|
|
|
|
myCont["idcardno"] = userCont.Idcardno //身份证号
|
|
|
|
|
myCont["passportno"] = userCont.Passportno //护照号码
|
|
|
|
|
myCont["globalroaming"] = userCont.Globalroaming //国际区号
|
|
|
|
|
myCont["mobilephone"] = userCont.Mobilephone //手机号码
|
|
|
|
|
myCont["email"] = userCont.Email //电子邮件
|
|
|
|
|
myCont["gender"] = userCont.Gender //性别(1:男性;2:女性;3:中性)
|
|
|
|
|
myCont["birthday"] = userCont.Birthday //birthday
|
|
|
|
|
myCont["myfolk"] = userCont.Myfolk //民族
|
|
|
|
|
myCont["nativeplace"] = userCont.Nativeplace //籍贯
|
|
|
|
|
myCont["idcardstartdate"] = userCont.Idcardstartdate //身份证有效期开始
|
|
|
|
|
myCont["idcardenddate"] = userCont.Idcardenddate //身份证有效期结束
|
|
|
|
|
myCont["idcardaddress"] = userCont.Idcardaddress //身份证地址
|
|
|
|
|
myCont["idcardIssued"] = userCont.IdcardIssued //身份证签发机关
|
|
|
|
|
myCont["health"] = userCont.Health //健康状况(1:良好;2:一般;3:较弱,4:有生理缺陷;5:残废)
|
|
|
|
|
myCont["maritalstatus"] = userCont.Maritalstatus //婚姻状况(1:未婚;2:已婚;3:丧偶;4:离异)
|
|
|
|
|
myCont["internaltelephone"] = userCont.Internaltelephone //内线电话
|
|
|
|
|
myCont["currentresidence"] = userCont.Currentresidence //现居住地址
|
|
|
|
|
myCont["constellationing"] = userCont.Constellation //星座(1:白羊座;2:金牛座;3:双子座;4:巨蟹座;5:狮子座;6:处女座;7:天枰座;8:天蝎座;9:射手座;10:摩羯座;11:水瓶座;12:双鱼座)
|
|
|
|
|
myCont["isdoubleworker"] = userCont.Isdoubleworker //是否双职工(1:是;2:否)
|
|
|
|
|
myCont["isveterans"] = userCont.Isveterans //是否为退役军人(1:是;2:否)
|
|
|
|
|
myCont["veteransnumber"] = userCont.Veteransnumber //退役证编号
|
|
|
|
|
myCont["jobstartdate"] = userCont.Jobstartdate //参加工作日期
|
|
|
|
|
myCont["entrydate"] = userCont.Entrydate //入职日期
|
|
|
|
|
myCont["probationperiod"] = userCont.Probationperiod //试用期
|
|
|
|
|
myCont["planformaldate"] = userCont.Planformaldate //预计转正日期
|
|
|
|
|
myCont["political_outlook"] = userCont.PoliticalOutlook //政治面貌(1:群众;2:无党派;3:台盟会员;4:九三社员;5:致公党员;6:农工党员;7:民进会员;8:民建会员;9:民盟盟员;10:民革会员,11:共青团员;12:预备党员;13:中共党员)
|
|
|
|
|
redisClient.HashMsetAdd(redisMyContKey, myCont)
|
|
|
|
|
saveData["userinfo"] = myCont
|
|
|
|
|
var sendKpiCont WriteIderCont
|
|
|
|
|
sendKpiCont.Openid = requestData.OpenId
|
|
|
|
|
sendKpiCont.Key = userKeyCode
|
|
|
|
|
sendKpiCont.Token = sha1Token
|
|
|
|
|
sendKpiCont.UserInfo.Key = strconv.FormatInt(userCont.Key, 10)
|
|
|
|
|
sendKpiCont.UserInfo.Number = userCont.Number
|
|
|
|
|
sendKpiCont.UserInfo.Password = userCont.Password
|
|
|
|
|
sendDate, _ := json.Marshal(sendKpiCont)
|
|
|
|
|
sdff := overallhandle.CurlPostJosn("http://kpi.hxgk.group/kpiapi/empower/write_token", sendDate)
|
|
|
|
|
fmt.Printf("redisMyContKey------Login----->%v----->%v\n", string(sdff), string(sendDate))
|
|
|
|
|
overallhandle.Result(0, saveData, c)
|
|
|
|
|
|
|
|
|
|
// return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取权限点位
|
|
|
|
|
func getRoleSeat(roleId string) (menuStr, buttonStr string) {
|
|
|
|
|
var roleInfo models.SystemRole
|
|
|
|
|
err := roleInfo.GetCont(map[string]interface{}{"r_id": roleId}, "r_menu_oper", "r_jurisdiction")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
menuStr = roleInfo.MenuOper
|
|
|
|
|
buttonStr = roleInfo.Jurisdiction
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-10-19 09:51:50
|
|
|
|
|
@ 功能: 修改员工微信或企业微信UserId
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) EditUsWechatOpenId(c *gin.Context) {
|
|
|
|
|
var requestData EditweChatUserId
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c, "参数错误")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.WechatId == "" && requestData.WorkWechatId == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c, "微信OpenId或企业微信OpenId至少存在一个")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var usCont models.PersonArchives
|
|
|
|
|
err := usCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(101, err, c, "该用户不存在!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
err = usCont.EiteCont(map[string]interface{}{"`id`": usCont.Id}, map[string]interface{}{"`wechat`": requestData.WechatId, "`work_wechat`": requestData.WorkWechatId, "`eite_time`": time.Now().Unix()})
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(106, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
overallhandle.Result(0, err, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-11-26 10:57:26
|
|
|
|
|
@ 功能: 导出人员信息
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) ArchivesListExporCsv(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.PersonArchives{}).Select("`id`").Where("state = 1")
|
|
|
|
|
|
|
|
|
|
if requestData.Number != "" {
|
|
|
|
|
gormDb = gormDb.Where("number LIKE ?", "%"+requestData.Number+"%")
|
|
|
|
|
}
|
|
|
|
|
if requestData.Name != "" {
|
|
|
|
|
gormDb = gormDb.Where("name LIKE ?", "%"+requestData.Name+"%")
|
|
|
|
|
}
|
|
|
|
|
if requestData.HireClass != 0 {
|
|
|
|
|
gormDb = gormDb.Where("hire_class = ?", requestData.HireClass)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Company != 0 {
|
|
|
|
|
gormDb = gormDb.Where("company = ?", requestData.Company)
|
|
|
|
|
}
|
|
|
|
|
// if requestData.Deparment != "" {
|
|
|
|
|
// gormDb = gormDb.Where("FIND_IN_SET(?,`deparment`)", requestData.Deparment)
|
|
|
|
|
// }
|
|
|
|
|
if requestData.AdminOrg != 0 {
|
|
|
|
|
var sunAry overallhandle.AllSunList[int64]
|
|
|
|
|
sunAry.GetAllSunOrg(requestData.AdminOrg)
|
|
|
|
|
sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg)
|
|
|
|
|
gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position != 0 {
|
|
|
|
|
gormDb = gormDb.Where("position = ?", requestData.Position)
|
|
|
|
|
}
|
|
|
|
|
if len(requestData.EmpType) > 0 {
|
|
|
|
|
gormDb = gormDb.Where("emp_type IN ?", requestData.EmpType)
|
|
|
|
|
} else {
|
|
|
|
|
gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Role != "" {
|
|
|
|
|
gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("`teamid` = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
var idAry []int64
|
|
|
|
|
// errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&staffList).Error
|
|
|
|
|
errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error
|
|
|
|
|
var positionAry []peopleManOutList
|
|
|
|
|
|
|
|
|
|
var manContList []models.ManCont
|
|
|
|
|
errGorm = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Find(&manContList).Error
|
|
|
|
|
var peopleContList []ExportPeopleCont
|
|
|
|
|
for _, v := range manContList {
|
|
|
|
|
var staffInfo peopleManOutList
|
|
|
|
|
staffInfo.ManCont = v
|
|
|
|
|
var getSpur models.Position
|
|
|
|
|
getWhe := overallhandle.MapOut()
|
|
|
|
|
getWhe["id"] = v.Position
|
|
|
|
|
getSpur.GetCont(getWhe, "name", "person_in_charge")
|
|
|
|
|
staffInfo.PositionName = getSpur.Name
|
|
|
|
|
staffInfo.PersonInCharge = getSpur.PersonInCharge
|
|
|
|
|
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
|
|
|
|
|
//公司
|
|
|
|
|
if v.Company != 0 {
|
|
|
|
|
var getSpurDepart models.AdministrativeOrganization
|
|
|
|
|
getWheDepart := overallhandle.MapOut()
|
|
|
|
|
getWheDepart["id"] = v.Company
|
|
|
|
|
getSpurDepart.GetCont(getWheDepart, "name")
|
|
|
|
|
staffInfo.CompanyName = getSpurDepart.Name
|
|
|
|
|
}
|
|
|
|
|
//主部门
|
|
|
|
|
if v.MainDeparment != 0 {
|
|
|
|
|
var getSpurDepartMain models.AdministrativeOrganization
|
|
|
|
|
getWheDepartMain := overallhandle.MapOut()
|
|
|
|
|
getWheDepartMain["id"] = v.MainDeparment
|
|
|
|
|
getSpurDepartMain.GetCont(getWheDepartMain, "name")
|
|
|
|
|
staffInfo.MainDeparmentName = getSpurDepartMain.Name
|
|
|
|
|
}
|
|
|
|
|
//二级著部门
|
|
|
|
|
if v.SunMainDeparment != 0 {
|
|
|
|
|
var sunMainDepart models.AdministrativeOrganization
|
|
|
|
|
sunMainDepart.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`")
|
|
|
|
|
staffInfo.SunMainDeparmentName = sunMainDepart.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 {
|
|
|
|
|
// staffInfo.DeparmentName = strings.Join(departNameAry, " ")
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
var orgContTypeCont models.OrgContType
|
|
|
|
|
orgContTypeCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`", "`level`")
|
|
|
|
|
if orgContTypeCont.Level >= 6 {
|
|
|
|
|
staffInfo.WorkPostName = orgContTypeCont.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
positionAry = append(positionAry, staffInfo)
|
|
|
|
|
|
|
|
|
|
var peoCont ExportPeopleCont
|
|
|
|
|
peoCont.Number = staffInfo.Number // `json:"number"`
|
|
|
|
|
peoCont.Name = staffInfo.Name // `json:"name"`
|
|
|
|
|
peoCont.Tel = staffInfo.Mobilephone // `json:"tel"`
|
|
|
|
|
peoCont.Idcardenddate = staffInfo.Idcardno // `json:"idcardenddate"`
|
|
|
|
|
peoCont.Org = fmt.Sprintf("%v/%v/%v", staffInfo.CompanyName, staffInfo.MainDeparmentName, staffInfo.SunMainDeparmentName) // `json:"org"`
|
|
|
|
|
peoCont.Post = staffInfo.PositionName // `json:"post"`
|
|
|
|
|
peoCont.Team = staffInfo.TeamName // `json:"team"`
|
|
|
|
|
peoCont.EmpTypeNAme = EmptypeToStr(staffInfo.EmpType)
|
|
|
|
|
peopleContList = append(peopleContList, peoCont)
|
|
|
|
|
}
|
|
|
|
|
if errGorm != nil {
|
|
|
|
|
overallhandle.Result(105, errGorm, c)
|
|
|
|
|
} else {
|
|
|
|
|
titleAry := []string{"工号", "姓名", "联系电话", "身份证号", "行政组织", "职务", "班组", "状态"}
|
|
|
|
|
filename, errCsv := WriteCsvFile("人员档案表", titleAry, peopleContList)
|
|
|
|
|
// overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
|
|
|
|
|
fmt.Printf("导出------------->%v,%v", filename, errCsv)
|
|
|
|
|
overallhandle.Result(1, filename, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-11-27 10:04:01
|
|
|
|
|
@ 功能: 获取单个人员档案
|
|
|
|
|
@ 参数
|
|
|
|
|
#
|
|
|
|
|
@ 返回值
|
|
|
|
|
#
|
|
|
|
|
@ 方法原型
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
func (s *StaffApi) GetArchivesCon(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 satffCont models.ManCont
|
|
|
|
|
staffErr := satffCont.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if staffErr != nil {
|
|
|
|
|
overallhandle.Result(105, staffErr, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var staffCenter staffArchivesCont
|
|
|
|
|
staffCenter.ManCont = satffCont
|
|
|
|
|
staffCenter.IdStr = strconv.FormatInt(satffCont.Id, 10)
|
|
|
|
|
if satffCont.Birthday != 0 {
|
|
|
|
|
staffCenter.BirthdayTime = overallhandle.UnixTimeToDay(satffCont.Birthday, 14) //生日
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Idcardstartdate != 0 {
|
|
|
|
|
staffCenter.IdCardStartTimeData = overallhandle.UnixTimeToDay(satffCont.Idcardstartdate, 14) //身份证有效期开始时间
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Idcardenddate != 0 {
|
|
|
|
|
staffCenter.IdCardEndTimeData = overallhandle.UnixTimeToDay(satffCont.Idcardenddate, 14) //身份证有效期结束时间
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Entrydate != 0 {
|
|
|
|
|
staffCenter.EntrydateTime = overallhandle.UnixTimeToDay(satffCont.Entrydate, 14) //入职日期
|
|
|
|
|
}
|
|
|
|
|
if satffCont.Planformaldate != 0 {
|
|
|
|
|
staffCenter.PlanformaldateTime = overallhandle.UnixTimeToDay(satffCont.Planformaldate, 14) //预计转正日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Jobstartdate != 0 {
|
|
|
|
|
staffCenter.JobstartdateStr = overallhandle.UnixTimeToDay(satffCont.Jobstartdate, 14) //参加工作日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Entrydate != 0 {
|
|
|
|
|
staffCenter.EntrydateStr = overallhandle.UnixTimeToDay(satffCont.Entrydate, 14) //入职日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if satffCont.Company != 0 {
|
|
|
|
|
// var groupInfos models.AdministrativeOrganization
|
|
|
|
|
// groupInfos.GetCont(map[string]interface{}{"`id`": satffCont.Company}, "`name`")
|
|
|
|
|
// staffCenter.CompanyName = groupInfos.Name
|
|
|
|
|
// }
|
|
|
|
|
// if satffCont.MainDeparment != 0 {
|
|
|
|
|
// var demperMainInfos models.AdministrativeOrganization
|
|
|
|
|
// demperMainInfos.GetCont(map[string]interface{}{"`id`": satffCont.MainDeparment}, "`name`")
|
|
|
|
|
// staffCenter.MainDeparmentName = demperMainInfos.Name
|
|
|
|
|
// }
|
|
|
|
|
// if satffCont.AdminOrg != 0 {
|
|
|
|
|
// var adminOrg models.AdministrativeOrganization
|
|
|
|
|
// adminOrg.GetCont(map[string]interface{}{"`id`": satffCont.AdminOrg}, "`name`")
|
|
|
|
|
// staffCenter.AdminOrgName = adminOrg.Name
|
|
|
|
|
// }
|
|
|
|
|
if satffCont.Position != 0 {
|
|
|
|
|
var postisInfo models.Position
|
|
|
|
|
postisInfo.GetCont(map[string]interface{}{"`id`": satffCont.Position}, "`name`", "`person_in_charge`")
|
|
|
|
|
staffCenter.PositionName = postisInfo.Name
|
|
|
|
|
staffCenter.PersonInCharge = postisInfo.PersonInCharge
|
|
|
|
|
if postisInfo.PersonInCharge != 1 {
|
|
|
|
|
staffCenter.PersonInCharge = satffCont.PersonInCharge
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
staffCenter.PersonInCharge = satffCont.PersonInCharge
|
|
|
|
|
}
|
|
|
|
|
if satffCont.JobClass != 0 {
|
|
|
|
|
var jobsInfo models.JobClass
|
|
|
|
|
jobsInfo.GetCont(map[string]interface{}{"`id`": satffCont.JobClass}, "`name`")
|
|
|
|
|
staffCenter.JobClassName = jobsInfo.Name
|
|
|
|
|
}
|
|
|
|
|
if satffCont.JobId != 0 {
|
|
|
|
|
var dutiresInfo models.Duties
|
|
|
|
|
dutiresInfo.GetCont(map[string]interface{}{"`id`": satffCont.JobId}, "`name`")
|
|
|
|
|
staffCenter.JobIdName = dutiresInfo.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Company != 0 {
|
|
|
|
|
var comCont models.AdministrativeOrganization
|
|
|
|
|
comCont.GetCont(map[string]interface{}{"`id`": satffCont.Company}, "`name`")
|
|
|
|
|
staffCenter.CompanyName = comCont.Name //公司名称
|
|
|
|
|
if overallhandle.IsInTrue[int64](satffCont.Company, staffCenter.AllOrgList) == false {
|
|
|
|
|
staffCenter.AllOrgList = append(staffCenter.AllOrgList, satffCont.Company)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if satffCont.MainDeparment != 0 {
|
|
|
|
|
var mainDepartCont models.AdministrativeOrganization
|
|
|
|
|
mainDepartCont.GetCont(map[string]interface{}{"`id`": satffCont.MainDeparment}, "`name`")
|
|
|
|
|
staffCenter.MainDeparmentName = mainDepartCont.Name //主部门
|
|
|
|
|
if overallhandle.IsInTrue[int64](satffCont.MainDeparment, staffCenter.AllOrgList) == false {
|
|
|
|
|
staffCenter.AllOrgList = append(staffCenter.AllOrgList, satffCont.MainDeparment)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if satffCont.SunMainDeparment != 0 {
|
|
|
|
|
var sunDepartCont models.AdministrativeOrganization
|
|
|
|
|
sunDepartCont.GetCont(map[string]interface{}{"`id`": satffCont.SunMainDeparment}, "`name`")
|
|
|
|
|
staffCenter.SunMainDeparmentName = sunDepartCont.Name //二级部门
|
|
|
|
|
if overallhandle.IsInTrue[int64](satffCont.SunMainDeparment, staffCenter.AllOrgList) == false {
|
|
|
|
|
staffCenter.AllOrgList = append(staffCenter.AllOrgList, satffCont.SunMainDeparment)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if satffCont.TeamId != 0 {
|
|
|
|
|
var teamCont models.TeamGroup
|
|
|
|
|
teamCont.GetCont(map[string]interface{}{"`id`": satffCont.TeamId}, "`name`")
|
|
|
|
|
staffCenter.TeamName = teamCont.Name //班组名
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if satffCont.Company != staffCenter.AdminOrg && satffCont.MainDeparment != staffCenter.AdminOrg && satffCont.SunMainDeparment != staffCenter.AdminOrg {
|
|
|
|
|
var orgCont models.AdministrativeOrganization
|
|
|
|
|
orgCont.GetCont(map[string]interface{}{"`id`": satffCont.AdminOrg}, "`name`")
|
|
|
|
|
staffCenter.WorkPostName = orgCont.Name //工段
|
|
|
|
|
if overallhandle.IsInTrue[int64](satffCont.AdminOrg, staffCenter.AllOrgList) == false {
|
|
|
|
|
staffCenter.AllOrgList = append(staffCenter.AllOrgList, satffCont.AdminOrg)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffCenter.PoliticalOutlookName = overallhandle.PolitiToString(satffCont.PoliticalOutlook)
|
|
|
|
|
if satffCont.Ruleid != 0 {
|
|
|
|
|
var ruleCont workgroup.WorkTimeType
|
|
|
|
|
ruleCont.GetCont(map[string]interface{}{"`id`": satffCont.Ruleid}, "`name`")
|
|
|
|
|
staffCenter.RuleId = strconv.FormatInt(satffCont.Ruleid, 10)
|
|
|
|
|
staffCenter.RuleName = ruleCont.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffCenter.KeyStr = strconv.FormatInt(satffCont.Key, 10)
|
|
|
|
|
if satffCont.ResponsibleDepartmentJson != "" {
|
|
|
|
|
json.Unmarshal([]byte(satffCont.ResponsibleDepartmentJson), &staffCenter.OrgresList)
|
|
|
|
|
// jsonErr := json.Unmarshal([]byte(satffCont.ResponsibleDepartmentJson), &staffCenter.OrgresList)
|
|
|
|
|
// fmt.Printf("satffCont---------->%v---------->%v---------->%v\n", satffCont.ResponsibleDepartmentJson, satffCont, jsonErr)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var personalityTest []personalitycolor.Charcolortest
|
|
|
|
|
overall.CONSTANT_Personality_Color.Where("`c_states` = 1 AND `c_number` = ?", satffCont.Number).Find(&personalityTest)
|
|
|
|
|
|
|
|
|
|
if len(personalityTest) > 0 {
|
|
|
|
|
rongXin := false
|
|
|
|
|
gaoKe := false
|
|
|
|
|
for _, v := range personalityTest {
|
|
|
|
|
if v.Class == 10000002 {
|
|
|
|
|
rongXin = true
|
|
|
|
|
}
|
|
|
|
|
if v.Class == 10000001 {
|
|
|
|
|
gaoKe = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if rongXin && gaoKe {
|
|
|
|
|
staffCenter.IsColorTrue = 4
|
|
|
|
|
} else if rongXin {
|
|
|
|
|
staffCenter.IsColorTrue = 3
|
|
|
|
|
} else {
|
|
|
|
|
staffCenter.IsColorTrue = 1
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if satffCont.ExcelTemplate == 296 {
|
|
|
|
|
var rcpdInfo models.TalentInventory
|
|
|
|
|
err := rcpdInfo.GetCont(map[string]interface{}{"`userKey`": satffCont.Key}, "`userTypes`")
|
|
|
|
|
fmt.Printf("获取聪哥---------->%v\n", rcpdInfo)
|
|
|
|
|
if err != nil {
|
|
|
|
|
staffCenter.IsColorTrue = 2
|
|
|
|
|
} else {
|
|
|
|
|
if rcpdInfo.UserTypes != "" {
|
|
|
|
|
staffCenter.IsColorTrue = 5
|
|
|
|
|
staffCenter.UserTypes = rcpdInfo.UserTypes
|
|
|
|
|
} else {
|
|
|
|
|
staffCenter.IsColorTrue = 2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
staffCenter.IsColorTrue = 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
overallhandle.Result(0, staffCenter, c)
|
|
|
|
|
// return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-11-27 10:28:31
|
|
|
|
|
@ 功能: 获取员工主信息
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) GetPeopleMainCont(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 myCont models.PersonArchives
|
|
|
|
|
err := myCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`id`", "`number`", "`name`", "`icon`", "`admin_org`", "`position`", "`teamid`", "`job_id`", "`job_class`", "`job_leve`", "`wechat`", "`work_wechat`", "`key`", "`company`", "`maindeparment`", "`sun_main_deparment`", "`ruleid`", "`icon_photo`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// fmt.Printf("员工信息-------->%v\n", myCont)
|
|
|
|
|
var myInfo MyMainCont
|
|
|
|
|
myInfo.Id = strconv.FormatInt(myCont.Id, 10)
|
|
|
|
|
myInfo.Key = strconv.FormatInt(myCont.Key, 10) //员工key
|
|
|
|
|
myInfo.Number = myCont.Number //员工工号
|
|
|
|
|
myInfo.Name = myCont.Name //姓名
|
|
|
|
|
myInfo.Icon = myCont.Icon //头像
|
|
|
|
|
if myCont.IconPhoto != "" {
|
|
|
|
|
myInfo.Icon = myCont.IconPhoto
|
|
|
|
|
}
|
|
|
|
|
myInfo.AdminOrg = myCont.AdminOrg //所属行政组织
|
|
|
|
|
myInfo.TeamId = myCont.TeamId //班组
|
|
|
|
|
myInfo.Position = myCont.Position //职位
|
|
|
|
|
myInfo.JobClass = myCont.JobClass //职务分类
|
|
|
|
|
myInfo.JobId = myCont.JobId //职务
|
|
|
|
|
myInfo.JobLeve = myCont.JobLeve //职务等级
|
|
|
|
|
myInfo.Wechat = myCont.Wechat //微信UserId"`
|
|
|
|
|
myInfo.WorkWechat = myCont.WorkWechat //`企业微信UserId"`
|
|
|
|
|
if myCont.Company != 0 {
|
|
|
|
|
var comCont models.AdministrativeOrganization
|
|
|
|
|
comCont.GetCont(map[string]interface{}{"`id`": myCont.Company}, "`name`")
|
|
|
|
|
myInfo.CompanyName = comCont.Name //公司名称
|
|
|
|
|
}
|
|
|
|
|
if myCont.MainDeparment != 0 {
|
|
|
|
|
var mainDepartCont models.AdministrativeOrganization
|
|
|
|
|
mainDepartCont.GetCont(map[string]interface{}{"`id`": myCont.MainDeparment}, "`name`")
|
|
|
|
|
myInfo.MainDeparmentName = mainDepartCont.Name //主部门
|
|
|
|
|
}
|
|
|
|
|
if myCont.SunMainDeparment != 0 {
|
|
|
|
|
var sunDepartCont models.AdministrativeOrganization
|
|
|
|
|
sunDepartCont.GetCont(map[string]interface{}{"`id`": myCont.SunMainDeparment}, "`name`")
|
|
|
|
|
myInfo.SunMainDeparmentName = sunDepartCont.Name //二级部门
|
|
|
|
|
}
|
|
|
|
|
if myCont.TeamId != 0 {
|
|
|
|
|
var teamCont models.TeamGroup
|
|
|
|
|
teamCont.GetCont(map[string]interface{}{"`id`": myCont.TeamId}, "`name`")
|
|
|
|
|
myInfo.TeamName = teamCont.Name //班组名
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if myCont.Company != myInfo.AdminOrg && myCont.MainDeparment != myInfo.AdminOrg && myCont.SunMainDeparment != myInfo.AdminOrg {
|
|
|
|
|
var orgCont models.AdministrativeOrganization
|
|
|
|
|
orgCont.GetCont(map[string]interface{}{"`id`": myCont.AdminOrg}, "`name`")
|
|
|
|
|
myInfo.WorkPostName = orgCont.Name //工段
|
|
|
|
|
}
|
|
|
|
|
if myCont.Position != 0 {
|
|
|
|
|
var postCont models.Position
|
|
|
|
|
postCont.GetCont(map[string]interface{}{"`id`": myCont.Position}, "`name`")
|
|
|
|
|
myInfo.PositionName = postCont.Name //岗位名称
|
|
|
|
|
}
|
|
|
|
|
if myCont.JobClass != 0 {
|
|
|
|
|
var jobClassCont models.JobClass
|
|
|
|
|
jobClassCont.GetCont(map[string]interface{}{"`id`": myCont.JobClass}, "`name`")
|
|
|
|
|
myInfo.JobClassName = jobClassCont.Name //职务分类
|
|
|
|
|
}
|
|
|
|
|
if myCont.JobId != 0 {
|
|
|
|
|
var jobCont models.Duties
|
|
|
|
|
jobCont.GetCont(map[string]interface{}{"`id`": myCont.JobId}, "`name`")
|
|
|
|
|
myInfo.JobName = jobCont.Name //职务名称
|
|
|
|
|
}
|
|
|
|
|
switch myCont.JobLeve {
|
|
|
|
|
case 1:
|
|
|
|
|
myInfo.JobLeveName = "一级"
|
|
|
|
|
case 2:
|
|
|
|
|
myInfo.JobLeveName = "二级"
|
|
|
|
|
case 3:
|
|
|
|
|
myInfo.JobLeveName = "三级"
|
|
|
|
|
default:
|
|
|
|
|
myInfo.JobLeveName = ""
|
|
|
|
|
}
|
|
|
|
|
var manContEs models.PersonnelContent
|
|
|
|
|
manContEs.GetCont(map[string]interface{}{"`key`": myCont.Key}, "`mobilephone`")
|
|
|
|
|
myInfo.Tel = manContEs.Mobilephone
|
|
|
|
|
if myCont.Ruleid != 0 {
|
|
|
|
|
var ruleCont workgroup.WorkTimeType
|
|
|
|
|
ruleCont.GetCont(map[string]interface{}{"`id`": myCont.Ruleid}, "`name`")
|
|
|
|
|
myInfo.RuleId = strconv.FormatInt(myCont.Ruleid, 10)
|
|
|
|
|
myInfo.RuleName = ruleCont.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
overallhandle.Result(0, myInfo, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-11-29 13:28:34
|
|
|
|
|
@ 功能: 获取集团内部工作经历列表
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) GetInsideWorkHistoryList(c *gin.Context) {
|
|
|
|
|
var requestData allocationOfRightsToRole
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(101, requestData.Id, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insideWorkHistoryList []models.InsideWorkHistory
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.InsideWorkHistory{}).Where("`state` BETWEEN 1 AND 2 AND `key` = ?", requestData.Id)
|
|
|
|
|
err := gormDb.Order("start_time desc").Order("end_time asc").Order("`id` desc").Find(&insideWorkHistoryList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(107, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// orgId :=
|
|
|
|
|
var sendData []outInsetWork
|
|
|
|
|
for _, v := range insideWorkHistoryList {
|
|
|
|
|
orgId := v.Group
|
|
|
|
|
if v.Company != 0 {
|
|
|
|
|
orgId = v.Company
|
|
|
|
|
}
|
|
|
|
|
if v.Department != 0 {
|
|
|
|
|
orgId = v.Department
|
|
|
|
|
}
|
|
|
|
|
if v.WorkShop != 0 {
|
|
|
|
|
orgId = v.WorkShop
|
|
|
|
|
}
|
|
|
|
|
if v.WorkshopSection != 0 {
|
|
|
|
|
orgId = v.WorkshopSection
|
|
|
|
|
}
|
|
|
|
|
_, companyId, departmentId, sunDepartId, workShopId := overallhandle.GetOrgStructure(orgId)
|
|
|
|
|
allOrgName := ""
|
|
|
|
|
if companyId != 0 {
|
|
|
|
|
var companyCont models.AdministrativeOrganization
|
|
|
|
|
errCom := companyCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`")
|
|
|
|
|
if errCom == nil {
|
|
|
|
|
allOrgName = companyCont.Name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if departmentId != 0 {
|
|
|
|
|
var departCont models.AdministrativeOrganization
|
|
|
|
|
errCom := departCont.GetCont(map[string]interface{}{"`id`": departmentId}, "`name`")
|
|
|
|
|
if errCom == nil {
|
|
|
|
|
if allOrgName != "" {
|
|
|
|
|
allOrgName = fmt.Sprintf("%v / %v", allOrgName, departCont.Name)
|
|
|
|
|
} else {
|
|
|
|
|
allOrgName = departCont.Name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if sunDepartId != 0 {
|
|
|
|
|
var sunDepartCont models.AdministrativeOrganization
|
|
|
|
|
errCom := sunDepartCont.GetCont(map[string]interface{}{"`id`": sunDepartId}, "`name`")
|
|
|
|
|
if errCom == nil {
|
|
|
|
|
if allOrgName != "" {
|
|
|
|
|
allOrgName = fmt.Sprintf("%v / %v", allOrgName, sunDepartCont.Name)
|
|
|
|
|
} else {
|
|
|
|
|
allOrgName = sunDepartCont.Name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if workShopId != 0 {
|
|
|
|
|
var workShopCont models.AdministrativeOrganization
|
|
|
|
|
errCom := workShopCont.GetCont(map[string]interface{}{"`id`": workShopId}, "`name`")
|
|
|
|
|
if errCom == nil {
|
|
|
|
|
if allOrgName != "" {
|
|
|
|
|
allOrgName = fmt.Sprintf("%v / %v", allOrgName, workShopCont.Name)
|
|
|
|
|
} else {
|
|
|
|
|
allOrgName = workShopCont.Name
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var snedCont outInsetWork
|
|
|
|
|
snedCont.StartTime = overallhandle.UnixTimeToDay(v.StartTime, 14) //开始时间
|
|
|
|
|
endTimeStr := "至今"
|
|
|
|
|
if v.EndTime != 0 {
|
|
|
|
|
endTimeStr = overallhandle.UnixTimeToDay(v.EndTime, 14)
|
|
|
|
|
}
|
|
|
|
|
snedCont.Id = strconv.FormatInt(v.Id, 10)
|
|
|
|
|
snedCont.EndTime = endTimeStr //结束时间
|
|
|
|
|
snedCont.AllOrgName = allOrgName //性质组织全称
|
|
|
|
|
snedCont.OrgId = orgId //行政组织ID
|
|
|
|
|
snedCont.PostId = v.Position //职务ID
|
|
|
|
|
snedCont.PostLevel = v.GradePositions //职务等级
|
|
|
|
|
var postCont models.Position
|
|
|
|
|
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`", "`superior`")
|
|
|
|
|
snedCont.PostName = postCont.Name //职务名称
|
|
|
|
|
snedCont.TeamId = v.Team //班组ID
|
|
|
|
|
var teamCont models.TeamGroup
|
|
|
|
|
teamCont.GetCont(map[string]interface{}{"`id`": v.Team}, "`name`")
|
|
|
|
|
snedCont.TeamName = teamCont.Name //班组名称
|
|
|
|
|
snedCont.ChangeType = v.ChangeType //调动类型
|
|
|
|
|
snedCont.ChangeTypeName = changeTypeToStr(v.ChangeType)
|
|
|
|
|
snedCont.AssignType = v.AssignType //1、主职;2:兼职
|
|
|
|
|
var dutiesCont models.Duties
|
|
|
|
|
dutiesCont.GetCont(map[string]interface{}{"`id`": v.JobId}, "`name`")
|
|
|
|
|
snedCont.JobId = v.JobId
|
|
|
|
|
snedCont.JobName = dutiesCont.Name
|
|
|
|
|
// snedCont.SuperiorPostName string //上级职务名称
|
|
|
|
|
// snedCont.SuperiorManName []string //上级人员
|
|
|
|
|
// snedCont.SubordinatesCount int //下属熟练
|
|
|
|
|
snedCont.ChangeReason = v.ChangeReason
|
|
|
|
|
snedCont.SuperiorPostName = v.SuperiorPosition
|
|
|
|
|
snedCont.SuperiorManName = v.SuperiorName
|
|
|
|
|
snedCont.SubordinatesCount = v.Subordinates
|
|
|
|
|
|
|
|
|
|
snedCont.Bdlx = v.Bdlx
|
|
|
|
|
snedCont.Gsmc = v.Gsmc
|
|
|
|
|
snedCont.Yjbm = v.Yjbm
|
|
|
|
|
snedCont.Ejbm = v.Ejbm
|
|
|
|
|
snedCont.Gongduan = v.Gongduan
|
|
|
|
|
snedCont.Dengji = v.Dengji
|
|
|
|
|
snedCont.Zhiwei = v.Zhiwei
|
|
|
|
|
|
|
|
|
|
sendData = append(sendData, snedCont)
|
|
|
|
|
}
|
|
|
|
|
overallhandle.Result(0, sendData, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-11-29 14:51:58
|
|
|
|
|
@ 功能: 获取职务名称,职务人员,下属数量
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#orgId 行政组织
|
|
|
|
|
#postId 职务ID
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func getSuperiorPeopleAndSubMan(orgId, postId int64) (postName, manTitle string) {
|
|
|
|
|
var postCont models.Position
|
|
|
|
|
postCont.GetCont(map[string]interface{}{"`id`": postId}, "`id`", "`name`", "`administrative_organization`")
|
|
|
|
|
postName = postCont.Name
|
|
|
|
|
var orgAry []int64
|
|
|
|
|
orgAry = append(orgAry, orgId)
|
|
|
|
|
if orgId != postCont.Id {
|
|
|
|
|
orgAry = append(orgAry, postCont.Id)
|
|
|
|
|
}
|
|
|
|
|
var manList []models.PersonArchives
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`number`", "`name`").Where("").Find(&manList).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
var nameAry []string
|
|
|
|
|
for _, v := range manList {
|
|
|
|
|
nameAry = append(nameAry, fmt.Sprintf("%v(%v)", v.Name, v.Number))
|
|
|
|
|
}
|
|
|
|
|
manTitle = strings.Join(nameAry, ",")
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-12-03 15:08:17
|
|
|
|
|
@ 功能: 判断是否已经存在主职
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) JudgePrincipalPosition(c *gin.Context) {
|
|
|
|
|
var requestData judgeMainPost
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.UserKey == "" {
|
|
|
|
|
overallhandle.Result(101, requestData, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// if requestData.OrgId == "" || requestData.PostId == "" || requestData.UserKey == "" {
|
|
|
|
|
// overallhandle.Result(101, requestData, c)
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
//获取所在部门
|
|
|
|
|
// orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64)
|
|
|
|
|
// _, _, departmentId, _, _ := overallhandle.GetOrgStructure(orgIdInt)
|
|
|
|
|
//查找是否已经存在主部门
|
|
|
|
|
var insideWorkHisCont models.InsideWorkHistory
|
|
|
|
|
err = insideWorkHisCont.GetCont(map[string]interface{}{"`key`": requestData.UserKey, "`assign_type`": 1})
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(0, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
overallhandle.Result(11111, err, c, "已经存在主职!是否替换!")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-12-03 15:55:23
|
|
|
|
|
@ 功能: 添加职工履历(新版)
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) AddInsideHistoryNew(c *gin.Context) {
|
|
|
|
|
var requestData eidtInsideHistoryWorkEs
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(101, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.Id, c, "员工标识符不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.OrgId == 0 {
|
|
|
|
|
overallhandle.Result(1, requestData.OrgId, c, "行政组织不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// if requestData.Position == "" {
|
|
|
|
|
// overallhandle.Result(1, requestData.Id, c, "岗位不能为空")
|
|
|
|
|
// return
|
|
|
|
|
// }
|
|
|
|
|
if requestData.Team == 0 {
|
|
|
|
|
overallhandle.Result(1, requestData.Team, c, "班组不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.StartTime == "" {
|
|
|
|
|
overallhandle.Result(1, requestData.StartTime, c, "就任此职位开始时间不能为空")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
startTimeVal, timeErr := overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.StartTime))
|
|
|
|
|
if timeErr == false {
|
|
|
|
|
overallhandle.Result(1, requestData.StartTime, c, "就任此职位开始时间格式不正确")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.ChangeType == 0 {
|
|
|
|
|
requestData.ChangeType = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.AssignType == 0 {
|
|
|
|
|
requestData.AssignType = 2
|
|
|
|
|
}
|
|
|
|
|
idInt64, _ := strconv.ParseInt(requestData.Id, 10, 64)
|
|
|
|
|
//获取行政组织关系
|
|
|
|
|
// orgIdInt, _ := strconv.ParseInt(requestData.OrgId, 10, 64)
|
|
|
|
|
groupId, companyId, departmentId, sunDepartId, workShopId := overallhandle.GetOrgStructure(requestData.OrgId)
|
|
|
|
|
//判断该经历shi
|
|
|
|
|
if requestData.AssignType == 1 {
|
|
|
|
|
//判断是否已经存在主职
|
|
|
|
|
var insideWorkHisCont models.InsideWorkHistory
|
|
|
|
|
err = insideWorkHisCont.GetCont(map[string]interface{}{"`key`": idInt64, "`assign_type`": 1})
|
|
|
|
|
if err == nil {
|
|
|
|
|
//存在主职,将主职移除
|
|
|
|
|
synPro.Add(1)
|
|
|
|
|
go handleMainZhi(idInt64, 2)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
synPro.Wait() //等待执行完毕
|
|
|
|
|
var insCont models.InsideWorkHistory
|
|
|
|
|
insCont.Key = idInt64 //员工识别符"`
|
|
|
|
|
insCont.Group = groupId //集团"`
|
|
|
|
|
insCont.Company = companyId //公司"`
|
|
|
|
|
insCont.Department = departmentId //部室"`
|
|
|
|
|
insCont.WorkShop = sunDepartId //二级部门或车间"`
|
|
|
|
|
insCont.WorkshopSection = workShopId //工段"`
|
|
|
|
|
// requestData.Position, _ := strconv.ParseInt(requestData.Position, 10, 64)
|
|
|
|
|
insCont.Position = requestData.Position //职位"`
|
|
|
|
|
// requestData.JobId, _ := strconv.ParseInt(requestData.JobId, 10, 64)
|
|
|
|
|
insCont.JobId = requestData.JobId
|
|
|
|
|
insCont.GradePositions = requestData.GradePositions //职等"`
|
|
|
|
|
insCont.StartTime = startTimeVal //开始日期"`
|
|
|
|
|
var endTimeVal int64
|
|
|
|
|
if requestData.EndTime != "" {
|
|
|
|
|
endTimeVal, _ = overallhandle.DateToTimeStamp(fmt.Sprintf("%v 00:00:00", requestData.EndTime))
|
|
|
|
|
} else {
|
|
|
|
|
endTimeVal = 0
|
|
|
|
|
}
|
|
|
|
|
insCont.EndTime = endTimeVal //结束日期"`
|
|
|
|
|
// teamId, _ := strconv.ParseInt(requestData.Team, 10, 64)
|
|
|
|
|
insCont.Team = requestData.Team //班组(1:长白;2:甲;3:乙;4:丙;5:丁)"`
|
|
|
|
|
insCont.ChangeType = requestData.ChangeType //变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"`
|
|
|
|
|
insCont.Time = time.Now().Unix() //创建时间"`
|
|
|
|
|
insCont.State = 1 //状态(1:启用;2:禁用;3:删除)"`
|
|
|
|
|
insCont.AssignType = requestData.AssignType //1、主职;2:兼职"`
|
|
|
|
|
err = overall.CONSTANT_DB_HR.Create(&insCont).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(104, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
//处理人员管理部门与主部门关系
|
|
|
|
|
var userInfo models.PersonArchives
|
|
|
|
|
err = userInfo.GetCont(map[string]interface{}{"`key`": idInt64}, "`deparment`", "`admin_org`", "`deparment`", "`position`", "`job_id`", "`job_leve`", "`sun_main_deparment`", "`teamid`")
|
|
|
|
|
if err == nil {
|
|
|
|
|
//获取所有关联部门
|
|
|
|
|
var departIdAry []int64
|
|
|
|
|
err = overall.CONSTANT_DB_HR.Model(&models.InsideWorkHistory{}).Select("DISTINCT `department`").Where("`state` = 1 AND `key` = ?", idInt64).Find(&departIdAry).Error
|
|
|
|
|
saveUserInfo := overallhandle.MapOut()
|
|
|
|
|
if userInfo.Deparment == "" && len(departIdAry) > 0 {
|
|
|
|
|
var departIdStr []string
|
|
|
|
|
for _, v := range departIdAry {
|
|
|
|
|
departIdStr = append(departIdStr, strconv.FormatInt(v, 10))
|
|
|
|
|
}
|
|
|
|
|
saveUserInfo["`deparment`"] = strings.Join(departIdStr, ",")
|
|
|
|
|
}
|
|
|
|
|
if requestData.AssignType == 1 {
|
|
|
|
|
if userInfo.AdminOrg != requestData.OrgId {
|
|
|
|
|
saveUserInfo["`company`"] = companyId
|
|
|
|
|
saveUserInfo["`maindeparment`"] = departmentId
|
|
|
|
|
saveUserInfo["`sun_main_deparment`"] = sunDepartId
|
|
|
|
|
saveUserInfo["`admin_org`"] = requestData.OrgId
|
|
|
|
|
saveUserInfo["`position`"] = requestData.Position
|
|
|
|
|
saveUserInfo["`job_id`"] = requestData.JobId
|
|
|
|
|
saveUserInfo["`job_leve`"] = requestData.GradePositions
|
|
|
|
|
//获取职务类型
|
|
|
|
|
var dutiesCont models.Duties
|
|
|
|
|
dutiesCont.GetCont(map[string]interface{}{"`id`": requestData.JobId}, "`job_type`")
|
|
|
|
|
saveUserInfo["`job_class`"] = dutiesCont.JobType
|
|
|
|
|
saveUserInfo["`teamid`"] = requestData.Team
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(saveUserInfo) > 0 {
|
|
|
|
|
saveUserInfo["`eite_time`"] = time.Now().Unix()
|
|
|
|
|
userInfo.EiteCont(map[string]interface{}{"`key`": idInt64}, saveUserInfo)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
overallhandle.Result(0, err, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2022-12-03 16:03:55
|
|
|
|
|
@ 功能: 变更主职
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#userKey 员工Key
|
|
|
|
|
#assignType 1、主职;2:兼职
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func handleMainZhi(userKey int64, assignType int) {
|
|
|
|
|
defer synPro.Done()
|
|
|
|
|
var insCont models.InsideWorkHistory
|
|
|
|
|
insCont.EditCont(map[string]interface{}{"`key`": userKey}, map[string]interface{}{"`assign_type`": assignType})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 人员列表(对外)
|
|
|
|
|
func (s *StaffApi) ArchivesListWai(c *gin.Context) {
|
|
|
|
|
var requestData peopleList
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Page < 0 {
|
|
|
|
|
requestData.Page = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.PageSize < 0 {
|
|
|
|
|
requestData.PageSize = 10
|
|
|
|
|
}
|
|
|
|
|
// overallhandle.Result(0, requestData, c)
|
|
|
|
|
// return
|
|
|
|
|
// var staffList []models.ManCont
|
|
|
|
|
// var staffList []models.PersonArchives
|
|
|
|
|
// gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("state = 1 AND `number` NOT LIKE ?", "%W%")
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("`number` NOT LIKE ?", "%W%")
|
|
|
|
|
|
|
|
|
|
if requestData.Number != "" {
|
|
|
|
|
gormDb = gormDb.Where("number LIKE ?", "%"+requestData.Number+"%")
|
|
|
|
|
}
|
|
|
|
|
if requestData.Name != "" {
|
|
|
|
|
gormDb = gormDb.Where("name LIKE ?", "%"+requestData.Name+"%")
|
|
|
|
|
}
|
|
|
|
|
if requestData.HireClass != 0 {
|
|
|
|
|
gormDb = gormDb.Where("hire_class = ?", requestData.HireClass)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Company != 0 {
|
|
|
|
|
gormDb = gormDb.Where("company = ?", requestData.Company)
|
|
|
|
|
}
|
|
|
|
|
// if requestData.Deparment != "" {
|
|
|
|
|
// gormDb = gormDb.Where("FIND_IN_SET(?,`deparment`)", requestData.Deparment)
|
|
|
|
|
// }
|
|
|
|
|
var banZu []workgroup.TeamsRules
|
|
|
|
|
var ruleTypeId int64
|
|
|
|
|
var ruleTypeName string
|
|
|
|
|
if requestData.AdminOrg != 0 {
|
|
|
|
|
// var idAry []int64
|
|
|
|
|
// idAry = overallhandle.GetDepartmentSun(requestData.AdminOrg, idAry)
|
|
|
|
|
// idAry = append(idAry, requestData.AdminOrg)
|
|
|
|
|
// gormDb = gormDb.Where("admin_org IN ?", idAry)
|
|
|
|
|
|
|
|
|
|
//duo'yuan'h
|
|
|
|
|
var sunAry overallhandle.AllSunList[int64]
|
|
|
|
|
sunAry.GetAllSunOrg(requestData.AdminOrg)
|
|
|
|
|
sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg)
|
|
|
|
|
gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList)
|
|
|
|
|
|
|
|
|
|
if requestData.Days != "" {
|
|
|
|
|
menuCont, _, err := CureeRunRules(requestData.AdminOrg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(200, err, c, "此行政组织还未设定班组轮询规则!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
banZu, err = menuCont.CountOrgTeamsIsDay(requestData.Days)
|
|
|
|
|
// jsonVal, _ := json.Marshal(banZu)
|
|
|
|
|
// fmt.Printf("\n\n\n\n\n规则列表:\n %v\n\n\n\n", string(jsonVal))
|
|
|
|
|
if err == nil {
|
|
|
|
|
var dayTeamsId []int64
|
|
|
|
|
for _, v := range banZu {
|
|
|
|
|
if v.CycleWorkTime != 0 && !overallhandle.IsInTrue(v.TeamsId, dayTeamsId) {
|
|
|
|
|
dayTeamsId = append(dayTeamsId, v.TeamsId)
|
|
|
|
|
}
|
|
|
|
|
ruleTypeId = v.RuleTypeId
|
|
|
|
|
ruleTypeName = v.RuleTypeName
|
|
|
|
|
}
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
if overallhandle.IsInTrue(requestData.Teamid, dayTeamsId) {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(200, err, c, "当天此行政组织内的此班组处于休息状态!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if len(dayTeamsId) > 0 {
|
|
|
|
|
dayTeamsId = append(dayTeamsId, 6)
|
|
|
|
|
gormDb = gormDb.Where("teamid IN ?", dayTeamsId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if requestData.Position != 0 {
|
|
|
|
|
gormDb = gormDb.Where("position = ?", requestData.Position)
|
|
|
|
|
}
|
|
|
|
|
// if requestData.EmpType != 0 {
|
|
|
|
|
// gormDb = gormDb.Where("emp_type = ?", requestData.EmpType)
|
|
|
|
|
// } else {
|
|
|
|
|
// gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10)
|
|
|
|
|
// }
|
|
|
|
|
if len(requestData.EmpType) > 0 {
|
|
|
|
|
gormDb = gormDb.Where("emp_type IN ?", requestData.EmpType)
|
|
|
|
|
}
|
|
|
|
|
if requestData.Role != "" {
|
|
|
|
|
gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role)
|
|
|
|
|
}
|
|
|
|
|
// if requestData.Teamid != 0 {
|
|
|
|
|
// gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
// }
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
var idAry []int64
|
|
|
|
|
// errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&staffList).Error
|
|
|
|
|
errGorm := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error
|
|
|
|
|
var positionAry []peopleManOutList
|
|
|
|
|
|
|
|
|
|
var manContList []models.ManCont
|
|
|
|
|
errGorm = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Find(&manContList).Error
|
|
|
|
|
|
|
|
|
|
for _, v := range manContList {
|
|
|
|
|
|
|
|
|
|
if requestData.Days != "" {
|
|
|
|
|
v = Shiftdjustment(requestData.Days, v)
|
|
|
|
|
// fmt.Printf("\n\n\n\n结果:%v\n\n\n\n", v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var staffInfo peopleManOutList
|
|
|
|
|
staffInfo.ManCont = v
|
|
|
|
|
var getSpur models.Position
|
|
|
|
|
getWhe := overallhandle.MapOut()
|
|
|
|
|
if v.Position != 0 {
|
|
|
|
|
getWhe["id"] = v.Position
|
|
|
|
|
getSpur.GetCont(getWhe, "name", "person_in_charge")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffInfo.PositionName = getSpur.Name
|
|
|
|
|
// staffInfo.PersonInCharge = getSpur.PersonInCharge
|
|
|
|
|
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
|
|
|
|
|
//公司
|
|
|
|
|
if v.Company != 0 {
|
|
|
|
|
var getSpurDepart models.AdministrativeOrganization
|
|
|
|
|
getWheDepart := overallhandle.MapOut()
|
|
|
|
|
getWheDepart["id"] = v.Company
|
|
|
|
|
getSpurDepart.GetCont(getWheDepart, "name")
|
|
|
|
|
staffInfo.CompanyName = getSpurDepart.Name
|
|
|
|
|
}
|
|
|
|
|
//主部门
|
|
|
|
|
if v.MainDeparment != 0 {
|
|
|
|
|
var getSpurDepartMain models.AdministrativeOrganization
|
|
|
|
|
getWheDepartMain := overallhandle.MapOut()
|
|
|
|
|
getWheDepartMain["id"] = v.MainDeparment
|
|
|
|
|
getSpurDepartMain.GetCont(getWheDepartMain, "name")
|
|
|
|
|
staffInfo.MainDeparmentName = getSpurDepartMain.Name
|
|
|
|
|
}
|
|
|
|
|
//二级著部门
|
|
|
|
|
if v.SunMainDeparment != 0 {
|
|
|
|
|
var sunMainDepart models.AdministrativeOrganization
|
|
|
|
|
sunMainDepart.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`")
|
|
|
|
|
staffInfo.SunMainDeparmentName = sunMainDepart.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 {
|
|
|
|
|
// staffInfo.DeparmentName = strings.Join(departNameAry, " ")
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
var orgContTypeCont models.OrgContType
|
|
|
|
|
orgContTypeCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`", "`level`")
|
|
|
|
|
if orgContTypeCont.Level >= 6 {
|
|
|
|
|
staffInfo.WorkPostName = orgContTypeCont.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffInfo.PersonInCharge = 2
|
|
|
|
|
if v.PersonInCharge == 1 {
|
|
|
|
|
orgResList := strings.Split(v.ResponsibleDepartment, ",")
|
|
|
|
|
if len(orgResList) > 0 {
|
|
|
|
|
orgIdStr := strconv.FormatInt(requestData.AdminOrg, 10)
|
|
|
|
|
if overallhandle.IsInTrue[string](orgIdStr, orgResList) == true {
|
|
|
|
|
staffInfo.PersonInCharge = 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendMap, _ := GetUesrOffice(v.Key)
|
|
|
|
|
staffInfo.OfficeList = sendMap
|
|
|
|
|
positionAry = append(positionAry, staffInfo)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if errGorm != nil {
|
|
|
|
|
overallhandle.Result(105, errGorm, c)
|
|
|
|
|
} else {
|
|
|
|
|
sendExpand := overallhandle.MapOut()
|
|
|
|
|
var sendRuleInfo DaysTeamsRuler
|
|
|
|
|
if len(banZu) > 0 {
|
|
|
|
|
sendRuleInfo.RuleTypeId = strconv.FormatInt(ruleTypeId, 10)
|
|
|
|
|
sendRuleInfo.RuleTypeName = ruleTypeName
|
|
|
|
|
|
|
|
|
|
var workTimePer []workgroup.WorkingTimePeriod
|
|
|
|
|
overall.CONSTANT_DB_HR.Where("`type_id` = ?", ruleTypeId).Find(&workTimePer)
|
|
|
|
|
var teamRuleMap []DaysTeamsRulerInfo
|
|
|
|
|
if len(workTimePer) > 0 {
|
|
|
|
|
for _, v := range workTimePer {
|
|
|
|
|
for _, bv := range banZu {
|
|
|
|
|
if v.Id == bv.CycleWorkTime {
|
|
|
|
|
var teamRuleInfo DaysTeamsRulerInfo
|
|
|
|
|
teamRuleInfo.TeamsId = strconv.FormatInt(bv.TeamsId, 10) //生产班组ID
|
|
|
|
|
teamRuleInfo.TeamsName = bv.TeamsName //生产班组名称
|
|
|
|
|
teamRuleInfo.RuleId = strconv.FormatInt(v.Id, 10) //规则ID
|
|
|
|
|
teamRuleInfo.RuleName = v.Name //规则名称
|
|
|
|
|
teamRuleInfo.StartTime = v.StartTime //开始时间
|
|
|
|
|
teamRuleInfo.EndTime = v.EndTime //结束时间
|
|
|
|
|
teamRuleMap = append(teamRuleMap, teamRuleInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sort.Slice(teamRuleMap, func(i, j int) bool {
|
|
|
|
|
return teamRuleMap[i].StartTime < teamRuleMap[j].StartTime
|
|
|
|
|
})
|
|
|
|
|
sendRuleInfo.List = teamRuleMap
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sendExpand["ruler"] = sendRuleInfo
|
|
|
|
|
|
|
|
|
|
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c, sendExpand)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-02-17 14:18:25
|
|
|
|
|
@ 功能: 调班计算
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#查询时间
|
|
|
|
|
#当前人
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func Shiftdjustment(day string, use models.ManCont) (pick models.ManCont) {
|
|
|
|
|
if day == "" || use.Id == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var diaoIno customerForm.DiaoBanSetup
|
|
|
|
|
overall.CONSTANT_DB_AppPlatform.First(&diaoIno)
|
|
|
|
|
var wvTimeAll overallhandle.DateTimeTotimes
|
|
|
|
|
wvTimeAll.BaisStrToTimeLing(day)
|
|
|
|
|
taDay := wvTimeAll.AllTime * 1000
|
|
|
|
|
// fmt.Printf("当前时间戳:%v\n:%v\n", wvTimeAll.AllTime, taDay)
|
|
|
|
|
|
|
|
|
|
redisSqKey := fmt.Sprintf("%v_%v", use.Key, taDay)
|
|
|
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
|
|
|
|
|
isTrue, tokenInfo := redisClient.Get(redisSqKey)
|
|
|
|
|
if isTrue {
|
|
|
|
|
json.Unmarshal([]byte(tokenInfo), &pick)
|
|
|
|
|
} else {
|
|
|
|
|
var hbsqCont customerForm.HuanBanShenQing
|
|
|
|
|
if diaoIno.Id != 0 && diaoIno.Source == "yes" {
|
|
|
|
|
var sqlDb datacenter.DataBastType
|
|
|
|
|
sqlDb.Type = diaoIno.SqlType
|
|
|
|
|
sqlDb.Ip = diaoIno.Ip
|
|
|
|
|
sqlDb.DataBaseName = diaoIno.DataBaseName
|
|
|
|
|
sqlDb.Port = int64(diaoIno.Port)
|
|
|
|
|
sqlDb.UserName = diaoIno.UserName
|
|
|
|
|
sqlDb.Pwd = diaoIno.Pwd
|
|
|
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
|
|
|
if err != nil {
|
|
|
|
|
sqlDborm, err = datacenter.GainDataStorce(diaoIno.SourceId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var appFormPage appPlatform.CustomerFormView
|
|
|
|
|
err = appFormPage.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": diaoIno.TableKey}, "`tablekey`")
|
|
|
|
|
gormDb := sqlDborm.Table(appFormPage.TableKey)
|
|
|
|
|
gormDb.Where("`states` = 1 AND `creater` = ? AND `dang1zhi2ri4qi1` = ?", use.Key, taDay).First(&hbsqCont)
|
|
|
|
|
// sqlDB, _ := gormDb.DB()
|
|
|
|
|
// sqlDB.Close()
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Printf("xuan")
|
|
|
|
|
hbsqCont.GetCont(map[string]interface{}{"`states`": 1, "`creater`": use.Key, "dang1zhi2ri4qi1": taDay}) //当值日期
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// overall.CONSTANT_DB_CustomerForm.Model(&customerForm.HuanBanShenQing{}).Where("`states` = 1 AND `creater` = ? AND `dang1zhi2ri4qi1` = ?", use.Key).Find(&hbsqCont)
|
|
|
|
|
if hbsqCont.MastersKey != 0 {
|
|
|
|
|
var starTask customerForm.TaskRecord
|
|
|
|
|
starTask.GetCont(map[string]interface{}{"`masters_key`": hbsqCont.MastersKey})
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("\n\nstarTask:%v\n\n\n\n", starTask)
|
|
|
|
|
|
|
|
|
|
if starTask.Status == 4 {
|
|
|
|
|
reg1 := regexp.MustCompile(`\(([^)]+)\)`)
|
|
|
|
|
userAry := reg1.FindAllStringSubmatch(hbsqCont.Diao4huan4ren229452110, -1) //按照正则规则提取数据
|
|
|
|
|
// fmt.Printf("\n\n按照正则规则提取数据:Diao4huan4ren229452110:%v\n\n userAry:%v\n\n", hbsqCont.Diao4huan4ren229452110, userAry)
|
|
|
|
|
for _, u := range userAry {
|
|
|
|
|
vLen := len(u)
|
|
|
|
|
if len(u) > 0 {
|
|
|
|
|
pick.GetCont(map[string]interface{}{"`number`": u[vLen-1]})
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Where("`number` = ? AND `emp_type` BETWEEN ? AND ? ", u[vLen-1], 1, 10).First(&pick).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
pickJson, _ := json.Marshal(pick)
|
|
|
|
|
redisClient.SetRedisTime(86400)
|
|
|
|
|
redisClient.Set(redisSqKey, string(pickJson))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
redisSqKeySq := fmt.Sprintf("%v_%v", use.Key, taDay)
|
|
|
|
|
redisClientSq := grocerystore.RunRedis(overall.CONSTANT_REDIS5)
|
|
|
|
|
isTrueSq, tokenInfoSq := redisClientSq.Get(redisSqKeySq)
|
|
|
|
|
if isTrueSq {
|
|
|
|
|
json.Unmarshal([]byte(tokenInfoSq), &pick)
|
|
|
|
|
} else {
|
|
|
|
|
var hbsqContDh customerForm.HuanBanShenQing
|
|
|
|
|
// hbsqContDh.GetCont(map[string]interface{}{"`states`": 1, "`creater`": use.Key, "`diao4huan4ri4qi1`": taDay}, "`masters_key`", "`creater` ") //调换日期
|
|
|
|
|
// fmt.Printf("用户信息:use.Number------->%v\n------->%v\n------->%v\n", use.Number, diaoIno.Id, diaoIno.Source)
|
|
|
|
|
if diaoIno.Id != 0 && diaoIno.Source == "yes" {
|
|
|
|
|
var sqlDbes datacenter.DataBastType
|
|
|
|
|
sqlDbes.Type = diaoIno.SqlType
|
|
|
|
|
sqlDbes.Ip = diaoIno.Ip
|
|
|
|
|
sqlDbes.DataBaseName = diaoIno.DataBaseName
|
|
|
|
|
sqlDbes.Port = int64(diaoIno.Port)
|
|
|
|
|
sqlDbes.UserName = diaoIno.UserName
|
|
|
|
|
sqlDbes.Pwd = diaoIno.Pwd
|
|
|
|
|
sqlDbesorm, err := sqlDbes.StartDataBast()
|
|
|
|
|
// fmt.Printf("用户信息:err----1--->%v\n", err)
|
|
|
|
|
if err != nil {
|
|
|
|
|
sqlDbesorm, err = datacenter.GainDataStorce(diaoIno.SourceId)
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var appFormPage appPlatform.CustomerFormView
|
|
|
|
|
err = appFormPage.GetCont(map[string]interface{}{"`status`": 1, "`signCode`": diaoIno.TableKey}, "`tablekey`")
|
|
|
|
|
gormDb := sqlDbesorm.Table(appFormPage.TableKey)
|
|
|
|
|
// gormDb := sqlDbesorm.Table(diaoIno.TableKey)
|
|
|
|
|
err = gormDb.Where("`diao4huan4ren229452110` REGEXP ? AND `diao4huan4ri4qi1` = ? AND `states` = 1 ", use.Number, taDay).First(&hbsqContDh).Error
|
|
|
|
|
// fmt.Printf("用户信息:err----3--->%v--->%v\n", err, hbsqContDh)
|
|
|
|
|
// sqlDB, _ := gormDb.DB()
|
|
|
|
|
// sqlDB.Close()
|
|
|
|
|
} else {
|
|
|
|
|
overall.CONSTANT_DB_CustomerForm.Where("`diao4huan4ren229452110` REGEXP ? AND `diao4huan4ri4qi1` = ? AND `states` = 1 ", use.Number, taDay).First(&hbsqContDh)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if hbsqContDh.MastersKey != 0 {
|
|
|
|
|
var starTaskDh customerForm.TaskRecord
|
|
|
|
|
starTaskDh.GetCont(map[string]interface{}{"`masters_key`": hbsqContDh.MastersKey})
|
|
|
|
|
if starTaskDh.Status == 4 {
|
|
|
|
|
// pick.GetCont(map[string]interface{}{"`key`": hbsqContDh.Creater})
|
|
|
|
|
err := overall.CONSTANT_DB_HR.Where("`key` = ? AND `emp_type` BETWEEN ? AND ? ", hbsqContDh.Creater, 1, 10).First(&pick).Error
|
|
|
|
|
if err == nil {
|
|
|
|
|
pickJsonSq, _ := json.Marshal(pick)
|
|
|
|
|
redisClientSq.SetRedisTime(86400)
|
|
|
|
|
redisClientSq.Set(redisSqKeySq, string(pickJsonSq))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return use
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-06-14 13:34:27
|
|
|
|
|
@ 功能: 人员档案列表
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (s *StaffApi) ArchivesListCont(c *gin.Context) {
|
|
|
|
|
var requestData ArchivesSearch
|
|
|
|
|
c.ShouldBindJSON(&requestData)
|
|
|
|
|
if requestData.Page < 0 {
|
|
|
|
|
requestData.Page = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.PageSize < 0 {
|
|
|
|
|
requestData.PageSize = 10
|
|
|
|
|
}
|
|
|
|
|
if requestData.Right == 0 {
|
|
|
|
|
requestData.Right = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Where("`number` NOT LIKE ?", "%W%")
|
|
|
|
|
if requestData.KeyWords != "" {
|
|
|
|
|
gormDb = gormDb.Where("number LIKE ? OR name LIKE ?", "%"+requestData.KeyWords+"%", "%"+requestData.KeyWords+"%")
|
|
|
|
|
}
|
|
|
|
|
var banZu []workgroup.TeamsRules
|
|
|
|
|
var ruleTypeId int64
|
|
|
|
|
var ruleTypeName string
|
|
|
|
|
if requestData.AdminOrg != 0 {
|
|
|
|
|
var sunAry overallhandle.AllSunList[int64]
|
|
|
|
|
sunAry.GetAllSunOrg(requestData.AdminOrg)
|
|
|
|
|
sunAry.SunList = append(sunAry.SunList, requestData.AdminOrg)
|
|
|
|
|
gormDb = gormDb.Where("admin_org IN ?", sunAry.SunList)
|
|
|
|
|
|
|
|
|
|
if requestData.Days != "" {
|
|
|
|
|
menuCont, _, err := CureeRunRules(requestData.AdminOrg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.Result(200, err, c, "此行政组织还未设定班组轮询规则!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
banZu, err = menuCont.CountOrgTeamsIsDay(requestData.Days)
|
|
|
|
|
if err == nil {
|
|
|
|
|
var dayTeamsId []int64
|
|
|
|
|
for _, v := range banZu {
|
|
|
|
|
if v.CycleWorkTime != 0 && !overallhandle.IsInTrue(v.TeamsId, dayTeamsId) {
|
|
|
|
|
dayTeamsId = append(dayTeamsId, v.TeamsId)
|
|
|
|
|
}
|
|
|
|
|
ruleTypeId = v.RuleTypeId
|
|
|
|
|
ruleTypeName = v.RuleTypeName
|
|
|
|
|
}
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
if overallhandle.IsInTrue(requestData.Teamid, dayTeamsId) {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
} else {
|
|
|
|
|
overallhandle.Result(200, err, c, "当天此行政组织内的此班组处于休息状态!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
gormDb = gormDb.Where("teamid IN ?", dayTeamsId)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Teamid != 0 {
|
|
|
|
|
gormDb = gormDb.Where("teamid = ?", requestData.Teamid)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(requestData.Emptype) > 0 {
|
|
|
|
|
gormDb = gormDb.Where("emp_type IN ?", requestData.Emptype)
|
|
|
|
|
} else {
|
|
|
|
|
if requestData.Right != 1 {
|
|
|
|
|
gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 11, 14)
|
|
|
|
|
} else {
|
|
|
|
|
gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
var idAry []int64
|
|
|
|
|
err := gormDb.Order("company ASC,maindeparment ASC,admin_org ASC,position ASC").Limit(requestData.PageSize).Offset(overallhandle.LimitPage(requestData.Page, requestData.PageSize)).Find(&idAry).Error
|
|
|
|
|
var positionAry []peopleManOutList
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var manContList []models.ManCont
|
|
|
|
|
err = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Find(&manContList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for _, v := range manContList {
|
|
|
|
|
if requestData.Days != "" {
|
|
|
|
|
v = Shiftdjustment(requestData.Days, v)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var staffInfo peopleManOutList
|
|
|
|
|
staffInfo.ManCont = v
|
|
|
|
|
var getSpur models.Position
|
|
|
|
|
getWhe := overallhandle.MapOut()
|
|
|
|
|
if v.Position != 0 {
|
|
|
|
|
getWhe["id"] = v.Position
|
|
|
|
|
getSpur.GetCont(getWhe, "name", "person_in_charge")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffInfo.PositionName = getSpur.Name
|
|
|
|
|
// staffInfo.PersonInCharge = getSpur.PersonInCharge
|
|
|
|
|
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
|
|
|
|
|
//公司
|
|
|
|
|
if v.Company != 0 {
|
|
|
|
|
var getSpurDepart models.AdministrativeOrganization
|
|
|
|
|
getWheDepart := overallhandle.MapOut()
|
|
|
|
|
getWheDepart["id"] = v.Company
|
|
|
|
|
getSpurDepart.GetCont(getWheDepart, "name")
|
|
|
|
|
staffInfo.CompanyName = getSpurDepart.Name
|
|
|
|
|
}
|
|
|
|
|
//主部门
|
|
|
|
|
if v.MainDeparment != 0 {
|
|
|
|
|
var getSpurDepartMain models.AdministrativeOrganization
|
|
|
|
|
getWheDepartMain := overallhandle.MapOut()
|
|
|
|
|
getWheDepartMain["id"] = v.MainDeparment
|
|
|
|
|
getSpurDepartMain.GetCont(getWheDepartMain, "name")
|
|
|
|
|
staffInfo.MainDeparmentName = getSpurDepartMain.Name
|
|
|
|
|
}
|
|
|
|
|
//二级著部门
|
|
|
|
|
if v.SunMainDeparment != 0 {
|
|
|
|
|
var sunMainDepart models.AdministrativeOrganization
|
|
|
|
|
sunMainDepart.GetCont(map[string]interface{}{"`id`": v.SunMainDeparment}, "`name`")
|
|
|
|
|
staffInfo.SunMainDeparmentName = sunMainDepart.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var orgContTypeCont models.OrgContType
|
|
|
|
|
orgContTypeCont.GetCont(map[string]interface{}{"`id`": v.AdminOrg}, "`name`", "`level`")
|
|
|
|
|
if orgContTypeCont.Level >= 6 {
|
|
|
|
|
staffInfo.WorkPostName = orgContTypeCont.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
staffInfo.PersonInCharge = 2
|
|
|
|
|
if v.PersonInCharge == 1 {
|
|
|
|
|
orgResList := strings.Split(v.ResponsibleDepartment, ",")
|
|
|
|
|
if len(orgResList) > 0 {
|
|
|
|
|
orgIdStr := strconv.FormatInt(requestData.AdminOrg, 10)
|
|
|
|
|
if overallhandle.IsInTrue[string](orgIdStr, orgResList) == true {
|
|
|
|
|
staffInfo.PersonInCharge = 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
positionAry = append(positionAry, staffInfo)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sendExpand := overallhandle.MapOut()
|
|
|
|
|
var sendRuleInfo DaysTeamsRuler
|
|
|
|
|
if len(banZu) > 0 {
|
|
|
|
|
sendRuleInfo.RuleTypeId = strconv.FormatInt(ruleTypeId, 10)
|
|
|
|
|
sendRuleInfo.RuleTypeName = ruleTypeName
|
|
|
|
|
|
|
|
|
|
var workTimePer []workgroup.WorkingTimePeriod
|
|
|
|
|
overall.CONSTANT_DB_HR.Where("`type_id` = ?", ruleTypeId).Find(&workTimePer)
|
|
|
|
|
var teamRuleMap []DaysTeamsRulerInfo
|
|
|
|
|
if len(workTimePer) > 0 {
|
|
|
|
|
for _, v := range workTimePer {
|
|
|
|
|
for _, bv := range banZu {
|
|
|
|
|
if v.Id == bv.CycleWorkTime {
|
|
|
|
|
var teamRuleInfo DaysTeamsRulerInfo
|
|
|
|
|
teamRuleInfo.TeamsId = strconv.FormatInt(bv.TeamsId, 10) //生产班组ID
|
|
|
|
|
teamRuleInfo.TeamsName = bv.TeamsName //生产班组名称
|
|
|
|
|
teamRuleInfo.RuleId = strconv.FormatInt(v.Id, 10) //规则ID
|
|
|
|
|
teamRuleInfo.RuleName = v.Name //规则名称
|
|
|
|
|
teamRuleInfo.StartTime = v.StartTime //开始时间
|
|
|
|
|
teamRuleInfo.EndTime = v.EndTime //结束时间
|
|
|
|
|
teamRuleMap = append(teamRuleMap, teamRuleInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sort.Slice(teamRuleMap, func(i, j int) bool {
|
|
|
|
|
return teamRuleMap[i].StartTime < teamRuleMap[j].StartTime
|
|
|
|
|
})
|
|
|
|
|
sendRuleInfo.List = teamRuleMap
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sendExpand["ruler"] = sendRuleInfo
|
|
|
|
|
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c, sendExpand)
|
|
|
|
|
}
|