作者 tangxvhui

剔除 过期的api

package adapter
type AssessAnalysisResp struct {
GroupList []string //评估指标项列表
Uncomplete []string // 未完成填写评估的员工
Complete map[string]AssessComplete //已完成填写的评估内容
UserCount map[string]int //各项员工数量
}
type AssessComplete struct {
GroupKey string //评估指标项
Items []string //评估指标所有的评级
UserItem map[string][]string //每个评级下的员工名称
PercentItem map[string]string ///每个评级下的员工占比
CountItem map[string]int //每个评级下的员工数量
TotalUser int //填写该指标的员工数量
}
... ...
... ... @@ -13,7 +13,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"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"
)
... ... @@ -27,195 +26,195 @@ func NewStaffAssessServeice() *StaffAssessServeice {
}
// 获取我参与过的评估任务列表
func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (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()
}()
staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
var limit int = 200
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
}
offset = (param.PageNumber - 1) * param.PageSize
assessTaskList, err := staffAssessTaskRepo.SearchAssessTaskMe(param.UserId, param.CompanyId, limit, offset)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error())
}
cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId)
if 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())
}
listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
var temp adapter.SearchAssessMeResp
for _, v := range assessTaskList {
temp = adapter.SearchAssessMeResp{
AssessTaskId: v.Id,
BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
CycleId: v.CycleId,
CycleName: v.CycleName,
EvaluationProjectId: v.EvaluationProjectId,
EvaluationProjectName: v.EvaluationProjectName,
}
listData = append(listData, temp)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
}
// func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (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()
// }()
// staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// var limit int = 200
// var offset int = 0
// if param.PageSize > 0 {
// limit = param.PageSize
// }
// offset = (param.PageNumber - 1) * param.PageSize
// assessTaskList, err := staffAssessTaskRepo.SearchAssessTaskMe(param.UserId, param.CompanyId, limit, offset)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估任务"+err.Error())
// }
// cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId)
// if 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())
// }
// listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
// var temp adapter.SearchAssessMeResp
// for _, v := range assessTaskList {
// temp = adapter.SearchAssessMeResp{
// AssessTaskId: v.Id,
// BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
// EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
// CycleId: v.CycleId,
// CycleName: v.CycleName,
// EvaluationProjectId: v.EvaluationProjectId,
// EvaluationProjectName: v.EvaluationProjectName,
// }
// listData = append(listData, temp)
// }
// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
// }
// 获取项目评估进度描述
func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, 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()
}()
// 获取评估任务
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取个人参与的评估流程
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
}
//返回的数据结果
result := adapter.AssessTaskDescResp{
AssessTaskId: assessTaskData.Id,
EvaluationProjectId: assessTaskData.EvaluationProjectId,
EvaluationProjectName: assessTaskData.EvaluationProjectName,
CycleName: assessTaskData.CycleName,
BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),
EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"),
StepList: []adapter.AssessTaskStep{},
}
for _, v := range assessTaskData.StepList {
stepItem := adapter.AssessTaskStep{
SortBy: v.SortBy,
LinkNodeName: v.LinkNodeName,
LinkNodeId: v.LinkNodeId,
BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
LinkNodeType: v.LinkNodeType,
Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")),
Status: "",
}
switch v.LinkNodeType {
case domain.LinkNodeSelfAssessment:
//个人自评完成情况
_, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSelf)},
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessSelfData) > 0 {
stepItem.Status = string(assessSelfData[0].Status)
}
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
case domain.LinkNodeAllInvite:
//邀请别人评估自己
_, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"targetUserId": param.UserId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 5,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessInviteData) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
} else {
stepItem.Status = string(domain.StaffAssessUncompleted)
}
//待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
if len(assessInviteData) > 5 {
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
} else {
stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
}
case domain.LinkNodeAllAssessment:
//我评估别人,被邀请评估
_, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessInviteList) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
for _, v := range assessInviteList {
if v.Status == domain.StaffAssessUncompleted {
stepItem.Status = string(domain.StaffAssessUncompleted)
break
}
}
}
case domain.LinkNodeSuperiorAssessment:
//我评估别人,上级评估
_, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessSupperList) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
uncompletedNum := 0
for _, v := range assessSupperList {
if v.Status == domain.StaffAssessUncompleted {
uncompletedNum += 1
}
}
if uncompletedNum > 0 {
stepItem.Status = string(domain.StaffAssessUncompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
}
}
}
result.StepList = append(result.StepList, stepItem)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return &result, nil
}
// func (srv StaffAssessServeice) AssessTaskDesc(param *query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, 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()
// }()
// // 获取评估任务
// staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //获取个人参与的评估流程
// staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
// }
// //返回的数据结果
// result := adapter.AssessTaskDescResp{
// AssessTaskId: assessTaskData.Id,
// EvaluationProjectId: assessTaskData.EvaluationProjectId,
// EvaluationProjectName: assessTaskData.EvaluationProjectName,
// CycleName: assessTaskData.CycleName,
// BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),
// EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"),
// StepList: []adapter.AssessTaskStep{},
// }
// for _, v := range assessTaskData.StepList {
// stepItem := adapter.AssessTaskStep{
// SortBy: v.SortBy,
// LinkNodeName: v.LinkNodeName,
// LinkNodeId: v.LinkNodeId,
// BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
// EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
// LinkNodeType: v.LinkNodeType,
// Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")),
// Status: "",
// }
// switch v.LinkNodeType {
// case domain.LinkNodeSelfAssessment:
// //个人自评完成情况
// _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": assessTaskData.Id,
// "executorId": param.UserId,
// "typesList": []string{string(domain.AssessSelf)},
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
// }
// if len(assessSelfData) > 0 {
// stepItem.Status = string(assessSelfData[0].Status)
// }
// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
// case domain.LinkNodeAllInvite:
// //邀请别人评估自己
// _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": assessTaskData.Id,
// "targetUserId": param.UserId,
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// "limit": 5,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
// }
// if len(assessInviteData) > 0 {
// stepItem.Status = string(domain.StaffAssessCompleted)
// } else {
// stepItem.Status = string(domain.StaffAssessUncompleted)
// }
// //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
// if len(assessInviteData) > 5 {
// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
// } else {
// stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
// }
// case domain.LinkNodeAllAssessment:
// //我评估别人,被邀请评估
// _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": assessTaskData.Id,
// "executorId": param.UserId,
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
// }
// if len(assessInviteList) > 0 {
// stepItem.Status = string(domain.StaffAssessCompleted)
// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
// for _, v := range assessInviteList {
// if v.Status == domain.StaffAssessUncompleted {
// stepItem.Status = string(domain.StaffAssessUncompleted)
// break
// }
// }
// }
// case domain.LinkNodeSuperiorAssessment:
// //我评估别人,上级评估
// _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": assessTaskData.Id,
// "executorId": param.UserId,
// "typesList": []string{string(domain.AssessSuper)},
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
// }
// if len(assessSupperList) > 0 {
// stepItem.Status = string(domain.StaffAssessCompleted)
// stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
// uncompletedNum := 0
// for _, v := range assessSupperList {
// if v.Status == domain.StaffAssessUncompleted {
// uncompletedNum += 1
// }
// }
// if uncompletedNum > 0 {
// stepItem.Status = string(domain.StaffAssessUncompleted)
// stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
// }
// }
// }
// result.StepList = append(result.StepList, stepItem)
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// return &result, nil
// }
// 获取个人的自评反馈历史记录列表
func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) (map[string]interface{}, error) {
... ... @@ -601,68 +600,68 @@ func (srv StaffAssessServeice) createStaffAssessSupper(
}
// 获取某个员工360评估邀请的人员
func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, 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()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
}
_, assessList, err := assessReps.Find(map[string]interface{}{
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"staffAssessTaskId": param.AssessTaskId,
"targetUserId": param.UserId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessInviteUserResp{
AssessTaskId: assessTaskData.Id,
InviteDiffSuper: []domain.StaffDesc{},
InviteSameSuper: []domain.StaffDesc{},
}
for _, v := range assessTaskData.StepList {
if v.LinkNodeType != domain.LinkNodeAllInvite {
continue
}
result.LinkNodeId = v.LinkNodeId
result.LinkNodeName = v.LinkNodeName
result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
break
}
for _, v := range assessList {
if v.Types == domain.AssessInviteDiffSuper {
result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
}
if v.Types == domain.AssessInviteSameSuper {
result.InviteSameSuper = append(result.InviteSameSuper, v.Executor)
}
}
return &result, nil
}
// func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteUserQuery) (*adapter.AssessInviteUserResp, 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()
// }()
// assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// assessTaskReps := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// assessTaskData, err := assessTaskReps.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
// })
// if err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, "获取评估任务"+err.Error())
// }
// _, assessList, err := assessReps.Find(map[string]interface{}{
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// "staffAssessTaskId": param.AssessTaskId,
// "targetUserId": param.UserId,
// })
// if err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// result := adapter.AssessInviteUserResp{
// AssessTaskId: assessTaskData.Id,
// InviteDiffSuper: []domain.StaffDesc{},
// InviteSameSuper: []domain.StaffDesc{},
// }
// for _, v := range assessTaskData.StepList {
// if v.LinkNodeType != domain.LinkNodeAllInvite {
// continue
// }
// result.LinkNodeId = v.LinkNodeId
// result.LinkNodeName = v.LinkNodeName
// result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
// result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
// break
// }
// for _, v := range assessList {
// if v.Types == domain.AssessInviteDiffSuper {
// result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
// }
// if v.Types == domain.AssessInviteSameSuper {
// result.InviteSameSuper = append(result.InviteSameSuper, v.Executor)
// }
// }
// return &result, nil
// }
// 保存某个员工360邀请的人员
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (map[string]interface{}, error) {
... ... @@ -899,91 +898,91 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
}
// 获取员工自评的评估内容详情
func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, 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()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
"staffAssessTaskId": param.AssessTaskId,
"targetUserId": param.TargetUserId,
"typesList": []string{string(domain.AssessSelf)},
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
assessContentList := []*domain.StaffAssessContent{}
if assessData.Status == domain.StaffAssessCompleted {
//已完成
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
} else if assessData.Status == domain.StaffAssessUncompleted {
//未完成
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
}
// 恢复缓存数据
if param.AcquireCache != 0 {
srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
}
//获取员工描述
staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessInfoResp{
AssessId: assessData.Id,
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
LinkNodeId: assessData.LinkNodeId,
LinkNodeName: assessData.LinkNodeName,
EvaluationProjectId: assessData.EvaluationProjectId,
EvaluationProjectName: assessData.EvaluationProjectName,
BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
Status: string(assessData.Status),
TargetUserId: assessData.TargetUser.UserId,
TargetUserName: assessData.TargetUser.UserName,
CompanyId: assessData.CompanyId,
CompanyName: "",
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
}
if staffDesc != nil {
result.CompanyName = staffDesc.CompanyName
result.SupperUser = staffDesc.SupperUserName
result.DutyTime = staffDesc.DutyTime
}
return &result, nil
}
// func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuery) (*adapter.AssessInfoResp, 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()
// }()
// assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //获取员工的评估
// _, assessList, err := assessReps.Find(map[string]interface{}{
// "companyId": param.CompanyId,
// "staffAssessTaskId": param.AssessTaskId,
// "targetUserId": param.TargetUserId,
// "typesList": []string{string(domain.AssessSelf)},
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
// }
// if len(assessList) == 0 {
// return &adapter.AssessInfoResp{}, nil
// }
// assessData := assessList[0]
// assessContentList := []*domain.StaffAssessContent{}
// if assessData.Status == domain.StaffAssessCompleted {
// //已完成
// assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
// "staffAssessId": assessData.Id,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
// }
// } else if assessData.Status == domain.StaffAssessUncompleted {
// //未完成
// assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
// }
// }
// // 恢复缓存数据
// if param.AcquireCache != 0 {
// srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
// }
// //获取员工描述
// staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// result := adapter.AssessInfoResp{
// AssessId: assessData.Id,
// CycleId: assessData.CycleId,
// CycleName: assessData.CycleName,
// LinkNodeId: assessData.LinkNodeId,
// LinkNodeName: assessData.LinkNodeName,
// EvaluationProjectId: assessData.EvaluationProjectId,
// EvaluationProjectName: assessData.EvaluationProjectName,
// BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
// EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
// Status: string(assessData.Status),
// TargetUserId: assessData.TargetUser.UserId,
// TargetUserName: assessData.TargetUser.UserName,
// CompanyId: assessData.CompanyId,
// CompanyName: "",
// SupperUser: "",
// DutyTime: "",
// AssessContent: assessContentList,
// }
// if staffDesc != nil {
// result.CompanyName = staffDesc.CompanyName
// result.SupperUser = staffDesc.SupperUserName
// result.DutyTime = staffDesc.DutyTime
// }
// return &result, nil
// }
// 获取未完成的员工评估内容
func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext,
... ... @@ -1169,322 +1168,322 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
}
// 获取我要执行的的360评估,用户列表和评估填写的值
func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) (
*adapter.ListInviteUserAssessResp, 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()
}()
//获取对应的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取 executorId 对应的360评估任务 用户
condition := map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 20,
}
if param.PageSize > 0 {
condition["limit"] = param.PageSize
}
offset := (param.PageNumber - 1) * param.PageSize
if offset > 0 {
condition["offset"] = offset
}
cnt, assessList, err := assessRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var assessContentList []*domain.StaffAssessContent
if len(assessList) > 0 {
//获取评估用的所有评估项
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0])
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
}
}
//可变的表格列
changeableHeader := []adapter.ListTableHeader{}
//列名与字段对应
keyMap := map[string]string{}
for i, v := range assessContentList {
name := fmt.Sprintf("%s-%s", v.Category, v.Name)
key := fmt.Sprintf("k%d", i)
keyMap[name] = key
changeableHeader = append(changeableHeader, adapter.ListTableHeader{
Key: key,
Name: name,
})
}
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// 获取已经填报的内容
changeableRows := map[int]map[string]string{}
for _, v := range assessList {
_, contentList, err := assessContentRepo.Find(map[string]interface{}{
"staffAssessId": v.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error())
}
row := map[string]string{}
for _, vv := range contentList {
name := fmt.Sprintf("%s-%s", vv.Category, vv.Name)
if kk, ok := keyMap[name]; ok {
row[kk] = vv.Value
}
}
changeableRows[v.TargetUser.UserId] = row
}
//获取360邀请评估完成情况
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"status": domain.StaffAssessUncompleted,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//评估填写数据行转列
tableHeader := []adapter.ListTableHeader{
{Key: "userName", Name: "姓名"},
{Key: "status", Name: "状态"},
{Key: "types", Name: "360°评估关系"},
{Key: "endTime", Name: "360°评估截止日期"},
}
tableHeader = append(tableHeader, changeableHeader...)
listData := []map[string]interface{}{}
for _, v := range assessList {
m := map[string]interface{}{
"userName": v.TargetUser.UserName,
"userId": strconv.Itoa(v.TargetUser.UserId),
"status": string(v.Status),
"types": string(v.Types),
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
"assessId": strconv.Itoa(v.Id),
}
switch v.Status {
case domain.StaffAssessCompleted:
m["status"] = "已经完成"
case domain.StaffAssessUncompleted:
m["status"] = "未完成"
}
switch v.Types {
case domain.AssessInviteDiffSuper:
m["types"] = "不同上级同事"
case domain.AssessInviteSameSuper:
m["types"] = "相同上级同事"
}
if row, ok := changeableRows[v.TargetUser.UserId]; ok {
for k, v := range row {
m[k] = v
}
} else {
for _, v := range changeableHeader {
m[v.Key] = ""
}
}
listData = append(listData, m)
}
result := adapter.ListInviteUserAssessResp{
TableHeader: tableHeader,
List: listData,
Total: cnt,
}
for _, v := range assessTaskData.StepList {
if v.LinkNodeType == domain.LinkNodeAllAssessment {
result.LinkNodeId = v.LinkNodeId
result.LinkNodeName = v.LinkNodeName
result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
}
return &result, nil
}
// func (srv StaffAssessServeice) ListExecutorInviteAssess(param *query.ListInviteUserAssessQuery) (
// *adapter.ListInviteUserAssessResp, 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()
// }()
// //获取对应的评估任务
// assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //获取 executorId 对应的360评估任务 用户
// condition := map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
// "executorId": param.ExecutorId,
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// "limit": 20,
// }
// if param.PageSize > 0 {
// condition["limit"] = param.PageSize
// }
// offset := (param.PageNumber - 1) * param.PageSize
// if offset > 0 {
// condition["offset"] = offset
// }
// cnt, assessList, err := assessRepo.Find(condition)
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// var assessContentList []*domain.StaffAssessContent
// if len(assessList) > 0 {
// //获取评估用的所有评估项
// assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0])
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
// }
// }
// //可变的表格列
// changeableHeader := []adapter.ListTableHeader{}
// //列名与字段对应
// keyMap := map[string]string{}
// for i, v := range assessContentList {
// name := fmt.Sprintf("%s-%s", v.Category, v.Name)
// key := fmt.Sprintf("k%d", i)
// keyMap[name] = key
// changeableHeader = append(changeableHeader, adapter.ListTableHeader{
// Key: key,
// Name: name,
// })
// }
// assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// // 获取已经填报的内容
// changeableRows := map[int]map[string]string{}
// for _, v := range assessList {
// _, contentList, err := assessContentRepo.Find(map[string]interface{}{
// "staffAssessId": v.Id,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error())
// }
// row := map[string]string{}
// for _, vv := range contentList {
// name := fmt.Sprintf("%s-%s", vv.Category, vv.Name)
// if kk, ok := keyMap[name]; ok {
// row[kk] = vv.Value
// }
// }
// changeableRows[v.TargetUser.UserId] = row
// }
// //获取360邀请评估完成情况
// //我评估别人,被邀请评估
// cnnt, _, err := assessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
// "executorId": param.ExecutorId,
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// "status": domain.StaffAssessUncompleted,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
// }
// assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// //评估填写数据行转列
// tableHeader := []adapter.ListTableHeader{
// {Key: "userName", Name: "姓名"},
// {Key: "status", Name: "状态"},
// {Key: "types", Name: "360°评估关系"},
// {Key: "endTime", Name: "360°评估截止日期"},
// }
// tableHeader = append(tableHeader, changeableHeader...)
// listData := []map[string]interface{}{}
// for _, v := range assessList {
// m := map[string]interface{}{
// "userName": v.TargetUser.UserName,
// "userId": strconv.Itoa(v.TargetUser.UserId),
// "status": string(v.Status),
// "types": string(v.Types),
// "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
// "assessId": strconv.Itoa(v.Id),
// }
// switch v.Status {
// case domain.StaffAssessCompleted:
// m["status"] = "已经完成"
// case domain.StaffAssessUncompleted:
// m["status"] = "未完成"
// }
// switch v.Types {
// case domain.AssessInviteDiffSuper:
// m["types"] = "不同上级同事"
// case domain.AssessInviteSameSuper:
// m["types"] = "相同上级同事"
// }
// if row, ok := changeableRows[v.TargetUser.UserId]; ok {
// for k, v := range row {
// m[k] = v
// }
// } else {
// for _, v := range changeableHeader {
// m[v.Key] = ""
// }
// }
// listData = append(listData, m)
// }
// result := adapter.ListInviteUserAssessResp{
// TableHeader: tableHeader,
// List: listData,
// Total: cnt,
// }
// for _, v := range assessTaskData.StepList {
// if v.LinkNodeType == domain.LinkNodeAllAssessment {
// result.LinkNodeId = v.LinkNodeId
// result.LinkNodeName = v.LinkNodeName
// result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
// }
// }
// return &result, nil
// }
// 获取我需要执行的上级评估成员列表
func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (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()
}()
//获取对应的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
limit := 20
if param.PageSize > 0 {
limit = param.PageSize
}
condition := map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"limit": limit,
"targetUserName": param.UserName,
}
offset := (param.PageNumber - 1) * param.PageSize
if offset > 0 {
condition["offset"] = offset
}
//获取 executorId 对应的上级评估列表
cnt, assessList, err := assessRepo.Find(condition)
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)
}
//获取员工信息
userRepo := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
var targetUserList []*domain.User
if len(userIds) > 0 {
_, targetUserList, _ = userRepo.Find(map[string]interface{}{
"ids": userIds,
})
}
//获取职位信息
positionRepo := factory.CreatePositionRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取员工的职位
userPositionMap := map[int64][]*domain.Position{}
for _, v := range targetUserList {
if len(v.PositionId) == 0 {
continue
}
_, positionList, _ := positionRepo.Find(map[string]interface{}{
"ids": v.PositionId,
})
userPositionMap[v.Id] = positionList
}
//获取员工邀请的人完成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{}{
"transactionContext": transactionContext,
})
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
}
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"status": string(domain.StaffAssessUncompleted),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
resultList := []adapter.ListSupperAssessResp{}
for _, v := range assessList {
item := adapter.ListSupperAssessResp{
AssessId: v.Id,
UserId: v.TargetUser.UserId,
UserName: v.TargetUser.UserName,
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
InviteCompleted: 0,
Status: string(v.Status),
InviteTotal: 5,
Department: "",
Position: "",
DutyTime: "",
}
//填入部门
for _, vv := range v.TargetDepartment {
item.Department += vv.DepartmentName + " "
}
for _, vv := range targetUserList {
if vv.Id != int64(v.TargetUser.UserId) {
continue
}
//填入入职时间
item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
//填入职位
for _, vvv := range userPositionMap[vv.Id] {
item.Position += vvv.Name + " "
}
break
}
//
for _, vv := range inviteCompletedCount {
if v.TargetUser.UserId == vv.TargetUserId {
item.InviteCompleted = vv.InviteCompleted
item.InviteTotal = vv.InviteTotal
break
}
}
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)
}
}
return result, nil
}
// func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperAssessQuery) (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()
// }()
// //获取对应的评估任务
// assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// limit := 20
// if param.PageSize > 0 {
// limit = param.PageSize
// }
// condition := map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
// "executorId": param.ExecutorId,
// "typesList": []string{string(domain.AssessSuper)},
// "limit": limit,
// "targetUserName": param.UserName,
// }
// offset := (param.PageNumber - 1) * param.PageSize
// if offset > 0 {
// condition["offset"] = offset
// }
// //获取 executorId 对应的上级评估列表
// cnt, assessList, err := assessRepo.Find(condition)
// 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)
// }
// //获取员工信息
// userRepo := factory.CreateUserRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// var targetUserList []*domain.User
// if len(userIds) > 0 {
// _, targetUserList, _ = userRepo.Find(map[string]interface{}{
// "ids": userIds,
// })
// }
// //获取职位信息
// positionRepo := factory.CreatePositionRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //获取员工的职位
// userPositionMap := map[int64][]*domain.Position{}
// for _, v := range targetUserList {
// if len(v.PositionId) == 0 {
// continue
// }
// _, positionList, _ := positionRepo.Find(map[string]interface{}{
// "ids": v.PositionId,
// })
// userPositionMap[v.Id] = positionList
// }
// //获取员工邀请的人完成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{}{
// "transactionContext": transactionContext,
// })
// assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
// }
// //我评估别人,被邀请评估
// cnnt, _, err := assessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
// "executorId": param.ExecutorId,
// "typesList": []string{string(domain.AssessSuper)},
// "status": string(domain.StaffAssessUncompleted),
// })
// if err != nil {
// return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// resultList := []adapter.ListSupperAssessResp{}
// for _, v := range assessList {
// item := adapter.ListSupperAssessResp{
// AssessId: v.Id,
// UserId: v.TargetUser.UserId,
// UserName: v.TargetUser.UserName,
// EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
// InviteCompleted: 0,
// Status: string(v.Status),
// InviteTotal: 5,
// Department: "",
// Position: "",
// DutyTime: "",
// }
// //填入部门
// for _, vv := range v.TargetDepartment {
// item.Department += vv.DepartmentName + " "
// }
// for _, vv := range targetUserList {
// if vv.Id != int64(v.TargetUser.UserId) {
// continue
// }
// //填入入职时间
// item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
// //填入职位
// for _, vvv := range userPositionMap[vv.Id] {
// item.Position += vvv.Name + " "
// }
// break
// }
// //
// for _, vv := range inviteCompletedCount {
// if v.TargetUser.UserId == vv.TargetUserId {
// item.InviteCompleted = vv.InviteCompleted
// item.InviteTotal = vv.InviteTotal
// break
// }
// }
// 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)
// }
// }
// return result, nil
// }
// 根据staffAssessId 获取评估的填写信息
func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
... ... @@ -1764,38 +1763,38 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
// 获取员工被评估的列表
func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (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()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取员工的评估
cnt, assessList, err := assessReps.Find(map[string]interface{}{
"staffAssessTaskId": param.AssessTaskId,
"companyId": param.CompanyId,
"targetUserId": param.TargetUserId,
"typesList": param.Types,
})
if 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(cnt), assessList), nil
}
//获取员工的上级是谁 ,TODO
// func (srv StaffAssessServeice) ListTargetUserAssess(param *query.ListTargetUserAssessQuery) (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()
// }()
// assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //获取员工的评估
// cnt, assessList, err := assessReps.Find(map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
// "companyId": param.CompanyId,
// "targetUserId": param.TargetUserId,
// "typesList": param.Types,
// })
// if 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(cnt), assessList), nil
// }
// 获取员工的上级是谁 ,TODO
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -442,3 +442,138 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
}
return xlsxFile, nil
}
//员工绩效-项目管理-矩阵分析
func (srv StaffAssessServeice) AnalysisData(param *query.ListAssessContentCycleDay) (*adapter.AssessAnalysisResp, 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()
}()
roleRepo := factory.CreateRoleRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, roleList, err := roleRepo.Find(map[string]interface{}{
"type": domain.RoleTypeSystem,
"companyId": param.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
}
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"userId": param.OperaterId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
}
hrbp := -1
for _, v := range userRoleList {
for _, v2 := range roleList {
if v.RoleId == v2.Id {
hrbp = 1
break
}
}
if hrbp == 1 {
break
}
}
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
contentList, err := assessDao.SearchUserAssessContent(dao.SearchConditin1{
CompanyId: param.CompanyId,
CycleId: param.CycleId,
BeginDay: param.BeginDay,
TargetUserName: param.TargetUserName,
Limit: 9000,
Offset: 0,
OperaterId: param.OperaterId,
Hrbp: hrbp,
})
if 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())
}
log.Logger.Debug(fmt.Sprintf("获取到的数据列表%d", len(contentList)))
var groupList []string //评估指标项列表
var uncompleteItems []string //未完成填写评估的员工
completeUser := map[string]struct{}{} //完成填写评估的员工
completeItems := map[string]adapter.AssessComplete{} //已完成填写的评估内容
for _, v := range contentList {
if v.ContentId == 0 {
uncompleteItems = append(uncompleteItems, v.TargetUserName)
continue
}
completeUser[v.TargetUserId] = struct{}{}
key := v.Category + "-" + v.ContentName
if _, ok := completeItems[key]; !ok {
groupList = append(groupList, key)
//初始化数据结构
completeItems[key] = adapter.AssessComplete{
GroupKey: key,
Items: []string{},
UserItem: map[string][]string{},
PercentItem: map[string]string{},
CountItem: map[string]int{},
}
}
completeItem := completeItems[key]
if v.Rule.Type == domain.EvaluationTypeRating {
//提取出所有可选的评级
for _, v2 := range v.Rule.Rating.Levels {
if _, ok := completeItem.CountItem[v2.Code]; !ok {
completeItem.CountItem[v2.Code] = 0
completeItem.PercentItem[v2.Code] = ""
completeItem.UserItem[v2.Code] = []string{}
completeItem.Items = append(completeItem.Items, v2.Code)
}
}
}
if v.Rule.Type == domain.EvaluationTypeScore {
for _, v2 := range v.Rule.Score.Levels {
//提取出所有可选的评级
if _, ok := completeItem.CountItem[v2.Code]; !ok {
completeItem.CountItem[v2.Code] = 0
completeItem.PercentItem[v2.Code] = ""
completeItem.UserItem[v2.Code] = []string{}
completeItem.Items = append(completeItem.Items, v2.Code)
}
}
}
//根据填写的评级填充数据
completeItem.TotalUser = completeItem.TotalUser + 1
completeItem.CountItem[v.LevelValue] = completeItem.CountItem[v.LevelValue] + 1
percentSum := float64(completeItem.CountItem[v.LevelValue]) / float64(completeItem.TotalUser) * 100
completeItem.PercentItem[v.LevelValue] = fmt.Sprintf("%.2f %%", percentSum)
completeItem.UserItem[v.LevelValue] = append(completeItem.UserItem[v.LevelValue], v.TargetUserName)
completeItems[key] = completeItem
}
result := adapter.AssessAnalysisResp{
GroupList: groupList,
Uncomplete: uncompleteItems,
Complete: completeItems,
UserCount: map[string]int{
"total": len(uncompleteItems) + len(completeUser),
"uncomplete": len(uncompleteItems),
"complete": len(completeUser),
},
}
return &result, nil
}
... ...
... ... @@ -55,55 +55,6 @@ type EvaluationRule struct {
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
}
// // 根据评估填写的值,得出等级名称和填写的值量化值
// // 如果 评估方式是评分,对评估填写的值的小数点后的位数进行处理,
// // value 根据评估填写的值
// func (rule *EvaluationRule) ScoreOrRating(value *string) (string, error) {
// switch rule.Type {
// case EvaluationTypeRating:
// return rule.RatingValue(value)
// case EvaluationTypeScore:
// return rule.ScoreValue(value)
// }
// return "", errors.New("rule.Type 错误")
// }
// //根据评估填写的值,得出等级名称和填写的值量化值
// func (rule *EvaluationRule) ScoreValue(value *string) (string, error) {
// valueFloat, err := strconv.ParseFloat(*value, 64)
// if err != nil {
// return "", errors.New("评分填写的值错误")
// }
// if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
// return "", fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
// }
// //保留小数处理
// fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
// valueStr := fmt.Sprintf(fStr, valueFloat)
// *value = valueStr
// if rule.Score.IntervalState == 0 {
// // 未开启按分数子区间匹配等级
// return "", nil
// }
// valueDescrip := ""
// for _, v := range rule.Score.Levels {
// if valueFloat >= v.Start && valueFloat <= v.End {
// valueDescrip = v.Name
// }
// }
// return valueDescrip, nil
// }
// //根据评估填写的值,得出等级名称,
// func (rule *EvaluationRule) RatingValue(value *string) (string, error) {
// for _, v := range rule.Rating.Levels {
// if v.Code == *value {
// return v.Name, nil
// }
// }
// return "", errors.New("评估填写的值错误")
// }
// GenerateSysRule 当前公司下的生成默认规则
func GenerateSysRule(companyId int64) *EvaluationRule {
levels := make([]*RatingLevel, 0)
... ...
... ... @@ -190,18 +190,20 @@ func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]As
// 获取员工填写评估内容
type UserAssessContent struct {
AssessId string `json:"assessId"`
ContentId int `json:"contentId"`
TargetUserId string `json:"targetUserId"` //被评估人的id
TargetUserName string `json:"targetUserName"` //被评估人的名称
BeginDay string `json:"beginDay"` //评估的日期
EvaluationProjectId string `json:"evaluationProjectId"` //项目id
Value string `json:"value"` //评估填写的值
SortBy int `json:"sortBy"` //评估项顺序
Category string `json:"category"` //评估项分类
ContentName string `json:"contentName"` //评估项名称
Weight float64 `json:"weight"` //权重
CycleId string `json:"cycleId"` //周期id
AssessId string `json:"assessId"`
ContentId int `json:"contentId"`
TargetUserId string `json:"targetUserId"` //被评估人的id
TargetUserName string `json:"targetUserName"` //被评估人的名称
BeginDay string `json:"beginDay"` //评估的日期
EvaluationProjectId string `json:"evaluationProjectId"` //项目id
Value string `json:"value"` //评估填写的值
LevelValue string `json:"levelValue"` //评级的值
Rule domain.EvaluationRule `json:"rule"` //规则
SortBy int `json:"sortBy"` //评估项顺序
Category string `json:"category"` //评估项分类
ContentName string `json:"contentName"` //评估项名称
Weight float64 `json:"weight"` //权重
CycleId string `json:"cycleId"` //周期id
}
type SearchConditin1 struct {
... ... @@ -237,7 +239,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA
t_staff_assess_1.assess_id,staff_assess_content.id as content_id,
staff_assess_content.value ,staff_assess_content.sort_by ,t_staff_assess_1.cycle_id,
staff_assess_content.category ,staff_assess_content."name" as content_name ,
staff_assess_content.weight
staff_assess_content.weight,staff_assess_content.level_value,staff_assess_content."rule"
from t_staff_assess_1
left join staff_assess_content on t_staff_assess_1.assess_id = staff_assess_content.staff_assess_id
where 1=1
... ... @@ -250,7 +252,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA
//加入排序
sqlStr += ` order by convert_to(t_staff_assess_1.target_user_name,'GBK'),staff_assess_content.sort_by `
//获取前置sql语句
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
result := []UserAssessContent{}
... ... @@ -277,7 +279,7 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) {
condition = append(condition, "%"+param.TargetUserName+"%")
}
//获取前置sql语句
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, 5000, 0)
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, 5000, 0, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
var result int
... ... @@ -293,7 +295,8 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) {
// hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否
// limit int, 分页条数
// offset int 分页偏移
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string {
// assessType string 评估的类型
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int, assessType string) string {
sqlstr := `
set time zone 'PRC';
with t_user_department as (
... ... @@ -345,7 +348,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
and staff_assess_task.deleted_at isnull
where staff_assess.cycle_id = %d
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
and staff_assess."types" ='self'
and staff_assess."types" ='%s'
),
-- 根据查看权限过滤合并数据
t_staff_assess_1 as (
... ... @@ -368,7 +371,7 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
)
`
params := []interface{}{
companyId, userId, cycleId, hrbp, cycleId, userId, cycleId, beginDay, limit, offset,
companyId, userId, cycleId, hrbp, cycleId, userId, cycleId, beginDay, assessType, limit, offset,
}
sqlstr = fmt.Sprintf(sqlstr, params...)
... ... @@ -421,7 +424,7 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
//加入排序
sqlStr += ` order by convert_to(t_staff_assess_1.target_user_name,'GBK'),staff_assess_content.sort_by `
//获取前置sql语句
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset, string(domain.AssessSelf))
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
var result []ExportData1
... ...
... ... @@ -8,7 +8,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
... ... @@ -17,39 +16,39 @@ type StaffAssessController struct {
}
// 获取我的绩效任务列表
func (c *StaffAssessController) SearchAssessTaskMe() {
srv := service.NewStaffAssessServeice()
paramReq := &query.SearchAssessMeQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
// func (c *StaffAssessController) SearchAssessTaskMe() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.SearchAssessMeQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.UserId = int(userReq.UserId)
data, err := srv.SearchAssessTaskMe(paramReq)
c.Response(data, err)
}
// data, err := srv.SearchAssessTaskMe(paramReq)
// c.Response(data, err)
// }
// 获取我的绩效任务各环节完成情况
func (c *StaffAssessController) AssessTaskMeDesc() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessTaskDescQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
data, err := srv.AssessTaskDesc(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) AssessTaskMeDesc() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.AssessTaskDescQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.UserId = int(userReq.UserId)
// data, err := srv.AssessTaskDesc(paramReq)
// c.Response(data, err)
// }
// 获取个人的自评反馈历史记录列表
func (c *StaffAssessController) AssessSelfMeList() {
... ... @@ -84,38 +83,38 @@ func (c *StaffAssessController) CreateStaffAssessTask() {
}
// 获取当前登录员工自评详情
func (c *StaffAssessController) GetAssessSelfMeInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessSelfInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.GetAssessSelfInfo(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) GetAssessSelfMeInfo() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.AssessSelfInfoQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.TargetUserId = int(userReq.UserId)
// data, err := srv.GetAssessSelfInfo(paramReq)
// c.Response(data, err)
// }
// 获取我邀请的人
func (c *StaffAssessController) GetAssessMeInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &query.GetAssessInviteUserQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.UserId = int(userReq.UserId)
data, err := srv.GetAssessInviteUser(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) GetAssessMeInviteUser() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.GetAssessInviteUserQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.UserId = int(userReq.UserId)
// data, err := srv.GetAssessInviteUser(paramReq)
// c.Response(data, err)
// }
// 保存我邀请的员工
func (c *StaffAssessController) SaveAssessMeInviteUser() {
... ... @@ -156,61 +155,61 @@ func (c *StaffAssessController) SelectAssessInviteUser() {
}
// 获取我要执行360评估,用户列表和评估填写的值
func (c *StaffAssessController) ListMeInviteUserAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListInviteUserAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//获取当前用户信息
// paramReq.CompanyId = 1
// paramReq.ExecutorId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.ExecutorId = int(userReq.UserId)
data, err := srv.ListExecutorInviteAssess(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) ListMeInviteUserAssess() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.ListInviteUserAssessQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// //获取当前用户信息
// // paramReq.CompanyId = 1
// // paramReq.ExecutorId = 1
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.ExecutorId = int(userReq.UserId)
// data, err := srv.ListExecutorInviteAssess(paramReq)
// c.Response(data, err)
// }
// 获取我要执行的上级评估成员列表
func (c *StaffAssessController) ListMeSupperAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListSupperAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
// paramReq.CompanyId = 1
// paramReq.ExecutorId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.ExecutorId = int(userReq.UserId)
data, err := srv.ListExecutorSupperAssess(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) ListMeSupperAssess() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.ListSupperAssessQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// //TODO 获取当前用户信息
// // paramReq.CompanyId = 1
// // paramReq.ExecutorId = 1
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.ExecutorId = int(userReq.UserId)
// data, err := srv.ListExecutorSupperAssess(paramReq)
// c.Response(data, err)
// }
// 获取员工自评详情
func (c *StaffAssessController) GetAssessTargetUserSelfInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessSelfInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetAssessSelfInfo(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) GetAssessTargetUserSelfInfo() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.AssessSelfInfoQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// // paramReq.CompanyId = 1
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// data, err := srv.GetAssessSelfInfo(paramReq)
// c.Response(data, err)
// }
// 获取评估内容详情
func (c *StaffAssessController) GetAssessInfo() {
... ... @@ -247,42 +246,42 @@ func (c *StaffAssessController) SaveAssessInfo() {
}
// 被评估的员工的评估列表-360评估
func (c *StaffAssessController) ListTargetUserInviteAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetUserAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.Types = []string{string(domain.AssessInviteSameSuper), string(domain.AssessInviteDiffSuper)}
data, err := srv.ListTargetUserAssess(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) ListTargetUserInviteAssess() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.ListTargetUserAssessQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// // paramReq.CompanyId = 1
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.Types = []string{string(domain.AssessInviteSameSuper), string(domain.AssessInviteDiffSuper)}
// data, err := srv.ListTargetUserAssess(paramReq)
// c.Response(data, err)
// }
func (c *StaffAssessController) ListTargetUserMeSupperAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetUserAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.Types = []string{string(domain.AssessSuper)}
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.ListTargetUserAssess(paramReq)
c.Response(data, err)
}
// func (c *StaffAssessController) ListTargetUserMeSupperAssess() {
// srv := service.NewStaffAssessServeice()
// paramReq := &query.ListTargetUserAssessQuery{}
// err := c.BindJSON(paramReq)
// if err != nil {
// e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
// c.Response(nil, e)
// return
// }
// // paramReq.CompanyId = 1
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.CompanyId = int(userReq.CompanyId)
// paramReq.Types = []string{string(domain.AssessSuper)}
// paramReq.TargetUserId = int(userReq.UserId)
// data, err := srv.ListTargetUserAssess(paramReq)
// c.Response(data, err)
// }
//获取周期列表
// 获取周期列表
func (c *StaffAssessController) ListAssessCycle() {
srv := service.NewStaffAssessServeice()
userReq := middlewares.GetUser(c.Ctx)
... ... @@ -290,7 +289,7 @@ func (c *StaffAssessController) ListAssessCycle() {
c.Response(data, err)
}
//获取周期里的考核日期
// 获取周期里的考核日期
func (c *StaffAssessController) ListAssessCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessCycleDay{}
... ... @@ -306,7 +305,7 @@ func (c *StaffAssessController) ListAssessCycleDay() {
c.Response(data, err)
}
//根据周期里的考核日期,获取员工填写评估内容列表
// 根据周期里的考核日期,获取员工填写评估内容列表
func (c *StaffAssessController) ListAssessContentCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
... ... @@ -323,7 +322,7 @@ func (c *StaffAssessController) ListAssessContentCycleDay() {
c.Response(data, err)
}
//根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
// 根据周期里的考核日期,获取员工填写评估内容列表,导出为xlsx文件
func (c *StaffAssessController) ExportAssessContentCycleDay() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListAssessContentCycleDay{}
... ...
... ... @@ -10,8 +10,8 @@ import (
func init() {
assessTaskNS := web.NewNamespace("/v1/staff-assess-task",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
//web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
//web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
//web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
... ... @@ -21,19 +21,19 @@ func init() {
assessNS := web.NewNamespace("/v1/staff-assess",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工
web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工
web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存)
web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我被上级评估的列表
web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
//web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfMeInfo), //获取我的自评反馈详情
// web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessMeInviteUser), //获取邀请的员工
web.NSCtrlPost("/me/save-invite-user", (*controllers.StaffAssessController).SaveAssessMeInviteUser), //保存我邀请的员工
web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
//web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessController).ListMeInviteUserAssess), //我要执行的360评估的用户列表
//web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessController).ListMeSupperAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存)
// web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
//web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我被上级评估的列表
// web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
)
//v2 改版
assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
... ...