|
|
|
@ -3,6 +3,7 @@ package commonus |
|
|
|
//公共函数类
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"regexp" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
@ -626,3 +627,277 @@ func AdminClientIdentity() (isTrue bool, redisAdminInfo systemuser.RedisAdminInf |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//更具微信ID获取员工信息
|
|
|
|
func GetUesrContForWechatID(wechatId string) (isTrue bool, myCont PublicUserCont) { |
|
|
|
redisClient := redishandel.RunRedis() |
|
|
|
isTrue = false |
|
|
|
redisPrefix := "userInfo_" + global.GVA_CONFIG.RedisPrefix.PreFix + ":" + wechatId //redis KEY
|
|
|
|
redisCont, redisErr := redisClient.HashGetAll(redisPrefix) |
|
|
|
if redisErr == true { |
|
|
|
myCont.Number = redisCont["number"] |
|
|
|
departmentid, departmentidErr := strconv.ParseInt(redisCont["departmentid"], 10, 64) |
|
|
|
if departmentidErr == nil { |
|
|
|
myCont.DepartmentId = departmentid |
|
|
|
} |
|
|
|
workshop, workshopErr := strconv.ParseInt(redisCont["workshopid"], 10, 64) |
|
|
|
if workshopErr == nil { |
|
|
|
myCont.WorkshopId = workshop |
|
|
|
} |
|
|
|
postid, postidErr := strconv.ParseInt(redisCont["postid"], 10, 64) |
|
|
|
if postidErr == nil { |
|
|
|
myCont.PostId = postid |
|
|
|
} |
|
|
|
tema, temaErr := strconv.ParseInt(redisCont["tema"], 10, 64) |
|
|
|
if temaErr == nil { |
|
|
|
myCont.Tema = tema |
|
|
|
} |
|
|
|
temakey, temakeyErr := strconv.ParseInt(redisCont["key"], 10, 64) |
|
|
|
if temakeyErr == nil { |
|
|
|
myCont.Key = temakey |
|
|
|
} |
|
|
|
stateval, statevalErr := strconv.Atoi(redisCont["key"]) |
|
|
|
if statevalErr == nil { |
|
|
|
myCont.State = stateval |
|
|
|
} |
|
|
|
hireset, hiresetErr := strconv.Atoi(redisCont["hireset"]) |
|
|
|
if hiresetErr == nil { |
|
|
|
myCont.HireSet = hireset |
|
|
|
} |
|
|
|
groupset, groupsetErr := strconv.ParseInt(redisCont["group"], 10, 64) |
|
|
|
if groupsetErr == nil { |
|
|
|
myCont.Group = groupset |
|
|
|
} |
|
|
|
myCont.WechatId = wechatId |
|
|
|
myCont.Name = redisCont["name"] |
|
|
|
gender, genderErr := strconv.Atoi(redisCont["gender"]) |
|
|
|
if genderErr == nil { |
|
|
|
myCont.Gender = gender |
|
|
|
} |
|
|
|
age, ageErr := strconv.Atoi(redisCont["age"]) |
|
|
|
if ageErr == nil { |
|
|
|
myCont.Age = age |
|
|
|
} |
|
|
|
myCont.Tel = redisCont["tel"] |
|
|
|
category, categoryErr := strconv.Atoi(redisCont["category"]) |
|
|
|
if categoryErr == nil { |
|
|
|
myCont.Category = category |
|
|
|
} |
|
|
|
certificatestype, certificatestypeErr := strconv.Atoi(redisCont["certificatestype"]) |
|
|
|
if certificatestypeErr == nil { |
|
|
|
myCont.CertificatesType = certificatestype |
|
|
|
} |
|
|
|
myCont.CertificatesNum = redisCont["certificatesnum"] |
|
|
|
myCont.Birthday = redisCont["birthday"] |
|
|
|
myCont.EntryTime = redisCont["entrytime"] |
|
|
|
myCont.QuitTimeAttr = redisCont["quittimeattr"] |
|
|
|
myCont.Addrest = redisCont["addrest"] |
|
|
|
myCont.Icon = redisCont["icon"] |
|
|
|
myCont.NickName = redisCont["nickname"] |
|
|
|
myCont.DepartmentName = redisCont["departmentname"] |
|
|
|
myCont.WorkshopName = redisCont["workshopname"] |
|
|
|
myCont.PostName = redisCont["postname"] |
|
|
|
myCont.TemaName = redisCont["teamname"] |
|
|
|
isTrue = true |
|
|
|
// fmt.Printf("1===============>%v\n", myCont)
|
|
|
|
} else { |
|
|
|
|
|
|
|
var userCont testpage.PersonalDetails |
|
|
|
userErr := global.GVA_DB_Master.Model(&testpage.WorkMan{}).Select("worker_man.*", "worker_man_data.*").Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where("`qywx_key` = ? OR `wx_key` = ?", wechatId, wechatId).Find(&userCont).Error |
|
|
|
userInfo := MapOut() |
|
|
|
if userErr == nil { |
|
|
|
userInfo["number"] = userCont.Number |
|
|
|
userInfo["departmentid"] = userCont.DepartmentId |
|
|
|
userInfo["workshopid"] = userCont.WorkshopId |
|
|
|
userInfo["postid"] = userCont.PostId |
|
|
|
userInfo["tema"] = userCont.Tema |
|
|
|
userInfo["key"] = userCont.Key |
|
|
|
userInfo["state"] = userCont.State |
|
|
|
userInfo["hireset"] = userCont.HireSet |
|
|
|
userInfo["group"] = userCont.Group |
|
|
|
userInfo["wechatid"] = wechatId |
|
|
|
userInfo["name"] = userCont.Name |
|
|
|
userInfo["gender"] = userCont.Gender |
|
|
|
userInfo["age"] = userCont.Age |
|
|
|
userInfo["tel"] = userCont.Tel |
|
|
|
userInfo["category"] = userCont.Category |
|
|
|
userInfo["certificatestype"] = userCont.CertificatesType |
|
|
|
userInfo["certificatesnum"] = userCont.CertificatesNum |
|
|
|
userInfo["birthday"] = TimeStampToDate(userCont.Birthday, 6) |
|
|
|
userInfo["entrytime"] = TimeStampToDate(userCont.EntryTime, 6) |
|
|
|
userInfo["quittimeattr"] = TimeStampToDate(userCont.QuitTimeAttr, 6) |
|
|
|
userInfo["addrest"] = userCont.Addrest |
|
|
|
userInfo["icon"] = userCont.Icon |
|
|
|
userInfo["nickname"] = userCont.NickName |
|
|
|
isTrue = true |
|
|
|
myCont.Number = userCont.Number |
|
|
|
myCont.DepartmentId = userCont.DepartmentId |
|
|
|
|
|
|
|
bfIsTrue, bfInfo := GetBranchFactory(userCont.DepartmentId) |
|
|
|
if bfIsTrue == true { |
|
|
|
myCont.DepartmentName = bfInfo.Name |
|
|
|
userInfo["departmentname"] = bfInfo.Name |
|
|
|
} else { |
|
|
|
userInfo["departmentname"] = "" |
|
|
|
} |
|
|
|
myCont.WorkshopId = userCont.WorkshopId |
|
|
|
wsIsTrue, wsInfo := GetWorkShopSection(userCont.WorkshopId) |
|
|
|
if wsIsTrue == true { |
|
|
|
myCont.WorkshopName = wsInfo.Name |
|
|
|
userInfo["workshopname"] = wsInfo.Name |
|
|
|
} else { |
|
|
|
userInfo["workshopname"] = "" |
|
|
|
} |
|
|
|
myCont.PostId = userCont.PostId |
|
|
|
posErr, posCont := GetPosition(userCont.PostId) |
|
|
|
if posErr == true { |
|
|
|
myCont.PostName = posCont.Name |
|
|
|
userInfo["postname"] = posCont.Name |
|
|
|
} else { |
|
|
|
userInfo["postname"] = "" |
|
|
|
} |
|
|
|
myCont.Tema = userCont.Tema |
|
|
|
temErr, temCont := GetTeaming(userCont.Tema) |
|
|
|
if temErr == true { |
|
|
|
myCont.TemaName = temCont.Name |
|
|
|
userInfo["teamname"] = temCont.Name |
|
|
|
} else { |
|
|
|
userInfo["teamname"] = "" |
|
|
|
} |
|
|
|
myCont.Key = userCont.Key |
|
|
|
myCont.State = userCont.State |
|
|
|
myCont.HireSet = userCont.HireSet |
|
|
|
myCont.Group = userCont.Group |
|
|
|
myCont.WechatId = wechatId |
|
|
|
myCont.Name = userCont.Name |
|
|
|
myCont.Gender = userCont.Gender |
|
|
|
myCont.Age = userCont.Age |
|
|
|
myCont.Tel = userCont.Tel |
|
|
|
myCont.Category = userCont.Category |
|
|
|
myCont.CertificatesType = userCont.CertificatesType |
|
|
|
myCont.CertificatesNum = userCont.CertificatesNum |
|
|
|
myCont.Birthday = TimeStampToDate(userCont.Birthday, 6) |
|
|
|
myCont.EntryTime = TimeStampToDate(userCont.EntryTime, 6) |
|
|
|
myCont.QuitTimeAttr = TimeStampToDate(userCont.QuitTimeAttr, 6) |
|
|
|
myCont.Addrest = userCont.Addrest |
|
|
|
myCont.Icon = userCont.Icon |
|
|
|
myCont.NickName = userCont.NickName |
|
|
|
|
|
|
|
redisClient.SetRedisTime(604800) |
|
|
|
redisClient.HashMsetAdd(redisPrefix, userInfo) |
|
|
|
fmt.Printf("2===============>\n") |
|
|
|
} else { |
|
|
|
var userInfoStruct wechat.WechatUsers |
|
|
|
myErr := global.GVA_DB_WatchDate.Where("userid = ?", wechatId).First(&userInfoStruct).Error |
|
|
|
if myErr != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
groupContErr, groupCont := GetGroupInfo(userInfoStruct.MainDepartment) |
|
|
|
groupID := 1 |
|
|
|
if groupContErr == true { |
|
|
|
var groupMap []int |
|
|
|
jsonErr := json.Unmarshal([]byte(groupCont.Group), &groupMap) |
|
|
|
if jsonErr == nil { |
|
|
|
if len(groupMap) > 0 { |
|
|
|
for g_index, g_val := range groupMap { |
|
|
|
if g_index == 0 { |
|
|
|
groupID = g_val |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
isTrue = true |
|
|
|
tadyTime := time.Now().Unix() |
|
|
|
userInfo["number"] = userInfoStruct.UserNumber |
|
|
|
userInfo["departmentid"] = userInfoStruct.MainDepartment |
|
|
|
userInfo["workshopid"] = 0 |
|
|
|
userInfo["postid"] = 0 |
|
|
|
userInfo["tema"] = 0 |
|
|
|
userInfo["key"] = 0 |
|
|
|
userInfo["state"] = userInfoStruct.Status |
|
|
|
userInfo["hireset"] = 1 |
|
|
|
userInfo["group"] = groupID |
|
|
|
userInfo["wechatid"] = wechatId |
|
|
|
userInfo["name"] = userInfoStruct.Name |
|
|
|
userInfo["gender"] = userInfoStruct.Gender |
|
|
|
userInfo["age"] = 0 |
|
|
|
userInfo["tel"] = userInfoStruct.Mobile |
|
|
|
userInfo["category"] = 1 |
|
|
|
userInfo["certificatestype"] = 1 |
|
|
|
userInfo["certificatesnum"] = "" |
|
|
|
userInfo["birthday"] = TimeStampToDate(0, 6) |
|
|
|
userInfo["entrytime"] = TimeStampToDate(tadyTime, 6) |
|
|
|
userInfo["quittimeattr"] = TimeStampToDate(0, 6) |
|
|
|
userInfo["addrest"] = 0 |
|
|
|
userInfo["icon"] = userInfoStruct.Avatar |
|
|
|
userInfo["nickname"] = userInfoStruct.Name |
|
|
|
userInfo["departmentname"] = "" |
|
|
|
userInfo["workshopname"] = "" |
|
|
|
userInfo["postname"] = "" |
|
|
|
userInfo["teamname"] = "" |
|
|
|
|
|
|
|
myCont.Number = userInfoStruct.UserNumber |
|
|
|
myCont.DepartmentId = userInfoStruct.MainDepartment |
|
|
|
myCont.WorkshopId = 0 |
|
|
|
myCont.PostId = 0 |
|
|
|
myCont.Tema = 0 |
|
|
|
myCont.Key = 0 |
|
|
|
myCont.State = userInfoStruct.Status |
|
|
|
myCont.HireSet = 1 |
|
|
|
myCont.Group = 1 |
|
|
|
myCont.WechatId = wechatId |
|
|
|
myCont.Name = userInfoStruct.Name |
|
|
|
myCont.Gender = userInfoStruct.Gender |
|
|
|
myCont.Age = 1 |
|
|
|
myCont.Tel = userInfoStruct.Mobile |
|
|
|
myCont.Category = 1 |
|
|
|
myCont.CertificatesType = 1 |
|
|
|
myCont.CertificatesNum = "" |
|
|
|
myCont.Birthday = TimeStampToDate(0, 6) |
|
|
|
myCont.EntryTime = TimeStampToDate(tadyTime, 6) |
|
|
|
myCont.QuitTimeAttr = TimeStampToDate(0, 6) |
|
|
|
myCont.Addrest = "" |
|
|
|
myCont.Icon = userInfoStruct.Avatar |
|
|
|
myCont.NickName = userInfoStruct.Name |
|
|
|
|
|
|
|
redisClient.SetRedisTime(604800) |
|
|
|
redisClient.HashMsetAdd(redisPrefix, userInfo) |
|
|
|
fmt.Printf("3===============>\n") |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//获得分厂名称
|
|
|
|
func GetBranchFactory(id int64) (isTrue bool, ContInfo testpage.BranchFactory) { |
|
|
|
isTrue = false |
|
|
|
err := global.GVA_DB_Master.Where("bf_id = ?", id).First(&ContInfo).Error |
|
|
|
if err == nil { |
|
|
|
isTrue = true |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//获取职务信息
|
|
|
|
func GetPosition(id int64) (isTrue bool, content testpage.Position) { |
|
|
|
isTrue = false |
|
|
|
err := global.GVA_DB_Master.Where("ps_id = ?", id).First(&content).Error |
|
|
|
if err == nil { |
|
|
|
isTrue = true |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//获取班组信息
|
|
|
|
func GetTeaming(id int64) (isTrue bool, content testpage.Teaming) { |
|
|
|
isTrue = false |
|
|
|
err := global.GVA_DB_Master.Where("tm_id = ?", id).First(&content).Error |
|
|
|
if err == nil { |
|
|
|
isTrue = true |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//
|
|
|
|
|