作者 tangxvhui

暂存

@@ -7,8 +7,8 @@ type ListSupperAssessResp struct { @@ -7,8 +7,8 @@ type ListSupperAssessResp struct {
7 EndTime string `json:"endTime"` //截止时间 7 EndTime string `json:"endTime"` //截止时间
8 InviteTotal int `json:"inviteTota"` //邀请总数 8 InviteTotal int `json:"inviteTota"` //邀请总数
9 InviteCompleted int `json:"inviteCompleted"` //邀请未完成 9 InviteCompleted int `json:"inviteCompleted"` //邀请未完成
10 - Status string `json:"status"`  
11 - Department string `json:"department"` //部门  
12 - Position string `json:"position"` //职位  
13 - DutyTime string `json:"dutyTime"` //入职时间 10 + Status string `json:"status"` //评估任务是否填写完成
  11 + Department string `json:"department"` //部门
  12 + Position string `json:"position"` //职位
  13 + DutyTime string `json:"dutyTime"` //入职时间
14 } 14 }
1 -package query  
2 -  
3 -//个人的获取周期任务完成情况描述  
4 -type AssessCycleDescQuery struct {  
5 - AssessTaskId []int `json:"assessTaskId"` //评估任务的id  
6 - UserId int `json:"userId"` //当前登录人的id  
7 - CompanyId int `json:"companyId"` //当前登录的公司  
8 -}  
@@ -5,3 +5,10 @@ type AssessTaskDescQuery struct { @@ -5,3 +5,10 @@ type AssessTaskDescQuery struct {
5 UserId int `json:"userId"` //当前登录人的id 5 UserId int `json:"userId"` //当前登录人的id
6 CompanyId int `json:"companyId"` //当前登录的公司 6 CompanyId int `json:"companyId"` //当前登录的公司
7 } 7 }
  8 +
  9 +type AssessTaskDescV2Query struct {
  10 + CycleId int `json:"cycle"`
  11 + BeginDay string `json:"beginDay"`
  12 + UserId int `json:"userId"` //当前登录人的id
  13 + CompanyId int `json:"companyId"` //当前登录的公司
  14 +}
