作者 tangxvhui

Merge branch 'dev-tangxvhui' into test

@@ -4,5 +4,4 @@ type AssessCycleDayResp struct { @@ -4,5 +4,4 @@ type AssessCycleDayResp struct {
4 CycleId int `json:"cycleId"` 4 CycleId int `json:"cycleId"`
5 CycleName string `json:"cycleName"` 5 CycleName string `json:"cycleName"`
6 BeginDay string `json:"beginDay"` 6 BeginDay string `json:"beginDay"`
7 - AssessTaskId []int `json:"assessTaskId"`  
8 } 7 }
@@ -4,6 +4,8 @@ type ListInviteUserAssessResp struct { @@ -4,6 +4,8 @@ type ListInviteUserAssessResp struct {
4 LinkNodeName string `json:"linkNodeName"` 4 LinkNodeName string `json:"linkNodeName"`
5 LinkNodeId int `json:"linkNodeId"` 5 LinkNodeId int `json:"linkNodeId"`
6 LintNodeDesc string `json:"lintNodeDesc"` 6 LintNodeDesc string `json:"lintNodeDesc"`
  7 + BeginDay string `json:"beginDay"`
  8 + CycleId int `json:"cycleId"`
7 TableHeader []ListTableHeader `json:"tableHeader"` 9 TableHeader []ListTableHeader `json:"tableHeader"`
8 List []map[string]string `json:"list"` 10 List []map[string]string `json:"list"`
9 Total int `json:"total"` 11 Total int `json:"total"`
@@ -2,7 +2,9 @@ package adapter @@ -2,7 +2,9 @@ package adapter
2 2
3 type ListSupperAssessResp struct { 3 type ListSupperAssessResp struct {
4 AssessId int `json:"assessId"` // 4 AssessId int `json:"assessId"` //
5 - UsrId int `json:"userId,string"` 5 + CycleId int `json:"cycleId"` //周期id
  6 + BeginDay string `json:"beginDay"` //开始的日期
  7 + UserId int `json:"userId,string"` //用户id
6 UserName string `json:"userName"` //用户名称 8 UserName string `json:"userName"` //用户名称
7 EndTime string `json:"endTime"` //截止时间 9 EndTime string `json:"endTime"` //截止时间
8 InviteTotal int `json:"inviteTota"` //邀请总数 10 InviteTotal int `json:"inviteTota"` //邀请总数
@@ -6,8 +6,9 @@ type AssessTaskDescQuery struct { @@ -6,8 +6,9 @@ type AssessTaskDescQuery struct {
6 CompanyId int `json:"companyId"` //当前登录的公司 6 CompanyId int `json:"companyId"` //当前登录的公司
7 } 7 }
8 8
  9 +//获取我的项目周期进度描述
9 type AssessTaskDescV2Query struct { 10 type AssessTaskDescV2Query struct {
10 - CycleId int `json:"cycle"` 11 + CycleId int `json:"cycleId"`
11 BeginDay string `json:"beginDay"` 12 BeginDay string `json:"beginDay"`
12 UserId int `json:"userId"` //当前登录人的id 13 UserId int `json:"userId"` //当前登录人的id
13 CompanyId int `json:"companyId"` //当前登录的公司 14 CompanyId int `json:"companyId"` //当前登录的公司
  1 +package query
  2 +
  3 +// 根据周期和日期,获取员工的自评内容
  4 +type GetExecutorSelfAssessQuery struct {
  5 + CompanyId int `json:"companyId"` //
  6 + TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
  7 + CycleId int `json:"cycleId"` //评估周期id 必填
  8 + BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
  9 +}
1 -package query  
2 -  
3 -type ListAssessInviteUserQuery struct {  
4 - CompanyId int `json:"companyId"` //对公司  
5 - UserId int `json:"userId"` //被评估的员工id  
6 - CycleId int `json:"CycleId"` //评估任务的周期id  
7 - BeginDay string `json:"beginDay"` //日期  
8 -}  
1 package query 1 package query
2 2
  3 +// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
3 type ListExecutorAssessQuery struct { 4 type ListExecutorAssessQuery struct {
4 PageNumber int `json:"pageNumber"` 5 PageNumber int `json:"pageNumber"`
5 PageSize int `json:"pageSize"` 6 PageSize int `json:"pageSize"`
  1 +package query
  2 +
  3 +//根据周期和日期,获取员工邀请评估的人员
  4 +type ListInviteUserQuery struct {
  5 + CompanyId int `json:"companyId"` //对公司
  6 + TargetUserId int `json:"targetUserId,string"` //被评估的员工id
  7 + CycleId int `json:"CycleId"` //评估任务的周期id
  8 + BeginDay string `json:"beginDay"` //日期
  9 +}
1 package query 1 package query
2 2
  3 +// 获取我的项目周期列表
3 type SearchAssessMeQuery struct { 4 type SearchAssessMeQuery struct {
4 UserId int `json:"userId"` // 当前登录人的用户id 5 UserId int `json:"userId"` // 当前登录人的用户id
5 CompanyId int `json:"companyId"` //当前登录人的公司Id 6 CompanyId int `json:"companyId"` //当前登录人的公司Id
@@ -1454,7 +1454,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA @@ -1454,7 +1454,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssess(param *query.ListSupperA
1454 for _, v := range assessList { 1454 for _, v := range assessList {
1455 item := adapter.ListSupperAssessResp{ 1455 item := adapter.ListSupperAssessResp{
1456 AssessId: v.Id, 1456 AssessId: v.Id,
1457 - UsrId: v.TargetUser.UserId, 1457 + UserId: v.TargetUser.UserId,
1458 UserName: v.TargetUser.UserName, 1458 UserName: v.TargetUser.UserName,
1459 EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), 1459 EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
1460 InviteCompleted: 0, 1460 InviteCompleted: 0,
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" 11 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  14 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
14 ) 15 )
15 16
16 //获取我的项目周期列表 17 //获取我的项目周期列表
@@ -54,7 +55,6 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ @@ -54,7 +55,6 @@ func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQ
54 CycleId: v.CycleId, 55 CycleId: v.CycleId,
55 CycleName: v.CycleName, 56 CycleName: v.CycleName,
56 BeginDay: v.BeginDay, 57 BeginDay: v.BeginDay,
57 - AssessTaskId: v.AssessTaskId,  
58 } 58 }
59 listData = append(listData, temp) 59 listData = append(listData, temp)
60 } 60 }
@@ -217,7 +217,7 @@ func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Que @@ -217,7 +217,7 @@ func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Que
217 } 217 }
218 218
219 //根据周期获取,我的自评任务添加的邀请人 219 //根据周期获取,我的自评任务添加的邀请人
220 -func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { 220 +func (srv StaffAssessServeice) ListAssessInviteUserV2(param *query.ListInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
221 transactionContext, err := factory.CreateTransactionContext(nil) 221 transactionContext, err := factory.CreateTransactionContext(nil)
222 if err != nil { 222 if err != nil {
223 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 223 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -239,7 +239,7 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInvi @@ -239,7 +239,7 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInvi
239 _, myAssessTask, err := assessTaskRepo.Find(map[string]interface{}{ 239 _, myAssessTask, err := assessTaskRepo.Find(map[string]interface{}{
240 "cycleId": param.CycleId, 240 "cycleId": param.CycleId,
241 "beginDay": param.BeginDay, 241 "beginDay": param.BeginDay,
242 - "executorId": param.UserId, 242 + "executorId": param.TargetUserId,
243 "limit": 1, 243 "limit": 1,
244 }) 244 })
245 if err != nil { 245 if err != nil {
@@ -255,7 +255,7 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInvi @@ -255,7 +255,7 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInvi
255 _, assessList, err := assessReps.Find(map[string]interface{}{ 255 _, assessList, err := assessReps.Find(map[string]interface{}{
256 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 256 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
257 "staffAssessTaskId": assessTaskData.Id, 257 "staffAssessTaskId": assessTaskData.Id,
258 - "targetUserId": param.UserId, 258 + "targetUserId": param.TargetUserId,
259 }) 259 })
260 if err != nil { 260 if err != nil {
261 return nil, application.ThrowError(application.ARG_ERROR, "获取个人邀请列表"+err.Error()) 261 return nil, application.ThrowError(application.ARG_ERROR, "获取个人邀请列表"+err.Error())
@@ -291,7 +291,7 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInvi @@ -291,7 +291,7 @@ func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInvi
291 } 291 }
292 292
293 // 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值 293 // 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
294 -func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExecutorAssessQuery) ( 294 +func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecutorAssessQuery) (
295 *adapter.ListInviteUserAssessResp, error) { 295 *adapter.ListInviteUserAssessResp, error) {
296 transactionContext, err := factory.CreateTransactionContext(nil) 296 transactionContext, err := factory.CreateTransactionContext(nil)
297 if err != nil { 297 if err != nil {
@@ -307,9 +307,7 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -307,9 +307,7 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
307 assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ 307 assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
308 "transactionContext": transactionContext, 308 "transactionContext": transactionContext,
309 }) 309 })
310 - assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{  
311 - "transactionContext": transactionContext,  
312 - }) 310 +
313 //获取 executorId 对应的360评估任务 用户 311 //获取 executorId 对应的360评估任务 用户
314 condition := map[string]interface{}{ 312 condition := map[string]interface{}{
315 "beginDay": param.BeginDay, 313 "beginDay": param.BeginDay,
@@ -399,15 +397,6 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -399,15 +397,6 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
399 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) 397 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
400 } 398 }
401 399
402 - _, myAssessTaskData, err := assessTaskRepo.Find(map[string]interface{}{  
403 - "beginDay": param.BeginDay,  
404 - "cycleId": param.CycleId,  
405 - "executorId": param.ExecutorId,  
406 - "limit": 1,  
407 - })  
408 - if err != nil {  
409 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())  
410 - }  
411 if err := transactionContext.CommitTransaction(); err != nil { 400 if err := transactionContext.CommitTransaction(); err != nil {
412 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 401 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
413 } 402 }
@@ -426,6 +415,8 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -426,6 +415,8 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
426 "userName": v.TargetUser.UserName, 415 "userName": v.TargetUser.UserName,
427 "userId": strconv.Itoa(v.TargetUser.UserId), 416 "userId": strconv.Itoa(v.TargetUser.UserId),
428 "status": string(v.Status), 417 "status": string(v.Status),
  418 + "cycleId": strconv.FormatInt(v.CycleId, 10),
  419 + "beginDay": v.BeginTime.Local().Format("2006-01-02"),
429 "types": string(v.Types), 420 "types": string(v.Types),
430 "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"), 421 "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
431 "assessId": strconv.Itoa(v.Id), 422 "assessId": strconv.Itoa(v.Id),
@@ -458,20 +449,18 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -458,20 +449,18 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
458 List: listData, 449 List: listData,
459 Total: cnt, 450 Total: cnt,
460 } 451 }
461 - if len(myAssessTaskData) > 0 {  
462 - for _, v := range myAssessTaskData[0].StepList {  
463 - if v.LinkNodeType == domain.LinkNodeAllAssessment {  
464 - result.LinkNodeId = v.LinkNodeId  
465 - result.LinkNodeName = v.LinkNodeName  
466 - result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)  
467 - }  
468 - } 452 +
  453 + if len(assessList) > 0 {
  454 + result.BeginDay = assessList[0].BeginTime.Local().Format("2006-01-02")
  455 + result.CycleId = int(assessList[0].CycleId)
  456 + result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
469 } 457 }
  458 +
470 return &result, nil 459 return &result, nil
471 } 460 }
472 461
473 //根据周期和日期获取我需要执行的上级评估成员列表 462 //根据周期和日期获取我需要执行的上级评估成员列表
474 -func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExecutorAssessQuery) (map[string]interface{}, error) { 463 +func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecutorAssessQuery) (map[string]interface{}, error) {
475 transactionContext, err := factory.CreateTransactionContext(nil) 464 transactionContext, err := factory.CreateTransactionContext(nil)
476 if err != nil { 465 if err != nil {
477 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 466 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -510,7 +499,7 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -510,7 +499,7 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
510 if err != nil { 499 if err != nil {
511 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 500 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
512 } 501 }
513 - 502 + //获取目标用户
514 userIds := []int{} 503 userIds := []int{}
515 for _, v := range assessList { 504 for _, v := range assessList {
516 userIds = append(userIds, v.TargetUser.UserId) 505 userIds = append(userIds, v.TargetUser.UserId)
@@ -540,33 +529,26 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -540,33 +529,26 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
540 }) 529 })
541 userPositionMap[v.Id] = positionList 530 userPositionMap[v.Id] = positionList
542 } 531 }
543 -  
544 - //获取员工邀请的人完成360评估的数量 532 + //获取目标员工邀请的人完成360评估的数量
545 var inviteCompletedCount []dao.CountData 533 var inviteCompletedCount []dao.CountData
546 - if len(userIds) > 0 {  
547 - // d := dao.NewStaffAssessDao(map[string]interface{}{  
548 - // "transactionContext": transactionContext,  
549 - // })  
550 - // inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId)  
551 - // if err != nil {  
552 - // log.Logger.Error("获取员工邀请的人完成情况" + err.Error())  
553 - // }  
554 - }  
555 - assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ 534 + d := dao.NewStaffAssessDao(map[string]interface{}{
556 "transactionContext": transactionContext, 535 "transactionContext": transactionContext,
557 }) 536 })
558 - assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{  
559 - // "id": param.AssessTaskId,  
560 - }) 537 + if len(userIds) > 0 {
  538 + inviteCompletedCount, err = d.CountTargetUserInviteAssess1(userIds, param.CycleId, param.BeginDay)
561 if err != nil { 539 if err != nil {
562 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error()) 540 + log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
  541 + }
563 } 542 }
  543 +
