|
|
|
@ -1315,10 +1315,10 @@ func (s *StaffApi) AddInsideHistory(c *gin.Context) { |
|
|
|
overallhandle.Result(1, requestData.Id, c, "行政组织不能为空") |
|
|
|
return |
|
|
|
} |
|
|
|
if requestData.Position == "" { |
|
|
|
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 |
|
|
|
@ -1331,7 +1331,7 @@ func (s *StaffApi) AddInsideHistory(c *gin.Context) { |
|
|
|
requestData.ChangeType = 1 |
|
|
|
} |
|
|
|
if requestData.AssignType == 0 { |
|
|
|
requestData.AssignType = 1 |
|
|
|
requestData.AssignType = 2 |
|
|
|
} |
|
|
|
var insiderHistoryWork models.InsideWorkHistory |
|
|
|
idInt, _ := strconv.ParseInt(requestData.Id, 10, 64) |
|
|
|
@ -1410,7 +1410,7 @@ func (s *StaffApi) EidtInsideHistoryWorkCont(c *gin.Context) { |
|
|
|
} |
|
|
|
if requestData.Team == "" { |
|
|
|
if requestData.Team != strconv.FormatInt(insiderHistoryWork.Team, 10) { |
|
|
|
saveData["position"] = requestData.Team |
|
|
|
saveData["team"] = requestData.Team |
|
|
|
} |
|
|
|
} |
|
|
|
if requestData.StartTime == "" { |
|
|
|
@ -1442,6 +1442,14 @@ func (s *StaffApi) EidtInsideHistoryWorkCont(c *gin.Context) { |
|
|
|
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) |
|
|
|
@ -2344,6 +2352,7 @@ func (s *StaffApi) GetInsideWorkHistoryList(c *gin.Context) { |
|
|
|
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
|
|
|
|
@ -2359,7 +2368,10 @@ func (s *StaffApi) GetInsideWorkHistoryList(c *gin.Context) { |
|
|
|
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 //下属熟练
|
|
|
|
@ -2406,3 +2418,344 @@ func getSuperiorPeopleAndSubMan(orgId, postId int64) (postName, manTitle string) |
|
|
|
} |
|
|
|
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 |
|
|
|
} |
|
|
|
// 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%") |
|
|
|
|
|
|
|
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 requestData.EmpType != 0 { |
|
|
|
gormDb = gormDb.Where("emp_type = ?", requestData.EmpType) |
|
|
|
} else { |
|
|
|
gormDb = gormDb.Where("emp_type BETWEEN ? AND ?", 1, 10) |
|
|
|
} |
|
|
|
if requestData.Role != "" { |
|
|
|
gormDb = gormDb.Where("FIND_IN_SET(?,`role`)", requestData.Role) |
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
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) |
|
|
|
|
|
|
|
} |
|
|
|
if errGorm != nil { |
|
|
|
overallhandle.Result(105, errGorm, c) |
|
|
|
} else { |
|
|
|
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c) |
|
|
|
} |
|
|
|
} |
|
|
|
|