1 package query 1 package query
2 2
3 -type ListExecutorInviteAssessQuery struct { 3 +type ListExecutorAssessQuery struct {
4 PageNumber int `json:"pageNumber"` 4 PageNumber int `json:"pageNumber"`
5 PageSize int `json:"pageSize"` 5 PageSize int `json:"pageSize"`
6 UserName string `json:"userName"` //查询条件 员工的名称 6 UserName string `json:"userName"` //查询条件 员工的名称
7 CompanyId int `json:"companyId"` // 7 CompanyId int `json:"companyId"` //
8 ExecutorId int `json:"executorId,string"` //评估的执行人,必填 8 ExecutorId int `json:"executorId,string"` //评估的执行人,必填
9 - CycleId int `json:"cycleId"` //评估任务id 必填  
10 - BeginDay string `json:"beginDay"` 9 + CycleId int `json:"cycleId"` //评估周期id 必填
  10 + BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
11 } 11 }
@@ -246,7 +246,6 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery) @@ -246,7 +246,6 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
246 "limit": limit, 246 "limit": limit,
247 "endTime": time.Now(), //获取历史记录 247 "endTime": time.Now(), //获取历史记录
248 } 248 }
249 - // "status": string(domain.StaffAssessCompleted),  
250 if offset > 0 { 249 if offset > 0 {
251 condition["offset"] = offset 250 condition["offset"] = offset
252 } 251 }
@@ -14,7 +14,7 @@ import ( @@ -14,7 +14,7 @@ import (
14 ) 14 )
15 15
16 //获取我的项目周期列表 16 //获取我的项目周期列表
17 -func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { 17 +func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
18 transactionContext, err := factory.CreateTransactionContext(nil) 18 transactionContext, err := factory.CreateTransactionContext(nil)
19 if err != nil { 19 if err != nil {
20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -62,7 +62,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu @@ -62,7 +62,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
62 } 62 }
63 63
64 //获取我的项目周期进度描述 64 //获取我的项目周期进度描述
65 -func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessCycleDescResp, error) { 65 +func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Query) (*adapter.AssessCycleDescResp, error) {
66 transactionContext, err := factory.CreateTransactionContext(nil) 66 transactionContext, err := factory.CreateTransactionContext(nil)
67 if err != nil { 67 if err != nil {
68 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 68 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -81,12 +81,12 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -81,12 +81,12 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
81 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ 81 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
82 "transactionContext": transactionContext, 82 "transactionContext": transactionContext,
83 }) 83 })
84 - if len(param.AssessTaskId) == 0 {  
85 - return &adapter.AssessCycleDescResp{}, nil  
86 - } 84 +
87 _, assessTaskList, err := staffAssessTaskRepo.Find(map[string]interface{}{ 85 _, assessTaskList, err := staffAssessTaskRepo.Find(map[string]interface{}{
88 - "ids": param.AssessTaskId, 86 + "beginDay": param.BeginDay,
  87 + "cycleId": param.CycleId,
89 "companyId": param.CompanyId, 88 "companyId": param.CompanyId,
  89 + "limit": 1,
90 }) 90 })
91 if err != nil { 91 if err != nil {
92 return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error()) 92 return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
@@ -95,18 +95,6 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -95,18 +95,6 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
95 return &adapter.AssessCycleDescResp{}, nil 95 return &adapter.AssessCycleDescResp{}, nil
96 } 96 }
97 assessTaskDataAny := assessTaskList[0] 97 assessTaskDataAny := assessTaskList[0]
98 - var myAssessTask *domain.StaffAssessTask  
99 - for _, v := range assessTaskList {  
100 - if myAssessTask != nil {  
101 - break  
102 - }  
103 - for _, vv := range v.ExecutorId {  
104 - if param.UserId == vv {  
105 - myAssessTask = v  
106 - break  
107 - }  
108 - }  
109 - }  
110 //返回的数据结果 98 //返回的数据结果
111 result := adapter.AssessCycleDescResp{ 99 result := adapter.AssessCycleDescResp{
112 CycleId: int(assessTaskDataAny.CycleId), 100 CycleId: int(assessTaskDataAny.CycleId),
@@ -128,49 +116,48 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -128,49 +116,48 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
128 } 116 }
129 switch v.LinkNodeType { 117 switch v.LinkNodeType {
130 case domain.LinkNodeSelfAssessment: 118 case domain.LinkNodeSelfAssessment:
131 - if myAssessTask != nil {  
132 - //个人自评完成情况  
133 - _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{  
134 - "staffAssessTaskId": myAssessTask.Id,  
135 - "executorId": param.UserId,  
136 - "typesList": []string{string(domain.AssessSelf)},  
137 - })  
138 - if err != nil {  
139 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())  
140 - }  
141 - if len(assessSelfData) > 0 {  
142 - stepItem.Status = string(assessSelfData[0].Status)  
143 - }  
144 - stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) 119 + //个人自评完成情况
  120 + _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
  121 + "cycleId": assessTaskDataAny.CycleId,
  122 + "beginDay": assessTaskDataAny.BeginDay,
  123 + "executorId": param.UserId, //我作为执行人
  124 + "typesList": []string{string(domain.AssessSelf)},
  125 + })
  126 + if err != nil {
  127 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
145 } 128 }
  129 + if len(assessSelfData) > 0 {
  130 + stepItem.Status = string(assessSelfData[0].Status)
  131 + }
  132 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
