作者 tangxvhui

Merge branch '1.3.2-bug' into test

  1 +package adapter
  2 +
  3 +// 列包含表周期和项目信息
  4 +type CycleAndProjctListAdapter struct {
  5 + CycleId string `json:"cycleId"` //周期id
  6 + CycleName string `json:"cycleName"` //
  7 + ProjectId string `json:"projectId"` //项目id
  8 + ProjectName string `json:"projectName"`
  9 + TargetUserId string `json:"targetUserId"`
  10 +}
1 package command 1 package command
2 2
3 -// type QueryEvaluationInfo struct {  
4 -// CycleId int `json:"cycleId,string"` //周期id  
5 -// ExecutorId int `json:"executorId,string"` //执行人id  
6 -// CompanyId int `json:"-"` //公司id  
7 -// }  
8 -  
9 type QueryEvaluation struct { 3 type QueryEvaluation struct {
10 CycleId int `json:"cycleId,string"` //周期id 4 CycleId int `json:"cycleId,string"` //周期id
11 TargetUserId int `json:"targetUserId,string"` //员工id 5 TargetUserId int `json:"targetUserId,string"` //员工id
@@ -46,3 +40,11 @@ type QueryEvaluationSuper struct { @@ -46,3 +40,11 @@ type QueryEvaluationSuper struct {
46 UserId int `json:"-"` 40 UserId int `json:"-"`
47 Advanced int `json:"advanced"` 41 Advanced int `json:"advanced"`
48 } 42 }
  43 +
  44 +// QueryEvaluationSelf 获取周期自评小结详情
  45 +type QueryEvaluationSelf struct {
  46 + CycleId int `json:"cycleId,string"` //周期id
  47 + TargetUserId int `json:"targetUserId,string"` //员工id
  48 + ProjectId int `json:"projectId,string"` //项目id
  49 + CompanyId int `json:"-"` //公司id
  50 +}
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "fmt"
  5 +
  6 + "github.com/linmadan/egglib-go/core/application"
  7 + "github.com/linmadan/egglib-go/utils/tool_funs"
  8 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
4 permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission" 9 permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission"
5 permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command" 10 permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command"
  11 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
  12 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  14 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
7 ) 15 )
8 16
9 func getPermission(companyId int64) (*domain.Permission, error) { 17 func getPermission(companyId int64) (*domain.Permission, error) {
@@ -16,3 +24,165 @@ func getPermission(companyId int64) (*domain.Permission, error) { @@ -16,3 +24,165 @@ func getPermission(companyId int64) (*domain.Permission, error) {
16 } 24 }
17 return permissionData, nil 25 return permissionData, nil
18 } 26 }
  27 +
  28 +// ListCycleAndProject
  29 +// 自评小结列表,自评评估列表
  30 +func (srv *SummaryEvaluationService) ListCycleAndProject(param *command.QueryCycleList) (map[string]interface{}, error) {
  31 + transactionContext, err := factory.CreateTransactionContext(nil)
  32 + if err != nil {
  33 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  34 + }
  35 + if err := transactionContext.StartTransaction(); err != nil {
  36 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  37 + }
  38 + defer func() {
  39 + _ = transactionContext.RollbackTransaction()
  40 + }()
  41 + limit := 600
  42 + offset := 0
  43 + if param.PageSize > 0 {
  44 + limit = param.PageSize
  45 + }
  46 + if param.PageNumber > 0 {
  47 + offset = (param.PageNumber - 1) * param.PageSize
  48 + }
  49 + assessDao := dao.NewStaffAssessDao(map[string]interface{}{
  50 + "transactionContext": transactionContext,
  51 + })
  52 + projectList, err := assessDao.ListCycleAndProject(param.UserId, param.CompanyId, limit, offset)
  53 + if err != nil {
  54 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  55 + }
  56 + if err := transactionContext.CommitTransaction(); err != nil {
  57 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  58 + }
  59 +
  60 + cycleList := []adapter.CycleAndProjctListAdapter{}
  61 + for _, v := range projectList {
  62 + m := adapter.CycleAndProjctListAdapter{
  63 + CycleId: v.CycleId,
  64 + CycleName: v.CycleName,
  65 + ProjectId: v.EvaluationProjectId,
  66 + ProjectName: v.EvaluationProjectName,
  67 + TargetUserId: v.TargetUserId,
  68 + }
  69 +
  70 + cycleList = append(cycleList, m)
  71 + }
  72 + return tool_funs.SimpleWrapGridMap(int64(len(projectList)), cycleList), nil
  73 +
  74 +}
  75 +
  76 +// 周期综合自评小结详情
  77 +func (srv *SummaryEvaluationService) CountEvaluationSelfLevelV2(param *command.QueryEvaluationSelf) (*adapter.EvaluationInfoCountCodeAdapter, error) {
  78 + transactionContext, err := factory.CreateTransactionContext(nil)
  79 + if err != nil {
  80 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  81 + }
  82 + if err := transactionContext.StartTransaction(); err != nil {
  83 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  84 + }
  85 + defer func() {
  86 + _ = transactionContext.RollbackTransaction()
  87 + }()
  88 + //统计周期内,评估项等级的数量
  89 + assessDao := dao.NewStaffAssessDao(map[string]interface{}{
  90 + "transactionContext": transactionContext,
  91 + })
  92 + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
  93 + "transactionContext": transactionContext,
  94 + })
  95 + evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
  96 + "transactionContext": transactionContext,
  97 + })
  98 + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
  99 + "transactionContext": transactionContext,
  100 + })
  101 + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
  102 + "limit": 1,
  103 + "cycleId": param.CycleId,
  104 + "targetUserId": param.TargetUserId,
  105 + "types": domain.EvaluationSelf,
  106 + })
  107 + if err != nil {
  108 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  109 + }
  110 + if len(evaluationList) == 0 {
  111 + return &adapter.EvaluationInfoCountCodeAdapter{}, nil
  112 + }
  113 + evaluationData := evaluationList[0]
  114 + levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.ProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId)
  115 + if err != nil {
  116 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  117 + }
  118 + _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
  119 + "evaluationProjectId": param.ProjectId,
  120 + "nodeType": int(domain.LinkNodeSelfAssessment),
  121 + })
  122 + if err != nil {
  123 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  124 + }
  125 +
  126 + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{
  127 + "summaryEvaluationId": evaluationData.Id,
  128 + })
  129 +
  130 + if err != nil {
  131 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  132 + }
  133 + // 获取组装基本信息
  134 + evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
  135 + if err := transactionContext.CommitTransaction(); err != nil {
  136 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  137 + }
  138 +
  139 + evaluationItems := srv.buildSummaryItemValue(itemList, itemValues)
  140 +
  141 + levelCodeMap := map[int][]adapter.LevalCodeCount{}
  142 + for _, v := range evaluationItems {
  143 + codes := v.Rule.GetLevelCodes()
  144 + levelCode := []adapter.LevalCodeCount{}
  145 + for _, v2 := range codes {
  146 + levelCode = append(levelCode, adapter.LevalCodeCount{
  147 + Code: v2,
  148 + Number: 0,
  149 + })
  150 + }
  151 + levelCodeMap[v.EvaluationItemId] = levelCode
  152 + }
  153 + levelCodeCountMap := map[string]int{}
  154 + for _, v := range levelCodeCountList {
  155 + key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
  156 + levelCodeCountMap[key] = v.Cnt
  157 + }
  158 +
  159 + evaluationItemCount := []adapter.EvaluationItemCountCodeAdapter{}
  160 + for i := range evaluationItems {
  161 + itemCount := adapter.EvaluationItemCountCodeAdapter{
  162 + EvaluationItemAdapter: evaluationItems[i],
  163 + LevelCount: []adapter.LevalCodeCount{},
  164 + }
  165 + evaluationItemCount = append(evaluationItemCount, itemCount)
  166 + itemId := evaluationItems[i].EvaluationItemId
  167 + levelCodes, ok := levelCodeMap[itemId]
  168 + if !ok {
  169 + continue
  170 + }
  171 + evaluationItemCount[i].LevelCount = levelCodes
  172 + for i2 := range levelCodes {
  173 + key := fmt.Sprintf("%s-%s-%s",
  174 + evaluationItems[i].Category,
  175 + evaluationItems[i].Name,
  176 + levelCodes[i2].Code,
  177 + )
  178 + if mVal, ok := levelCodeCountMap[key]; ok {
  179 + levelCodes[i2].Number = mVal
  180 + }
  181 + }
  182 + }
  183 + evaluationInfo := adapter.EvaluationInfoCountCodeAdapter{
  184 + EvaluationBaseAdapter: evaluationBase,
  185 + EvaluationItems: evaluationItemCount,
  186 + }
  187 + return &evaluationInfo, nil
  188 +}
