Browse Source

修正参数

v2_dev
超级管理员 3 years ago
parent
commit
ba90e9f2ce
  1. 111
      api/version1/administrativeorganization/govcont.go
  2. 192
      api/version1/administrativeorganization/orgpost.go
  3. 136
      api/version1/administrativeorganization/position.go
  4. 60
      api/version1/administrativeorganization/type.go
  5. 2
      api/version1/inlet.go
  6. 15
      api/version1/personnelapi/staffarchives.go
  7. 23
      api/version1/roleapi/entry.go
  8. 18
      api/version1/roleapi/roleinfo.go
  9. 2
      apirouter/inlet.go
  10. 3
      apirouter/organization/organization_group.go
  11. 4
      apirouter/rolerouter/entry.go
  12. 18
      apirouter/rolerouter/roleapirouter.go
  13. 28
      grocerystore/redis.go
  14. 6
      initialization/route/route_entry.go
  15. 1
      models/position.go
  16. 43
      models/position_unify.go

111
api/version1/administrativeorganization/govcont.go

@ -3,6 +3,7 @@ package administrativeorganization
import (
"encoding/json"
"fmt"
"hr_server/grocerystore"
"hr_server/models"
"hr_server/overall"
"hr_server/overall/overallhandle"
@ -282,25 +283,52 @@ func (o *OrganizationApi) GovThree(c *gin.Context) {
idInt64, _ := strconv.ParseInt(requestData.IdStr, 10, 64)
requestData.Id = idInt64
}
fmt.Printf("requestData---------------->%v\n", requestData)
var govMap overallhandle.MenuList
// gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` IN ?", []int{1, 2}).Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307})
gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = ?", 1)
if requestData.All == 0 {
requestData.Id = 312
gormDb = gormDb.Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307})
}
if requestData.Level != 0 {
gormDb = gormDb.Where("aot.level <= ?", requestData.Level)
}
err := gormDb.Find(&govMap).Error
if err != nil {
overallhandle.Result(107, err, c)
return
//API Token数据
redisFileKey := fmt.Sprintf("Org:OrgContList:%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, "orgcont")
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4)
orgList, orgErr := redisClient.SMEMBERS(redisFileKey)
// fmt.Printf("requ---------------->%v--------------->%v\n", orgList, orgErr)
if orgErr != nil || len(orgList) < 1 {
// fmt.Printf("requestData---------------->%v\n", requestData)
// gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` IN ?", []int{1, 2}).Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307})
gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` = ?", 1)
if requestData.All == 0 {
requestData.Id = 312
gormDb = gormDb.Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307})
}
if requestData.Level != 0 {
gormDb = gormDb.Where("aot.level <= ?", requestData.Level)
}
err := gormDb.Find(&govMap).Error
if err != nil {
overallhandle.Result(107, err, c)
return
}
redisClient.SetRedisTime(86400)
for _, v := range govMap {
vJsonStr, jsonErr := json.Marshal(v)
if jsonErr == nil {
redisClient.Sadd(redisFileKey, string(vJsonStr))
}
}
} else {
if requestData.All == 0 {
requestData.Id = 312
}
for _, v := range orgList {
var redisCont overallhandle.OutGovCont
jsonErr := json.Unmarshal([]byte(v), &redisCont)
if jsonErr == nil {
govMap = append(govMap, redisCont)
}
}
}
// fmt.Printf("id==========>%v", govMap)
// govMap.GovRecursion(requestData.Id, 0)
fmt.Printf("govAry---------------->%v\n", requestData.Id)
// fmt.Printf("govAry---------------->%v\n", govMap)
govMapThree := overallhandle.GovThreeList(requestData.Id, govMap)
overallhandle.Result(0, govMapThree, c)
}
@ -332,7 +360,7 @@ func (o *OrganizationApi) GovThreeIng(c *gin.Context) {
idInt64, _ := strconv.ParseInt(requestData.IdStr, 10, 64)
requestData.Id = idInt64
}
fmt.Printf("requestData---------------->%v\n", requestData)
// fmt.Printf("requestData---------------->%v\n", requestData)
var govMap overallhandle.MenuList
// gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` IN ?", []int{1, 2}).Where("administrative_organization.id NOT IN ?", []int{312, 293, 305, 306, 307})
gormDb := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Select("administrative_organization.*,aot.name as classname,aot.level").Joins("left join administrative_organization_type as aot on aot.id = administrative_organization.organization_type").Where("administrative_organization.`state` BETWEEN ? AND ?", 1, 2)
@ -350,7 +378,7 @@ func (o *OrganizationApi) GovThreeIng(c *gin.Context) {
}
// fmt.Printf("id==========>%v", govMap)
// govMap.GovRecursion(requestData.Id, 0)
fmt.Printf("govAry---------------->%v\n", requestData.Id)
// fmt.Printf("govAry---------------->%v\n", requestData.Id)
govMapThree := overallhandle.GovThreeList(requestData.Id, govMap)
overallhandle.Result(0, govMapThree, c)
}
@ -539,7 +567,7 @@ func (o *OrganizationApi) GovThreeAboutMan(c *gin.Context) {
return allOrgAndPeople.OrgAndPeopleList[i].Sort < allOrgAndPeople.OrgAndPeopleList[j].Sort
})
// var outputDataList []OrgAndPeople
fmt.Printf("idInt------------------>%v\n", idInt)
// fmt.Printf("idInt------------------>%v\n", idInt)
govMapThree := OrgAndMAnThree(idInt, allOrgAndPeople.OrgAndPeopleList)
outputDataAry := overallhandle.MapOut()
outputDataAry["three"] = govMapThree
@ -838,6 +866,10 @@ func (o *OrganizationApi) GetOrgAndEveryOnePeople(c *gin.Context) {
orgIdList = sunAry.SunList
}
}
if !overallhandle.IsInTrue[int64](origin, orgIdList) {
orgIdList = append(orgIdList, origin)
}
fmt.Printf("获取行政组织--->%v\n", orgIdList)
var orgAndPeopleListCont empowerSync //启用协程结构体
synPro.Add(1)
go orgAndPeopleListCont.GetOrgList(isNotIn, orgIdList, requestData.Level) //获取行政组织
@ -846,6 +878,10 @@ func (o *OrganizationApi) GetOrgAndEveryOnePeople(c *gin.Context) {
synPro.Wait()
orgAndManList := orgAndPeopleListCont.readDataLock()
sort.Slice(orgAndManList, func(i, j int) bool {
return orgAndManList[i].Type < orgAndManList[j].Type
})
sendList := OrgAndManNewThree(origin, orgAndManList)
overallhandle.Result(0, sendList, c)
@ -988,7 +1024,10 @@ func OrgAndManNewThree(parentId int64, govAry []OrgAndEveryOnePeople) []OrgAndMa
node.IconPhoto = v.IconPhoto
node.Type = v.Type
node.Key = v.Key
node.Child = child
if len(child) > 0 {
node.Child = child
}
orgAndMAnMap = append(orgAndMAnMap, node)
}
@ -1096,6 +1135,13 @@ func (o *OrganizationApi) BasisOrgObtainSonOrgAndMan(c *gin.Context) {
employess.Open = "false" //上级ID
employess.Icon = man.Icon
employess.IconToBase64 = man.IconPhoto
employess.Wechat = man.Wechat
employess.Departmentid = man.DepartmentId //部门ID
employess.DepartmentName = man.DepartmentName //部门名称
employess.Postid = man.PostId //岗位ID
employess.PostName = man.PostName //岗位名称
employess.Tema = man.Tema //班组Id
employess.TemaName = man.TemaName //班组名称
sendData.Employees = append(sendData.Employees, employess)
}
}
@ -1127,7 +1173,7 @@ func (e *empowerSyncDepartMan) GetPeopleListIng(isNotIn int, orgId []int64) {
e.mutext.Lock()
defer e.mutext.Unlock()
var peopleList []models.PersonArchives
gormDnMan := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`").Where("`state` = 1 AND `emp_type` BETWEEN ? AND ?", 1, 10)
gormDnMan := overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`key`,`number`,`name`,`icon`,`icon_photo`,`admin_org`,`wechat`,`work_wechat`,`position`,`teamid`").Where("`state` = 1 AND `emp_type` BETWEEN ? AND ?", 1, 10)
if len(orgId) > 0 {
if isNotIn == 1 {
gormDnMan = gormDnMan.Where("`admin_org` NOT IN ?", orgId)
@ -1148,7 +1194,32 @@ func (e *empowerSyncDepartMan) GetPeopleListIng(isNotIn int, orgId []int64) {
peopleCont.Icon = v.Icon
peopleCont.IconPhoto = v.IconPhoto
peopleCont.Type = 2
peopleCont.Wechat = v.Wechat
if v.WorkWechat != "" {
peopleCont.Wechat = v.WorkWechat
}
peopleCont.Key = fmt.Sprintf("U%v", v.Key)
_, _, companyId, _, _ := overallhandle.GetOrgStructure(v.AdminOrg)
if companyId != 0 {
var orgCont models.AdministrativeOrganization
orgCont.GetCont(map[string]interface{}{"`id`": companyId}, "`name`")
peopleCont.DepartmentId = companyId //分厂Id
peopleCont.DepartmentName = orgCont.Name //分厂名称
}
//获取岗位
if v.Position != 0 {
var postCont models.Position
postCont.GetCont(map[string]interface{}{"`id`": v.Position}, "`name`")
peopleCont.PostId = v.Position //职务Id
peopleCont.PostName = postCont.Name //职务名称
}
if v.TeamId != 0 {
var teamCont models.TeamGroup
teamCont.GetCont(map[string]interface{}{"`id`": v.TeamId}, "`name`")
peopleCont.Tema = v.TeamId //班组Id
peopleCont.TemaName = teamCont.Name //班组名称
}
e.peopleList = append(e.peopleList, peopleCont)
}
}

192
api/version1/administrativeorganization/orgpost.go

@ -1,6 +1,9 @@
package administrativeorganization
import (
"encoding/json"
"fmt"
"hr_server/grocerystore"
"hr_server/models"
"hr_server/overall"
"hr_server/overall/overallhandle"
@ -31,86 +34,122 @@ import (
func (o *OrganizationApi) GetOrgAndPostThree(c *gin.Context) {
var requestData OrgAndMAnThreeType
c.ShouldBindJSON(&requestData)
//获取行政组织
var orgList []models.OrgContType
gormDb := overall.CONSTANT_DB_HR.Where("`state` = ? ", 1)
if requestData.All == 0 {
// requestData.Id = "309"
gormDb = gormDb.Where("`id` NOT IN ?", []int{312, 293, 305, 306, 307})
}
if requestData.Level != 0 {
gormDb = gormDb.Where("`level` <= ?", requestData.Level)
}
// departmentId := overallhandle.RecursionOrgLeveEs(282, 282, 3)
// overallhandle.Result(2555646, departmentId, c)
// return
err := gormDb.Find(&orgList).Error
if err != nil {
overallhandle.Result(107, err, c)
return
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
pageSize := 1
//计算分协程数据基数
switch {
case total > 10 && total <= 10000:
pageSize = 100
case total > 10000:
pageSize = 1000
default:
pageSize = 1
}
var contList []OutPutOrgAndPost
var syncOrgToPost OrgAndPostSync
for i, v := range orgList {
var sendCont OutPutOrgAndPost
sendCont.Id = strconv.FormatInt(v.Id, 10)
sendCont.Number = v.Number
sendCont.Name = v.Name
sendCont.Superior = v.Superior
sendCont.Attribute = 1
sendCont.Sort = 1
sendCont.OrgId = strconv.FormatInt(v.Id, 10)
if (i+1)%pageSize == 0 {
contList = append(contList, sendCont)
redisFileKey := fmt.Sprintf("OrgPost:OrgPostContList:%v_%v", overall.CONSTANT_CONFIG.RedisPrefixStr.Alias, "orgpostcont")
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS4)
orgList, orgErr := redisClient.SMEMBERS(redisFileKey)
if orgErr != nil || len(orgList) < 1 {
//获取行政组织
var orgList []models.OrgContType
gormDb := overall.CONSTANT_DB_HR.Where("`state` = ? ", 1)
if requestData.All == 0 {
// requestData.Id = "309"
gormDb = gormDb.Where("`id` NOT IN ?", []int{312, 293, 305, 306, 307})
}
if requestData.Level != 0 {
gormDb = gormDb.Where("`level` <= ?", requestData.Level)
}
// departmentId := overallhandle.RecursionOrgLeveEs(282, 282, 3)
// overallhandle.Result(2555646, departmentId, c)
// return
err := gormDb.Find(&orgList).Error
if err != nil {
overallhandle.Result(107, err, c)
return
}
var total int64
totalErr := gormDb.Count(&total).Error
if totalErr != nil {
total = 0
}
pageSize := 1
//计算分协程数据基数
switch {
case total > 10 && total <= 10000:
pageSize = 100
case total > 10000:
pageSize = 1000
default:
pageSize = 1
}
var contList []OutPutOrgAndPost
var syncOrgToPost OrgAndPostSync
for i, v := range orgList {
var sendCont OutPutOrgAndPost
sendCont.Id = strconv.FormatInt(v.Id, 10)
sendCont.Number = v.Number
sendCont.Name = v.Name
sendCont.Superior = v.Superior
sendCont.Attribute = 1
sendCont.Sort = 1
sendCont.OrgId = strconv.FormatInt(v.Id, 10)
if (i+1)%pageSize == 0 {
contList = append(contList, sendCont)
synProes.Add(1)
go syncOrgToPost.GetPostInfoList(contList)
contList = []OutPutOrgAndPost{}
} else {
contList = append(contList, sendCont)
}
}
if len(contList) > 0 { //判断盈余分组数据
synProes.Add(1)
go syncOrgToPost.GetPostInfoList(contList)
contList = []OutPutOrgAndPost{}
} else {
contList = append(contList, sendCont)
}
synProes.Wait()
allOrgAndPostContList := syncOrgToPost.readDataLock()
sort.Slice(allOrgAndPostContList, func(i, j int) bool {
return allOrgAndPostContList[i].Sort < allOrgAndPostContList[j].Sort
})
sort.Slice(allOrgAndPostContList, func(i, j int) bool {
return allOrgAndPostContList[i].Superior < allOrgAndPostContList[j].Superior
})
var allNumber []string
redisClient.SetRedisTime(86400)
for _, v := range allOrgAndPostContList {
allNumber = append(allNumber, v.Number)
vJsonStr, jsonErr := json.Marshal(v)
if jsonErr == nil {
redisClient.Sadd(redisFileKey, string(vJsonStr))
}
}
var sendList []OutPutOrgAndPostLoop
sendList = OrgAndPostThreeList(requestData.Id, allOrgAndPostContList)
outputDataAry := overallhandle.MapOut()
outputDataAry["count"] = len(allOrgAndPostContList)
outputDataAry["list"] = sendList
outputDataAry["allnumber"] = allNumber
overallhandle.Result(0, outputDataAry, c)
} else {
var sendListCont []OutPutOrgAndPost
var allNumber []string
for _, v := range orgList {
var redisCont OutPutOrgAndPost
jsonErr := json.Unmarshal([]byte(v), &redisCont)
fmt.Printf("jsonErr=========>%v\n", jsonErr)
if jsonErr == nil {
sendListCont = append(sendListCont, redisCont)
allNumber = append(allNumber, redisCont.Number)
}
}
sendList := OrgAndPostThreeList(requestData.Id, sendListCont)
outputDataAry := overallhandle.MapOut()
outputDataAry["count"] = len(sendListCont)
outputDataAry["list"] = sendList
outputDataAry["allnumber"] = allNumber
overallhandle.Result(0, outputDataAry, c)
}
if len(contList) > 0 { //判断盈余分组数据
synProes.Add(1)
go syncOrgToPost.GetPostInfoList(contList)
}
synProes.Wait()
allOrgAndPostContList := syncOrgToPost.readDataLock()
sort.Slice(allOrgAndPostContList, func(i, j int) bool {
return allOrgAndPostContList[i].Sort < allOrgAndPostContList[j].Sort
})
sort.Slice(allOrgAndPostContList, func(i, j int) bool {
return allOrgAndPostContList[i].Superior < allOrgAndPostContList[j].Superior
})
var allNumber []string
for _, v := range allOrgAndPostContList {
allNumber = append(allNumber, v.Number)
}
sendList := OrgAndPostThreeList(requestData.Id, allOrgAndPostContList)
outputDataAry := overallhandle.MapOut()
outputDataAry["count"] = len(allOrgAndPostContList)
outputDataAry["list"] = sendList
outputDataAry["allnumber"] = allNumber
overallhandle.Result(0, outputDataAry, c)
}
// 合成树形结构
func OrgAndPostThreeList(superiorId string, contList []OutPutOrgAndPost) *[]OutPutOrgAndPostLoop {
func OrgAndPostThreeList(superiorId string, contList []OutPutOrgAndPost) []OutPutOrgAndPostLoop {
three := []OutPutOrgAndPostLoop{}
for _, v := range contList {
supIdStr := strconv.FormatInt(v.Superior, 10)
@ -127,11 +166,14 @@ func OrgAndPostThreeList(superiorId string, contList []OutPutOrgAndPost) *[]OutP
node.OrgName = v.OrgName
node.DepartId = v.DepartId
node.DepartName = v.DepartName
node.Child = child
if len(child) > 0 {
node.Child = child
}
three = append(three, node)
}
}
return &three
return three
}
// 获取岗位列表

136
api/version1/administrativeorganization/position.go

@ -888,3 +888,139 @@ func (o *OrganizationApi) GetMyPositionList(c *gin.Context) {
overallhandle.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(positionAry)), positionAry, c)
}
}
/*
*
@ 作者: 秦东
@ 时间: 2023-03-28 10:37:04
@ 功能:
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (o *OrganizationApi) PositionUnify(c *gin.Context) {
var nameList []string
err := overall.CONSTANT_DB_HR.Model(&models.Position{}).Distinct("`name`").Find(&nameList).Error
if err != nil {
overallhandle.Result(105, err, c)
return
}
// var saveDataList []models.PositionUnify
var positisonUnify PositionUnifySync
for _, v := range nameList {
synPro.Add(1)
go positisonUnify.UnifyDataPosition(v)
}
synPro.Wait()
pounifyList := positisonUnify.readDataLock()
overallhandle.Result(0, pounifyList, c)
}
// 组装数据
func (p *PositionUnifySync) UnifyDataPosition(fieldName string) {
p.mutext.Lock()
defer p.mutext.Unlock()
var positionIdList []int64
err := overall.CONSTANT_DB_HR.Model(&models.Position{}).Select("`id`").Where("`name` = ?", fieldName).Find(&positionIdList).Error
// overall.CONSTANT_DB_HR.Model(&models.Position{}).Select("`id`").Where("`name` = ?", fieldName).Find(&positionIdList)
var orlUnifyCont models.PositionUnify
oldErr := orlUnifyCont.GetCont(map[string]interface{}{"`name`": fieldName})
if oldErr != nil {
var positionUnifyCont models.PositionUnify
positionUnifyCont.Name = fieldName //职位名称"`
positionUnifyCont.Time = time.Now().Unix() //创建时间"`
positionUnifyCont.State = 1 //(1:启用;2:禁用;3:删除)"`
if err == nil && len(positionIdList) > 0 {
idByte, jsonErr := json.Marshal(positionIdList)
if jsonErr == nil {
positionUnifyCont.Content = string(idByte) //关联具体岗位ID"`
}
}
p.PositionList = append(p.PositionList, positionUnifyCont)
overall.CONSTANT_DB_HR.Create(&positionUnifyCont)
} else {
saveNewData := overallhandle.MapOut()
if err == nil && len(positionIdList) > 0 {
idByte, jsonErr := json.Marshal(positionIdList)
if jsonErr == nil {
saveNewData["`content`"] = string(idByte) //关联具体岗位ID"`
}
}
saveNewData["`time`"] = time.Now().Unix()
var orlEditUnifyCont models.PositionUnify
orlEditUnifyCont.EiteCont(map[string]interface{}{"`id`": orlUnifyCont.Id}, saveNewData)
}
synPro.Done()
}
/*
*
@ 作者: 秦东
@ 时间: 2023-03-28 11:15:49
@ 功能: 职位岗位去重反写岗位关联
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (o *OrganizationApi) PositionUnifyForPosition(c *gin.Context) {
var positionUnifyList []models.PositionUnify
err := overall.CONSTANT_DB_HR.Where("state = ?", 1).Find(&positionUnifyList).Error
if err != nil || len(positionUnifyList) < 1 {
overallhandle.Result(105, err, c)
return
}
for _, v := range positionUnifyList {
synPro.Add(1)
go excudePosition(v)
}
synPro.Wait()
overallhandle.Result(0, err, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2023-03-28 11:19:54
@ 功能: 处理职位岗位去重反写岗位关联数据
@ 参数
#unifyCont 去重数据
@ 返回值
#
@ 方法原型
#
*/
func excudePosition(unifyCont models.PositionUnify) {
defer synPro.Done()
if unifyCont.Content != "" {
var poisitonId []int64
jsonErr := json.Unmarshal([]byte(unifyCont.Content), &poisitonId)
if jsonErr == nil {
saveData := overallhandle.MapOut()
saveData["`unify_id`"] = unifyCont.Id
saveData["`time`"] = time.Now().Unix()
overall.CONSTANT_DB_HR.Model(&models.Position{}).Where("`id` IN ?", poisitonId).Updates(&saveData)
}
}
}

