@ -2,6 +2,7 @@ package dutyassess
import (
import (
"encoding/json"
"encoding/json"
"fmt"
"strconv"
"strconv"
"strings"
"strings"
"time"
"time"
@ -711,3 +712,284 @@ func (d *DutyAssessApi) EiteDepartForDuty(c *gin.Context) {
response . Result ( 0 , sunTargetId , "编辑成功!" , c )
response . Result ( 0 , sunTargetId , "编辑成功!" , c )
}
}
//查看考核方案
func ( d * DutyAssessApi ) LookDepartDutyVersio ( c * gin . Context ) {
var requestData LookDutyVersio
err := c . ShouldBindJSON ( & requestData )
if err != nil {
response . Result ( 101 , err , "数据获取失败!" , c )
return
}
if requestData . Key == "" {
response . Result ( 102 , err , "数据获取失败!" , c )
return
}
//获取考核方案
var assessTargetContent assessmentmodel . PlanVersio
planVersioErr := global . GVA_DB_Performanceappraisal . Where ( "`key` = ?" , requestData . Key ) . First ( & assessTargetContent ) . Error
if planVersioErr != nil {
response . Result ( 103 , planVersioErr , "数据获取失败!" , c )
return
}
var uotContAry [ ] TargetContOutCont
if assessTargetContent . Content != "" {
var planVersioInfo [ ] AddDutyNewCont
jsonErr := json . Unmarshal ( [ ] byte ( assessTargetContent . Content ) , & planVersioInfo )
if jsonErr == nil {
for _ , pv := range planVersioInfo {
for _ , pvChild := range pv . Child {
var uotCont TargetContOutCont
//集团
uotCont . Group = strconv . FormatInt ( assessTargetContent . Group , 10 )
where := commonus . MapOut ( )
where [ "id" ] = assessTargetContent . Group
orgCont , _ := commonus . GetNewOrgCont ( where , "id" , "name" )
uotCont . GroupNAme = orgCont . Name
//维度
uotCont . Id = pvChild . Id
uotCont . Dimension = pv . Id
uotCont . DimensionName = pv . Name
uotCont . DimensionWeight = int64 ( pv . ZhiFraction )
//指标
uotCont . Target = pvChild . Id
uotCont . TargetName = pvChild . Name
uotCont . TargetWeight = pvChild . ReferenceScore
uotCont . Unit = pvChild . Unit
uotCont . Content = pvChild . Content
uotCont . State = pvChild . State
//获取指标内容
var evalTargerCont assessmentmodel . EvaluationTarget
evalErr := global . GVA_DB_Performanceappraisal . Where ( "`et_id` = ?" , pvChild . Id ) . First ( & evalTargerCont ) . Error
if evalErr == nil {
uotCont . Type = evalTargerCont . Type
uotCont . Cycles = evalTargerCont . Cycles
uotCont . CycleAttres = evalTargerCont . CycleAttres
// if uotCont.Type == 1 {
// } else {
// }
//获取执行人
uotCont . UserListAry , _ = getQualEvalUser ( requestData . Key , pv . Id , pvChild . Id )
}
uotCont . QualEvalId = requestData . Key
uotContAry = append ( uotContAry , uotCont )
}
}
} else {
var uotErr bool = false
uotContAry , uotErr = getLookAssessQualEvalList ( requestData . Key )
if uotErr == false {
response . Result ( 103 , uotErr , "数据获取失败!" , c )
return
}
}
} else {
var uotErr bool = false
uotContAry , uotErr = getLookAssessQualEvalList ( requestData . Key )
if uotErr == false {
response . Result ( 103 , uotErr , "数据获取失败!" , c )
return
}
}
// var uotErr bool = false
// uotContAry, uotErr = getLookAssessQualEvalList(requestData.Key)
// if uotErr == false {
// return
// }
response . Result ( 0 , uotContAry , "数据获取成功!" , c )
}
//获取执行人
/ *
@ key 版本号码
@ dimensionId 维度
@ targetId 指标
* /
func getQualEvalUser ( key , dimensionId , targetId string ) ( userContAry [ ] QualEvalArrt , istrue bool ) {
istrue = false
var qualEvalCont [ ] assessmentmodel . QualitativeEvaluation
listTargetErr := global . GVA_DB_Performanceappraisal . Select ( "qe_operator" ) . Where ( "`qe_dimension` = ? AND `qe_target` = ? AND `qe_qual_eval_id` = ?" , dimensionId , targetId , key ) . Find ( & qualEvalCont ) . Error
if listTargetErr != nil {
return
}
var userKey [ ] string
for _ , v := range qualEvalCont {
//判断执行人是否为空
if v . Operator != "" {
//解析执行人数值
userCont := strings . Split ( v . Operator , "," )
if len ( userCont ) > 0 {
for _ , uv := range userCont {
//判断执行人是否已经存在
if commonus . IsItTrueString ( uv , userKey ) == false {
userKey = append ( userKey , uv )
}
}
}
}
}
//获取执行人信息
if len ( userKey ) > 0 {
for _ , ukv := range userKey {
usWhere := commonus . MapOut ( )
usWhere [ "`key`" ] = ukv
usCont , usErr := commonus . GetNewHrPeopleInfo ( usWhere , "`number`" , "`name`" , "`company`" , "`deparment`" , "`icon`" )
if usErr == true {
var userCont QualEvalArrt
userCont . Id = ukv
userCont . Name = usCont . Name
userCont . Icon = usCont . Icon
where := commonus . MapOut ( )
where [ "id" ] = usCont . Company
orgCont , _ := commonus . GetNewOrgCont ( where , "id" , "name" )
userCont . GroupName = orgCont . Name
whereDepart := commonus . MapOut ( )
whereDepart [ "id" ] = usCont . Deparment
orgContDepart , _ := commonus . GetNewOrgCont ( whereDepart , "id" , "name" )
userCont . DepartmentName = orgContDepart . Name
// _, groupInfo := commonus.GetGroupCont(usCont.Group)
// userCont.GroupName = groupInfo.Name
// _, bfInfo := commonus.GetBranchFactory(usCont.DepartmentId)
// userCont.DepartmentName = bfInfo.Name
userCont . Number = usCont . Number
userContAry = append ( userContAry , userCont )
}
}
}
return
}
//获取部门考核项目
func getLookAssessQualEvalList ( Key string ) ( uotContAry [ ] TargetContOutCont , errMsg bool ) {
errMsg = false
var qualitativeEvaluationAry [ ] assessmentmodel . QualitativeEvaluation
listTargetErr := global . GVA_DB_Performanceappraisal . Select ( "qualitative_evaluation.*,dutyclass.sort" ) . Where ( "`qe_state` IN (1,2) AND `qe_qual_eval_id` = ?" , Key ) . Joins ( "left join dutyclass on id = qe_dimension" ) . Order ( "qe_group asc,qe_accept_evaluation asc,sort asc,qe_type asc,qe_target asc,qe_target_sun asc" ) . Find ( & qualitativeEvaluationAry ) . Error
if listTargetErr != nil || len ( qualitativeEvaluationAry ) < 1 {
return
}
// var uotContAry []TargetContOutCont
for _ , v := range qualitativeEvaluationAry {
var uotCont TargetContOutCont
uotCont . Id = strconv . FormatInt ( v . Id , 10 )
uotCont . Type = v . Type
uotCont . Group = strconv . FormatInt ( v . Group , 10 )
where := commonus . MapOut ( )
where [ "id" ] = v . Group
orgCont , _ := commonus . GetNewOrgCont ( where , "id" , "name" )
uotCont . GroupNAme = orgCont . Name
whereDepart := commonus . MapOut ( )
whereDepart [ "id" ] = v . AcceptEvaluation
orgContDepart , _ := commonus . GetNewOrgCont ( whereDepart , "id" , "name" )
uotCont . DepartmentName = orgContDepart . Name
// groupErr, groupCont := commonus.GetGroupCont(v.Group)
// if groupErr == true {
// uotCont.GroupNAme = groupCont.Name
// }
uotCont . DepartmentId = strconv . FormatInt ( v . AcceptEvaluation , 10 )
// deparConErr, deparConCont := commonus.GetBranchFactory(v.AcceptEvaluation)
// if deparConErr == true {
// uotCont.DepartmentName = deparConCont.Name
// }
uotCont . Dimension = strconv . FormatInt ( v . Dimension , 10 )
dutyClassCont , dutyClassErr := commonus . GetDutyClassInfo ( v . Dimension )
if dutyClassErr == true {
uotCont . DimensionName = dutyClassCont . Title
}
uotCont . DimensionWeight = commonus . GetDimesionTargetWeight ( 1 , v . Group , v . AcceptEvaluation , v . Dimension , 0 )
uotCont . Target = strconv . FormatInt ( v . Target , 10 )
targetInfo , targetErr := commonus . GetTargetInfo ( v . Target )
if targetErr == true {
uotCont . TargetName = targetInfo . Title
}
uotCont . TargetWeight = commonus . GetDimesionTargetWeight ( 2 , v . Group , v . AcceptEvaluation , v . Dimension , v . Target )
uotCont . TargetSun = strconv . FormatInt ( v . TargetSun , 10 )
info , infoErr := commonus . GetQualitativeTargetInfo ( v . TargetSun )
if infoErr == true {
uotCont . TargetSunName = info . Title
}
uotCont . DetailedTarget = strconv . FormatInt ( v . DetailedTarget , 10 )
dtCont , dtIsTrue := commonus . GetDetailedTargetInfo ( v . DetailedTarget )
if dtIsTrue == true {
uotCont . DetailedTargetName = dtCont . Title
if v . Content == "" {
uotCont . Content = dtCont . Content
} else {
uotCont . Content = v . Content
}
} else {
uotCont . Content = v . Content
}
uotCont . QualEvalId = v . QualEvalId
uotCont . Unit = v . Unit
uotCont . ReferenceScore = v . ReferenceScore
uotCont . Cycles = v . Cycles
uotCont . CycleAttres = v . CycleAttres
uotCont . State = v . State
userAry := strings . Split ( v . Operator , "," )
uotCont . UserList = userAry
for _ , u_v := range userAry {
// usCont, usErr := archiveapi.GetUserInfo([]string{"worker_man.wm_number", "worker_man_data.wmd_name"}, map[string]interface{}{"wm_key": u_v})
// if usErr == true {
// var userCont QualEvalArrt
// userCont.Id = u_v
// userCont.Name = usCont.Name
// uotCont.UserListAry = append(uotCont.UserListAry, userCont)
// }
usCont , usErr := commonus . GetWorkUser ( u_v )
// GetWorkUser
if usErr == true {
var userCont QualEvalArrt
userCont . Id = u_v
userCont . Name = usCont . Name
userCont . Icon = usCont . Icon
where := commonus . MapOut ( )
where [ "id" ] = usCont . Group
orgCont , _ := commonus . GetNewOrgCont ( where , "id" , "name" )
userCont . GroupName = orgCont . Name
whereDepart := commonus . MapOut ( )
whereDepart [ "id" ] = usCont . DepartmentId
orgContDepart , _ := commonus . GetNewOrgCont ( whereDepart , "id" , "name" )
userCont . DepartmentName = orgContDepart . Name
// _, groupInfo := commonus.GetGroupCont(usCont.Group)
// userCont.GroupName = groupInfo.Name
// _, bfInfo := commonus.GetBranchFactory(usCont.DepartmentId)
// userCont.DepartmentName = bfInfo.Name
userCont . Number = usCont . Number
uotCont . UserListAry = append ( uotCont . UserListAry , userCont )
}
}
if v . MinScore > 0 && v . MaxScore > 0 {
uotCont . MinOrMaxScore = fmt . Sprintf ( "%v-%v" , float64 ( v . MinScore ) / 100 , float64 ( v . MaxScore ) / 100 )
} else if v . MinScore > 0 && v . MaxScore <= 0 {
uotCont . MinOrMaxScore = fmt . Sprintf ( "%v" , float64 ( v . MinScore ) / 100 )
} else if v . MinScore <= 0 && v . MaxScore > 0 {
uotCont . MinOrMaxScore = fmt . Sprintf ( "%v" , float64 ( v . MaxScore ) / 100 )
} else {
uotCont . MinOrMaxScore = "0"
}
uotCont . DetailedTarget = strconv . FormatInt ( v . DetailedTarget , 10 )
uotContAry = append ( uotContAry , uotCont )
}
errMsg = true
return
}