@@ -64,10 +64,12 @@ func checkTaskRecord(param *domain.TaskRecord) error { @@ -64,10 +64,12 @@ func checkTaskRecord(param *domain.TaskRecord) error {
64 taskData := taskDataList[0] 64 taskData := taskDataList[0]
65 if param.AnomalyState != domain.AnomalyState1 { 65 if param.AnomalyState != domain.AnomalyState1 {
66 taskData.Anomaly += 1 66 taskData.Anomaly += 1
67 - }  
68 - if param.CanTaskAnomaly() { 67 + } else {
69 taskData.Anomaly = 0 68 taskData.Anomaly = 0
70 } 69 }
  70 + // if param.CanTaskAnomaly() {
  71 + // taskData.Anomaly = 0
  72 + // }
71 err = taskRepo.Save(taskData) 73 err = taskRepo.Save(taskData)
72 if err != nil { 74 if err != nil {
73 return fmt.Errorf("保存任务数据:%s", err) 75 return fmt.Errorf("保存任务数据:%s", err)
1 package domain 1 package domain
2 2
3 import ( 3 import (
4 - "strings"  
5 "time" 4 "time"
6 ) 5 )
7 6
@@ -46,13 +45,13 @@ type TaskRecordRepository interface { @@ -46,13 +45,13 @@ type TaskRecordRepository interface {
46 } 45 }
47 46
48 // 是否取消任务的里程碑反馈异常记录 47 // 是否取消任务的里程碑反馈异常记录
49 -func (record *TaskRecord) CanTaskAnomaly() bool {  
50 - trimSpace := strings.TrimLeft(record.AssistContent, "\n") // 去掉前换行符  
51 - trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符  
52 - trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符  
53 - // 上级填写内容有值,选项是已辅导,变为正常  
54 - if !(len(trimSpace) == 0 || trimSpace == "无") && record.AssistLevel != AssistLevel1 {  
55 - return true  
56 - }  
57 - return false  
58 -} 48 +// func (record *TaskRecord) CanTaskAnomaly() bool {
  49 +// trimSpace := strings.TrimLeft(record.AssistContent, "\n") // 去掉前换行符
  50 +// trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符
  51 +// trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符
  52 +// // 上级填写内容有值,选项是已辅导,变为正常
  53 +// if !(len(trimSpace) == 0 || trimSpace == "无") && record.AssistLevel != AssistLevel1 {
  54 +// return true
  55 +// }
  56 +// return false
  57 +// }
@@ -2,6 +2,7 @@ package dao @@ -2,6 +2,7 @@ package dao
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strconv"
5 6
6 "github.com/go-pg/pg/v10" 7 "github.com/go-pg/pg/v10"
7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
@@ -429,3 +430,33 @@ func (d *StaffAssessDao) CountUserSelfStaffAssess(param SearchConditin3) (int, e @@ -429,3 +430,33 @@ func (d *StaffAssessDao) CountUserSelfStaffAssess(param SearchConditin3) (int, e
429 _, err := tx.Query(pg.Scan(&result), sqlStr2, condition...) 430 _, err := tx.Query(pg.Scan(&result), sqlStr2, condition...)
430 return result, err 431 return result, err
431 } 432 }
  433 +
  434 +type CycleAndProjectItem struct {
  435 + CycleId string `pg:"cycle_id"`
  436 + CycleName string `pg:"cycle_name"`
  437 + EvaluationProjectId string `pg:"evaluation_project_id"`
  438 + EvaluationProjectName string `pg:"evaluation_project_name"`
  439 + TargetUserId string `pg:"target_user_id"`
  440 +}
  441 +
  442 +// 获取某个人的自评的周期和项目
  443 +func (d *StaffAssessDao) ListCycleAndProject(userId int, companyId int, offset int, limit int) (result []CycleAndProjectItem, err error) {
  444 + sqlStr := `select
  445 + distinct
  446 + staff_assess.cycle_id ,
  447 + staff_assess.cycle_name ,
  448 + staff_assess.evaluation_project_id ,
  449 + staff_assess.evaluation_project_name ,
  450 + target_user->>'userId' as target_user_id
  451 + from staff_assess
  452 + where 1=1
  453 + and company_id=?
  454 + and target_user->>'userId'=?
  455 + and "types"='self'
  456 + order by cycle_id desc
  457 + limit ? offset ? `
  458 + tx := d.transactionContext.PgTx
  459 + condition := []interface{}{companyId, strconv.Itoa(userId), limit, offset}
  460 + _, err = tx.Query(&result, sqlStr, condition...)
  461 + return result, err
  462 +}
@@ -117,6 +117,22 @@ func (c *SummaryEvaluationController) CountEvaluationSelfLevel() { @@ -117,6 +117,22 @@ func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
117 c.Response(data, err) 117 c.Response(data, err)
118 } 118 }
119 119
  120 +// CountEvaluationSelfLevelV2 获取自评小结
  121 +func (c *SummaryEvaluationController) CountEvaluationSelfLevelV2() {
  122 + srv := service.NewSummaryEvaluationService()
  123 + paramReq := &command.QueryEvaluationSelf{}
  124 + err := c.BindJSON(paramReq)
  125 + if err != nil {
  126 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  127 + c.Response(nil, e)
  128 + return
  129 + }
  130 + userReq := middlewares.GetUser(c.Ctx)
  131 + paramReq.CompanyId = int(userReq.CompanyId)
  132 + data, err := srv.CountEvaluationSelfLevelV2(paramReq)
  133 + c.Response(data, err)
  134 +}
  135 +
120 func (c *SummaryEvaluationController) Evaluation360List() { 136 func (c *SummaryEvaluationController) Evaluation360List() {
121 srv := service.NewSummaryEvaluationService() 137 srv := service.NewSummaryEvaluationService()
122 in := &command.QueryEvaluation360List{} 138 in := &command.QueryEvaluation360List{}
@@ -422,3 +438,20 @@ func (c *SummaryEvaluationController) ModifyFinishScore() { @@ -422,3 +438,20 @@ func (c *SummaryEvaluationController) ModifyFinishScore() {
422 err = srv.ModifyFinishScore(param) 438 err = srv.ModifyFinishScore(param)
423 c.Response(nil, err) 439 c.Response(nil, err)
424 } 440 }
  441 +
  442 +// 获取周期和项目列表
  443 +func (c *SummaryEvaluationController) ListCycleAndProject() {
  444 + srv := service.NewSummaryEvaluationService()
  445 + param := &command.QueryCycleList{}
  446 + err := c.BindJSON(param)
  447 + if err != nil {
  448 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  449 + c.Response(nil, e)
  450 + return
  451 + }
  452 + userReq := middlewares.GetUser(c.Ctx)
  453 + param.UserId = int(userReq.UserId)
  454 + param.CompanyId = int(userReq.CompanyId)
  455 + data, err := srv.ListCycleAndProject(param)
  456 + c.Response(data, err)
  457 +}
@@ -30,15 +30,17 @@ func init() { @@ -30,15 +30,17 @@ func init() {
30 web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper), 30 web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper),
31 web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreEvaluation), 31 web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreEvaluation),
32 web.NSCtrlPost("/evaluation-result", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult), 32 web.NSCtrlPost("/evaluation-result", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
33 - //web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),  
34 - // web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),  
35 web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish), 33 web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
36 web.NSCtrlPost("/evaluation-finish/modify-score", (*controllers.SummaryEvaluationController).ModifyFinishScore), 34 web.NSCtrlPost("/evaluation-finish/modify-score", (*controllers.SummaryEvaluationController).ModifyFinishScore),
37 - // web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),  
38 web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish), 35 web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish),
39 web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf), 36 web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf),
40 - //  
41 web.NSCtrlPost("/staff_assess/self/remark", (*controllers.SummaryEvaluationController).SearchAssessRemark), 37 web.NSCtrlPost("/staff_assess/self/remark", (*controllers.SummaryEvaluationController).SearchAssessRemark),
42 ) 38 )
43 web.AddNamespace(summaryNS) 39 web.AddNamespace(summaryNS)
  40 + summaryV2 := web.NewNamespace("/v2/summary-evaluation",
  41 + web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
  42 + web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevelV2),
  43 + web.NSCtrlPost("/cycle_project/list", (*controllers.SummaryEvaluationController).ListCycleAndProject),
  44 + )
  45 + web.AddNamespace(summaryV2)
44 } 46 }