60
api/version1/administrativeorganization/type.go

@ -272,16 +272,23 @@ type eitePositionInfoNes struct {
// 行政组织与个人列表
type OrgAndEveryOnePeople struct {
Id string `json:"id"` //识别符
OrgId int64 `json:"orgid"` //行政组织Id
Number string `json:"number"` //编号
Name string `json:"name"` //姓名
Superior string `json:"superior"` //上级
Icon string `json:"icon"` //头像
IconPhoto string `json:"icon_photo"` //头像
Type int `json:"type"` //类型 1:行政组织;2:人员
Key string `json:"key"` //列表识别
Sort int `json:"sort"` //排序
Id string `json:"id"` //识别符
OrgId int64 `json:"orgid"` //行政组织Id
Number string `json:"number"` //编号
Name string `json:"name"` //姓名
Superior string `json:"superior"` //上级
Icon string `json:"icon"` //头像
IconPhoto string `json:"icon_photo"` //头像
Type int `json:"type"` //类型 1:行政组织;2:人员
Key string `json:"key"` //列表识别
Sort int `json:"sort"` //排序
Wechat string `json:"wechat"` //微信或企业微信
DepartmentId int64 `json:"departmentid"` //部门ID
DepartmentName string `json:"departmentname"` //部门名称
PostId int64 `json:"postid"` //岗位ID
PostName string `json:"postname"` //岗位名称
Tema int64 `json:"tema"` //班组Id
TemaName string `json:"temaname"` //班组名称
}
// 授权协程操作
@ -345,12 +352,19 @@ type ChildDepartmentsCont struct {
// 审批节点选人人员节点
type EmployeesCont struct {
Id string `json:"id"`
EmployeeName string `json:"employeeName"` //人员名称
IsLeave string `json:"isLeave"` //行政组织名称
Open string `json:"open"` //上级ID
Icon string `json:"icon"` //头像
IconToBase64 string `json:"iconToBase64"` //头像
Id string `json:"id"`
EmployeeName string `json:"employeeName"` //人员名称
IsLeave string `json:"isLeave"` //行政组织名称
Open string `json:"open"` //上级ID
Icon string `json:"icon"` //头像
IconToBase64 string `json:"iconToBase64"` //头像
Wechat string `json:"wechat"` //微信或企业微信
Departmentid int64 `json:"departmentid"` //部门ID
DepartmentName string `json:"departmentname"` //部门名称
Postid int64 `json:"postid"` //岗位ID
PostName string `json:"postname"` //岗位名称
Tema int64 `json:"tema"` //班组Id
TemaName string `json:"temaname"` //班组名称
}
// 审批节点选择面包屑
@ -381,7 +395,7 @@ type OutPutOrgAndPost struct {
// 循环输出
type OutPutOrgAndPostLoop struct {
OutPutOrgAndPost
Child *[]OutPutOrgAndPostLoop `json:"child"` //下级
Child []OutPutOrgAndPostLoop `json:"child"` //下级
}
type OrgAndPostSync struct {
@ -394,3 +408,15 @@ func (o *OrgAndPostSync) readDataLock() []OutPutOrgAndPost {
defer o.mutext.RUnlock()
return o.orgAndPostList
}
// 协程操作统一岗位名称
type PositionUnifySync struct {
PositionList []models.PositionUnify
mutext sync.RWMutex
}
func (p *PositionUnifySync) readDataLock() []models.PositionUnify {
p.mutext.RLock()
defer p.mutext.RUnlock()
return p.PositionList
}

2
api/version1/inlet.go

@ -4,6 +4,7 @@ import (
"hr_server/api/version1/administrativeorganization"
"hr_server/api/version1/permitpowerapi"
"hr_server/api/version1/personnelapi"
"hr_server/api/version1/roleapi"
"hr_server/api/version1/shiyan"
"hr_server/api/version1/workrostering"
)
@ -14,6 +15,7 @@ type ApiInlet struct {
StaffApi personnelapi.StaffApi
ShiyanApi shiyan.ShiYan
RosteringApi workrostering.ApiModer
RoleApi roleapi.ApiModer
}
var AppApiInlet = new(ApiInlet)

15
api/version1/personnelapi/staffarchives.go

@ -92,7 +92,7 @@ func (s *StaffApi) ArchivesList(c *gin.Context) {
getWhe["id"] = v.Position
getSpur.GetCont(getWhe, "name", "person_in_charge")
staffInfo.PositionName = getSpur.Name
staffInfo.PersonInCharge = getSpur.PersonInCharge
// staffInfo.PersonInCharge = getSpur.PersonInCharge
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
//公司
if v.Company != 0 {
@ -2747,7 +2747,7 @@ func (s *StaffApi) ArchivesListWai(c *gin.Context) {
getWhe["id"] = v.Position
getSpur.GetCont(getWhe, "name", "person_in_charge")
staffInfo.PositionName = getSpur.Name
staffInfo.PersonInCharge = getSpur.PersonInCharge
// staffInfo.PersonInCharge = getSpur.PersonInCharge
staffInfo.KeyStr = strconv.FormatInt(v.Key, 10)
//公司
if v.Company != 0 {
@ -2793,6 +2793,17 @@ func (s *StaffApi) ArchivesListWai(c *gin.Context) {
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)
}

23
api/version1/roleapi/entry.go

@ -0,0 +1,23 @@
package roleapi
import (
"hr_server/overall/overallhandle"
"github.com/gin-gonic/gin"
)
// 角色API
type ApiModer struct{}
// 入口
func (s *ApiModer) Index(c *gin.Context) {
outputCont := overallhandle.MapOut()
outputCont["index"] = "角色API"
overallhandle.Result(0, outputCont, c)
}
// 获取角色列表
type GetRoleCont struct {
Name string `json:"name"`
overallhandle.PageTurning
}

18
api/version1/roleapi/roleinfo.go

@ -0,0 +1,18 @@
package roleapi
import (
"github.com/gin-gonic/gin"
)
// 获取角色列表
func (a *ApiModer) GetRoleContList(c *gin.Context) {
var requestData GetRoleCont
c.ShouldBindJSON(&requestData)
if requestData.Page == 0 {
requestData.Page = 1
}
if requestData.PageSize == 0 {
requestData.PageSize = 20
}
// gormDb := overall.CONSTANT_DB_HR
}

2
apirouter/inlet.go

@ -6,6 +6,7 @@ import (
"hr_server/apirouter/organization"
"hr_server/apirouter/permit"
"hr_server/apirouter/personnel"
"hr_server/apirouter/rolerouter"
"hr_server/apirouter/shiyanrouter"
"hr_server/apirouter/workteamapi"
)
@ -22,6 +23,7 @@ type RouterGroup struct {
EmpowerApiRouter empowerrote.EmpowerApiRouter
KingdeeApiRouter dockingjindie.DockingJindieApiRouter
RosteringApiRouter workteamapi.ApiRouter //排班相关管理
RoleApiRouter rolerouter.ApiRouter //角色相关
}
var RouterGroupInlet = new(RouterGroup)

3
apirouter/organization/organization_group.go

@ -70,6 +70,9 @@ func (o *OrganizationRoute) InitRouterGroup(route *gin.RouterGroup) {
apiRouter.POST("positionpeoplelist", apiHandle.PositionPeopleList) //职位(岗位)列表及相关人员
apiRouter.POST("positionunify", apiHandle.PositionUnify) //职位(岗位)去重
apiRouter.POST("posunifyposition", apiHandle.PositionUnifyForPosition) //职位(岗位)去重反写岗位关联
//班组
apiRouter.POST("teamcontlist", apiHandle.TeamContList) //班组列表
apiRouter.POST("getteamcont", apiHandle.GetTeamCont) //获取班组

4
apirouter/rolerouter/entry.go

@ -0,0 +1,4 @@
package rolerouter
//角色相关
type ApiRouter struct{}

18
apirouter/rolerouter/roleapirouter.go

@ -0,0 +1,18 @@
package rolerouter
import (
"hr_server/api/version1"
"github.com/gin-gonic/gin"
)
// 组织架构
func (a *ApiRouter) InitRouterGroup(route *gin.RouterGroup) {
apiRouter := route.Group("role")
var apiHandle = version1.AppApiInlet.RoleApi
{
apiRouter.GET("", apiHandle.Index) //入口
apiRouter.POST("", apiHandle.Index) //入口
apiRouter.POST("get_role_cont_list", apiHandle.GetRoleContList) //角色列表
}
}

28
grocerystore/redis.go

@ -397,3 +397,31 @@ func (r *RedisStoreType) Keys(key string) (val []string, err error) {
val, err = r.RedisDb.Keys(r.Context, key).Result()
return
}
/*
获取集合中所有成员列表
Redis Smembers 命令返回集合中的所有的成员 不存在的集合 key 被视为空集合
*/
func (r *RedisStoreType) SMEMBERS(key string) (val []string, err error) {
val, err = r.RedisDb.SMembers(r.Context, key).Result()
return
}
/*
Redis Sadd 命令将一个或多个成员元素加入到集合中已经存在于集合的成员元素将被忽略
假如集合 key 不存在则创建一个只包含添加的元素作成员的集合
当集合 key 不是集合类型时返回一个错误
注意 Redis2.4 版本以前 SADD 只接受单个成员值
语法
redis Sadd 命令基本语法如下
redis 127.0.0.1:6379> SADD KEY_NAME VALUE1..VALUEN
*/
func (r *RedisStoreType) Sadd(key string, value ...interface{}) (val int64, err error) {
val, err = r.RedisDb.SAdd(r.Context, key, value).Result()
return
}

6
initialization/route/route_entry.go

@ -43,6 +43,9 @@ func InitialRouter() *gin.Engine {
//排班相关操作
rosteringApi := apirouter.RouterGroupInlet.RosteringApiRouter
//角色相关
roleApi := apirouter.RouterGroupInlet.RoleApiRouter
//金蝶对接接口
jinDieDockingApi := apirouter.RouterGroupInlet.KingdeeApiRouter //人员
organizationApiKingdee := apirouter.RouterGroupInlet.OrganizationApiOpen //组织架构
@ -57,6 +60,8 @@ func InitialRouter() *gin.Engine {
rosteringApi.InitRouterGroup(appLoadRouterGroup) //排班相关操作
roleApi.InitRouterGroup(appLoadRouterGroup) //角色相关
}
//身份验证
@ -67,6 +72,7 @@ func InitialRouter() *gin.Engine {
permitPowerApi.InitRouterGroup(Authentication) //权限相关操作
staffApiFuben.InitRouterGroup(Authentication) //人员档案
organizationApiKingdee.InitRouterGroup(Authentication) //人员档案
}
return router

1
models/position.go

@ -22,6 +22,7 @@ type Position struct {
School int64 `json:"school" gorm:"column:school;type:bigint(20) unsigned;default:0;not null;comment:部门"`
KingdeeId string `json:"kingdeeid" gorm:"column:kingdeeid;type:varchar(255) unsigned;default:'';comment:金蝶对照ID"`
OrgList string `json:"orglist" gorm:"column:orglist;type:text;comment:行政组织关系"`
UnifyId int64 `json:"unifyid" gorm:"column:unify_id;type:bigint(20) unsigned;default:0;not null;comment:统一名称"`
}
func (Position *Position) TableName() string {

43
models/position_unify.go

@ -0,0 +1,43 @@
package models
import (
"hr_server/overall"
"strings"
)
// 职位(岗位)
type PositionUnify struct {
Id int64 `json:"id" gorm:"primaryKey;column:id;type:bigint(20) unsigned;not null;comment:Id;index"`
Name string `json:"name" gorm:"column:name;type:varchar(200) unsigned;default:'';not null;comment:职位名称"`
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"`
State int `json:"state" gorm:"column:state;type:int(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"`
Content string `json:"content" gorm:"column:content;type:longtext;comment:关联具体岗位ID"`
}
func (PositionUnify *PositionUnify) TableName() string {
return "position_unify"
}
// 编辑职务分类内容
func (cont *PositionUnify) EiteCont(whereMap interface{}, saveData map[string]interface{}) (err error) {
err = overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取行政组织内容
func (cont *PositionUnify) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_HR.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *PositionUnify) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_HR.Model(&cont).Where(whereMap).Count(&countId)
return
}
Loading…
Cancel
Save