564 //我评估别人,被邀请评估 544 //我评估别人,被邀请评估
565 cnnt, _, err := assessRepo.Find(map[string]interface{}{ 545 cnnt, _, err := assessRepo.Find(map[string]interface{}{
566 - // "staffAssessTaskId": param.AssessTaskId, 546 + "beginDay": param.BeginDay,
  547 + "cycleId": param.CycleId,
567 "executorId": param.ExecutorId, 548 "executorId": param.ExecutorId,
568 "typesList": []string{string(domain.AssessSuper)}, 549 "typesList": []string{string(domain.AssessSuper)},
569 "status": string(domain.StaffAssessUncompleted), 550 "status": string(domain.StaffAssessUncompleted),
  551 + "limit": 1,
570 }) 552 })
571 if err != nil { 553 if err != nil {
572 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) 554 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
@@ -579,7 +561,9 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -579,7 +561,9 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
579 for _, v := range assessList { 561 for _, v := range assessList {
580 item := adapter.ListSupperAssessResp{ 562 item := adapter.ListSupperAssessResp{
581 AssessId: v.Id, 563 AssessId: v.Id,
582 - UsrId: v.TargetUser.UserId, 564 + CycleId: int(v.CycleId),
  565 + BeginDay: v.BeginTime.Local().Format("2006-01-02"),
  566 + UserId: v.TargetUser.UserId,
583 UserName: v.TargetUser.UserName, 567 UserName: v.TargetUser.UserName,
584 EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"), 568 EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
585 InviteCompleted: 0, 569 InviteCompleted: 0,
@@ -616,15 +600,95 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec @@ -616,15 +600,95 @@ func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExec
616 resultList = append(resultList, item) 600 resultList = append(resultList, item)
617 } 601 }
618 result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList) 602 result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
619 - result["linkNodeName"] = ""  
620 - result["linkNodeId"] = ""  
621 result["lintNodeDesc"] = "" 603 result["lintNodeDesc"] = ""
622 - for _, v := range assessTaskData.StepList {  
623 - if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {  
624 - result["linkNodeName"] = v.LinkNodeName  
625 - result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId)  
626 - result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)  
627 - } 604 + if len(assessList) > 0 {
  605 + result["cycleId"] = assessList[0].CycleId
  606 + result["beginDay"] = assessList[0].BeginTime.Local().Format("2006-01-02")
  607 + result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
628 } 608 }
629 return result, nil 609 return result, nil
630 } 610 }
  611 +
  612 +//根据周期和日期,获取员工的自评内容
  613 +func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfAssessQuery) (*adapter.AssessInfoResp, error) {
  614 + transactionContext, err := factory.CreateTransactionContext(nil)
  615 + if err != nil {
  616 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  617 + }
  618 + if err := transactionContext.StartTransaction(); err != nil {
  619 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  620 + }
  621 + defer func() {
  622 + _ = transactionContext.RollbackTransaction()
  623 + }()
  624 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  625 + "transactionContext": transactionContext,
  626 + })
  627 + // 获取员工的评估
  628 + _, assessList, err := assessReps.Find(map[string]interface{}{
  629 + "companyId": param.CompanyId,
  630 + "executorId": param.TargetUserId,
  631 + "cycleId": param.CycleId,
  632 + "beginDay": param.BeginDay,
  633 + "typesList": []string{string(domain.AssessSelf)},
  634 + "limit": 1,
  635 + })
  636 + if err != nil {
  637 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  638 + }
  639 + if len(assessList) == 0 {
  640 + return nil, application.ThrowError(application.BUSINESS_ERROR, "不存在员工的自评内容")
  641 + }
  642 + assessData := assessList[0]
  643 +
  644 + assessContentList := []*domain.StaffAssessContent{}
  645 + if assessData.Status == domain.StaffAssessCompleted {
  646 + //已完成
  647 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  648 + "transactionContext": transactionContext,
  649 + })
  650 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  651 + "staffAssessId": assessData.Id,
  652 + })
  653 + if err != nil {
  654 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  655 + }
  656 + } else if assessData.Status == domain.StaffAssessUncompleted {
  657 + //未完成
  658 + assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
  659 + if err != nil {
  660 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  661 + }
  662 + }
  663 +
  664 + //获取员工描述
  665 + staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
  666 + if err := transactionContext.CommitTransaction(); err != nil {
  667 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  668 + }
  669 + result := adapter.AssessInfoResp{
  670 + AssessId: assessData.Id,
  671 + CycleId: assessData.CycleId,
  672 + CycleName: assessData.CycleName,
  673 + LinkNodeId: assessData.LinkNodeId,
  674 + LinkNodeName: assessData.LinkNodeName,
  675 + EvaluationProjectId: assessData.EvaluationProjectId,
  676 + EvaluationProjectName: assessData.EvaluationProjectName,
  677 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  678 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  679 + Status: string(assessData.Status),
  680 + TargetUserId: assessData.TargetUser.UserId,
  681 + TargetUserName: assessData.TargetUser.UserName,
  682 + CompanyId: assessData.CompanyId,
  683 + CompanyName: "",
  684 + SupperUser: "",
  685 + DutyTime: "",
  686 + AssessContent: assessContentList,
  687 + }
  688 + if staffDesc != nil {
  689 + result.CompanyName = staffDesc.CompanyName
  690 + result.SupperUser = staffDesc.SupperUserName
  691 + result.DutyTime = staffDesc.DutyTime
  692 + }
  693 + return &result, nil
  694 +}
