@ -6,6 +6,8 @@ import (
"appPlatform/overall"
"appPlatform/overall/publicmethod"
"encoding/json"
"fmt"
"sort"
"strconv"
"strings"
@ -55,6 +57,9 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) {
orgCont . GetCont ( map [ string ] interface { } { "`id`" : myContInfo . MainDeparment } , "`name`" )
sendData . OrganizationName = orgCont . Name //行政组织名称
sendData . Avatar = myContInfo . Icon
if myContInfo . IconPhpto != "" {
sendData . Avatar = myContInfo . IconPhpto
}
roleList := strings . Split ( myContInfo . Role , "," )
// roleList = append(roleList, "ROOT")
sendData . Roles = roleList
@ -63,9 +68,98 @@ func (a *ApiMethod) GetUserCont(c *gin.Context) {
// menuPoint, opeart, orgList := GetUserPower("appsystem", myContInfo.Position, roleList)
// fmt.Printf("menuPoint======>%v\nopeart======>%v\norgList======>%v\n", menuPoint, opeart, orgList)
sendData . Perms = menuPoint
switch myContInfo . Gender {
case 1 :
sendData . GenderStr = "男"
case 2 :
sendData . GenderStr = "女"
default :
sendData . GenderStr = "第三性别"
}
sendData . EmpType = myContInfo . EmpType
sendData . PostList = GainOrgPostLog ( myContInfo . Key )
sendData . Mobilephone = myContInfo . Mobilephone
sendData . Currentresidence = myContInfo . Currentresidence
publicmethod . Result ( 0 , sendData , c )
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 07 10 : 19 : 45
@ 功能 : 获取集团内任职记录
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func GainOrgPostLog ( uid int64 ) ( postLog [ ] string ) {
var workHistory [ ] modelshr . InsideWorkHistory
err := overall . CONSTANT_DB_HR . Where ( "`state` = 1 AND `end_time` = 0 AND `key` = ?" , uid ) . Order ( "`assign_type` ASC" ) . Order ( "`start_time` DESC" ) . Find ( & workHistory ) . Error
if err != nil && len ( workHistory ) < 1 {
return
}
for _ , v := range workHistory {
var orgList [ ] int64
var orgNameList [ ] string
if ! publicmethod . IsInTrue [ int64 ] ( v . Company , orgList ) {
orgList = append ( orgList , v . Company )
var orgOne modelshr . AdministrativeOrganization
orgOne . GetCont ( map [ string ] interface { } { "`id`" : v . Company } , "`name`" )
orgNameList = append ( orgNameList , orgOne . Name )
}
if ! publicmethod . IsInTrue [ int64 ] ( v . Department , orgList ) {
orgList = append ( orgList , v . Department )
var orgTwo modelshr . AdministrativeOrganization
orgTwo . GetCont ( map [ string ] interface { } { "`id`" : v . Department } , "`name`" )
orgNameList = append ( orgNameList , orgTwo . Name )
}
if ! publicmethod . IsInTrue [ int64 ] ( v . WorkShop , orgList ) {
orgList = append ( orgList , v . WorkShop )
var orgTree modelshr . AdministrativeOrganization
orgTree . GetCont ( map [ string ] interface { } { "`id`" : v . WorkShop } , "`name`" )
orgNameList = append ( orgNameList , orgTree . Name )
}
if ! publicmethod . IsInTrue [ int64 ] ( v . WorkshopSection , orgList ) {
orgList = append ( orgList , v . WorkshopSection )
var orgTree modelshr . AdministrativeOrganization
orgTree . GetCont ( map [ string ] interface { } { "`id`" : v . WorkshopSection } , "`name`" )
orgNameList = append ( orgNameList , orgTree . Name )
}
fmt . Println ( orgNameList )
fmt . Println ( orgList )
fmt . Println ( v . WorkshopSection )
if len ( orgNameList ) > 0 {
allOrgName := strings . Join ( orgNameList , " / " )
if v . Position != 0 {
var postCont modelshr . Position
postCont . GetCont ( map [ string ] interface { } { "`id`" : v . Position } , "`name`" )
if v . GradePositions != 0 {
allOrgName = fmt . Sprintf ( "%v %v级%v" , allOrgName , v . GradePositions , postCont . Name )
} else {
allOrgName = fmt . Sprintf ( "%v %v" , allOrgName , postCont . Name )
}
}
if v . AssignType == 1 {
allOrgName = fmt . Sprintf ( "%v(主职)" , allOrgName )
postLog = append ( postLog , allOrgName )
} else {
allOrgName := fmt . Sprintf ( "%v(兼职)" , allOrgName )
postLog = append ( postLog , allOrgName )
}
}
}
return
}
/ *
*
@ 作者 : 秦东
@ -152,3 +246,212 @@ func GetUserPower(appType string, postId int64, roleList []string) (menuPoint, o
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2023 - 11 - 0 8 16 : 37 : 43
@ 功能 : 统计行政组织下人员年龄比例
@ 参数
#
@ 返回值
#
@ 方法原型
#
* /
func ( a * ApiMethod ) StatisticalAgeRatio ( c * gin . Context ) {
var requestData publicmethod . PublicId
err := c . ShouldBindJSON ( & requestData )
if err != nil {
publicmethod . Result ( 100 , err , c )
return
}
if requestData . Id == "" {
requestData . Id = "309"
}
orgId , _ := strconv . ParseInt ( requestData . Id , 10 , 64 )
var sunOrg publicmethod . GetOrgAllParent
sunOrg . GetOrgSonAllId ( orgId )
sunOrg . Id = append ( sunOrg . Id , orgId )
var idCard [ ] string
err = overall . CONSTANT_DB_HR . Model ( & modelshr . ManCont { } ) . Select ( "COALESCE(`idcardno`,'')" ) . Where ( "`admin_org` IN ? AND emp_type BETWEEN ? AND ?" , sunOrg . Id , 1 , 10 ) . Find ( & idCard ) . Error
if err != nil && len ( idCard ) < 1 {
publicmethod . Result ( 107 , err , c )
return
}
var ageAry [ ] int
// jisuan
for i := 0 ; i < len ( idCard ) ; i ++ {
if idCard [ i ] != "" {
var myAge publicmethod . BirthdayAge
myAge . GetAgeByBirthday ( idCard [ i ] )
// if publicmethod.IsInTrue[int](myAge.Age,ageAry){}
ageAry = append ( ageAry , myAge . Age )
}
}
if len ( ageAry ) < 1 {
publicmethod . Result ( 107 , err , c )
return
}
//根据维度序号排序
sort . Slice ( ageAry , func ( i , j int ) bool {
return ageAry [ i ] < ageAry [ j ]
} )
maxAge := ageAry [ len ( ageAry ) - 1 ]
// maxAge = 42
ageNumberList := publicmethod . StatisticalDuplication [ int ] ( ageAry )
ageMap := make ( map [ int ] int )
if len ( ageNumberList ) > 0 {
for i , v := range ageNumberList {
if i <= maxAge && i <= 20 {
if _ , isOk := ageMap [ 20 ] ; isOk {
ageMap [ 20 ] = ageMap [ 20 ] + v
} else {
ageMap [ 20 ] = v
}
}
if i <= maxAge && i <= 25 && i > 20 {
if _ , isOk := ageMap [ 25 ] ; isOk {
ageMap [ 25 ] = ageMap [ 25 ] + v
} else {
ageMap [ 25 ] = v
}
}
if i <= maxAge && i <= 30 && i > 25 {
if _ , isOk := ageMap [ 30 ] ; isOk {
ageMap [ 30 ] = ageMap [ 30 ] + v
} else {
ageMap [ 30 ] = v
}
}
if i <= maxAge && i <= 35 && i > 30 {
if _ , isOk := ageMap [ 35 ] ; isOk {
ageMap [ 35 ] = ageMap [ 35 ] + v
} else {
ageMap [ 35 ] = v
}
}
if i <= maxAge && i <= 40 && i > 35 {
if _ , isOk := ageMap [ 40 ] ; isOk {
ageMap [ 40 ] = ageMap [ 40 ] + v
} else {
ageMap [ 40 ] = v
}
}
if i <= maxAge && i <= 45 && i > 40 {
if _ , isOk := ageMap [ 45 ] ; isOk {
ageMap [ 45 ] = ageMap [ 45 ] + v
} else {
ageMap [ 45 ] = v
}
}
if i <= maxAge && i <= 50 && i > 45 {
if _ , isOk := ageMap [ 50 ] ; isOk {
ageMap [ 50 ] = ageMap [ 50 ] + v
} else {
ageMap [ 50 ] = v
}
}
if i <= maxAge && i <= 55 && i > 50 {
if _ , isOk := ageMap [ 55 ] ; isOk {
ageMap [ 55 ] = ageMap [ 55 ] + v
} else {
ageMap [ 55 ] = v
}
}
if i <= maxAge && i <= 60 && i > 55 {
if _ , isOk := ageMap [ 60 ] ; isOk {
ageMap [ 60 ] = ageMap [ 60 ] + v
} else {
ageMap [ 60 ] = v
}
}
if i <= maxAge && i > 60 {
if _ , isOk := ageMap [ 70 ] ; isOk {
ageMap [ 70 ] = ageMap [ 70 ] + v
} else {
ageMap [ 70 ] = v
}
}
}
}
var sendAgeAry [ ] AgeType
if len ( ageMap ) > 0 {
if ageVal , isOk := ageMap [ 20 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "20岁以下"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 25 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "20岁-25岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 30 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "25岁-30岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 35 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "30岁-35岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 40 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "35岁-40岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 45 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "40岁-45岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 50 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "45岁-50岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 55 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "50岁-55岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 60 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "55岁-60岁(含)"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
if ageVal , isOk := ageMap [ 70 ] ; isOk {
var sendAgeCont AgeType
sendAgeCont . Name = "60岁以上"
sendAgeCont . Value = ageVal
sendAgeAry = append ( sendAgeAry , sendAgeCont )
}
}
sheng := publicmethod . MapOut [ string ] ( )
sheng [ "aaffg" ] = ageNumberList
sheng [ "ageAry" ] = ageAry
sheng [ "maxAge" ] = maxAge
sheng [ "ageMap" ] = ageMap
sheng [ "sendAgeAry" ] = sendAgeAry
publicmethod . Result ( 0 , sendAgeAry , c )
}