...
|
...
|
@@ -231,105 +231,250 @@ func (srv StaffAssessServeice) QueryMemberPerformanceIndicator(in *query.MemberP |
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
var projectItemUsed = map[int][]*domain.EvaluationItemUsed{} // 项目ID-> 评估内容项
|
|
|
var userProjectMap = map[int][]*dao.IndicatorUserProject{} // 用户ID-> 用户评估的项目(用户在周期内可能有多个项目模板,激活状态只能是1个)
|
|
|
var projectIds = make([]int, 0)
|
|
|
|
|
|
if len(in.UserIds) > 0 {
|
|
|
staffAssessRepository := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, assessList, err := staffAssessRepository.Find(map[string]interface{}{
|
|
|
"cycleId": in.CycleId,
|
|
|
"targetUserIds": in.UserIds,
|
|
|
"types": domain.AssessSelf,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
projectIdsMap := map[int]int{}
|
|
|
for i := range assessList {
|
|
|
it := assessList[i]
|
|
|
projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId
|
|
|
|
|
|
// 用户存在多个项目模板
|
|
|
array, ok := userProjectMap[it.TargetUser.UserId]
|
|
|
if !ok {
|
|
|
array = make([]*dao.IndicatorUserProject, 0)
|
|
|
}
|
|
|
userProjectMap[it.TargetUser.UserId] = append(array, &dao.IndicatorUserProject{
|
|
|
AssessId: it.Id,
|
|
|
EvaluationProjectId: it.EvaluationProjectId,
|
|
|
TargetUserId: it.TargetUser.UserId,
|
|
|
TargetUserName: it.TargetUser.UserName,
|
|
|
})
|
|
|
}
|
|
|
for k, _ := range projectIdsMap {
|
|
|
projectIds = append(projectIds, k)
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
list, err := assessDao.MemberAllProjectId(
|
|
|
in.CompanyId,
|
|
|
in.UserName,
|
|
|
in.OperatorId,
|
|
|
in.CycleId,
|
|
|
hrbp)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
projectIdsMap := map[int]int{}
|
|
|
for i := range list {
|
|
|
it := list[i]
|
|
|
projectIdsMap[it.EvaluationProjectId] = it.EvaluationProjectId
|
|
|
|
|
|
// 用户存在多个项目模板
|
|
|
array, ok := userProjectMap[it.TargetUserId]
|
|
|
if !ok {
|
|
|
array = make([]*dao.IndicatorUserProject, 0)
|
|
|
}
|
|
|
userProjectMap[it.TargetUserId] = append(array, &it)
|
|
|
}
|
|
|
|
|
|
for k, _ := range projectIdsMap {
|
|
|
projectIds = append(projectIds, k)
|
|
|
}
|
|
|
}
|
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
list, err := assessDao.MemberPerformanceIndicator(
|
|
|
in.UserName,
|
|
|
in.CompanyId,
|
|
|
in.OperatorId,
|
|
|
in.CycleId,
|
|
|
hrbp,
|
|
|
string(domain.AssessSelf),
|
|
|
in.UserIds)
|
|
|
if err != nil {
|
|
|
|
|
|
// 项目ID->查询所有评估项
|
|
|
if len(projectIds) > 0 {
|
|
|
itemUsedRepository := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
_, itemList, err := itemUsedRepository.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
for i := range itemList {
|
|
|
it := itemList[i]
|
|
|
array, ok := projectItemUsed[it.EvaluationProjectId]
|
|
|
if !ok {
|
|
|
array = make([]*domain.EvaluationItemUsed, 0)
|
|
|
}
|
|
|
projectItemUsed[it.EvaluationProjectId] = append(array, it)
|
|
|
}
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// (全部周期数据)筛选出第一个周期的数据,减少后续数据遍历
|
|
|
dupleMap := map[string]string{}
|
|
|
dupleList := make([]dao.PerformanceIndicatorAssess, 0)
|
|
|
for i := range list {
|
|
|
it := list[i]
|
|
|
if v, ok := dupleMap[it.TargetUserId]; ok {
|
|
|
if v == it.BeginDay {
|
|
|
dupleList = append(dupleList, it)
|
|
|
adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
|
|
|
categoryMap := map[string]int{} // 内容分类
|
|
|
for i := range in.UserIds {
|
|
|
userId := in.UserIds[i]
|
|
|
userIdInt, err := strconv.Atoi(userId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
iupArray, ok := userProjectMap[userIdInt]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
var pia = &adapter.PerformanceIndicatorAdapter{
|
|
|
TargetUserId: userId,
|
|
|
TargetUserName: iupArray[0].TargetUserName,
|
|
|
PIContents: make([]adapter.PIContent, 0),
|
|
|
}
|
|
|
adapterList = append(adapterList, pia)
|
|
|
for _, assess := range iupArray {
|
|
|
items, ok := projectItemUsed[assess.EvaluationProjectId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
} else {
|
|
|
// 有内容分类,才算正常数据,反之不显示
|
|
|
if len(it.ContentCategory) > 0 {
|
|
|
dupleMap[it.TargetUserId] = it.BeginDay
|
|
|
dupleList = append(dupleList, it)
|
|
|
for _, item := range items {
|
|
|
if len(item.Category) == 0 {
|
|
|
continue
|
|
|
}
|
|
|
onlyKey1 := userId + item.Category
|
|
|
if _, ok := categoryMap[onlyKey1]; !ok {
|
|
|
categoryMap[onlyKey1] = 0
|
|
|
// 不存在分类时,创建分类内容
|
|
|
pia.PIContents = append(pia.PIContents, adapter.PIContent{
|
|
|
Category: item.Category,
|
|
|
Names: make([]string, 0),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 内容名称有值合并到数组
|
|
|
if len(item.Name) > 0 {
|
|
|
for index := range pia.PIContents {
|
|
|
piContent := &pia.PIContents[index]
|
|
|
if piContent.Category == item.Category {
|
|
|
piContent.Names = append(piContent.Names, item.Name)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
piaMap := map[string]*adapter.PerformanceIndicatorAdapter{}
|
|
|
categoryMap := map[string]int{} // 内容分类
|
|
|
//categoryNameMap := map[string]int{} // 内容分类下的名称
|
|
|
/*
|
|
|
// 旧版(如果未填写自评会出现数据评估项丢失的BUG)
|
|
|
hrbp, err := srv.getHRBP(transactionContext, in.CompanyId, in.OperatorId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
|
|
|
for i := range dupleList {
|
|
|
it := dupleList[i]
|
|
|
|
|
|
var pia *adapter.PerformanceIndicatorAdapter
|
|
|
if v, ok := piaMap[it.TargetUserId]; ok {
|
|
|
pia = v
|
|
|
} else {
|
|
|
pia = &adapter.PerformanceIndicatorAdapter{
|
|
|
TargetUserId: it.TargetUserId,
|
|
|
TargetUserName: it.TargetUserName,
|
|
|
PIContents: make([]adapter.PIContent, 0),
|
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
list, err := assessDao.MemberPerformanceIndicator(
|
|
|
in.UserName,
|
|
|
in.CompanyId,
|
|
|
in.OperatorId,
|
|
|
in.CycleId,
|
|
|
hrbp,
|
|
|
string(domain.AssessSelf),
|
|
|
in.UserIds)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// (全部周期数据)筛选出第一个周期的数据,减少后续数据遍历
|
|
|
dupleMap := map[string]string{}
|
|
|
dupleList := make([]dao.PerformanceIndicatorAssess, 0)
|
|
|
for i := range list {
|
|
|
it := list[i]
|
|
|
if v, ok := dupleMap[it.TargetUserId]; ok {
|
|
|
if v == it.BeginDay {
|
|
|
dupleList = append(dupleList, it)
|
|
|
}
|
|
|
} else {
|
|
|
// 有内容分类,才算正常数据,反之不显示
|
|
|
if len(it.ContentCategory) > 0 {
|
|
|
dupleMap[it.TargetUserId] = it.BeginDay
|
|
|
dupleList = append(dupleList, it)
|
|
|
}
|
|
|
}
|
|
|
piaMap[it.TargetUserId] = pia
|
|
|
adapterList = append(adapterList, pia)
|
|
|
}
|
|
|
|
|
|
// 分类名称有值才能合并分类数组
|
|
|
if len(it.ContentCategory) > 0 {
|
|
|
onlyKey1 := it.TargetUserId + it.ContentCategory
|
|
|
if _, ok := categoryMap[onlyKey1]; !ok {
|
|
|
categoryMap[onlyKey1] = 0
|
|
|
|
|
|
// 不存在分类时,创建分类内容
|
|
|
pia.PIContents = append(pia.PIContents, adapter.PIContent{
|
|
|
Category: it.ContentCategory,
|
|
|
Names: make([]string, 0),
|
|
|
})
|
|
|
piaMap := map[string]*adapter.PerformanceIndicatorAdapter{}
|
|
|
categoryMap := map[string]int{} // 内容分类
|
|
|
//categoryNameMap := map[string]int{} // 内容分类下的名称
|
|
|
|
|
|
adapterList := make([]*adapter.PerformanceIndicatorAdapter, 0)
|
|
|
for i := range dupleList {
|
|
|
it := dupleList[i]
|
|
|
|
|
|
var pia *adapter.PerformanceIndicatorAdapter
|
|
|
if v, ok := piaMap[it.TargetUserId]; ok {
|
|
|
pia = v
|
|
|
} else {
|
|
|
pia = &adapter.PerformanceIndicatorAdapter{
|
|
|
TargetUserId: it.TargetUserId,
|
|
|
TargetUserName: it.TargetUserName,
|
|
|
PIContents: make([]adapter.PIContent, 0),
|
|
|
}
|
|
|
piaMap[it.TargetUserId] = pia
|
|
|
adapterList = append(adapterList, pia)
|
|
|
}
|
|
|
|
|
|
// 内容名称有值合并到数组
|
|
|
if len(it.ContentName) > 0 {
|
|
|
// 周期筛选过的,不再需要唯一值验证判断,直接添加到对应的分类下
|
|
|
for index := range pia.PIContents {
|
|
|
piContent := &pia.PIContents[index]
|
|
|
if piContent.Category == it.ContentCategory {
|
|
|
piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
break
|
|
|
// 分类名称有值才能合并分类数组
|
|
|
if len(it.ContentCategory) > 0 {
|
|
|
onlyKey1 := it.TargetUserId + it.ContentCategory
|
|
|
if _, ok := categoryMap[onlyKey1]; !ok {
|
|
|
categoryMap[onlyKey1] = 0
|
|
|
|
|
|
// 不存在分类时,创建分类内容
|
|
|
pia.PIContents = append(pia.PIContents, adapter.PIContent{
|
|
|
Category: it.ContentCategory,
|
|
|
Names: make([]string, 0),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 内容名称有值合并到数组
|
|
|
if len(it.ContentName) > 0 {
|
|
|
// 周期筛选过的,不再需要唯一值验证判断,直接添加到对应的分类下
|
|
|
for index := range pia.PIContents {
|
|
|
piContent := &pia.PIContents[index]
|
|
|
if piContent.Category == it.ContentCategory {
|
|
|
piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
//onlyKey2 := it.TargetUserId + it.ContentCategory + it.ContentName
|
|
|
//if _, ok := categoryNameMap[onlyKey2]; !ok {
|
|
|
// categoryNameMap[onlyKey2] = 0
|
|
|
//
|
|
|
// for index := range pia.PIContents {
|
|
|
// piContent := pia.PIContents[index]
|
|
|
// if piContent.Category == it.ContentCategory {
|
|
|
// piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
// break
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
//onlyKey2 := it.TargetUserId + it.ContentCategory + it.ContentName
|
|
|
//if _, ok := categoryNameMap[onlyKey2]; !ok {
|
|
|
// categoryNameMap[onlyKey2] = 0
|
|
|
//
|
|
|
// for index := range pia.PIContents {
|
|
|
// piContent := pia.PIContents[index]
|
|
|
// if piContent.Category == it.ContentCategory {
|
|
|
// piContent.Names = append(piContent.Names, it.ContentName)
|
|
|
// break
|
|
|
// }
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
*/
|
|
|
//if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
//}
|
|
|
|
|
|
return tool_funs.SimpleWrapGridMap(int64(len(adapterList)), adapterList), nil
|
|
|
}
|
...
|
...
|
@@ -374,8 +519,7 @@ func (srv StaffAssessServeice) ExportPerformanceIndicator(in *query.ExportPerfor |
|
|
for i := range list {
|
|
|
it := list[i]
|
|
|
if v, ok := selectedMap[it.TargetUserId]; ok {
|
|
|
v.UserName = it.TargetUserName
|
|
|
|
|
|
//v.UserName = it.TargetUserName
|
|
|
if v.Category == it.ContentCategory && v.Name == it.ContentName {
|
|
|
conditionList = append(conditionList, it)
|
|
|
conditionMap[it.TargetUserId+it.BeginDay] = it
|
...
|
...
|
|