作者 tangxvhui

更新

... ... @@ -4,22 +4,31 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
// 评估信息详情
type EvaluationInfoAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //
CycleId int `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
TargetUserId int `json:"targetUserId"` //被评估的目标用户,被执行的
TargetUserName string `json:"targetUserName"` //
CompanyLogo string `json:"companyLogo"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间
Status string `json:"status"` //完成状态
EvaluationItems []EvaluationItemAdapter `json:"evaluationItems"`
EvaluationBaseAdapter
EvaluationItems []EvaluationItemAdapter `json:"evaluationItems"`
}
// 评估任务的基本信息
type EvaluationBaseAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //
CycleId int `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的
TargetUserName string `json:"targetUserName"` //
CompanyLogo string `json:"companyLogo,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
Types int `json:"types"` //评估类型
DutyTime string `json:"dutyTime"` //入职时间
Status string `json:"status"` //完成状态
CheckResult string `json:"checkResult"` //确认绩效结果
TotalScore string `json:"totalScore"` //评估总分
Version string `json:"version"` //评估填写方式
}
// 评估填写项
... ... @@ -51,29 +60,6 @@ type LevalCodeCount struct {
ItemList []string `json:"itemList"` //对应的评估项名称
}
// 评估任务的基本信息
type EvaluationBaseAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //
CycleId int `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
LinkNodeId int `json:"linkNodeId,string"` //评估环节id
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的
TargetUserName string `json:"targetUserName"` //
CompanyLogo string `json:"companyLogo,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
Types int `json:"types"` //评估类型
DutyTime string `json:"dutyTime"` //入职时间
Status string `json:"status"` //完成状态
CheckResult string `json:"checkResult"` //确认绩效结果
TotalScore string `json:"totalScore"` //评估总分
Version string `json:"version"` //评估填写方式
}
// 自评估内容详情
type EvaluationInfoSelfAdapter struct {
EvaluationBaseAdapter
... ...
package adapter
type EvaluationSuperListAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id
TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工
TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工
EvaluationStatus string `json:"evaluationStatus"` //上级评估完成状态
EndTime string `json:"endTime"` //截止时间
TotalScoreSelf string `json:"totalScoreSelf"` //综合自评总分
TotalScoreSuper string `json:"totalScoreSuper"` //综合自评总分
Department string `json:"department"` //部门
Position string `json:"position"` //职位
EntryTime string `json:"entryTime"` //入职时间
}
type EvaluationSuperItemAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id
TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工
TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工
CycleId int64 `json:"cycleId,string"` //周期id
TotalScore string `json:"totalScore"` //得分
Department string `json:"department"` //部门
Position string `json:"position"` //职位
}
... ...
package adapter
// 获取周期评估的列表 ,根据页面需要提供不同的结构变体
// 获取执行人的上级评估的列表
type EvaluationSuperListAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id
TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工
TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工
EvaluationStatus string `json:"evaluationStatus"` //上级评估完成状态
EndTime string `json:"endTime"` //截止时间
TotalScoreSelf string `json:"totalScoreSelf"` //综合自评总分
TotalScoreSuper string `json:"totalScoreSuper"` //综合自评总分
Department string `json:"department"` //部门
Position string `json:"position"` //职位
EntryTime string `json:"entryTime"` //入职时间
}
// 绩效分析-周期评估
// 按周期获取所有员工的评估考核结果
type EvaluationSuperItemAdapter struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"` //评估任务id
TargetUserName string `json:"targetUserName"` //目标用户,被评估的员工
TargetUserId int `json:"targetUserId,string"` //目标用户,被评估的员工
CycleId int64 `json:"cycleId,string"` //周期id
TotalScore string `json:"totalScore"` //得分
Department string `json:"department"` //部门
Position string `json:"position"` //职位
}
// 人资稽查-页面列表展示
type EvaluationItemAdapter2 struct {
EvaluationId int `json:"evaluationId"` // 周期评估id
CycleId int `json:"cycleId"` // 周期id
TargetUserId int `json:"targetUserId,string"` // 目标用户ID
TargetUserName string `json:"targetUserName"` // 目标用户名称
Department string `json:"departmentVal"` // 部门(拼接文本)
Position string `json:"positionVal"` // 职位(拼接文本)
DutyTime string `json:"dutyTime"` // 入职时间(2006-01-02 15:04)
Status string `json:"statusVal"` // 完成状态(拼接文本)
EndTime string `json:"endTime"` // 截止时间(2006-01-02 15:04)
OverdueCount int `json:"overdueCount"` // 自评逾期次数
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 评估信息详情 根据页面需要提供不同的结构变体
// 人资稽查-页面列表,获取详情 用于编辑展示
func (srv *SummaryEvaluationService) GetEvaluationShow1(param command.QueryEvaluation) (result *adapter.EvaluationInfoAdapter, err error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//每个人员每个周期的评估目录
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
// 评估的填写值
evaluationValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
//评估用到的题目
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
var evaluationList []*domain.SummaryEvaluation
_, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.EvaluationSuper,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 查找上级评估数据
// 如果没有就查找 360 或人资评估数据
if len(evaluationList) == 0 {
_, evaluationList, err = evaluationRepo.Find(map[string]interface{}{
"limit": 500,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"typesList": []int{int(domain.EvaluationHrbp), int(domain.Evaluation360)},
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if len(evaluationList) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "该人员没有上级评估、人资评估、360评估。")
}
var evaluationIds []int64
for _, val := range evaluationList {
evaluationIds = append(evaluationIds, int64(val.Id))
}
_, evaluationValueList, err := evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationProjectId := evaluationList[0].EvaluationProjectId
//获取所有题目
_, itemUsedList, err := itemUsedRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
// 获取组装基本信息
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationList[0])
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemUsedList, evaluationValueList)
result = &adapter.EvaluationInfoAdapter{
EvaluationBaseAdapter: evaluationBase,
EvaluationItems: itemValuesAdapter,
}
return
}
... ...
package service
import (
"fmt"
"strings"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
//获取周期评估的列表 ,根据页面需要提供不同的结构变体
// 人资稽查 页面列表数据输出
// 根据周期id 获取类型为"上级评估" 的全部周期评估
func (srv *SummaryEvaluationService) ListEvaluationShow1(param command.QueryEvaluationList) (result map[string]interface{}, err error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 必须是HRBP权限的人才能编辑操作
hrbp, err := roleService.GetHrBp(transactionContext, param.CompanyId, param.UserId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if hrbp != domain.RoleTypeSystem {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
limit := param.PageSize
offset := limit * (param.PageNumber - 1)
if offset < 0 {
offset = 0
}
condition := map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"types": domain.EvaluationSelf,
"limit": limit,
"offset": offset,
}
if len(param.TargetUserName) > 0 {
condition["targetUserName"] = "%" + param.TargetUserName + "%"
}
count, list, err := evaluationRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
userIds := make([]int, 0)
projectIds := make([]int, 0)
projectCountMap := map[string]int{} // 自评逾期数量
userMap := map[int64]*domain.User{} // 用户
positionMap := map[int64]*domain.Position{} // 职位
for i := range list {
it := list[i]
userIds = append(userIds, it.TargetUser.UserId)
projectIds = append(projectIds, list[i].EvaluationProjectId)
}
if len(userIds) > 0 {
_, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
positionIds := make([]int, 0)
for i := range users {
userMap[users[i].Id] = users[i]
positionIds = append(positionIds, users[i].PositionId...)
}
if len(positionIds) > 0 {
_, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range positions {
positionMap[positions[i].Id] = positions[i]
}
}
}
if len(projectIds) > 0 {
targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range targetCount {
key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
projectCountMap[key] = targetCount[i].Cnt
}
}
now := time.Now().Local() // 当前时间
resultList := make([]*adapter.EvaluationItemAdapter2, 0)
for i := range list {
v := list[i]
endTime := v.EndTime.Local()
// 状态
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
} else {
if now.After(endTime) {
statusVal = "已逾期"
} else {
statusVal = "待完成"
}
}
// 部门拼接
var departmentBuild strings.Builder
departmentBuild.WriteString("")
for i2 := range v.TargetDepartment {
departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
if i2 != len(v.TargetDepartment)-1 {
departmentBuild.WriteString(",")
}
}
// 入职时间
entryTime := ""
// 职位拼接
var positionBuild strings.Builder
positionBuild.WriteString("")
if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
for i2 := range user.PositionId {
if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
positionBuild.WriteString(position.Name)
if i2 != len(user.PositionId)-1 {
departmentBuild.WriteString(",")
}
}
}
entryTime = user.EntryTime
}
// 自评逾期数量
overdueCount := 0
key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
if cnt, ok := projectCountMap[key]; ok {
overdueCount = cnt
}
result := &adapter.EvaluationItemAdapter2{
CycleId: int(v.CycleId),
EvaluationId: v.Id,
TargetUserId: v.TargetUser.UserId,
TargetUserName: v.TargetUser.UserName,
Department: departmentBuild.String(),
Position: positionBuild.String(),
DutyTime: entryTime,
Status: statusVal,
EndTime: endTime.Local().Format("2006-01-02 15:04"),
OverdueCount: overdueCount,
}
resultList = append(resultList, result)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 外层显示截止时间
endTime := ""
if len(list) > 0 {
endTime = list[0].EndTime.Local().Format("2006-01-02 15:04:05")
}
grid := tool_funs.SimpleWrapGridMap(int64(count), resultList)
grid["endTime"] = endTime
return grid, nil
}
... ...
... ... @@ -748,7 +748,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval
return &result, nil
}
// 获取执行人的上级评估的列表
// 获取执行人的上级评估的列表 ,当前登录用户可以填写哪些评估
func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.QueryExecutorEvaluationList) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -1239,6 +1239,7 @@ func (srv *SummaryEvaluationService) GetTargetEvaluationResult(param *command.Qu
return &eiAdapter, nil
}
// 绩效分析-周期评估
// 按周期获取所有员工的评估考核结果
func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.QueryEvaluationList) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ...
... ... @@ -211,6 +211,7 @@ func (c *SummaryEvaluationController) EditEvaluation360() {
c.Response(data, err)
}
// 获取人资综评列表
func (c *SummaryEvaluationController) EvaluationHRBPList() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRList{}
... ... @@ -227,6 +228,7 @@ func (c *SummaryEvaluationController) EvaluationHRBPList() {
c.Response(data, err)
}
// 获取人资综评详情
func (c *SummaryEvaluationController) GetEvaluationHRBP() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRBPMy{}
... ...