作者 tangxvhui

添加 周期综合评估下,周期评估列表

... ... @@ -10,3 +10,13 @@ type EvaluationSuperListAdapter struct {
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 command
type QueryEvaluationList struct {
// 查询执行人的上级评估列表
type QueryExecutorEvaluationList struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CycleId int `json:"cycleId,string"`
... ... @@ -8,3 +9,12 @@ type QueryEvaluationList struct {
ExecutorId int `json:"-"`
TargetUserName string `json:"targetUserName"`
}
// 查询上级评估列表
type QueryEvaluationList struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CycleId int `json:"cycleId,string"`
CompanyId int `json:"-"`
TargetUserName string `json:"targetUserName"`
}
... ...
... ... @@ -990,8 +990,8 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC
return result, nil
}
// 获取上级评估的列表
func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) {
// 获取执行人的上级评估的列表
func (srv *SummaryEvaluationService) ListExecutorEvaluationSuper(param *command.QueryExecutorEvaluationList) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1011,9 +1011,6 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
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
... ... @@ -1080,28 +1077,15 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
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
}
}
if len(positionIds) > 0 {
_, positionList, err := positionRepo.Find(map[string]interface{}{"ids": departmentIds})
_, positionList, err := positionRepo.Find(map[string]interface{}{"ids": positionIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
}
... ... @@ -1124,14 +1108,11 @@ func (srv *SummaryEvaluationService) ListEvaluationSuper(param *command.QueryEva
Position: "",
EntryTime: "",
}
for _, dep := range v.TargetDepartment {
item.Department += dep.DepartmentName + " "
}
//填充员工信息
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 {
... ... @@ -1310,7 +1291,107 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command
}
// 获取周期综合评估下,周期评估列表
func (srv *SummaryEvaluationService) ListEvalationSuper() (map[int]interface{}, error) {
func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(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 := (param.PageNumber - 1) * param.PageSize
//获取评估列表信息
condition1 := map[string]interface{}{
"cycleId": param.CycleId,
"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())
}
targetUserIds := []int{}
for _, v := range evaluationList {
targetUserIds = append(targetUserIds, v.TargetUser.UserId)
}
return nil, nil
//获取员工信息
userMap := map[int64]*domain.User{}
if len(targetUserIds) > 0 {
_, 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 positionIds []int
//获取职位列表
positionMap := map[int64]*domain.Position{}
for _, v := range userMap {
positionIds = append(positionIds, v.PositionId...)
}
if len(positionIds) > 0 {
_, positionList, err := positionRepo.Find(map[string]interface{}{"ids": positionIds})
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())
}
evaluationListAdapter := []*adapter.EvaluationSuperItemAdapter{}
for _, v := range evaluationList {
item := adapter.EvaluationSuperItemAdapter{
SummaryEvaluationId: v.Id,
TargetUserName: v.TargetUser.UserName,
TargetUserId: v.TargetUser.UserId,
CycleId: v.CycleId,
TotalScore: v.TotalScore,
Department: "",
Position: "",
}
for _, dep := range v.TargetDepartment {
item.Department += dep.DepartmentName + " "
}
//填充员工信息
if targetUser, ok := userMap[int64(v.TargetUser.UserId)]; ok {
//填充职位信息
for _, positionId := range targetUser.PositionId {
if position, ok := positionMap[int64(positionId)]; ok {
item.Position += position.Name + " "
}
}
}
evaluationListAdapter = append(evaluationListAdapter, &item)
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), evaluationListAdapter)
return result, nil
}
... ...
... ... @@ -259,10 +259,10 @@ func (c *SummaryEvaluationController) EditEvaluationSuper() {
c.Response(data, err)
}
// 上级评估列表
func (c *SummaryEvaluationController) ListEvaluationSuper() {
// 执行人的上级评估列表
func (c *SummaryEvaluationController) ListExecutorEvaluationSuper() {
srv := service.NewSummaryEvaluationService()
param := &command.QueryEvaluationList{}
param := &command.QueryExecutorEvaluationList{}
err := c.BindJSON(param)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
... ... @@ -272,7 +272,7 @@ func (c *SummaryEvaluationController) ListEvaluationSuper() {
userReq := middlewares.GetUser(c.Ctx)
param.CompanyId = int(userReq.CompanyId)
param.ExecutorId = int(userReq.UserId)
data, err := srv.ListEvaluationSuper(param)
data, err := srv.ListExecutorEvaluationSuper(param)
c.Response(data, err)
}
... ... @@ -307,3 +307,19 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
data, err := srv.GetTargetUserEvaluationSuper(paramReq)
c.Response(data, err)
}
// 按周期获取上级评估列表
func (c *SummaryEvaluationController) ListAllEvaluationSuper() {
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)
data, err := srv.ListAllEvaluationSuper(param)
c.Response(data, err)
}
... ...
... ... @@ -25,9 +25,10 @@ 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.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper),
web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreSuperEvaluation),
web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper),
web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
//
)
web.AddNamespace(summaryNS)
... ...