作者 tangxvhui

日常保存

... ... @@ -11,6 +11,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
//获取我的项目周期列表
... ... @@ -510,7 +511,7 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//获取目标用户
userIds := []int{}
for _, v := range assessList {
userIds = append(userIds, v.TargetUser.UserId)
... ... @@ -540,33 +541,26 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
})
userPositionMap[v.Id] = positionList
}
//获取员工邀请的人完成360评估的数量
//获取目标员工邀请的人完成360评估的数量
var inviteCompletedCount []dao.CountData
if len(userIds) > 0 {
// d := dao.NewStaffAssessDao(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId)
// if err != nil {
// log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
// }
}
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
d := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
if len(userIds) > 0 {
inviteCompletedCount, err = d.CountTargetUserInviteAssess1(userIds, param.CycleId, param.BeginDay)
if err != nil {
log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
}
}
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"status": string(domain.StaffAssessUncompleted),
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
... ... @@ -616,15 +610,9 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
resultList = append(resultList, item)
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
result["linkNodeName"] = ""
result["linkNodeId"] = ""
result["lintNodeDesc"] = ""
for _, v := range assessTaskData.StepList {
if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
result["linkNodeName"] = v.LinkNodeName
result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId)
result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
if len(assessList) > 0 {
result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
return result, nil
}
... ...
... ... @@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
return result, err
}
func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int, beginDay string) ([]CountData, error) {
sqlStr := `SELECT
staff_assess.target_user->>'userId' as target_user_id,
count(staff_assess."id") AS invite_total,
sum(
case WHEN staff_assess.status='completed' THEN 1
ELSE 0 END
) as invite_completed
FROM staff_assess
WHERE staff_assess.target_user->>'userId' IN(?)
AND staff_assess.types IN ('invite_same_super','invite_diff_super')
and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') = ?
and staff_assess.cycle_id =?
GROUP BY target_user_id`
userIdStr := []string{}
for _, v := range userIds {
str := strconv.Itoa(v)
userIdStr = append(userIdStr, str)
}
condition := []interface{}{
pg.In(userIdStr), beginDay, cycleId,
}
tx := d.transactionContext.PgTx
result := []CountData{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
// 根据评估的人执行人id,搜索 executorId参与的评估任务
func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
... ...