作者 郑周

Merge branch 'dev-zhengzhou' into test

... ... @@ -38,7 +38,7 @@ func TestOtherAccountToken(t *testing.T) {
UserId: 3422174102828544,
CompanyId: 8,
Phone: "17708397664",
PlatformId: 28,
PlatformId: 29,
Name: "杨欢",
AdminType: 1,
}
... ...
... ... @@ -12,17 +12,22 @@ type QueryEvaluation struct {
CompanyId int `json:"-"` //公司id
}
// QueryEvaluation360My [我] 对 [目标用户]进行360评估
type QueryEvaluation360My struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
CompanyId int `json:"-"` // 公司ID
UserId int `json:"-"` // 用户ID
}
// QueryEvaluation360 [他人] 对 [目标用户]进行360评估
type QueryEvaluation360 struct {
//SummaryEvaluationId int `json:"summaryEvaluationId,string"`
CycleId int `json:"cycleId,string"` // 周期ID
TargetUserId int `json:"targetUserId,string"` // 目标人ID
CompanyId int `json:"-"` // 公司ID
UserId int `json:"-"` // 用户ID
}
type QueryEvaluationHRBP struct {
//SummaryEvaluationId int `json:"summaryEvaluationId,string"`
//UserId int `json:"-"` // 用户ID
CycleId int `json:"cycleId,string"` // 周期ID
TargetUserId int `json:"targetUserId,string"` // 目标人ID
CompanyId int `json:"-"` // 公司ID
... ...
... ... @@ -185,8 +185,8 @@ func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvalu
return grid, nil
}
// GetEvaluation360 获取360综评详情(登录人作为评估人,评估内容)
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
// GetEvaluation360 获取360综评详情(我评估目标用户)
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360My) (*adapter.EvaluationInfoAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
... ... @@ -199,31 +199,19 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
//sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
//if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.Evaluation360},
)
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 { // 数据不存在
result := adapter.EvaluationInfoAdapter{}
result.EvaluationItems = make([]adapter.EvaluationItemAdapter, 0)
return &result, nil
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
sEvaluation := evaluations[0]
// 360评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"companyId": param.CompanyId,
"evaluatorId": param.UserId,
})
if err != nil {
... ... @@ -259,7 +247,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
}
// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)
func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*[]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
... ... @@ -268,7 +256,6 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva
_ = transactionContext.RollbackTransaction()
}()
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
... ... @@ -282,17 +269,25 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
result := adapter.EvaluationInfoAdapter{}
result.EvaluationItems = make([]adapter.EvaluationItemAdapter, 0)
return &result, nil
//return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
list := make([]adapter.EvaluationItemAdapter, 0)
return &list, nil
}
sEvaluation := evaluations[0]
executorMap := map[int]domain.StaffDesc{} // 执行人
evaluationIds := make([]int, 0) // 评估周期ID
for i := range evaluations {
executor := evaluations[i].Executor
executorMap[executor.UserId] = executor
evaluationIds = append(evaluationIds, evaluations[i].Id)
}
// 得到项目ID
evaluationProjectId := evaluations[0].EvaluationProjectId
// 360评估内容(自评模板)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
... ... @@ -300,28 +295,18 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationIdList": evaluationIds,
"types": domain.Evaluation360,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估人ID -> User
evaluatorMap := map[int]*domain.User{}
evaluatorIds := make([]int, 0)
filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
for i := range itemList {
if itemList[i].EvaluatorId > 0 {
filterItemList = append(filterItemList, itemList[i])
evaluatorIds = append(evaluatorIds, itemList[i].EvaluatorId)
}
}
if len(evaluatorIds) > 0 {
_, users, err := userRepo.Find(map[string]interface{}{"ids": evaluatorIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range users {
evaluatorMap[int(users[i].Id)] = users[i]
}
}
... ... @@ -331,26 +316,26 @@ func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEva
itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
if user, ok := evaluatorMap[itemValuesAdapter[i].EvaluatorId]; ok {
itemValuesAdapter[i].EvaluatorName = user.Name
if executor, ok := executorMap[itemValuesAdapter[i].EvaluatorId]; ok {
itemValuesAdapter[i].EvaluatorName = executor.UserName
}
}
result := adapter.EvaluationInfoAdapter{
SummaryEvaluationId: sEvaluation.Id,
CycleId: int(sEvaluation.CycleId),
CycleName: sEvaluation.CycleName,
EvaluationProjectId: sEvaluation.EvaluationProjectId,
EvaluationProjectName: sEvaluation.EvaluationProjectName,
LinkNodeId: sEvaluation.NodeId,
BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
TargetUserId: sEvaluation.TargetUser.UserId,
TargetUserName: sEvaluation.TargetUser.UserName,
Status: string(sEvaluation.Status),
EvaluationItems: itemValuesAdapter,
}
return &result, nil
//result := adapter.EvaluationInfoAdapter{
// SummaryEvaluationId: sEvaluation.Id,
// CycleId: int(sEvaluation.CycleId),
// CycleName: sEvaluation.CycleName,
// EvaluationProjectId: sEvaluation.EvaluationProjectId,
// EvaluationProjectName: sEvaluation.EvaluationProjectName,
// LinkNodeId: sEvaluation.NodeId,
// BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
// EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
// TargetUserId: sEvaluation.TargetUser.UserId,
// TargetUserName: sEvaluation.TargetUser.UserName,
// Status: string(sEvaluation.Status),
// EvaluationItems: itemValuesAdapter,
//}
return &itemValuesAdapter, nil
}
// EditEvaluation360 编辑提交360综评
... ... @@ -595,7 +580,7 @@ func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEval
}
// GetEvaluationHRBP 获取人资综评详情
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*[]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
... ... @@ -619,17 +604,26 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 { // 数据不存在
result := adapter.EvaluationInfoAdapter{}
result.EvaluationItems = make([]adapter.EvaluationItemAdapter, 0)
return &result, nil
//return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
if len(evaluations) == 0 {
list := make([]adapter.EvaluationItemAdapter, 0)
return &list, nil
}
executorMap := map[int]domain.StaffDesc{} // 执行人
evaluationIds := make([]int, 0) // 评估周期ID
for i := range evaluations {
executor := evaluations[i].Executor
executorMap[executor.UserId] = executor
evaluationIds = append(evaluationIds, evaluations[i].Id)
}
sEvaluation := evaluations[0]
// 得到项目ID
evaluationProjectId := evaluations[0].EvaluationProjectId
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"evaluatorId": -1,
})
... ... @@ -638,7 +632,10 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationIdList": evaluationIds,
"types": domain.EvaluationHrbp,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -648,21 +645,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
}
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
result := adapter.EvaluationInfoAdapter{
SummaryEvaluationId: sEvaluation.Id,
CycleId: int(sEvaluation.CycleId),
CycleName: sEvaluation.CycleName,
EvaluationProjectId: sEvaluation.EvaluationProjectId,
EvaluationProjectName: sEvaluation.EvaluationProjectName,
LinkNodeId: sEvaluation.NodeId,
BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
TargetUserId: sEvaluation.TargetUser.UserId,
TargetUserName: sEvaluation.TargetUser.UserName,
Status: string(sEvaluation.Status),
EvaluationItems: itemValuesAdapter,
}
return &result, nil
//result := adapter.EvaluationInfoAdapter{
// SummaryEvaluationId: sEvaluation.Id,
// CycleId: int(sEvaluation.CycleId),
// CycleName: sEvaluation.CycleName,
// EvaluationProjectId: sEvaluation.EvaluationProjectId,
// EvaluationProjectName: sEvaluation.EvaluationProjectName,
// LinkNodeId: sEvaluation.NodeId,
// BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
// EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
// TargetUserId: sEvaluation.TargetUser.UserId,
// TargetUserName: sEvaluation.TargetUser.UserName,
// Status: string(sEvaluation.Status),
// EvaluationItems: itemValuesAdapter,
//}
return &itemValuesAdapter, nil
}
// EditEvaluationHRBP 编辑提交人资综评
... ...
... ... @@ -116,6 +116,10 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
query.Where("summary_evaluation_id in(?)", pg.In(v))
}
if v, ok := queryOptions["types"]; ok {
query.Where("types=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -130,7 +130,7 @@ func (c *SummaryEvaluationController) Evaluation360List() {
func (c *SummaryEvaluationController) GetEvaluation360() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360{}
in := &command.QueryEvaluation360My{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
... ... @@ -155,7 +155,6 @@ func (c *SummaryEvaluationController) GetEvaluation360All() {
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
in.UserId = int(userReq.UserId)
data, err := srv.GetEvaluation360All(in)
c.Response(data, err)
}
... ... @@ -202,7 +201,6 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() {
return
}
userReq := middlewares.GetUser(c.Ctx)
//in.UserId = int(userReq.UserId)
in.CompanyId = int(userReq.CompanyId)
data, err := srv.GetEvaluationHRBP(in)
c.Response(data, err)
... ...