146 case domain.LinkNodeAllInvite: 133 case domain.LinkNodeAllInvite:
147 - if myAssessTask != nil {  
148 - //邀请别人评估自己  
149 - _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{  
150 - "staffAssessTaskId": myAssessTask.Id,  
151 - "targetUserId": param.UserId, //我被作为目标  
152 - "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},  
153 - "limit": 5,  
154 - })  
155 - if err != nil {  
156 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())  
157 - }  
158 - if len(assessInviteData) > 0 {  
159 - stepItem.Status = string(domain.StaffAssessCompleted)  
160 - } else {  
161 - stepItem.Status = string(domain.StaffAssessUncompleted)  
162 - }  
163 - //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可  
164 - if len(assessInviteData) > 5 {  
165 - stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)  
166 - } else {  
167 - stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))  
168 - } 134 + //邀请别人评估自己
  135 + _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
  136 + "cycleId": assessTaskDataAny.CycleId,
  137 + "beginDay": assessTaskDataAny.BeginDay,
  138 + "targetUserId": param.UserId, //我被作为目标
  139 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  140 + "limit": 5,
  141 + })
  142 + if err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  144 + }
  145 + if len(assessInviteData) > 0 {
  146 + stepItem.Status = string(domain.StaffAssessCompleted)
  147 + } else {
  148 + stepItem.Status = string(domain.StaffAssessUncompleted)
  149 + }
  150 + //待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
  151 + if len(assessInviteData) > 5 {
  152 + stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
  153 + } else {
  154 + stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
169 } 155 }
170 case domain.LinkNodeAllAssessment: 156 case domain.LinkNodeAllAssessment:
171 //我评估别人,被邀请评估 157 //我评估别人,被邀请评估
172 _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{ 158 _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
173 - //TODO 159 + "cycleId": assessTaskDataAny.CycleId,
  160 + "beginDay": assessTaskDataAny.BeginDay,
174 "executorId": param.UserId, //我作为执行人 161 "executorId": param.UserId, //我作为执行人
175 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 162 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
176 }) 163 })
@@ -190,8 +177,8 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -190,8 +177,8 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
190 case domain.LinkNodeSuperiorAssessment: 177 case domain.LinkNodeSuperiorAssessment:
191 //我评估别人,上级评估 178 //我评估别人,上级评估
192 cnnt, _, err := staffAssessRepo.Find(map[string]interface{}{ 179 cnnt, _, err := staffAssessRepo.Find(map[string]interface{}{
193 - "cycleId": param.CycleId,  
194 - "beginDay": param.BeginDay, 180 + "cycleId": assessTaskDataAny.CycleId,
  181 + "beginDay": assessTaskDataAny.BeginDay,
195 "executorId": param.UserId, 182 "executorId": param.UserId,
196 "typesList": []string{string(domain.AssessSuper)}, 183 "typesList": []string{string(domain.AssessSuper)},
197 "status": domain.StaffAssessUncompleted, 184 "status": domain.StaffAssessUncompleted,
@@ -201,8 +188,8 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -201,8 +188,8 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
201 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取未完成的评估环节"+err.Error()) 188 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取未完成的评估环节"+err.Error())
202 } 189 }
203 cnnt2, _, err := staffAssessRepo.Find(map[string]interface{}{ 190 cnnt2, _, err := staffAssessRepo.Find(map[string]interface{}{
204 - "cycleId": param.CycleId,  
205 - "beginDay": param.BeginDay, 191 + "cycleId": assessTaskDataAny.CycleId,
  192 + "beginDay": assessTaskDataAny.BeginDay,
206 "executorId": param.UserId, 193 "executorId": param.UserId,
207 "typesList": []string{string(domain.AssessSuper)}, 194 "typesList": []string{string(domain.AssessSuper)},
208 "status": domain.StaffAssessCompleted, 195 "status": domain.StaffAssessCompleted,
@@ -211,7 +198,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -211,7 +198,7 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
211 if err != nil { 198 if err != nil {
212 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取已完成的评估环节"+err.Error()) 199 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取已完成的评估环节"+err.Error())
213 } 200 }
214 - if cnnt+cnnt2 > 0 { 201 + if (cnnt + cnnt2) > 0 {
215 stepItem.Status = string(domain.StaffAssessCompleted) 202 stepItem.Status = string(domain.StaffAssessCompleted)
216 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) 203 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
217 uncompletedNum := cnnt 204 uncompletedNum := cnnt
@@ -229,8 +216,8 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -229,8 +216,8 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
229 return &result, nil 216 return &result, nil
230 } 217 }
231 218
232 -//根据周期获取,我的自评任务的添加的邀请人  
233 -func (srv StaffAssessServeice) ListAssessInviteUser(param query.ListAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) { 219 +//根据周期获取,我的自评任务添加的邀请人
  220 +func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
234 transactionContext, err := factory.CreateTransactionContext(nil) 221 transactionContext, err := factory.CreateTransactionContext(nil)
235 if err != nil { 222 if err != nil {
236 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 223 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -256,7 +243,7 @@ func (srv StaffAssessServeice) ListAssessInviteUser(param query.ListAssessInvite @@ -256,7 +243,7 @@ func (srv StaffAssessServeice) ListAssessInviteUser(param query.ListAssessInvite
256 "limit": 1, 243 "limit": 1,
257 }) 244 })
258 if err != nil { 245 if err != nil {
259 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的评估任务不存在,"+err.Error()) 246 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的自评任务不存在,"+err.Error())
260 } 247 }
261 248
262 if len(myAssessTask) == 0 { 249 if len(myAssessTask) == 0 {
@@ -304,7 +291,7 @@ func (srv StaffAssessServeice) ListAssessInviteUser(param query.ListAssessInvite @@ -304,7 +291,7 @@ func (srv StaffAssessServeice) ListAssessInviteUser(param query.ListAssessInvite
304 } 291 }
305 292
306 // 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值 293 // 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
307 -func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExecutorInviteAssessQuery) ( 294 +func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExecutorAssessQuery) (
308 *adapter.ListInviteUserAssessResp, error) { 295 *adapter.ListInviteUserAssessResp, error) {
309 transactionContext, err := factory.CreateTransactionContext(nil) 296 transactionContext, err := factory.CreateTransactionContext(nil)
310 if err != nil { 297 if err != nil {
@@ -331,6 +318,9 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -331,6 +318,9 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
331 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 318 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
332 "limit": 20, 319 "limit": 20,
333 } 320 }
  321 + if len(param.UserName) > 0 {
  322 + condition["targetUserName"] = param.UserName
  323 + }
334 if param.PageSize > 0 { 324 if param.PageSize > 0 {
335 condition["limit"] = param.PageSize 325 condition["limit"] = param.PageSize
336 } 326 }
@@ -344,12 +334,18 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -344,12 +334,18 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
344 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 334 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
345 } 335 }
346 var assessContentList []*domain.StaffAssessContent 336 var assessContentList []*domain.StaffAssessContent
347 - if len(assessList) > 0 {  
348 - //获取评估用的所有评估项  
349 - assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessList[0]) 337 + projectIdMap := map[int]struct{}{}
  338 + //获取评估用的所有评估项
  339 + for i := range assessList {
  340 + if _, ok := projectIdMap[assessList[i].EvaluationProjectId]; ok {
  341 + continue
  342 + }
  343 + projectIdMap[assessList[i].EvaluationProjectId] = struct{}{}
  344 + assessContentListTemp, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessList[i])
350 if err != nil { 345 if err != nil {
351 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error()) 346 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
352 } 347 }
  348 + assessContentList = append(assessContentList, assessContentListTemp...)
353 } 349 }
354 //可变的表格列 350 //可变的表格列
355 changeableHeader := []adapter.ListTableHeader{} 351 changeableHeader := []adapter.ListTableHeader{}
@@ -358,6 +354,9 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -358,6 +354,9 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
358 for i, v := range assessContentList { 354 for i, v := range assessContentList {
359 name := fmt.Sprintf("%s-%s", v.Category, v.Name) 355 name := fmt.Sprintf("%s-%s", v.Category, v.Name)
360 key := fmt.Sprintf("k%d", i) 356 key := fmt.Sprintf("k%d", i)
  357 + if _, ok := keyMap[name]; ok {
  358 + continue
  359 + }
361 keyMap[name] = key 360 keyMap[name] = key
362 changeableHeader = append(changeableHeader, adapter.ListTableHeader{ 361 changeableHeader = append(changeableHeader, adapter.ListTableHeader{
363 Key: key, 362 Key: key,
@@ -471,7 +470,161 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec @@ -471,7 +470,161 @@ func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExec
471 return &result, nil 470 return &result, nil
472 } 471 }
473 472
474 -func (srv StaffAssessServeice) ListExecutorSupperAssessDay() (map[string]interface{}, error) { 473 +//根据周期和日期获取我需要执行的上级评估成员列表
  474 +func (srv StaffAssessServeice) ListExecutorDaySupperAssess(param *query.ListExecutorAssessQuery) (map[string]interface{}, error) {
  475 + transactionContext, err := factory.CreateTransactionContext(nil)
  476 + if err != nil {
  477 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  478 + }
  479 + if err := transactionContext.StartTransaction(); err != nil {
  480 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  481 + }
  482 + defer func() {
  483 + _ = transactionContext.RollbackTransaction()
  484 + }()
  485 + //获取对应的评估任务
  486 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  487 + "transactionContext": transactionContext,
  488 + })
475 489
476 - return nil, nil 490 + limit := 20
  491 + if param.PageSize > 0 {
  492 + limit = param.PageSize
  493 + }
  494 + condition := map[string]interface{}{
  495 + "beginDay": param.BeginDay,
  496 + "cycleId": param.CycleId,
  497 + "executorId": param.ExecutorId,
  498 + "typesList": []string{string(domain.AssessSuper)},
  499 + "limit": limit,
  500 + }
  501 + if len(param.UserName) > 0 {
  502 + condition["targetUserName"] = param.UserName
  503 + }
  504 + offset := (param.PageNumber - 1) * param.PageSize
  505 + if offset > 0 {
  506 + condition["offset"] = offset
  507 + }
  508 + //获取 executorId 对应的上级评估列表
  509 + cnt, assessList, err := assessRepo.Find(condition)
  510 + if err != nil {
  511 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  512 + }
  513 +
  514 + userIds := []int{}
  515 + for _, v := range assessList {
  516 + userIds = append(userIds, v.TargetUser.UserId)
  517 + }
  518 + //获取员工信息
  519 + userRepo := factory.CreateUserRepository(map[string]interface{}{
  520 + "transactionContext": transactionContext,
  521 + })
  522 + var targetUserList []*domain.User
  523 + if len(userIds) > 0 {
  524 + _, targetUserList, _ = userRepo.Find(map[string]interface{}{
  525 + "ids": userIds,
  526 + })
  527 + }
  528 + //获取职位信息
  529 + positionRepo := factory.CreatePositionRepository(map[string]interface{}{
  530 + "transactionContext": transactionContext,
  531 + })
  532 + //获取员工的职位
  533 + userPositionMap := map[int64][]*domain.Position{}
  534 + for _, v := range targetUserList {
  535 + if len(v.PositionId) == 0 {
  536 + continue
  537 + }
  538 + _, positionList, _ := positionRepo.Find(map[string]interface{}{
  539 + "ids": v.PositionId,
  540 + })
  541 + userPositionMap[v.Id] = positionList
  542 + }
  543 +
  544 + //获取员工邀请的人完成360评估的数量
  545 + 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{}{
  556 + "transactionContext": transactionContext,
  557 + })
  558 + assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
  559 + // "id": param.AssessTaskId,
  560 + })
  561 + if err != nil {
  562 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
  563 + }
  564 + //我评估别人,被邀请评估
  565 + cnnt, _, err := assessRepo.Find(map[string]interface{}{
  566 + // "staffAssessTaskId": param.AssessTaskId,
  567 + "executorId": param.ExecutorId,
  568 + "typesList": []string{string(domain.AssessSuper)},
  569 + "status": string(domain.StaffAssessUncompleted),
  570 + })
  571 + if err != nil {
  572 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  573 + }
  574 + if err := transactionContext.CommitTransaction(); err != nil {
  575 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  576 + }
  577 +
  578 + resultList := []adapter.ListSupperAssessResp{}
  579 + for _, v := range assessList {
  580 + item := adapter.ListSupperAssessResp{
  581 + AssessId: v.Id,
  582 + UsrId: v.TargetUser.UserId,
  583 + UserName: v.TargetUser.UserName,
  584 + EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
  585 + InviteCompleted: 0,
  586 + Status: string(v.Status),
  587 + InviteTotal: 5,
  588 + Department: "",
  589 + Position: "",
  590 + DutyTime: "",
  591 + }
  592 + //填入部门
  593 + for _, vv := range v.TargetDepartment {
  594 + item.Department += vv.DepartmentName + " "
  595 + }
  596 + for _, vv := range targetUserList {
  597 + if vv.Id != int64(v.TargetUser.UserId) {
  598 + continue
  599 + }
  600 + //填入入职时间
  601 + item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
  602 + //填入职位
  603 + for _, vvv := range userPositionMap[vv.Id] {
  604 + item.Position += vvv.Name + " "
  605 + }
  606 + break
  607 + }
  608 + //
  609 + for _, vv := range inviteCompletedCount {
  610 + if v.TargetUser.UserId == vv.TargetUserId {
  611 + item.InviteCompleted = vv.InviteCompleted
  612 + item.InviteTotal = vv.InviteTotal
  613 + break
  614 + }
  615 + }
  616 + resultList = append(resultList, item)
  617 + }
  618 + result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
  619 + result["linkNodeName"] = ""
  620 + result["linkNodeId"] = ""
  621 + 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 + }
  628 + }
  629 + return result, nil
477 } 630 }