@ -33,8 +33,8 @@ func (s *StaffApi) NewKingdee(c *gin.Context) {
saveKingDee . Cont = string ( requesJson )
saveKingDee . Cont = string ( requesJson )
saveKingDee . Time = time . Now ( ) . Unix ( )
saveKingDee . Time = time . Now ( ) . Unix ( )
overallhandle . WriteLog ( "i" , "KingDee对接数据!" , saveKingDee )
overallhandle . WriteLog ( "i" , "KingDee对接数据!" , saveKingDee )
kingdeeErr := overall . CONSTANT_DB_HR . Create ( & saveKingDee ) . Error
// kingdeeErr := overall.CONSTANT_DB_HR.Create(&saveKingDee).Error
overallhandle . WriteLog ( "w" , "KingDee写入数据库状态!" , kingdeeErr )
// overallhandle.WriteLog("w", "KingDee写入数据库状态!", kingdeeErr)
var manContent models . PersonArchives
var manContent models . PersonArchives
manErr := manContent . GetCont ( map [ string ] interface { } { "`number`" : requestData . Number } )
manErr := manContent . GetCont ( map [ string ] interface { } { "`number`" : requestData . Number } )
if manErr == nil {
if manErr == nil {
@ -54,16 +54,39 @@ func (s *StaffApi) NewKingdee(c *gin.Context) {
overallhandle . Result ( 0 , manErr , c )
overallhandle . Result ( 0 , manErr , c )
}
}
// 编辑员工
/ *
*
@ 作者 : 秦东
@ 时间 : 2022 - 12 - 19 0 9 : 35 : 48
@ 功能 : 编辑员工
@ 参数
# perArcInfo 原始头像
# manCont 接收得员工数据
@ 返回值
#
@ 方法原型
#
* /
func eidtAddManContJinDie ( perArcInfo models . PersonArchives , manCont addKingdeePersonneles ) error {
func eidtAddManContJinDie ( perArcInfo models . PersonArchives , manCont addKingdeePersonneles ) error {
fmt . Printf ( "编辑" )
fmt . Printf ( "编辑--->%v\n" , manCont )
eidtManCont := overallhandle . MapOut ( )
eidtManCont := overallhandle . MapOut ( )
if manCont . Name != "" && manCont . Name != perArcInfo . Name {
if manCont . Name != "" && manCont . Name != perArcInfo . Name {
eidtManCont [ "`name`" ] = manCont . Name
eidtManCont [ "`name`" ] = manCont . Name
}
}
if manCont . Icon != "" && manCont . Icon != perArcInfo . Icon {
if manCont . Icon != "" {
eidtManCont [ "`icon`" ] = manCont . Icon
newIcon := fmt . Sprintf ( "data:image/jpeg;base64,%v" , strings . Replace ( manCont . Icon , "\r\n" , "" , - 1 ) )
if newIcon != perArcInfo . Icon {
eidtManCont [ "`icon_photo`" ] = newIcon
}
}
}
if manCont . HireType != "" {
if manCont . HireType != "" {
hireTypes , hireTypesErr := overallhandle . StringToInt ( manCont . HireType )
hireTypes , hireTypesErr := overallhandle . StringToInt ( manCont . HireType )
if hireTypesErr != nil {
if hireTypesErr != nil {
@ -212,6 +235,7 @@ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePe
manChangeRecord . JobLevel = positionGrade
manChangeRecord . JobLevel = positionGrade
changeRecordTrue = true
changeRecordTrue = true
}
}
// fmt.Printf("第一学历--->%v--->%v\n", changeRecordTrue, manChangeRecord)
// fmt.Printf("第一学历--->%v--->%v\n", changeRecordTrue, manChangeRecord)
if len ( eidtManCont ) > 0 {
if len ( eidtManCont ) > 0 {
var manMainCont models . PersonArchives
var manMainCont models . PersonArchives
@ -237,6 +261,7 @@ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePe
}
}
}
}
//编辑人员附属信息
//编辑人员附属信息
synPro . Add ( 1 )
synPro . Add ( 1 )
go editManAuxiliaryDataNew ( perArcInfo . Key , manCont )
go editManAuxiliaryDataNew ( perArcInfo . Key , manCont )
@ -254,7 +279,8 @@ func eidtAddManContJinDie(perArcInfo models.PersonArchives, manCont addKingdeePe
go editWorkHistoryMan ( perArcInfo . Key , manCont . Number , manCont . WorkHistoryList )
go editWorkHistoryMan ( perArcInfo . Key , manCont . Number , manCont . WorkHistoryList )
//编辑集团内工作履历
//编辑集团内工作履历
synPro . Add ( 1 )
synPro . Add ( 1 )
go editInsideWorkHistoryMan ( perArcInfo . Key , manCont . InsideWorkHistory )
// go editInsideWorkHistoryMan(perArcInfo.Key, manCont.InsideWorkHistory)
go editInsideWorkHistoryManNew ( perArcInfo . Key , manCont . InsideWorkHistory )
synPro . Wait ( )
synPro . Wait ( )
return nil
return nil
@ -385,7 +411,11 @@ func newAddManContJinDie(oldSchool models.WorkMan, manCont addKingdeePersonneles
var oldPersonArchives models . Personnel
var oldPersonArchives models . Personnel
oldPersErr := overall . CONSTANT_DB_HR_Jin . Where ( map [ string ] interface { } { "`number`" : manCont . Number } ) . First ( & oldPersonArchives ) . Error
oldPersErr := overall . CONSTANT_DB_HR_Jin . Where ( map [ string ] interface { } { "`number`" : manCont . Number } ) . First ( & oldPersonArchives ) . Error
if oldPersErr == nil {
if oldPersErr == nil {
if manCont . Icon == "" {
if manCont . Icon != "" {
manMainCont . IconPhoto = fmt . Sprintf ( "data:image/jpeg;base64,%v" , strings . Replace ( manCont . Icon , "\r\n" , "" , - 1 ) )
}
if oldPersonArchives . Icon != "" {
manMainCont . Icon = oldPersonArchives . Icon
manMainCont . Icon = oldPersonArchives . Icon
}
}
if oldPersonArchives . Key != 0 {
if oldPersonArchives . Key != 0 {
@ -448,7 +478,8 @@ func newAddManContJinDie(oldSchool models.WorkMan, manCont addKingdeePersonneles
go editWorkHistoryMan ( manKeyNum , manCont . Number , manCont . WorkHistoryList )
go editWorkHistoryMan ( manKeyNum , manCont . Number , manCont . WorkHistoryList )
//编辑集团内工作履历
//编辑集团内工作履历
synPro . Add ( 1 )
synPro . Add ( 1 )
go editInsideWorkHistoryMan ( manKeyNum , manCont . InsideWorkHistory )
// go editInsideWorkHistoryMan(manKeyNum, manCont.InsideWorkHistory)
go editInsideWorkHistoryManNew ( manKeyNum , manCont . InsideWorkHistory )
synPro . Wait ( )
synPro . Wait ( )
}
}
return nil
return nil
@ -1730,3 +1761,265 @@ func editInsideWorkHistoryMan(manKeyNum int64, contList []insideHistoryer) {
}
}
}
}
}
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2022 - 12 - 19 10 : 16 : 57
@ 功能 : 编辑集团内工作经历
@ 参数
# manKeyNum 员工Key
# contList 工作经历
@ 返回值
#
@ 方法原型
#
* /
func editInsideWorkHistoryManNew ( manKeyNum int64 , contList [ ] insideHistoryer ) {
defer synPro . Done ( )
if len ( contList ) > 0 && manKeyNum > 0 {
var topGroup int64 = 0 // 集团ID
var groupTopCont models . AdministrativeOrganization
groupTopCont . GetCont ( map [ string ] interface { } { "superior" : 0 } , "id" )
topGroup = groupTopCont . Id
//获取个人信息
var myCont models . PersonArchives
myCont . GetCont ( map [ string ] interface { } { "key" : manKeyNum } , "`company`" , "`maindeparment`" , "`admin_org`" , "`sun_main_deparment`" , "`position`" , "`teamid`" )
//1、判断是否存在集团工作经历
var oldInsideWork [ ] models . InsideWorkHistory
overall . CONSTANT_DB_HR . Where ( "`key` = ?" , manKeyNum ) . Find ( & oldInsideWork )
//已经写入得编号
var writeIn [ ] int
var creadAllData [ ] models . InsideWorkHistory //新增工作经历
for i , v := range contList {
WorkShop := myCont . SunMainDeparment
if v . Workshop != "" {
var workShopCont models . AdministrativeOrganization
workShopErr := workShopCont . GetCont ( map [ string ] interface { } { "kingdeeid" : v . Workshop } , "id" )
if workShopErr == nil {
WorkShop = workShopCont . Id //部室"`
}
}
WorkshopSection := myCont . AdminOrg
// fmt.Printf("v.WorkshopSection --------------------->%v\n", v.WorkshopSection)
if v . WorkshopSection != "" {
var workShopSecCont models . AdministrativeOrganization
workShopSecErr := workShopSecCont . GetCont ( map [ string ] interface { } { "kingdeeid" : v . WorkshopSection } , "id" )
// fmt.Printf("v.WorkshopSection ----------id----------->%v\n", workShopSecCont)
if workShopSecErr == nil {
WorkshopSection = workShopSecCont . Id //工段"`
// if v.Department == v.Company {
// cont.Department = overallhandle.RecursionOrgLeve(workShopSecCont.Id, 4)
// }
// if cont.WorkShop == 0 {
// cont.WorkShop = overallhandle.RecursionOrgLeve(workShopSecCont.Id, 5)
// }
}
}
var wssCont models . AdministrativeOrganization
wssCont . GetCont ( map [ string ] interface { } { "kingdeeid" : v . WorkshopSection } , "id" ) //工段信息
if wssCont . Id == 0 {
wssCont . Id = myCont . AdminOrg
}
//集团
var groupContes models . AdministrativeOrganization
if v . Group != "" {
groupContes . GetCont ( map [ string ] interface { } { "kingdeeid" : v . Group } , "id" )
if groupContes . Id == 0 {
groupContes . Id = topGroup
}
} else {
groupContes . Id = topGroup
}
//部门
var dempCont models . AdministrativeOrganization
dempCont . GetCont ( map [ string ] interface { } { "kingdeeid" : v . Department } , "id" )
if dempCont . Id == groupContes . Id {
if wssCont . Id != 0 {
dempCont . Id = overallhandle . RecursionOrgLeve ( wssCont . Id , 4 )
}
}
if dempCont . Id == 0 {
dempCont . Id = myCont . MainDeparment
}
//公司
var compayCont models . AdministrativeOrganization
compayCont . GetCont ( map [ string ] interface { } { "kingdeeid" : v . Company } , "id" )
if compayCont . Id == 0 {
compayCont . Id = myCont . Company
}
//职务
var postCont models . Position
postCont . GetCont ( map [ string ] interface { } { "kingdeeid" : v . Position } , "id" )
if postCont . Id == 0 {
postCont . Id = myCont . Position
}
//判断是否存在集团内部工作经历
if len ( oldInsideWork ) > 0 {
changeTypeInt := changeTypeToInt ( v . ChangeType )
//判断当前工作经历是否存在
var insiCont models . InsideWorkHistory
isErr := insiCont . GetCont ( map [ string ] interface { } { "`key`" : manKeyNum , "`group`" : groupContes . Id , "`company`" : compayCont . Id , "`department`" : dempCont . Id , "workshop_section" : wssCont . Id , "position" : postCont . Id , "`change_type`" : changeTypeInt } )
if isErr == nil {
//此项存在
if overallhandle . IsInTrue [ int ] ( i , writeIn ) == false {
writeIn = append ( writeIn , i )
}
editSaveData := overallhandle . MapOut ( )
startTime := time . Now ( ) . Unix ( )
if v . StartTime != "" {
var startTimeErr bool
startTime , startTimeErr = overallhandle . DateToTimeStamp ( v . StartTime )
if startTimeErr == false {
startTime , _ = overallhandle . DateToTimeStamp ( fmt . Sprintf ( "%v 00:00:00" , v . StartTime ) )
}
}
if startTime != insiCont . StartTime {
editSaveData [ "`start_time`" ] = startTime
}
state := 1
var endTime int64
if v . EndTime != "" {
if v . EndTime != "至今" && v . EndTime != "2199-12-31 00:00:00" && v . EndTime != "2199-12-31" && v . EndTime != "7258003200" {
var endTimeErr bool
endTime , endTimeErr = overallhandle . DateToTimeStamp ( v . EndTime )
if endTimeErr == false {
endTime , _ = overallhandle . DateToTimeStamp ( fmt . Sprintf ( "%v 00:00:00" , v . EndTime ) )
}
state = 2 //状态(1:启用;2:休眠;3:删除)"`
}
}
if changeTypeInt > 12 && changeTypeInt <= 14 {
endTime = time . Now ( ) . Unix ( )
}
if endTime != insiCont . EndTime {
editSaveData [ "`end_time`" ] = endTime
editSaveData [ "`state`" ] = state
}
if insiCont . GradePositions != v . GradePositions {
editSaveData [ "`grade_positions`" ] = v . GradePositions
}
if insiCont . ChangeType != changeTypeInt {
editSaveData [ "`change_type`" ] = changeTypeInt
}
assignTypeInt := assignTypeToInt ( v . AssignType )
if insiCont . AssignType != assignTypeInt {
editSaveData [ "`assign_type`" ] = assignTypeInt
}
if len ( editSaveData ) > 0 {
var editCont models . InsideWorkHistory
editCont . EditCont ( map [ string ] interface { } { "`id`" : insiCont . Id } , editSaveData )
}
} else {
if overallhandle . IsInTrue [ int ] ( i , writeIn ) == false {
writeIn = append ( writeIn , i )
}
//此项不存在
var creadCont models . InsideWorkHistory
creadCont . Key = manKeyNum //员工识别符"`
creadCont . Group = groupContes . Id //集团"`
creadCont . Company = compayCont . Id //公司"`
creadCont . Department = dempCont . Id // 部室"`
creadCont . WorkShop = WorkShop //二级部门或车间"`
creadCont . WorkshopSection = WorkshopSection //工段"`
creadCont . Position = postCont . Id //职位"`
creadCont . GradePositions = v . GradePositions //职等"`
startTime := time . Now ( ) . Unix ( )
if v . StartTime != "" {
var startTimeErr bool
startTime , startTimeErr = overallhandle . DateToTimeStamp ( v . StartTime )
if startTimeErr == false {
startTime , _ = overallhandle . DateToTimeStamp ( fmt . Sprintf ( "%v 00:00:00" , v . StartTime ) )
}
}
creadCont . StartTime = startTime //开始日期"`
state := 1
var endTime int64
if v . EndTime != "" {
if v . EndTime != "至今" && v . EndTime != "2199-12-31 00:00:00" && v . EndTime != "2199-12-31" && v . EndTime != "7258003200" {
var endTimeErr bool
endTime , endTimeErr = overallhandle . DateToTimeStamp ( v . EndTime )
if endTimeErr == false {
endTime , _ = overallhandle . DateToTimeStamp ( fmt . Sprintf ( "%v 00:00:00" , v . EndTime ) )
}
state = 2 //状态(1:启用;2:休眠;3:删除)"`
}
}
changeTypeInted := changeTypeToInt ( v . ChangeType )
if changeTypeInted > 12 && changeTypeInted <= 14 {
endTime = time . Now ( ) . Unix ( )
}
creadCont . EndTime = endTime //结束日期"`
creadCont . Team = myCont . TeamId //(1:长白;2:甲;3:乙;4:丙;5:丁)"`
creadCont . ChangeType = changeTypeToInt ( v . ChangeType ) // 变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"`
creadCont . Time = time . Now ( ) . Unix ( ) //创建时间"`
creadCont . State = state //状态(1:启用;2:禁用;3:删除)"`
creadCont . AssignType = assignTypeToInt ( v . AssignType ) // 1、主职;2:兼职"`
creadAllData = append ( creadAllData , creadCont )
}
} else {
if overallhandle . IsInTrue [ int ] ( i , writeIn ) == false {
writeIn = append ( writeIn , i )
}
var creadCont models . InsideWorkHistory
creadCont . Key = manKeyNum //员工识别符"`
creadCont . Group = groupContes . Id //集团"`
creadCont . Company = compayCont . Id //公司"`
creadCont . Department = dempCont . Id // 部室"`
creadCont . WorkShop = WorkShop //二级部门或车间"`
creadCont . WorkshopSection = WorkshopSection //工段"`
creadCont . Position = postCont . Id //职位"`
creadCont . GradePositions = v . GradePositions //职等"`
startTime := time . Now ( ) . Unix ( )
if v . StartTime != "" {
var startTimeErr bool
startTime , startTimeErr = overallhandle . DateToTimeStamp ( v . StartTime )
if startTimeErr == false {
startTime , _ = overallhandle . DateToTimeStamp ( fmt . Sprintf ( "%v 00:00:00" , v . StartTime ) )
}
}
creadCont . StartTime = startTime //开始日期"`
state := 1
var endTime int64
if v . EndTime != "" {
if v . EndTime != "至今" && v . EndTime != "2199-12-31 00:00:00" && v . EndTime != "2199-12-31" && v . EndTime != "7258003200" {
var endTimeErr bool
endTime , endTimeErr = overallhandle . DateToTimeStamp ( v . EndTime )
if endTimeErr == false {
endTime , _ = overallhandle . DateToTimeStamp ( fmt . Sprintf ( "%v 00:00:00" , v . EndTime ) )
}
state = 2 //状态(1:启用;2:休眠;3:删除)"`
}
}
achangeTypeInted := changeTypeToInt ( v . ChangeType )
if achangeTypeInted > 12 && achangeTypeInted <= 14 {
endTime = time . Now ( ) . Unix ( )
}
creadCont . EndTime = endTime //结束日期"`
creadCont . Team = myCont . TeamId //(1:长白;2:甲;3:乙;4:丙;5:丁)"`
creadCont . ChangeType = changeTypeToInt ( v . ChangeType ) // 变动类型(1:预入职;2:雇佣入职;3:转正;4:晋升;5:降级;6:职等调整;7:调动调入;8:跨公司调动调入;9:借调;10:平调;11:兼职;12:预离职;13:离职;14:退休;15:返聘;16:员工初始化;)"`
creadCont . Time = time . Now ( ) . Unix ( ) //创建时间"`
creadCont . State = state //状态(1:启用;2:禁用;3:删除)"`
creadCont . AssignType = assignTypeToInt ( v . AssignType ) // 1、主职;2:兼职"`
creadAllData = append ( creadAllData , creadCont )
}
}
if len ( creadAllData ) > 1 {
overall . CONSTANT_DB_HR . Create ( & creadAllData )
}
}
}