@@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask @@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
57 return result, err 57 return result, err
58 } 58 }
59 59
  60 +func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int, beginDay string) ([]CountData, error) {
  61 + sqlStr := `SELECT
  62 + staff_assess.target_user->>'userId' as target_user_id,
  63 + count(staff_assess."id") AS invite_total,
  64 + sum(
  65 + case WHEN staff_assess.status='completed' THEN 1
  66 + ELSE 0 END
  67 + ) as invite_completed
  68 + FROM staff_assess
  69 + WHERE staff_assess.target_user->>'userId' IN(?)
  70 + AND staff_assess.types IN ('invite_same_super','invite_diff_super')
  71 + and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') = ?
  72 + and staff_assess.cycle_id =?
  73 + GROUP BY target_user_id`
  74 + userIdStr := []string{}
  75 + for _, v := range userIds {
  76 + str := strconv.Itoa(v)
  77 + userIdStr = append(userIdStr, str)
  78 + }
  79 + condition := []interface{}{
  80 + pg.In(userIdStr), beginDay, cycleId,
  81 + }
  82 + tx := d.transactionContext.PgTx
  83 + result := []CountData{}
  84 + _, err := tx.Query(&result, sqlStr, condition...)
  85 + return result, err
  86 +}
  87 +
60 // 根据评估的人执行人id,搜索 executorId参与的评估任务 88 // 根据评估的人执行人id,搜索 executorId参与的评估任务
61 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) { 89 func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
62 90
@@ -385,7 +413,6 @@ type AssessCycleDayMe struct { @@ -385,7 +413,6 @@ type AssessCycleDayMe struct {
385 BeginDay string `json:"beginDay"` 413 BeginDay string `json:"beginDay"`
386 CycleId int `json:"cycleId"` 414 CycleId int `json:"cycleId"`
387 CycleName string `json:"cycleName"` 415 CycleName string `json:"cycleName"`
388 - AssessTaskId []int `json:"assessTaskId"`  
389 } 416 }
390 417
391 // 根据评估的人执行人id,搜索 executorId参与的评估周期 418 // 根据评估的人执行人id,搜索 executorId参与的评估周期
@@ -398,7 +425,6 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi @@ -398,7 +425,6 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
398 } 425 }
399 sqlStr := ` 426 sqlStr := `
400 SELECT 427 SELECT
401 - jsonb_agg (staff_assess_task.id) as assess_task_id,  
402 staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day 428 staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
403 FROM staff_assess_task 429 FROM staff_assess_task
404 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id" 430 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "github.com/linmadan/egglib-go/web/beego"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
  9 +)
  10 +
  11 +type StaffAssessControllerV2 struct {
  12 + beego.BaseController
  13 +}
  14 +
  15 +// 获取我的绩效任务列表
  16 +func (c *StaffAssessControllerV2) SearchAssessTaskMe() {
  17 + srv := service.NewStaffAssessServeice()
  18 + paramReq := &query.SearchAssessMeQuery{}
  19 + err := c.BindJSON(paramReq)
  20 + if err != nil {
  21 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  22 + c.Response(nil, e)
  23 + return
  24 + }
  25 + userReq := middlewares.GetUser(c.Ctx)
  26 + paramReq.CompanyId = int(userReq.CompanyId)
  27 + paramReq.UserId = int(userReq.UserId)
  28 +
  29 + data, err := srv.SearchAssessTaskMeV2(paramReq)
  30 + c.Response(data, err)
  31 +}
  32 +
  33 +// 获取我的绩效任务各环节完成情况
  34 +func (c *StaffAssessControllerV2) AssessTaskMeDesc() {
  35 + srv := service.NewStaffAssessServeice()
  36 + paramReq := &query.AssessTaskDescV2Query{}
  37 + err := c.BindJSON(paramReq)
  38 + if err != nil {
  39 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  40 + c.Response(nil, e)
  41 + return
  42 + }
  43 + userReq := middlewares.GetUser(c.Ctx)
  44 + paramReq.CompanyId = int(userReq.CompanyId)
  45 + paramReq.UserId = int(userReq.UserId)
  46 + data, err := srv.AssessTaskDescV2(paramReq)
  47 + c.Response(data, err)
  48 +}
  49 +
  50 +// 获取我要执行360评估,用户列表和评估填写的值
  51 +func (c *StaffAssessControllerV2) ListMeInviteUserAssess() {
  52 + srv := service.NewStaffAssessServeice()
  53 + paramReq := &query.ListExecutorAssessQuery{}
  54 + err := c.BindJSON(paramReq)
  55 + if err != nil {
  56 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  57 + c.Response(nil, e)
  58 + return
  59 + }
  60 + //获取当前用户信息
  61 + userReq := middlewares.GetUser(c.Ctx)
  62 + paramReq.CompanyId = int(userReq.CompanyId)
  63 + paramReq.ExecutorId = int(userReq.UserId)
  64 + data, err := srv.ListExecutorInviteAssessV2(paramReq)
  65 + c.Response(data, err)
  66 +}
  67 +
  68 +// 获取我要执行的上级评估成员列表
  69 +func (c *StaffAssessControllerV2) ListMeSupperAssess() {
  70 + srv := service.NewStaffAssessServeice()
  71 + paramReq := &query.ListExecutorAssessQuery{}
  72 + err := c.BindJSON(paramReq)
  73 + if err != nil {
  74 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  75 + c.Response(nil, e)
  76 + return
  77 + }
  78 + // 获取当前用户信息
  79 + userReq := middlewares.GetUser(c.Ctx)
  80 + paramReq.CompanyId = int(userReq.CompanyId)
  81 + paramReq.ExecutorId = int(userReq.UserId)
  82 + data, err := srv.ListExecutorSupperAssessV2(paramReq)
  83 + c.Response(data, err)
  84 +}
  85 +
  86 +// 获取我邀请的人
  87 +func (c *StaffAssessControllerV2) GetAssessMeInviteUser() {
  88 + srv := service.NewStaffAssessServeice()
  89 + paramReq := &query.ListInviteUserQuery{}
  90 + err := c.BindJSON(paramReq)
  91 + if err != nil {
  92 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  93 + c.Response(nil, e)
  94 + return
  95 + }
  96 + userReq := middlewares.GetUser(c.Ctx)
  97 + paramReq.CompanyId = int(userReq.CompanyId)
  98 + paramReq.TargetUserId = int(userReq.UserId)
  99 + data, err := srv.ListAssessInviteUserV2(paramReq)
  100 + c.Response(data, err)
  101 +}
  102 +
  103 +// 获取员工自评详情
  104 +func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
  105 + srv := service.NewStaffAssessServeice()
  106 + paramReq := &query.GetExecutorSelfAssessQuery{}
  107 + err := c.BindJSON(paramReq)
  108 + if err != nil {
  109 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  110 + c.Response(nil, e)
  111 + return
  112 + }
  113 + // paramReq.CompanyId = 1
  114 + userReq := middlewares.GetUser(c.Ctx)
  115 + paramReq.CompanyId = int(userReq.CompanyId)
  116 + data, err := srv.GetAssessSelfInfoV2(paramReq)
  117 + c.Response(data, err)
  118 +}
