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.
1357 lines
46 KiB
1357 lines
46 KiB
package dockingorganization
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"hr_server/models"
|
|
"hr_server/overall"
|
|
"hr_server/overall/overallhandle"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// 接口实验
|
|
func (d *DockingJinDieApi) DockKingdeeApi(c *gin.Context) {
|
|
// GetOrgType()
|
|
// JobClass()
|
|
// DutiesContrast()
|
|
OrgAdmin()
|
|
// Position()
|
|
// xingzheng()
|
|
outMap := overallhandle.MapOut()
|
|
overallhandle.Result(0, outMap, c)
|
|
}
|
|
|
|
func xingzheng() {
|
|
var orgList []models.AdministrativeOrganization
|
|
// orgList.GetCont(map[string]interface{}{"ispower": 1})
|
|
overall.CONSTANT_DB_HR.Where("ispower = 1").Find(&orgList)
|
|
var id []string
|
|
var num []string
|
|
for _, v := range orgList {
|
|
|
|
id = append(id, strconv.FormatInt(v.Id, 10))
|
|
num = append(num, v.Number)
|
|
}
|
|
fmt.Println(strings.Join(id, ","))
|
|
fmt.Println(strings.Join(num, ","))
|
|
}
|
|
|
|
// 行政组织类型
|
|
func GetOrgType() {
|
|
var orgContAry []orgClass
|
|
sendUrl := fmt.Sprintf("%v/person/adminUnitType", overall.DockingKingdeeUrl)
|
|
respBody, err := GetUrl(sendUrl)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "未能获取到行政组织类型!", err)
|
|
return
|
|
}
|
|
err = json.Unmarshal(respBody, &orgContAry)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "行政组织类型映射错误!", err)
|
|
return
|
|
}
|
|
overallhandle.WriteLog("i", "行政组织类型映射成功!", orgContAry)
|
|
if len(orgContAry) < 0 {
|
|
overallhandle.WriteLog("e", "未能获取到行政组织类型!", orgContAry)
|
|
return
|
|
}
|
|
|
|
fmt.Printf("err---------------------->%v\n", err)
|
|
var kingDeeIdAry []string
|
|
//进行行政组织类别对照
|
|
for _, v := range orgContAry {
|
|
if overallhandle.StringIsInMap(v.Id, kingDeeIdAry) == false {
|
|
kingDeeIdAry = append(kingDeeIdAry, v.Id)
|
|
}
|
|
//判断该项是否存在
|
|
var orgCont models.AdministrativeOrganizationType
|
|
orgErr := orgCont.GetCont(map[string]interface{}{"kingdeeid": v.Id}, "id", "name", "state")
|
|
if orgErr == nil {
|
|
//判断是否编辑
|
|
if v.Name != orgCont.Name {
|
|
editOrgErr := orgCont.EiteCont(map[string]interface{}{"id": orgCont.Id}, map[string]interface{}{"name": v.Name, "state": 1})
|
|
if editOrgErr == nil {
|
|
overallhandle.WriteLog("edit", "行政组织类型更新成功!", editOrgErr, v)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "行政组织类型更新失败!", editOrgErr, v)
|
|
}
|
|
} else {
|
|
if orgCont.State != 1 {
|
|
editOrgErr := orgCont.EiteCont(map[string]interface{}{"id": orgCont.Id}, map[string]interface{}{"state": 1})
|
|
if editOrgErr == nil {
|
|
overallhandle.WriteLog("edit", "行政组织类型更新成功!state", editOrgErr, v)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "行政组织类型更新失败!state", editOrgErr, v)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
orgCont.Name = v.Name
|
|
orgCont.State = 1
|
|
orgCont.Time = time.Now().Unix()
|
|
orgCont.KingdeeId = v.Id
|
|
addOrgErr := overall.CONSTANT_DB_HR.Create(&orgCont).Error
|
|
if addOrgErr == nil {
|
|
overallhandle.WriteLog("add", "行政组织类型写入成功!", addOrgErr, orgCont)
|
|
} else {
|
|
overallhandle.WriteLog("add", "行政组织类型写入失败!", addOrgErr, orgCont)
|
|
}
|
|
}
|
|
}
|
|
var orgAll []models.AdministrativeOrganizationType
|
|
allErr := overall.CONSTANT_DB_HR.Where("`state` = 1").Find(&orgAll).Error
|
|
if allErr == nil && len(orgAll) > 0 {
|
|
var eidtId []string
|
|
for _, av := range orgAll {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, kingDeeIdAry) == false {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, eidtId) == false {
|
|
eidtId = append(eidtId, av.KingdeeId)
|
|
}
|
|
}
|
|
}
|
|
if len(eidtId) > 0 && len(orgAll) > len(eidtId) {
|
|
orgContEditErr := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganizationType{}).Where("`kingdeeid` IN ?", eidtId).Updates(map[string]interface{}{"state": 2}).Error
|
|
if orgContEditErr == nil {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得行政组织类型成功!", orgContEditErr, eidtId)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得行政组织类型失败!", orgContEditErr, eidtId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 职务类型
|
|
func JobClass() {
|
|
// fmt.Printf("1")
|
|
var jobClassInfo []jobClassType
|
|
sendUrl := fmt.Sprintf("%v/person/ptype", overall.DockingKingdeeUrl)
|
|
respBody, err := GetUrl(sendUrl)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "未能获取到职务类型!", err)
|
|
return
|
|
}
|
|
err = json.Unmarshal(respBody, &jobClassInfo)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "职务类型映射错误!", err)
|
|
return
|
|
}
|
|
overallhandle.WriteLog("i", "职务类型映射成功!", jobClassInfo)
|
|
if len(jobClassInfo) < 0 {
|
|
overallhandle.WriteLog("e", "未能获取到职务类型!", jobClassInfo)
|
|
return
|
|
}
|
|
var kingDeeIdAry []string
|
|
//进行职务类型对照
|
|
for _, v := range jobClassInfo {
|
|
if overallhandle.StringIsInMap(v.Id, kingDeeIdAry) == false {
|
|
kingDeeIdAry = append(kingDeeIdAry, v.Id)
|
|
}
|
|
//判断该项是否存在
|
|
var jobClassCont models.JobClass
|
|
jobClassErr := jobClassCont.GetCont(map[string]interface{}{"kingdeeid": v.Id})
|
|
if jobClassErr == nil {
|
|
//存在判断是否要进行更新
|
|
if v.Name != jobClassCont.Name {
|
|
editOrgErr := jobClassCont.EiteJobClassCont(map[string]interface{}{"id": jobClassCont.Id}, map[string]interface{}{"name": v.Name, "state": 1})
|
|
if editOrgErr == nil {
|
|
overallhandle.WriteLog("edit", "职务类型更新成功!", editOrgErr, v)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "职务类型更新失败!", editOrgErr, v)
|
|
}
|
|
} else {
|
|
if jobClassCont.State != 1 {
|
|
editOrgErr := jobClassCont.EiteJobClassCont(map[string]interface{}{"id": jobClassCont.Id}, map[string]interface{}{"state": 1})
|
|
if editOrgErr == nil {
|
|
overallhandle.WriteLog("edit", "职务类型更新成功!state", editOrgErr, v)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "职务类型更新失败!state", editOrgErr, v)
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
//不存在,进行新增
|
|
jobClassCont.Name = v.Name
|
|
jobClassCont.KingdeeNum = v.Fnumber
|
|
jobClassCont.KingdeeId = v.Id
|
|
jobClassCont.State = 1
|
|
jobClassCont.Time = time.Now().Unix()
|
|
addErr := overall.CONSTANT_DB_HR.Create(&jobClassCont).Error
|
|
if addErr == nil {
|
|
overallhandle.WriteLog("add", "职务类型写入成功!", addErr, jobClassCont)
|
|
} else {
|
|
overallhandle.WriteLog("add", "职务类型写入失败!", addErr, jobClassCont)
|
|
}
|
|
}
|
|
}
|
|
|
|
var jobClassAll []models.JobClass
|
|
allErr := overall.CONSTANT_DB_HR.Where("`state` = 1").Find(&jobClassAll).Error
|
|
if allErr == nil && len(jobClassAll) > 0 {
|
|
var eidtId []string
|
|
for _, av := range jobClassAll {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, kingDeeIdAry) == false {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, eidtId) == false {
|
|
eidtId = append(eidtId, av.KingdeeId)
|
|
}
|
|
}
|
|
}
|
|
if len(eidtId) > 0 && len(jobClassAll) > len(eidtId) {
|
|
jobClassContEditErr := overall.CONSTANT_DB_HR.Model(&models.JobClass{}).Where("`kingdeeid` IN ?", eidtId).Updates(map[string]interface{}{"state": 2}).Error
|
|
if jobClassContEditErr == nil {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得职务类型成功!", jobClassContEditErr, eidtId)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得职务类型失败!", jobClassContEditErr, eidtId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 职务
|
|
func DutiesContrast() {
|
|
var jobInfo []jobContDuck
|
|
sendUrl := fmt.Sprintf("%v/person/job", overall.DockingKingdeeUrl)
|
|
respBody, err := GetUrl(sendUrl)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "未能获取到职务!", err)
|
|
return
|
|
}
|
|
err = json.Unmarshal(respBody, &jobInfo)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "职务映射错误!", err)
|
|
return
|
|
}
|
|
overallhandle.WriteLog("i", "职务映射成功!", jobInfo)
|
|
if len(jobInfo) < 0 {
|
|
overallhandle.WriteLog("e", "未能获取到职务!", jobInfo)
|
|
return
|
|
}
|
|
// fmt.Printf("jobInfo:%v\n", jobInfo)
|
|
var kingDeeIdAry []string
|
|
//进行职务对照
|
|
for _, v := range jobInfo {
|
|
if overallhandle.StringIsInMap(v.Id, kingDeeIdAry) == false {
|
|
kingDeeIdAry = append(kingDeeIdAry, v.Id)
|
|
}
|
|
//判断该项是否存在
|
|
var dutiesCont models.Duties
|
|
dutiesErr := dutiesCont.GetCont(map[string]interface{}{"kingdeeid": v.Id}, "`id`", "`name`", "`number`", "`state`", "`job_type`")
|
|
if dutiesErr == nil {
|
|
//存在,进行更新
|
|
//获取职务Id
|
|
var jobClassInfo models.JobClass
|
|
jobClassInfo.GetCont(map[string]interface{}{"kingdeeid": v.Fjobtype}, "`id`")
|
|
var editOrgErr error
|
|
isCaoZuo := false
|
|
if v.Name != dutiesCont.Name {
|
|
if dutiesCont.JobType != jobClassInfo.Id {
|
|
editOrgErr = dutiesCont.EiteCont(map[string]interface{}{"id": dutiesCont.Id}, map[string]interface{}{"name": v.Name, "state": 1, "job_type": jobClassInfo.Id, "`number`": v.Fnumber})
|
|
isCaoZuo = true
|
|
} else {
|
|
editOrgErr = dutiesCont.EiteCont(map[string]interface{}{"id": dutiesCont.Id}, map[string]interface{}{"name": v.Name, "state": 1, "`number`": v.Fnumber})
|
|
isCaoZuo = true
|
|
}
|
|
} else {
|
|
if dutiesCont.State != 1 {
|
|
if dutiesCont.JobType != jobClassInfo.Id {
|
|
editOrgErr = dutiesCont.EiteCont(map[string]interface{}{"id": dutiesCont.Id}, map[string]interface{}{"state": 1, "job_type": jobClassInfo.Id, "`number`": v.Fnumber})
|
|
isCaoZuo = true
|
|
} else {
|
|
editOrgErr = dutiesCont.EiteCont(map[string]interface{}{"id": dutiesCont.Id}, map[string]interface{}{"state": 1, "`number`": v.Fnumber})
|
|
isCaoZuo = true
|
|
}
|
|
}
|
|
}
|
|
if v.Fnumber != dutiesCont.Number {
|
|
editOrgErr = dutiesCont.EiteCont(map[string]interface{}{"id": dutiesCont.Id}, map[string]interface{}{"`number`": v.Fnumber})
|
|
isCaoZuo = true
|
|
}
|
|
if isCaoZuo == true {
|
|
if editOrgErr == nil {
|
|
overallhandle.WriteLog("edit", "职务更新成功!", editOrgErr, v)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "职务更新失败!", editOrgErr, v)
|
|
}
|
|
}
|
|
} else {
|
|
//不存在,进行新增
|
|
//获取旧对照表数据
|
|
var oldDutiesInfo models.Duties
|
|
oldDutErr := overall.CONSTANT_DB_HR_Jin.Model(&models.Duties{}).Select("weight,number").Where("`name` = ?", v.Name).First(&oldDutiesInfo).Error
|
|
//获取职务Id
|
|
var jobClassInfo models.JobClass
|
|
jobClassErr := jobClassInfo.GetCont(map[string]interface{}{"kingdeeid": v.Fjobtype}, "`id`")
|
|
var dutiesInfo models.Duties
|
|
dutiesInfo.Name = v.Name
|
|
if jobClassErr == nil {
|
|
dutiesInfo.JobType = jobClassInfo.Id
|
|
}
|
|
if oldDutErr == nil {
|
|
dutiesInfo.Weight = oldDutiesInfo.Weight
|
|
dutiesInfo.Number = oldDutiesInfo.Number
|
|
} else {
|
|
dutiesInfo.Weight = 0
|
|
dutiesInfo.Number = ""
|
|
}
|
|
dutiesInfo.Time = time.Now().Unix()
|
|
dutiesInfo.State = 1
|
|
dutiesInfo.KingdeeId = v.Id
|
|
dutiesInfo.KingdeeNum = v.Fnumber
|
|
addErr := overall.CONSTANT_DB_HR.Create(&dutiesInfo).Error
|
|
if addErr == nil {
|
|
overallhandle.WriteLog("add", "职务写入成功!", addErr, dutiesInfo)
|
|
} else {
|
|
overallhandle.WriteLog("add", "职务写入失败!", addErr, dutiesInfo)
|
|
}
|
|
}
|
|
}
|
|
|
|
var dutiesAll []models.Duties
|
|
allErr := overall.CONSTANT_DB_HR.Where("`state` = 1").Find(&dutiesAll).Error
|
|
if allErr == nil && len(dutiesAll) > 0 {
|
|
var eidtId []string
|
|
for _, av := range dutiesAll {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, kingDeeIdAry) == false {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, eidtId) == false {
|
|
eidtId = append(eidtId, av.KingdeeId)
|
|
}
|
|
}
|
|
}
|
|
if len(eidtId) > 0 && len(dutiesAll) > len(eidtId) {
|
|
dutiesContEditErr := overall.CONSTANT_DB_HR.Model(&models.Duties{}).Where("`kingdeeid` IN ?", eidtId).Updates(map[string]interface{}{"state": 2}).Error
|
|
if dutiesContEditErr == nil {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得职务成功!", dutiesContEditErr, eidtId)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得职务失败!", dutiesContEditErr, eidtId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 行政组织
|
|
func OrgAdmin() {
|
|
var orgInfo []orgAdminType
|
|
sendUrl := fmt.Sprintf("%v/person/adminunit", overall.DockingKingdeeUrl)
|
|
respBody, err := GetUrl(sendUrl)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "未能获取到行政组织!", err)
|
|
return
|
|
}
|
|
err = json.Unmarshal(respBody, &orgInfo)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "行政组织映射错误!", err)
|
|
return
|
|
}
|
|
overallhandle.WriteLog("i", "行政组织映射完成!", orgInfo)
|
|
if len(orgInfo) < 0 {
|
|
overallhandle.WriteLog("e", "未能获取到行政组织!", orgInfo)
|
|
return
|
|
}
|
|
var kingDeeIdAry []string
|
|
|
|
//进行职务对照
|
|
for _, v := range orgInfo {
|
|
if overallhandle.StringIsInMap(v.Id, kingDeeIdAry) == false {
|
|
kingDeeIdAry = append(kingDeeIdAry, v.Id)
|
|
}
|
|
//判断该项是否存在
|
|
var orgInfoContCont models.AdministrativeOrganization
|
|
orgInfoContErr := orgInfoContCont.GetCont(map[string]interface{}{"kingdeeid": v.Id})
|
|
if orgInfoContErr == nil {
|
|
//存在,进行更新
|
|
isEdit := false
|
|
saveData := overallhandle.MapOut()
|
|
if v.Name != orgInfoContCont.Name {
|
|
saveData["name"] = v.Name
|
|
isEdit = true
|
|
}
|
|
if v.Abbreviation != orgInfoContCont.Abbreviation {
|
|
saveData["abbreviation"] = v.Abbreviation
|
|
isEdit = true
|
|
}
|
|
if v.Number != orgInfoContCont.Number {
|
|
saveData["number"] = v.Number
|
|
isEdit = true
|
|
}
|
|
if orgInfoContCont.State != 1 {
|
|
saveData["state"] = 1
|
|
isEdit = true
|
|
}
|
|
//判断行政组织类型是否需要改变
|
|
var judgeOrgType models.AdministrativeOrganizationType
|
|
judgeOrgTypeErr := judgeOrgType.GetCont(map[string]interface{}{"id": orgInfoContCont.OrganizationType}, "`id`", "`kingdeeid`")
|
|
if judgeOrgTypeErr == nil {
|
|
if v.GovClass != judgeOrgType.KingdeeId {
|
|
var orgTypeNewType models.AdministrativeOrganizationType
|
|
orgTypeNewTypeErr := orgTypeNewType.GetCont(map[string]interface{}{"kingdeeid": v.GovClass}, "id")
|
|
if orgTypeNewTypeErr == nil {
|
|
saveData["organization_type"] = orgTypeNewType.Id
|
|
isEdit = true
|
|
}
|
|
}
|
|
}
|
|
if isEdit == true {
|
|
saveData["time"] = time.Now().Unix()
|
|
editErr := orgInfoContCont.EiteCont(map[string]interface{}{"id": orgInfoContCont.Id}, saveData)
|
|
if editErr == nil {
|
|
overallhandle.WriteLog("edit", "行政组织更新成功!", editErr, v, saveData)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "行政组织更新失败!", editErr, v, saveData)
|
|
}
|
|
}
|
|
} else {
|
|
//不存在进行添加
|
|
var orgCont models.AdministrativeOrganization
|
|
orgCont.KingdeeId = v.Id
|
|
orgCont.Number = v.Number
|
|
orgCont.Name = v.Name
|
|
orgCont.Abbreviation = v.Abbreviation
|
|
orgCont.State = 1
|
|
orgCont.Time = time.Now().Unix()
|
|
//获取行政组织类型
|
|
var orgType models.AdministrativeOrganizationType
|
|
orgTypeErr := orgType.GetCont(map[string]interface{}{"kingdeeid": v.GovClass}, "id")
|
|
if orgTypeErr == nil {
|
|
orgCont.OrganizationType = orgType.Id
|
|
}
|
|
//获取知行学院及企业微信对照码
|
|
var orgOldCont models.AdministrativeOrganization
|
|
orgOldErr := overall.CONSTANT_DB_HR_Jin.Model(&models.AdministrativeOrganization{}).Select("wechat_organization_id,schoole").Where("`number` = ?", v.Number).First(&orgOldCont).Error
|
|
if orgOldErr == nil {
|
|
orgCont.WechatOrganizationId = orgOldCont.WechatOrganizationId
|
|
orgCont.Schoole = orgOldCont.Schoole
|
|
}
|
|
if overallhandle.StringIsInMap(v.Number, OrgNumberDuiZhao) {
|
|
orgCont.IsPower = 1
|
|
}
|
|
// orgCont.IsPower
|
|
addErr := overall.CONSTANT_DB_HR.Create(&orgCont).Error
|
|
if addErr == nil {
|
|
overallhandle.WriteLog("add", "行政组织写入成功!", addErr, orgCont)
|
|
} else {
|
|
overallhandle.WriteLog("add", "行政组织写入失败!", addErr, orgCont)
|
|
}
|
|
}
|
|
|
|
}
|
|
//职务上级校正
|
|
for _, cv := range orgInfo {
|
|
var parentContCorre models.AdministrativeOrganization
|
|
parentErr := parentContCorre.GetCont(map[string]interface{}{"kingdeeid": cv.Id}, "`id`", "`superior`")
|
|
if parentErr == nil {
|
|
if cv.Superior != "" {
|
|
var orgCorrePrent models.AdministrativeOrganization
|
|
orgCorrePrentErr := orgCorrePrent.GetCont(map[string]interface{}{"kingdeeid": cv.Superior}, "id")
|
|
if orgCorrePrentErr == nil {
|
|
if parentContCorre.Superior != orgCorrePrent.Id {
|
|
saveData := overallhandle.MapOut()
|
|
saveData["superior"] = orgCorrePrent.Id
|
|
saveData["time"] = time.Now().Unix()
|
|
parentIngErr := parentContCorre.EiteCont(map[string]interface{}{"id": parentContCorre.Id}, saveData)
|
|
overallhandle.WriteLog("add", "行政组织写入成功!", parentIngErr, saveData)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
//关闭已经弃用得行政组织
|
|
var orgAdminAll []models.AdministrativeOrganization
|
|
allErr := overall.CONSTANT_DB_HR.Where("`state` = 1").Find(&orgAdminAll).Error
|
|
if allErr == nil && len(orgAdminAll) > 0 {
|
|
var eidtId []string
|
|
for _, av := range orgAdminAll {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, kingDeeIdAry) == false {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, eidtId) == false {
|
|
eidtId = append(eidtId, av.KingdeeId)
|
|
}
|
|
}
|
|
}
|
|
if len(eidtId) > 0 && len(orgAdminAll) > len(eidtId) {
|
|
orgAdminEditErr := overall.CONSTANT_DB_HR.Model(&models.AdministrativeOrganization{}).Where("`kingdeeid` IN ?", eidtId).Updates(map[string]interface{}{"state": 2}).Error
|
|
if orgAdminEditErr == nil {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得行政组织成功!", orgAdminEditErr, eidtId)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得行政组织失败!", orgAdminEditErr, eidtId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 职位
|
|
func Position() {
|
|
var orgInfo []positionType
|
|
sendUrl := fmt.Sprintf("%v/person/position", overall.DockingKingdeeUrl)
|
|
respBody, err := GetUrl(sendUrl)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "未能获取到职位!", err)
|
|
return
|
|
}
|
|
err = json.Unmarshal(respBody, &orgInfo)
|
|
if err != nil {
|
|
overallhandle.WriteLog("e", "职位映射错误!", err)
|
|
return
|
|
}
|
|
overallhandle.WriteLog("i", "职位映射完成!", orgInfo)
|
|
if len(orgInfo) < 0 {
|
|
overallhandle.WriteLog("e", "金蝶对照数据!", orgInfo)
|
|
return
|
|
}
|
|
|
|
var kingDeeIdAry []string
|
|
//批量写入
|
|
var batchPosition []models.Position
|
|
//进行职位对照
|
|
for _, v := range orgInfo {
|
|
if overallhandle.StringIsInMap(v.Id, kingDeeIdAry) == false {
|
|
kingDeeIdAry = append(kingDeeIdAry, v.Id)
|
|
}
|
|
// strconv.Atoi(v.FIsRespPosition)
|
|
personInt64, _ := strconv.Atoi(v.FIsRespPosition)
|
|
|
|
//获取职务信息
|
|
var zhiwuCont models.Duties
|
|
zhiwuCont.GetCont(map[string]interface{}{"kingdeeid": v.FJobID}, "id")
|
|
|
|
//判断该项是否存在
|
|
var positCont models.Position
|
|
positContErr := positCont.GetCont(map[string]interface{}{"kingdeeid": v.Id})
|
|
if positContErr == nil {
|
|
//存在,进行更新
|
|
isEdit := false
|
|
saveData := overallhandle.MapOut()
|
|
if v.Name != positCont.Name {
|
|
saveData["name"] = v.Name
|
|
isEdit = true
|
|
}
|
|
if positCont.State != 1 {
|
|
saveData["state"] = 1
|
|
isEdit = true
|
|
}
|
|
|
|
if v.Fnumber != positCont.Number {
|
|
saveData["number"] = v.Fnumber
|
|
isEdit = true
|
|
}
|
|
if zhiwuCont.Id != positCont.Duties {
|
|
saveData["duties"] = zhiwuCont.Id
|
|
isEdit = true
|
|
}
|
|
//获取行政组织
|
|
var orgCont models.AdministrativeOrganization
|
|
orgContErr := orgCont.GetCont(map[string]interface{}{"kingdeeid": v.FAdminOrgUnitID}, "id", "superior")
|
|
if orgContErr == nil {
|
|
if orgCont.Id != positCont.AdministrativeOrganization {
|
|
saveData["administrative_organization"] = orgCont.Id
|
|
saveData["department"] = overallhandle.GetGroupOrDepartPower(orgCont.Superior, 1)
|
|
isEdit = true
|
|
}
|
|
}
|
|
|
|
if isEdit == true {
|
|
saveData["time"] = time.Now().Unix()
|
|
editErr := positCont.EiteCont(map[string]interface{}{"id": positCont.Id}, saveData)
|
|
if editErr == nil {
|
|
overallhandle.WriteLog("edit", "职位更新成功!", editErr, v, saveData)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "职位更新失败!", editErr, v, saveData)
|
|
}
|
|
}
|
|
} else {
|
|
//不存在,新增
|
|
positCont.Number = v.Fnumber
|
|
positCont.Name = v.Name
|
|
positCont.KingdeeId = v.Id
|
|
positCont.Time = time.Now().Unix()
|
|
positCont.State = 1
|
|
//获取行政组织
|
|
var orgCont models.AdministrativeOrganization
|
|
orgContErr := orgCont.GetCont(map[string]interface{}{"kingdeeid": v.FAdminOrgUnitID}, "id", "superior")
|
|
if orgContErr == nil {
|
|
positCont.AdministrativeOrganization = orgCont.Id
|
|
positCont.Department = overallhandle.GetGroupOrDepartPower(orgCont.Superior, 1)
|
|
}
|
|
//获取知行学院及企业微信对照码
|
|
var orgOldCont models.Position
|
|
orgOldErr := overall.CONSTANT_DB_HR_Jin.Model(&models.Position{}).Select("school,person_in_charge").Where("`number` = ?", v.Fnumber).First(&orgOldCont).Error
|
|
positCont.PersonInCharge = personInt64
|
|
if orgOldErr == nil {
|
|
if personInt64 != orgOldCont.PersonInCharge {
|
|
if orgOldCont.PersonInCharge == 1 {
|
|
positCont.PersonInCharge = orgOldCont.PersonInCharge
|
|
}
|
|
}
|
|
positCont.School = orgOldCont.School
|
|
}
|
|
positCont.Duties = zhiwuCont.Id
|
|
|
|
//判断该部门下此职位是否已经存在
|
|
var posistInfo models.Position
|
|
overall.CONSTANT_DB_HR.Where("`name` = ? AND `department` = ?", v.Name, orgCont.Superior).First(&posistInfo)
|
|
if posistInfo.Id != 0 {
|
|
saveData := overallhandle.MapOut()
|
|
saveData["`number`"] = v.Fnumber
|
|
saveData["`duties`"] = zhiwuCont.Id
|
|
saveData["`time`"] = time.Now().Unix()
|
|
saveData["`administrative_organization`"] = orgCont.Id
|
|
// saveData["`superior`"] = orgCont.Superior
|
|
saveData["`person_in_charge`"] = positCont.PersonInCharge
|
|
saveData["`department`"] = orgCont.Superior
|
|
saveData["`kingdeeid`"] = v.FAdminOrgUnitID
|
|
|
|
var savePostInfo models.Position
|
|
savePostInfo.EiteCont(map[string]interface{}{"`id`": posistInfo.Id}, saveData)
|
|
|
|
} else {
|
|
batchPosition = append(batchPosition, positCont)
|
|
}
|
|
|
|
// if v.Id == "QBsfJ1fbSKW+3q6eOJltjHSuYS4=" {
|
|
// fmt.Printf("positCont---->%v\n", positCont)
|
|
// return
|
|
// }
|
|
|
|
if len(batchPosition)%100 == 0 {
|
|
synPro.Add(1)
|
|
go writePositis(batchPosition)
|
|
var batchPositionNew []models.Position
|
|
batchPosition = batchPositionNew
|
|
|
|
// addErr := overall.CONSTANT_DB_HR.Create(&batchPosition).Error
|
|
// if addErr == nil {
|
|
// var batchPositionNew []models.Position
|
|
// batchPosition = batchPositionNew
|
|
// overallhandle.WriteLog("add", "职位写入成功!", addErr, batchPosition)
|
|
// } else {
|
|
// overallhandle.WriteLog("add", "职位写入失败!", addErr, batchPosition)
|
|
// }
|
|
}
|
|
|
|
}
|
|
}
|
|
if len(batchPosition) > 0 {
|
|
synPro.Add(1)
|
|
go writePositis(batchPosition)
|
|
}
|
|
synPro.Wait()
|
|
//职位上级校正
|
|
var calibPositList []positionType
|
|
for _, cv := range orgInfo {
|
|
calibPositList = append(calibPositList, cv)
|
|
if len(calibPositList)%100 == 0 {
|
|
synPro.Add(1)
|
|
go calibrationPosition(calibPositList)
|
|
var calibPositListNew []positionType
|
|
calibPositList = calibPositListNew
|
|
}
|
|
}
|
|
|
|
if len(calibPositList) > 0 {
|
|
synPro.Add(1)
|
|
go calibrationPosition(calibPositList)
|
|
}
|
|
synPro.Wait()
|
|
|
|
//关闭已经弃用得行政组织
|
|
var orgAdminAll []models.Position
|
|
allErr := overall.CONSTANT_DB_HR.Where("`state` = 1").Find(&orgAdminAll).Error
|
|
if allErr == nil && len(orgAdminAll) > 0 {
|
|
var eidtId []string
|
|
for _, av := range orgAdminAll {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, kingDeeIdAry) == false {
|
|
if overallhandle.StringIsInMap(av.KingdeeId, eidtId) == false {
|
|
eidtId = append(eidtId, av.KingdeeId)
|
|
}
|
|
}
|
|
}
|
|
if len(eidtId) > 0 && len(orgAdminAll) > len(eidtId) {
|
|
orgAdminEditErr := overall.CONSTANT_DB_HR.Model(&models.Position{}).Where("`kingdeeid` IN ?", eidtId).Updates(map[string]interface{}{"state": 2}).Error
|
|
if orgAdminEditErr == nil {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得职位成功!", orgAdminEditErr, eidtId)
|
|
} else {
|
|
overallhandle.WriteLog("edit", "禁用已不使用得职位失败!", orgAdminEditErr, eidtId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 协程写入职位
|
|
func writePositis(batchPositionNew []models.Position) {
|
|
defer synPro.Done()
|
|
if len(batchPositionNew) > 0 {
|
|
addErr := overall.CONSTANT_DB_HR.Create(&batchPositionNew).Error
|
|
if addErr == nil {
|
|
overallhandle.WriteLog("add", "职位写入成功!", addErr, batchPositionNew)
|
|
} else {
|
|
overallhandle.WriteLog("add", "职位写入失败!", addErr, batchPositionNew)
|
|
}
|
|
}
|
|
}
|
|
|
|
// 协程职位校正
|
|
func calibrationPosition(orgInfo []positionType) {
|
|
defer synPro.Done()
|
|
if len(orgInfo) > 0 {
|
|
for _, cv := range orgInfo {
|
|
var parentContCorre models.Position
|
|
parentErr := parentContCorre.GetCont(map[string]interface{}{"kingdeeid": cv.Id}, "`id`", "`superior`")
|
|
if parentErr == nil {
|
|
var orgCorrePrent models.Position
|
|
orgCorrePrentErr := orgCorrePrent.GetCont(map[string]interface{}{"kingdeeid": cv.FParentID}, "id")
|
|
if orgCorrePrentErr == nil {
|
|
if parentContCorre.Superior != orgCorrePrent.Id {
|
|
saveData := overallhandle.MapOut()
|
|
saveData["superior"] = orgCorrePrent.Id
|
|
saveData["time"] = time.Now().Unix()
|
|
parentContCorre.EiteCont(map[string]interface{}{"id": parentContCorre.Id}, saveData)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 09:36:18
|
|
@ 功能: 数据校正
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func UserDataCorrection() {
|
|
var userId []int64
|
|
overall.CONSTANT_DB_HR.Model(&models.PersonArchives{}).Select("`id`").Find(&userId)
|
|
if len(userId) > 0 {
|
|
var guoduId []int64
|
|
for i, v := range userId {
|
|
//分组启动携程
|
|
if (i+1)%500 == 0 {
|
|
synPro.Add(1)
|
|
go SynProCorrection(guoduId)
|
|
guoduId = []int64{}
|
|
} else {
|
|
guoduId = append(guoduId, v)
|
|
}
|
|
|
|
}
|
|
if len(guoduId) > 0 {
|
|
synPro.Add(1)
|
|
go SynProCorrection(guoduId)
|
|
}
|
|
synPro.Wait()
|
|
}
|
|
fmt.Println("数据校验完成!")
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 10:04:44
|
|
@ 功能: 协程处理同步
|
|
#userId 要处理人的ID
|
|
*/
|
|
func SynProCorrection(userIdAry []int64) {
|
|
defer synPro.Done()
|
|
var userAry []models.PersonArchives
|
|
overall.CONSTANT_DB_HR.Where("`id` IN ?", userIdAry).Find(&userAry)
|
|
// fmt.Printf("userAry--->%v--->%v\n\n", len(userAry), userAry)
|
|
if len(userAry) > 0 {
|
|
for _, v := range userAry {
|
|
var manInfo models.PersonnelContent
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", v.Key).First(&manInfo)
|
|
var emeContact []models.EmergencyContact //紧机联系人
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", v.Key).Find(&emeContact)
|
|
var familyList []models.FamilyMembers //家庭成员
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", v.Key).Find(&familyList)
|
|
var perEduList []models.PersonnelEducation //教育经历
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", v.Key).Find(&perEduList)
|
|
var workEduList []models.WorkHistory //工作履历
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", v.Key).Find(&workEduList)
|
|
var workInsideEduList []models.InsideWorkHistory //编辑集团内工作履历
|
|
overall.CONSTANT_DB_HR.Where("`key` = ?", v.Key).Find(&workInsideEduList)
|
|
var creadContList []models.UserOrg //任职关系
|
|
overall.CONSTANT_DB_HR.Where("`userKey` = ?", v.Key).Find(&creadContList)
|
|
//TiDb 数据库
|
|
tidbSubHandel(v)
|
|
//编辑人员附属信息
|
|
editUserAttribute(overall.CONSTANT_Hr_Server, manInfo)
|
|
//紧急联系人
|
|
if len(emeContact) > 0 {
|
|
editEmerCpntcat(overall.CONSTANT_Hr_Server, v.Key, emeContact)
|
|
}
|
|
//家庭成员
|
|
if len(familyList) > 0 {
|
|
editFamilyMember(overall.CONSTANT_Hr_Server, v.Key, familyList)
|
|
}
|
|
//教育经历
|
|
if len(perEduList) > 0 {
|
|
editPerEdu(overall.CONSTANT_Hr_Server, v.Key, perEduList)
|
|
}
|
|
//工作履历
|
|
if len(workEduList) > 0 {
|
|
editWorkJob(overall.CONSTANT_Hr_Server, v.Key, workEduList)
|
|
}
|
|
//编辑集团内工作履历
|
|
if len(workInsideEduList) > 0 {
|
|
editInsideWorkJob(overall.CONSTANT_Hr_Server, v.Key, workInsideEduList)
|
|
}
|
|
//任职关系
|
|
if len(creadContList) > 0 {
|
|
editInsideWorkJobOrg(overall.CONSTANT_Hr_Server, v.Key, creadContList)
|
|
}
|
|
//外网数据库
|
|
waiSubHandel(v)
|
|
//编辑人员附属信息
|
|
editUserAttribute(overall.CONSTANT_HRSERVER_DATABASE, manInfo)
|
|
//紧急联系人
|
|
if len(emeContact) > 0 {
|
|
editEmerCpntcat(overall.CONSTANT_HRSERVER_DATABASE, v.Key, emeContact)
|
|
}
|
|
//家庭成员
|
|
if len(familyList) > 0 {
|
|
editFamilyMember(overall.CONSTANT_HRSERVER_DATABASE, v.Key, familyList)
|
|
}
|
|
//教育经历
|
|
if len(perEduList) > 0 {
|
|
editPerEdu(overall.CONSTANT_HRSERVER_DATABASE, v.Key, perEduList)
|
|
}
|
|
//工作履历
|
|
if len(workEduList) > 0 {
|
|
editWorkJob(overall.CONSTANT_HRSERVER_DATABASE, v.Key, workEduList)
|
|
}
|
|
//编辑集团内工作履历
|
|
if len(workInsideEduList) > 0 {
|
|
editInsideWorkJob(overall.CONSTANT_HRSERVER_DATABASE, v.Key, workInsideEduList)
|
|
}
|
|
//任职关系
|
|
if len(creadContList) > 0 {
|
|
editInsideWorkJobOrg(overall.CONSTANT_HRSERVER_DATABASE, v.Key, creadContList)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 13:39:28
|
|
@ 功能: 任职关系
|
|
*/
|
|
func editInsideWorkJobOrg(gormDb *gorm.DB, userKry int64, emeList []models.UserOrg) {
|
|
if len(emeList) > 0 {
|
|
gormDb.Where("`userKey` = ?", userKry).Delete(&models.UserOrg{})
|
|
var newWrite []models.UserOrg
|
|
for _, v := range emeList {
|
|
var newInfo models.UserOrg
|
|
newInfo.Company = v.Company
|
|
newInfo.Orgid = v.Orgid
|
|
newInfo.Position = v.Position
|
|
newInfo.TeamsId = v.TeamsId
|
|
newInfo.StartTime = v.StartTime
|
|
newInfo.AssignType = v.AssignType
|
|
newInfo.Time = time.Now().Unix()
|
|
newWrite = append(newWrite, newInfo)
|
|
}
|
|
if len(newWrite) > 0 {
|
|
gormDb.Create(&newWrite)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 13:39:28
|
|
@ 功能: 编辑集团内工作履历
|
|
*/
|
|
func editInsideWorkJob(gormDb *gorm.DB, userKry int64, emeList []models.InsideWorkHistory) {
|
|
if len(emeList) > 0 {
|
|
gormDb.Where("`key` = ?", userKry).Delete(&models.InsideWorkHistory{})
|
|
var newWrite []models.InsideWorkHistory
|
|
for _, v := range emeList {
|
|
var newInfo models.InsideWorkHistory
|
|
newInfo.Key = v.Key
|
|
newInfo.Group = v.Group
|
|
newInfo.Company = v.Company
|
|
newInfo.Department = v.Department
|
|
newInfo.WorkShop = v.WorkShop
|
|
newInfo.WorkshopSection = v.WorkshopSection
|
|
newInfo.Position = v.Position
|
|
newInfo.GradePositions = v.GradePositions
|
|
newInfo.StartTime = v.StartTime
|
|
newInfo.EndTime = v.EndTime
|
|
newInfo.Team = v.Team
|
|
newInfo.ChangeType = v.ChangeType
|
|
newInfo.Time = time.Now().Unix()
|
|
newInfo.State = v.State
|
|
newInfo.AssignType = v.AssignType
|
|
newInfo.JobId = v.JobId
|
|
newInfo.WorkCont = v.WorkCont
|
|
|
|
newInfo.ChangeReason = v.ChangeReason
|
|
newInfo.SuperiorPosition = v.SuperiorPosition
|
|
newInfo.SuperiorName = v.SuperiorName
|
|
newInfo.Subordinates = v.Subordinates
|
|
newInfo.Bdlx = v.Bdlx
|
|
newInfo.Gsmc = v.Gsmc
|
|
newInfo.Yjbm = v.Yjbm
|
|
newInfo.Ejbm = v.Ejbm
|
|
newInfo.Gongduan = v.Gongduan
|
|
newInfo.Dengji = v.Dengji
|
|
newInfo.Zhiwei = v.Zhiwei
|
|
newWrite = append(newWrite, newInfo)
|
|
}
|
|
if len(newWrite) > 0 {
|
|
gormDb.Create(&newWrite)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 13:39:28
|
|
@ 功能: 教育经历
|
|
*/
|
|
func editWorkJob(gormDb *gorm.DB, userKry int64, emeList []models.WorkHistory) {
|
|
if len(emeList) > 0 {
|
|
gormDb.Where("`key` = ?", userKry).Delete(&models.WorkHistory{})
|
|
var newWrite []models.WorkHistory
|
|
for _, v := range emeList {
|
|
var newInfo models.WorkHistory
|
|
newInfo.Number = v.Number
|
|
newInfo.Key = v.Key
|
|
newInfo.Company = v.Company
|
|
newInfo.Deparment = v.Deparment
|
|
newInfo.Job = v.Job
|
|
newInfo.EntryTime = v.EntryTime
|
|
newInfo.Leavedate = v.Leavedate
|
|
newInfo.Witness = v.Witness
|
|
newInfo.WitnessTel = v.WitnessTel
|
|
newInfo.Remarks = v.Remarks
|
|
newInfo.Time = time.Now().Unix()
|
|
newInfo.State = v.State
|
|
newInfo.WorkCont = v.WorkCont
|
|
newInfo.SuperiorPosition = v.SuperiorPosition
|
|
newInfo.MinionNumber = v.MinionNumber
|
|
newInfo.CompanyNature = v.CompanyNature
|
|
newInfo.Industry = v.Industry
|
|
newWrite = append(newWrite, newInfo)
|
|
}
|
|
if len(newWrite) > 0 {
|
|
gormDb.Create(&newWrite)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 13:39:28
|
|
@ 功能: 教育经历
|
|
*/
|
|
func editPerEdu(gormDb *gorm.DB, userKry int64, emeList []models.PersonnelEducation) {
|
|
if len(emeList) > 0 {
|
|
err := gormDb.Where("`key` = ?", userKry).Delete(&models.PersonnelEducation{}).Error
|
|
if err == nil {
|
|
gormDb.Create(&emeList)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 13:39:28
|
|
@ 功能: 家庭成员
|
|
*/
|
|
func editFamilyMember(gormDb *gorm.DB, userKry int64, emeList []models.FamilyMembers) {
|
|
if len(emeList) > 0 {
|
|
err := gormDb.Where("`key` = ?", userKry).Delete(&models.FamilyMembers{}).Error
|
|
if err == nil {
|
|
gormDb.Create(&emeList)
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 13:39:28
|
|
@ 功能: 紧急联系人
|
|
*/
|
|
func editEmerCpntcat(gormDb *gorm.DB, userKry int64, emeList []models.EmergencyContact) {
|
|
if len(emeList) > 0 {
|
|
err := gormDb.Where("`key` = ?", userKry).Delete(&models.EmergencyContact{}).Error
|
|
if err == nil {
|
|
gormDb.Create(&emeList)
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 10:38:08
|
|
@ 功能: tidb数据库数据处理
|
|
*/
|
|
func tidbSubHandel(user models.PersonArchives) {
|
|
var tidbUser models.PersonArchives
|
|
overall.CONSTANT_Hr_Server.Where("`number` = ?", user.Number).First(&tidbUser)
|
|
if tidbUser.Id != 0 {
|
|
//存在就修改
|
|
editMap := overallhandle.MapOut()
|
|
if user.Name != "" && user.Name != tidbUser.Name {
|
|
editMap["name"] = user.Name
|
|
}
|
|
if user.Icon != "" && user.Icon != tidbUser.Icon {
|
|
editMap["icon"] = user.Icon
|
|
}
|
|
if user.HireClass != 0 && user.HireClass != tidbUser.HireClass {
|
|
editMap["hire_class"] = user.HireClass
|
|
}
|
|
if user.EmpType != 0 && user.EmpType != tidbUser.EmpType {
|
|
editMap["emp_type"] = user.EmpType
|
|
}
|
|
if user.Company != 0 && user.Company != tidbUser.Company {
|
|
editMap["company"] = user.Company
|
|
}
|
|
if user.MainDeparment != 0 && user.MainDeparment != tidbUser.MainDeparment {
|
|
editMap["maindeparment"] = user.MainDeparment
|
|
}
|
|
if user.Deparment != "" && user.Deparment != tidbUser.Deparment {
|
|
editMap["deparment"] = user.Deparment
|
|
}
|
|
if user.AdminOrg != 0 && user.AdminOrg != tidbUser.AdminOrg {
|
|
editMap["admin_org"] = user.AdminOrg
|
|
}
|
|
if user.Position != 0 && user.Position != tidbUser.Position {
|
|
editMap["position"] = user.Position
|
|
}
|
|
if user.JobClass != 0 && user.JobClass != tidbUser.JobClass {
|
|
editMap["job_class"] = user.JobClass
|
|
}
|
|
if user.JobId != 0 && user.JobId != tidbUser.JobId {
|
|
editMap["job_id"] = user.JobId
|
|
}
|
|
if user.JobLeve != 0 && user.JobLeve != tidbUser.JobLeve {
|
|
editMap["job_leve"] = user.JobLeve
|
|
}
|
|
if user.Wechat != "" && user.Wechat != tidbUser.Wechat {
|
|
editMap["wechat"] = user.Wechat
|
|
}
|
|
if user.WorkWechat != "" && user.WorkWechat != tidbUser.WorkWechat {
|
|
editMap["work_wechat"] = user.WorkWechat
|
|
}
|
|
if user.State != 0 && user.State != tidbUser.State {
|
|
editMap["state"] = user.State
|
|
}
|
|
if user.IsAdmin != 0 && user.IsAdmin != tidbUser.IsAdmin {
|
|
editMap["is_admin"] = user.IsAdmin
|
|
}
|
|
if user.EmpTypeName != "" && user.EmpTypeName != tidbUser.EmpTypeName {
|
|
editMap["emp_type_name"] = user.EmpTypeName
|
|
}
|
|
if user.HireClassName != "" && user.HireClassName != tidbUser.HireClassName {
|
|
editMap["hire_class_name"] = user.HireClassName
|
|
}
|
|
if user.SunMainDeparment != 0 && user.SunMainDeparment != tidbUser.SunMainDeparment {
|
|
editMap["sun_main_deparment"] = user.SunMainDeparment
|
|
}
|
|
if user.TeamId != 0 && user.TeamId != tidbUser.TeamId {
|
|
editMap["teamid"] = user.TeamId
|
|
}
|
|
if user.Ruleid != 0 && user.Ruleid != tidbUser.Ruleid {
|
|
editMap["ruleid"] = user.Ruleid
|
|
}
|
|
if user.IconPhoto != "" && user.IconPhoto != tidbUser.IconPhoto {
|
|
editMap["icon_photo"] = user.IconPhoto
|
|
}
|
|
if user.PersonInCharge != 0 && user.PersonInCharge != tidbUser.PersonInCharge {
|
|
editMap["person_in_charge"] = user.PersonInCharge
|
|
}
|
|
if user.ResponsibleDepartment != "" && user.ResponsibleDepartment != tidbUser.ResponsibleDepartment {
|
|
editMap["responsible_department"] = user.ResponsibleDepartment
|
|
}
|
|
if user.ResponsibleDepartmentJson != "" && user.ResponsibleDepartmentJson != tidbUser.ResponsibleDepartmentJson {
|
|
editMap["responsible_department_json"] = user.ResponsibleDepartmentJson
|
|
}
|
|
if user.WorkSection != 0 && user.WorkSection != tidbUser.WorkSection {
|
|
editMap["work_section"] = user.WorkSection
|
|
}
|
|
if user.IsShowTrue != 0 && user.IsShowTrue != tidbUser.IsShowTrue {
|
|
editMap["is_show_true"] = user.IsShowTrue
|
|
}
|
|
if user.ExcelTemplate != 0 && user.ExcelTemplate != tidbUser.ExcelTemplate {
|
|
editMap["excel_template"] = user.ExcelTemplate
|
|
}
|
|
if len(editMap) > 0 {
|
|
editMap["eite_time"] = time.Now().Unix()
|
|
overall.CONSTANT_Hr_Server.Model(&models.PersonArchives{}).Where("`number` = ?", user.Number).Updates(editMap)
|
|
}
|
|
} else {
|
|
//不存在就新增
|
|
overall.CONSTANT_Hr_Server.Create(&user)
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 10:38:08
|
|
@ 功能: 外网数据库数据处理
|
|
*/
|
|
func waiSubHandel(user models.PersonArchives) {
|
|
var tidbUser models.PersonArchives
|
|
overall.CONSTANT_HRSERVER_DATABASE.Where("`number` = ?", user.Number).First(&tidbUser)
|
|
fmt.Printf("外网数据库数据处理->%v\n", tidbUser)
|
|
if tidbUser.Id != 0 {
|
|
//存在就修改
|
|
editMap := overallhandle.MapOut()
|
|
if user.Name != "" && user.Name != tidbUser.Name {
|
|
editMap["name"] = user.Name
|
|
}
|
|
if user.Icon != "" && user.Icon != tidbUser.Icon {
|
|
editMap["icon"] = user.Icon
|
|
}
|
|
if user.HireClass != 0 && user.HireClass != tidbUser.HireClass {
|
|
editMap["hire_class"] = user.HireClass
|
|
}
|
|
if user.EmpType != 0 && user.EmpType != tidbUser.EmpType {
|
|
editMap["emp_type"] = user.EmpType
|
|
}
|
|
if user.Company != 0 && user.Company != tidbUser.Company {
|
|
editMap["company"] = user.Company
|
|
}
|
|
if user.MainDeparment != 0 && user.MainDeparment != tidbUser.MainDeparment {
|
|
editMap["maindeparment"] = user.MainDeparment
|
|
}
|
|
if user.Deparment != "" && user.Deparment != tidbUser.Deparment {
|
|
editMap["deparment"] = user.Deparment
|
|
}
|
|
if user.AdminOrg != 0 && user.AdminOrg != tidbUser.AdminOrg {
|
|
editMap["admin_org"] = user.AdminOrg
|
|
}
|
|
if user.Position != 0 && user.Position != tidbUser.Position {
|
|
editMap["position"] = user.Position
|
|
}
|
|
if user.JobClass != 0 && user.JobClass != tidbUser.JobClass {
|
|
editMap["job_class"] = user.JobClass
|
|
}
|
|
if user.JobId != 0 && user.JobId != tidbUser.JobId {
|
|
editMap["job_id"] = user.JobId
|
|
}
|
|
if user.JobLeve != 0 && user.JobLeve != tidbUser.JobLeve {
|
|
editMap["job_leve"] = user.JobLeve
|
|
}
|
|
if user.Wechat != "" && user.Wechat != tidbUser.Wechat {
|
|
editMap["wechat"] = user.Wechat
|
|
}
|
|
if user.WorkWechat != "" && user.WorkWechat != tidbUser.WorkWechat {
|
|
editMap["work_wechat"] = user.WorkWechat
|
|
}
|
|
if user.State != 0 && user.State != tidbUser.State {
|
|
editMap["state"] = user.State
|
|
}
|
|
if user.IsAdmin != 0 && user.IsAdmin != tidbUser.IsAdmin {
|
|
editMap["is_admin"] = user.IsAdmin
|
|
}
|
|
if user.EmpTypeName != "" && user.EmpTypeName != tidbUser.EmpTypeName {
|
|
editMap["emp_type_name"] = user.EmpTypeName
|
|
}
|
|
if user.HireClassName != "" && user.HireClassName != tidbUser.HireClassName {
|
|
editMap["hire_class_name"] = user.HireClassName
|
|
}
|
|
if user.SunMainDeparment != 0 && user.SunMainDeparment != tidbUser.SunMainDeparment {
|
|
editMap["sun_main_deparment"] = user.SunMainDeparment
|
|
}
|
|
if user.TeamId != 0 && user.TeamId != tidbUser.TeamId {
|
|
editMap["teamid"] = user.TeamId
|
|
}
|
|
if user.Ruleid != 0 && user.Ruleid != tidbUser.Ruleid {
|
|
editMap["ruleid"] = user.Ruleid
|
|
}
|
|
if user.IconPhoto != "" && user.IconPhoto != tidbUser.IconPhoto {
|
|
editMap["icon_photo"] = user.IconPhoto
|
|
}
|
|
if user.PersonInCharge != 0 && user.PersonInCharge != tidbUser.PersonInCharge {
|
|
editMap["person_in_charge"] = user.PersonInCharge
|
|
}
|
|
if user.ResponsibleDepartment != "" && user.ResponsibleDepartment != tidbUser.ResponsibleDepartment {
|
|
editMap["responsible_department"] = user.ResponsibleDepartment
|
|
}
|
|
if user.ResponsibleDepartmentJson != "" && user.ResponsibleDepartmentJson != tidbUser.ResponsibleDepartmentJson {
|
|
editMap["responsible_department_json"] = user.ResponsibleDepartmentJson
|
|
}
|
|
if user.WorkSection != 0 && user.WorkSection != tidbUser.WorkSection {
|
|
editMap["work_section"] = user.WorkSection
|
|
}
|
|
if user.IsShowTrue != 0 && user.IsShowTrue != tidbUser.IsShowTrue {
|
|
editMap["is_show_true"] = user.IsShowTrue
|
|
}
|
|
if user.ExcelTemplate != 0 && user.ExcelTemplate != tidbUser.ExcelTemplate {
|
|
editMap["excel_template"] = user.ExcelTemplate
|
|
}
|
|
fmt.Printf("外网数据库数据处理------要修改的数据------>%v----->%v\n", len(editMap), editMap)
|
|
if len(editMap) > 0 {
|
|
editMap["eite_time"] = time.Now().Unix()
|
|
err := overall.CONSTANT_HRSERVER_DATABASE.Model(&models.PersonArchives{}).Where("`number` = ?", user.Number).Updates(editMap).Error
|
|
fmt.Printf("外网数据库数据处理------要修改的数据------>%v----->%v\n", len(editMap), err)
|
|
}
|
|
} else {
|
|
//不存在就新增
|
|
overall.CONSTANT_HRSERVER_DATABASE.Create(&user)
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-04-02 11:36:47
|
|
@ 功能: 编辑附属人员信息
|
|
*/
|
|
func editUserAttribute(gormDb *gorm.DB, userAttribute models.PersonnelContent) {
|
|
var manInfo models.PersonnelContent
|
|
gormDb.Where("`key` = ?", userAttribute.Key).First(&manInfo)
|
|
if manInfo.Number != "" {
|
|
//数据存在修改
|
|
editMap := overallhandle.MapOut()
|
|
if userAttribute.Idcardno != "" && userAttribute.Idcardno != manInfo.Idcardno {
|
|
editMap["idcardno"] = userAttribute.Idcardno
|
|
}
|
|
if userAttribute.Passportno != "" && userAttribute.Passportno != manInfo.Passportno {
|
|
editMap["passportno"] = userAttribute.Passportno
|
|
}
|
|
if userAttribute.Globalroaming != "" && userAttribute.Globalroaming != manInfo.Globalroaming {
|
|
editMap["globalroaming"] = userAttribute.Globalroaming
|
|
}
|
|
if userAttribute.Mobilephone != "" && userAttribute.Mobilephone != manInfo.Mobilephone {
|
|
editMap["mobilephone"] = userAttribute.Mobilephone
|
|
}
|
|
if userAttribute.Gender != 0 && userAttribute.Gender != manInfo.Gender {
|
|
editMap["gender"] = userAttribute.Gender
|
|
}
|
|
if userAttribute.Birthday != 0 && userAttribute.Birthday != manInfo.Birthday {
|
|
editMap["birthday"] = userAttribute.Birthday
|
|
}
|
|
if userAttribute.Myfolk != "" && userAttribute.Myfolk != manInfo.Myfolk {
|
|
editMap["myfolk"] = userAttribute.Myfolk
|
|
}
|
|
if userAttribute.Nativeplace != "" && userAttribute.Nativeplace != manInfo.Nativeplace {
|
|
editMap["nativeplace"] = userAttribute.Nativeplace
|
|
}
|
|
if userAttribute.Idcardstartdate != 0 && userAttribute.Idcardstartdate != manInfo.Idcardstartdate {
|
|
editMap["idcardstartdate"] = userAttribute.Idcardstartdate
|
|
}
|
|
if userAttribute.Idcardenddate != 0 && userAttribute.Idcardenddate != manInfo.Idcardenddate {
|
|
editMap["idcardenddate"] = userAttribute.Idcardenddate
|
|
}
|
|
if userAttribute.Idcardaddress != "" && userAttribute.Idcardaddress != manInfo.Idcardaddress {
|
|
editMap["idcardaddress"] = userAttribute.Idcardaddress
|
|
}
|
|
if userAttribute.IdcardIssued != "" && userAttribute.IdcardIssued != manInfo.IdcardIssued {
|
|
editMap["idcardIssued"] = userAttribute.IdcardIssued
|
|
}
|
|
if userAttribute.Health != 0 && userAttribute.Health != manInfo.Health {
|
|
editMap["health"] = userAttribute.Health
|
|
}
|
|
if userAttribute.Maritalstatus != 0 && userAttribute.Maritalstatus != manInfo.Maritalstatus {
|
|
editMap["maritalstatus"] = userAttribute.Maritalstatus
|
|
}
|
|
if userAttribute.Internaltelephone != "" && userAttribute.Internaltelephone != manInfo.Internaltelephone {
|
|
editMap["internaltelephone"] = userAttribute.Internaltelephone
|
|
}
|
|
if userAttribute.Currentresidence != "" && userAttribute.Currentresidence != manInfo.Currentresidence {
|
|
editMap["currentresidence"] = userAttribute.Currentresidence
|
|
}
|
|
if userAttribute.Constellation != 0 && userAttribute.Constellation != manInfo.Constellation {
|
|
editMap["constellationing"] = userAttribute.Constellation
|
|
}
|
|
if userAttribute.Isdoubleworker != 0 && userAttribute.Isdoubleworker != manInfo.Isdoubleworker {
|
|
editMap["isdoubleworker"] = userAttribute.Isdoubleworker
|
|
}
|
|
if userAttribute.Isveterans != 0 && userAttribute.Isveterans != manInfo.Isveterans {
|
|
editMap["isveterans"] = userAttribute.Isveterans
|
|
}
|
|
if userAttribute.Veteransnumber != "" && userAttribute.Veteransnumber != manInfo.Veteransnumber {
|
|
editMap["veteransnumber"] = userAttribute.Veteransnumber
|
|
}
|
|
if userAttribute.Jobstartdate != 0 && userAttribute.Jobstartdate != manInfo.Jobstartdate {
|
|
editMap["jobstartdate"] = userAttribute.Jobstartdate
|
|
}
|
|
if userAttribute.Entrydate != 0 && userAttribute.Entrydate != manInfo.Entrydate {
|
|
editMap["entrydate"] = userAttribute.Entrydate
|
|
}
|
|
if userAttribute.Probationperiod != 0 && userAttribute.Probationperiod != manInfo.Probationperiod {
|
|
editMap["probationperiod"] = userAttribute.Probationperiod
|
|
}
|
|
if userAttribute.Planformaldate != 0 && userAttribute.Planformaldate != manInfo.Planformaldate {
|
|
editMap["planformaldate"] = userAttribute.Planformaldate
|
|
}
|
|
if userAttribute.PoliticalOutlook != 0 && userAttribute.PoliticalOutlook != manInfo.PoliticalOutlook {
|
|
editMap["political_outlook"] = userAttribute.PoliticalOutlook
|
|
}
|
|
if userAttribute.MaritalstatusCn != "" && userAttribute.MaritalstatusCn != manInfo.MaritalstatusCn {
|
|
editMap["maritalstatus_cn"] = userAttribute.MaritalstatusCn
|
|
}
|
|
if userAttribute.PoliticalOutlookCn != "" && userAttribute.PoliticalOutlookCn != manInfo.PoliticalOutlookCn {
|
|
editMap["political_outlook_cn"] = userAttribute.PoliticalOutlookCn
|
|
}
|
|
if userAttribute.HealthCn != "" && userAttribute.HealthCn != manInfo.HealthCn {
|
|
editMap["health_cn"] = userAttribute.HealthCn
|
|
}
|
|
if userAttribute.NameUsedBefore != "" && userAttribute.NameUsedBefore != manInfo.NameUsedBefore {
|
|
editMap["name_used_before"] = userAttribute.NameUsedBefore
|
|
}
|
|
if userAttribute.CareerPlanning != "" && userAttribute.CareerPlanning != manInfo.CareerPlanning {
|
|
editMap["career_planning"] = userAttribute.CareerPlanning
|
|
}
|
|
if userAttribute.HelpObtained != "" && userAttribute.HelpObtained != manInfo.HelpObtained {
|
|
editMap["help_obtained"] = userAttribute.HelpObtained
|
|
}
|
|
if userAttribute.Hobby != "" && userAttribute.Hobby != manInfo.Hobby {
|
|
editMap["hobby"] = userAttribute.Hobby
|
|
}
|
|
if userAttribute.DomicileType != "" && userAttribute.DomicileType != manInfo.DomicileType {
|
|
editMap["domicile_type"] = userAttribute.DomicileType
|
|
}
|
|
if userAttribute.IdCardnoLongTerm != 0 && userAttribute.IdCardnoLongTerm != manInfo.IdCardnoLongTerm {
|
|
editMap["idCardnoLongTerm"] = userAttribute.IdCardnoLongTerm
|
|
}
|
|
if userAttribute.MobileShortNumber != "" && userAttribute.MobileShortNumber != manInfo.MobileShortNumber {
|
|
editMap["mobileShortNumber"] = userAttribute.MobileShortNumber
|
|
}
|
|
if userAttribute.Channel != 0 && userAttribute.Channel != manInfo.Channel {
|
|
editMap["channel"] = userAttribute.Channel
|
|
}
|
|
if userAttribute.BloodType != "" && userAttribute.BloodType != manInfo.BloodType {
|
|
editMap["bloodType"] = userAttribute.BloodType
|
|
}
|
|
if len(editMap) > 0 {
|
|
editMap["time"] = time.Now().Unix()
|
|
gormDb.Model(&models.PersonnelContent{}).Where("`key` = ?", userAttribute.Key).Updates(editMap)
|
|
}
|
|
} else {
|
|
//数据不存在,新增
|
|
gormDb.Create(&userAttribute)
|
|
}
|
|
}
|
|
|