作者 tangxvhui

更新 上级评估的 列表

... ... @@ -4,7 +4,7 @@ type QueryEvaluationList struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CycleId int `json:"cycleId,string"`
CompanyId int `json:"companyId"`
ExecutorId int `json:"executorId"`
TargetUsrName string `json:"targetUsrName"`
CompanyId int `json:"-"`
ExecutorId int `json:"-"`
TargetUserName string `json:"targetUserName"`
}
... ...
... ... @@ -994,10 +994,40 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
userRepo := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
cnt, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
positionRepo := factory.CreatePositionRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
limit := param.PageSize
offset := (param.PageNumber - 1) * param.PageSize
//获取评估列表信息
condition1 := map[string]interface{}{
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"types": int(domain.EvaluationSuper),
"limit": limit,
}
if offset > 0 {
condition1["offset"] = offset
}
if len(param.TargetUserName) == 0 {
condition1["targetUserName"] = "%" + param.TargetUserName + "%"
}
//获取评估列表信息
cnt, evaluationList, err := evaluationRepo.Find(condition1)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//获取未完成上级评估的数量
cntUn, _, err := evaluationRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"types": int(domain.EvaluationSuper),
"status": domain.EvaluationUncompleted,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1006,21 +1036,109 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
for _, v := range evaluationList {
targetUserIds = append(targetUserIds, v.TargetUser.UserId)
}
var userList []*domain.User
//获取员工的综合自评
evaluationSelfMap := map[int]*domain.SummaryEvaluation{}
for _, v := range evaluationList {
_, evaluationSelfList, err := evaluationRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"executorId": v.TargetUser.UserId,
"types": int(domain.EvaluationSelf),
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取综合自评"+err.Error())
}
if len(evaluationSelfList) > 0 {
evaluationSelfMap[v.TargetUser.UserId] = evaluationSelfList[0]
}
}
//获取员工信息
userMap := map[int64]*domain.User{}
if len(targetUserIds) > 0 {
_, userList, err = userRepo.Find(map[string]interface{}{
_, userList, err := userRepo.Find(map[string]interface{}{
"ids": targetUserIds,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for _, v := range userList {
userMap[v.Id] = v
}
}
var departmentIds []int
//获取部门
departmentMap := map[int64]*domain.Department{}
var positionIds []int
//获取职位列表
positionMap := map[int64]*domain.Position{}
for _, v := range userMap {
departmentIds = append(departmentIds, v.DepartmentId...)
positionIds = append(positionIds, v.PositionId...)
}
if len(departmentIds) > 0 {
_, departmentList, err := departmentRepo.Find(map[string]interface{}{"ids": departmentIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
}
for _, v := range departmentList {
departmentMap[v.Id] = v
}
}
_ = userList
_ = evaluationList
_ = cnt
if len(positionIds) > 0 {
_, positionList, err := positionRepo.Find(map[string]interface{}{"ids": departmentIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
}
for _, v := range positionList {
positionMap[v.Id] = v
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
evaluationListAdapter := []*adapter.EvaluationSuperListAdapter{}
for _, v := range evaluationList {
item := adapter.EvaluationSuperListAdapter{
SummaryEvaluationId: v.Id,
TargetUserName: v.TargetUser.UserName,
EvaluationStatus: string(v.Status),
EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
TotalScoreSelf: "",
Department: "",
Position: "",
EntryTime: "",
}
//填充员工信息
if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok {
//填充部门信息
for _, departId := range targetUser.DepartmentId {
if depart, ok := departmentMap[int64(departId)]; ok {
item.Department += depart.Name + " "
}
}
//填充职位信息
for _, positionId := range targetUser.PositionId {
if position, ok := positionMap[int64(positionId)]; ok {
item.Position += position.Name + " "
}
}
//填充入职时间
item.EntryTime = targetUser.EntryTime
}
//填充自评总分
if evaluationSelf, ok := evaluationSelfMap[v.TargetUser.UserId]; ok {
item.TotalScoreSelf = evaluationSelf.TotalScore
}
evaluationListAdapter = append(evaluationListAdapter, &item)
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), evaluationListAdapter)
result["endTime"] = ""
result["uncompleted_number"] = 0
if len(evaluationList) > 0 {
result["endTime"] = evaluationList[0].EndTime.Format("2006-01-02 15:04:05")
result["uncompleted_number"] = cntUn
}
return result, nil
}
... ...
... ... @@ -144,6 +144,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
query.Where(`summary_evaluation.target_user->>'userId'='?'`, v)
}
if v, ok := queryOptions["targetUserName"]; ok {
query.Where(`summary_evaluation.target_user->>'userName' like ?`, v)
}
if v, ok := queryOptions["executorId"]; ok {
query.Where(`summary_evaluation.executor->>'userId'='?'`, v)
}
... ...
... ... @@ -205,3 +205,19 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() {
data, err := srv.EditEvaluationSuper(param)
c.Response(data, err)
}
func (c *SummaryEvaluationController) ListEvaluationSuper() {
srv := service.NewSummaryEvaluationService()
param := &command.QueryEvaluationList{}
err := c.BindJSON(param)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
param.CompanyId = int(userReq.CompanyId)
param.ExecutorId = int(userReq.UserId)
data, err := srv.ListEvaluationSuper(param)
c.Response(data, err)
}
... ...
... ... @@ -22,6 +22,7 @@ func init() {
web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel),
web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper),
web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper),
web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListEvaluationSuper),
)
web.AddNamespace(summaryNS)
}
... ...