You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
318 lines
11 KiB
318 lines
11 KiB
package humanResources
|
|
|
|
import (
|
|
"appPlatform/models/modelshr"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2026-02-12 10:28:16
|
|
@ 功能: 根据权限获取员工列表
|
|
*/
|
|
func (a *ApiMethod) AuthorizeEmployeeList(c *gin.Context) {
|
|
dataVal, err := publicmethod.ReceiveData(c) //接收数据处理
|
|
if err != nil {
|
|
publicmethod.Result(102, err, c)
|
|
return
|
|
}
|
|
var requestData SearchPowPople
|
|
err = json.Unmarshal(dataVal, &requestData)
|
|
if requestData.Page < 0 {
|
|
requestData.Page = 1
|
|
}
|
|
if requestData.PageSize < 0 {
|
|
requestData.PageSize = 10
|
|
}
|
|
//获取当前操作人
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
var myContInfo modelshr.ManCont
|
|
jsonCont, _ := json.Marshal(context)
|
|
json.Unmarshal(jsonCont, &myContInfo)
|
|
//获取权限
|
|
myPower := publicmethod.GetMyMenuPower(myContInfo.Key, requestData.MenuId)
|
|
//获取人员列表
|
|
gormDb := overall.CONSTANT_DB_HR.Model(&modelshr.UserOrgCont{}).Select("`id`").Where("`number` NOT LIKE ?", "%W%")
|
|
if requestData.Name != "" {
|
|
gormDb = gormDb.Where("`number` LIKE ? OR `name` LIKE ? OR `mobilephone` LIKE ?", "%"+requestData.Name+"%", "%"+requestData.Name+"%", "%"+requestData.Name+"%")
|
|
}
|
|
if len(requestData.Employ) > 0 {
|
|
gormDb = gormDb.Where("`emp_type` IN ?", requestData.Employ)
|
|
} else {
|
|
if requestData.OnJob != 0 {
|
|
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 11, 14)
|
|
} else {
|
|
gormDb = gormDb.Where("`emp_type` BETWEEN ? AND ?", 1, 10)
|
|
}
|
|
}
|
|
if len(requestData.Team) > 0 {
|
|
gormDb = gormDb.Where("`teamid` IN ?", requestData.Team)
|
|
}
|
|
if requestData.JoinTime != "" {
|
|
startTime, endTime := publicmethod.OenDayStartOrEndTime(requestData.JoinTime, 1)
|
|
gormDb = gormDb.Where("`entrydate` BETWEEN ? AND ?", startTime, endTime)
|
|
}
|
|
fmt.Printf("可见范围---------->%v\n\n", myPower.Scope)
|
|
switch myPower.Scope { //可见范围(1:本人;2:本岗位;3:本部门;4:本分部;5:指定行政组织;6:所有)
|
|
case 2:
|
|
gormDb = gormDb.Where("`position` = ?", myContInfo.Position)
|
|
case 3:
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(int64(myContInfo.MainDeparment))
|
|
sunOrg.Id = append(sunOrg.Id, int64(myContInfo.MainDeparment))
|
|
if requestData.OrgId != 0 {
|
|
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) {
|
|
var pickSunOrg publicmethod.GetOrgAllParent
|
|
pickSunOrg.GetOrgSun(int64(requestData.OrgId))
|
|
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId))
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", pickSunOrg.Id, pickSunOrg.Id)
|
|
} else {
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", sunOrg.Id, sunOrg.Id)
|
|
}
|
|
} else {
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", sunOrg.Id, sunOrg.Id)
|
|
}
|
|
|
|
case 4:
|
|
if requestData.OrgId != 0 {
|
|
if int64(requestData.OrgId) == myContInfo.Company {
|
|
gormDb = gormDb.Where("`company` = ?", myContInfo.Company)
|
|
} else {
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(myContInfo.Company)
|
|
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) {
|
|
var pickSunOrg publicmethod.GetOrgAllParent
|
|
pickSunOrg.GetOrgSun(int64(requestData.OrgId))
|
|
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId))
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", pickSunOrg.Id, pickSunOrg.Id)
|
|
} else {
|
|
gormDb = gormDb.Where("`company` = ?", myContInfo.Company)
|
|
}
|
|
}
|
|
|
|
} else {
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(myContInfo.Company)
|
|
if publicmethod.IsInTrue[int64](int64(requestData.OrgId), sunOrg.Id) {
|
|
var pickSunOrg publicmethod.GetOrgAllParent
|
|
pickSunOrg.GetOrgSun(int64(requestData.OrgId))
|
|
pickSunOrg.Id = append(pickSunOrg.Id, int64(requestData.OrgId))
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", pickSunOrg.Id, pickSunOrg.Id)
|
|
} else {
|
|
gormDb = gormDb.Where("`company` = ?", myContInfo.Company)
|
|
}
|
|
}
|
|
|
|
case 5:
|
|
if requestData.OrgId != 0 {
|
|
//目标行政组织
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(int64(requestData.OrgId))
|
|
sunOrg.Id = append(sunOrg.Id, int64(requestData.OrgId))
|
|
//可观测的行政组织
|
|
var oid []int64
|
|
for _, v := range myPower.ScopeManAry {
|
|
oid = append(oid, int64(v))
|
|
}
|
|
lookOrg := publicmethod.Intersect[int64](sunOrg.Id, oid)
|
|
if len(lookOrg) > 0 {
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", lookOrg, lookOrg)
|
|
} else {
|
|
gormDb = gormDb.Where("`orgid` = ? OR `admin_org` = ?", myContInfo.AdminOrg, myContInfo.AdminOrg)
|
|
}
|
|
}
|
|
case 6:
|
|
if requestData.OrgId != 0 {
|
|
var sunOrg publicmethod.GetOrgAllParent
|
|
sunOrg.GetOrgSun(int64(requestData.OrgId))
|
|
sunOrg.Id = append(sunOrg.Id, int64(requestData.OrgId))
|
|
if len(sunOrg.Id) > 0 {
|
|
gormDb = gormDb.Where("`orgid` IN ? OR `admin_org` IN ?", sunOrg.Id, sunOrg.Id)
|
|
} else {
|
|
gormDb = gormDb.Where("`orgid` = ? OR `admin_org` = ?", requestData.OrgId, requestData.OrgId)
|
|
}
|
|
}
|
|
default:
|
|
gormDb = gormDb.Where("`key` = ?", myContInfo.Key)
|
|
}
|
|
//获取人员总数
|
|
var total int64
|
|
totalErr := gormDb.Count(&total).Error
|
|
if totalErr != nil {
|
|
total = 0
|
|
}
|
|
var idAry []int64
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
err = gormDb.Order("`time` DESC").Find(&idAry).Error
|
|
if err != nil && len(idAry) < 1 {
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(idAry)), idAry, c)
|
|
return
|
|
}
|
|
var manContList []modelshr.ManCont
|
|
err = overall.CONSTANT_DB_HR.Where("`id` IN ?", idAry).Order("`time` DESC").Find(&manContList).Error
|
|
if err != nil {
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(idAry)), idAry, c)
|
|
return
|
|
}
|
|
var sendList []SendPowerPeople
|
|
for _, v := range manContList {
|
|
var sendCont SendPowerPeople
|
|
sendCont.ManCont = v
|
|
sendCont.KeyStr = strconv.FormatInt(v.Key, 10)
|
|
sendCont.EmploymentHistory = MyAppointment(v)
|
|
sendCont.PersonInCharge = 2
|
|
if v.PersonInCharge == 1 {
|
|
orgResList := strings.Split(v.ResponsibleDepartment, ",")
|
|
if len(orgResList) > 0 {
|
|
orgIdStr := strconv.FormatInt(int64(requestData.OrgId), 10)
|
|
if publicmethod.IsInTrue[string](orgIdStr, orgResList) == true {
|
|
sendCont.PersonInCharge = 1
|
|
}
|
|
}
|
|
}
|
|
sendList = append(sendList, sendCont)
|
|
}
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(sendList)), sendList, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2026-02-12 11:17:24
|
|
@ 功能: 获取任职情况
|
|
*/
|
|
func MyAppointment(userCont modelshr.ManCont) (list []EmploymentHistoryInfo) {
|
|
if userCont.Key == 0 {
|
|
return
|
|
}
|
|
var orgHistory []modelshr.UserOrg
|
|
overall.CONSTANT_DB_HR.Where("`userKey` = ?", userCont.Key).Find(&orgHistory)
|
|
for _, v := range orgHistory {
|
|
var contVal EmploymentHistoryInfo
|
|
var orgAllName []string
|
|
if v.Orgid != 0 {
|
|
_, companyId, departmentId, sunDepartId, workShopId := publicmethod.GetOrgStructurees(v.Orgid)
|
|
|
|
if companyId != 0 {
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`")
|
|
if orgCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, orgCont.Name)
|
|
}
|
|
}
|
|
}
|
|
|
|
if departmentId != 0 {
|
|
var departCont modelshr.AdministrativeOrganization
|
|
departCont.GetCont(map[string]interface{}{"`id`": departmentId}, "`name`")
|
|
if departCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](departCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, departCont.Name)
|
|
}
|
|
}
|
|
}
|
|
if sunDepartId != 0 {
|
|
var sunDepartCont modelshr.AdministrativeOrganization
|
|
sunDepartCont.GetCont(map[string]interface{}{"`id`": sunDepartId}, "`name`")
|
|
if sunDepartCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](sunDepartCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, sunDepartCont.Name)
|
|
}
|
|
}
|
|
}
|
|
if workShopId != 0 {
|
|
var workCont modelshr.AdministrativeOrganization
|
|
workCont.GetCont(map[string]interface{}{"`id`": workShopId}, "`name`")
|
|
if workCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](workCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, workCont.Name)
|
|
}
|
|
}
|
|
}
|
|
} else if v.Company != 0 {
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": v.Company}, "`name`")
|
|
if orgCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, orgCont.Name)
|
|
}
|
|
}
|
|
}
|
|
contVal.OrgAllName = strings.Join(orgAllName, " / ")
|
|
if v.Position != 0 {
|
|
var postCont modelshr.Position
|
|
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`")
|
|
contVal.PositionName = postCont.Name
|
|
}
|
|
if v.TeamsId != 0 {
|
|
var teamCont modelshr.TeamGroup
|
|
teamCont.GetCont(map[string]interface{}{"`id`": v.TeamsId}, "`name`")
|
|
contVal.TeamName = teamCont.Name
|
|
}
|
|
contVal.Attribute = v.AssignType
|
|
list = append(list, contVal)
|
|
}
|
|
if len(list) < 1 {
|
|
var contVal EmploymentHistoryInfo
|
|
var orgAllName []string
|
|
if userCont.Company != 0 {
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.Company}, "`name`")
|
|
if orgCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, orgCont.Name)
|
|
}
|
|
}
|
|
}
|
|
if userCont.MainDeparment != 0 {
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.MainDeparment}, "`name`")
|
|
if orgCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, orgCont.Name)
|
|
}
|
|
}
|
|
}
|
|
if userCont.SunMainDeparment != 0 {
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.SunMainDeparment}, "`name`")
|
|
if orgCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, orgCont.Name)
|
|
}
|
|
}
|
|
}
|
|
if userCont.AdminOrg != 0 {
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
orgCont.GetCont(map[string]interface{}{"`id`": userCont.AdminOrg}, "`name`")
|
|
if orgCont.Name != "" {
|
|
if !publicmethod.IsInTrue[string](orgCont.Name, orgAllName) {
|
|
orgAllName = append(orgAllName, orgCont.Name)
|
|
}
|
|
}
|
|
}
|
|
contVal.OrgAllName = strings.Join(orgAllName, " / ")
|
|
if userCont.Position != 0 {
|
|
var postCont modelshr.Position
|
|
postCont.GetCont(map[string]interface{}{"`id`": userCont.Position}, "`name`")
|
|
contVal.PositionName = postCont.Name
|
|
}
|
|
if userCont.TeamId != 0 {
|
|
var teamCont modelshr.TeamGroup
|
|
teamCont.GetCont(map[string]interface{}{"`id`": userCont.TeamId}, "`name`")
|
|
contVal.TeamName = teamCont.Name
|
|
}
|
|
contVal.Attribute = 1
|
|
list = append(list, contVal)
|
|
}
|
|
return
|
|
}
|
|
|