@@ -12,7 +12,7 @@ func init() { @@ -12,7 +12,7 @@ func init() {
12 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()), 12 web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
13 web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表 13 web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
14 web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述 14 web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
15 - web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务 15 + //web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
16 web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表 16 web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
17 web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期 17 web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
18 web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表 18 web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
@@ -33,8 +33,24 @@ func init() { @@ -33,8 +33,24 @@ func init() {
33 web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表 33 web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
34 web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表 34 web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表
35 web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情 35 web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
  36 + )
  37 + //v2 改版
  38 + assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
  39 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  40 + web.NSCtrlPost("/search/me", (*controllers.StaffAssessControllerV2).SearchAssessTaskMe), //获取我参与过的评估项目列表
  41 + web.NSCtrlPost("/desc/me", (*controllers.StaffAssessControllerV2).AssessTaskMeDesc),
  42 + )
36 43
  44 + assessV2NS := web.NewNamespace("/v2/staff-assess",
  45 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  46 + web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessControllerV2).ListMeInviteUserAssess), //我要执行的360评估的用户列表
  47 + web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessControllerV2).ListMeSupperAssess), //我要执行的360评估的用户列表
  48 + web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessControllerV2).GetAssessMeInviteUser), //获取邀请的员工
  49 + web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessControllerV2).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
37 ) 50 )
  51 +
38 web.AddNamespace(assessTaskNS) 52 web.AddNamespace(assessTaskNS)
39 web.AddNamespace(assessNS) 53 web.AddNamespace(assessNS)
  54 + web.AddNamespace(assessTaskV2NS)
  55 + web.AddNamespace(assessV2NS)
40 } 56 }