作者 郑周

Merge remote-tracking branch 'origin/test' into test

# Conflicts:
#	pkg/application/staff_assess/service/service.go
@@ -4,4 +4,5 @@ type AssessCycleDayResp struct { @@ -4,4 +4,5 @@ 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"`
7 } 8 }
@@ -7,7 +7,7 @@ type ListSupperAssessResp struct { @@ -7,7 +7,7 @@ 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"` 10 + Status string `json:"status"` //评估任务是否填写完成
11 Department string `json:"department"` //部门 11 Department string `json:"department"` //部门
12 Position string `json:"position"` //职位 12 Position string `json:"position"` //职位
13 DutyTime string `json:"dutyTime"` //入职时间 13 DutyTime string `json:"dutyTime"` //入职时间
1 -package query  
2 -  
3 -type AssessCycleDescQuery struct {  
4 - CycleId int `json:"cycleId"` //评估任务的id  
5 - BeginDay string `json:"beginDay"` //开始时间 2022-01-02  
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
  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
  2 +
  3 +type ListExecutorAssessQuery struct {
  4 + PageNumber int `json:"pageNumber"`
  5 + PageSize int `json:"pageSize"`
  6 + UserName string `json:"userName"` //查询条件 员工的名称
  7 + CompanyId int `json:"companyId"` //
  8 + ExecutorId int `json:"executorId,string"` //评估的执行人,必填
  9 + CycleId int `json:"cycleId"` //评估周期id 必填
  10 + BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
  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 }
@@ -2,6 +2,7 @@ package service @@ -2,6 +2,7 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strconv"
5 6
6 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
7 "github.com/linmadan/egglib-go/utils/tool_funs" 8 "github.com/linmadan/egglib-go/utils/tool_funs"
@@ -12,8 +13,8 @@ import ( @@ -12,8 +13,8 @@ import (
12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
13 ) 14 )
14 15
15 -//获取我的项目周期  
16 -func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) { 16 +//获取我的项目周期列表
  17 +func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
17 transactionContext, err := factory.CreateTransactionContext(nil) 18 transactionContext, err := factory.CreateTransactionContext(nil)
18 if err != nil { 19 if err != nil {
19 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 20 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -53,6 +54,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu @@ -53,6 +54,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
53 CycleId: v.CycleId, 54 CycleId: v.CycleId,
54 CycleName: v.CycleName, 55 CycleName: v.CycleName,
55 BeginDay: v.BeginDay, 56 BeginDay: v.BeginDay,
  57 + AssessTaskId: v.AssessTaskId,
56 } 58 }
57 listData = append(listData, temp) 59 listData = append(listData, temp)
58 } 60 }
@@ -60,7 +62,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu @@ -60,7 +62,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
60 } 62 }
61 63
62 //获取我的项目周期进度描述 64 //获取我的项目周期进度描述
63 -func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessCycleDescResp, error) { 65 +func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Query) (*adapter.AssessCycleDescResp, error) {
64 transactionContext, err := factory.CreateTransactionContext(nil) 66 transactionContext, err := factory.CreateTransactionContext(nil)
65 if err != nil { 67 if err != nil {
66 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 68 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -79,23 +81,20 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -79,23 +81,20 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
79 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ 81 staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
80 "transactionContext": transactionContext, 82 "transactionContext": transactionContext,
81 }) 83 })
82 - assessTaskDataAny, err := staffAssessTaskRepo.FindOne(map[string]interface{}{  
83 - "cycleId": param.CycleId, 84 +
  85 + _, assessTaskList, err := staffAssessTaskRepo.Find(map[string]interface{}{
84 "beginDay": param.BeginDay, 86 "beginDay": param.BeginDay,
  87 + "cycleId": param.CycleId,
  88 + "companyId": param.CompanyId,
85 "limit": 1, 89 "limit": 1,
86 }) 90 })
87 if err != nil { 91 if err != nil {
88 return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error()) 92 return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
89 } 93 }
90 - _, myAssessTask, err := staffAssessTaskRepo.Find(map[string]interface{}{  
91 - "cycleId": param.CycleId,  
92 - "beginDay": param.BeginDay,  
93 - "executorId": param.UserId,  
94 - "limit": 1,  
95 - })  
96 - if err != nil {  
97 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的评估任务不存在,"+err.Error()) 94 + if len(assessTaskList) == 0 {
  95 + return &adapter.AssessCycleDescResp{}, nil
98 } 96 }
  97 + assessTaskDataAny := assessTaskList[0]
99 //返回的数据结果 98 //返回的数据结果
100 result := adapter.AssessCycleDescResp{ 99 result := adapter.AssessCycleDescResp{
101 CycleId: int(assessTaskDataAny.CycleId), 100 CycleId: int(assessTaskDataAny.CycleId),
@@ -117,11 +116,11 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -117,11 +116,11 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
117 } 116 }
118 switch v.LinkNodeType { 117 switch v.LinkNodeType {
119 case domain.LinkNodeSelfAssessment: 118 case domain.LinkNodeSelfAssessment:
120 - if len(myAssessTask) > 0 {  
121 //个人自评完成情况 119 //个人自评完成情况
122 _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{ 120 _, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
123 - "staffAssessTaskId": myAssessTask[0].Id,  
124 - "executorId": param.UserId, 121 + "cycleId": assessTaskDataAny.CycleId,
  122 + "beginDay": assessTaskDataAny.BeginDay,
  123 + "executorId": param.UserId, //我作为执行人
125 "typesList": []string{string(domain.AssessSelf)}, 124 "typesList": []string{string(domain.AssessSelf)},
126 }) 125 })
127 if err != nil { 126 if err != nil {
@@ -131,13 +130,12 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -131,13 +130,12 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
131 stepItem.Status = string(assessSelfData[0].Status) 130 stepItem.Status = string(assessSelfData[0].Status)
132 } 131 }
133 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) 132 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
134 - }  
135 case domain.LinkNodeAllInvite: 133 case domain.LinkNodeAllInvite:
136 - if len(myAssessTask) > 0 {  
137 //邀请别人评估自己 134 //邀请别人评估自己
138 _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{ 135 _, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
139 - // "staffAssessTaskId": assessTaskData.Id,  
140 - "targetUserId": param.UserId, 136 + "cycleId": assessTaskDataAny.CycleId,
  137 + "beginDay": assessTaskDataAny.BeginDay,
  138 + "targetUserId": param.UserId, //我被作为目标
141 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 139 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
142 "limit": 5, 140 "limit": 5,
143 }) 141 })
@@ -155,18 +153,17 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -155,18 +153,17 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
155 } else { 153 } else {
156 stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData)) 154 stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
157 } 155 }
158 - }  
159 case domain.LinkNodeAllAssessment: 156 case domain.LinkNodeAllAssessment:
160 //我评估别人,被邀请评估 157 //我评估别人,被邀请评估
161 _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{ 158 _, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
162 - "beginDay": param.BeginDay,  
163 - "executorId": param.UserId, 159 + "cycleId": assessTaskDataAny.CycleId,
  160 + "beginDay": assessTaskDataAny.BeginDay,
  161 + "executorId": param.UserId, //我作为执行人
164 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 162 "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
165 }) 163 })
166 if err != nil { 164 if err != nil {
167 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) 165 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
168 } 166 }
169 -  
170 if len(assessInviteList) > 0 { 167 if len(assessInviteList) > 0 {
171 stepItem.Status = string(domain.StaffAssessCompleted) 168 stepItem.Status = string(domain.StaffAssessCompleted)
172 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) 169 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
@@ -179,23 +176,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -179,23 +176,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
179 } 176 }
180 case domain.LinkNodeSuperiorAssessment: 177 case domain.LinkNodeSuperiorAssessment:
181 //我评估别人,上级评估 178 //我评估别人,上级评估
182 - _, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{  
183 - // "staffAssessTaskId": assessTaskData.Id, 179 + cnnt, _, err := staffAssessRepo.Find(map[string]interface{}{
  180 + "cycleId": assessTaskDataAny.CycleId,
  181 + "beginDay": assessTaskDataAny.BeginDay,
184 "executorId": param.UserId, 182 "executorId": param.UserId,
185 "typesList": []string{string(domain.AssessSuper)}, 183 "typesList": []string{string(domain.AssessSuper)},
  184 + "status": domain.StaffAssessUncompleted,
  185 + "limit": 1,
186 }) 186 })
187 if err != nil { 187 if err != nil {
188 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) 188 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取未完成的评估环节"+err.Error())
189 } 189 }
190 - if len(assessSupperList) > 0 { 190 + cnnt2, _, err := staffAssessRepo.Find(map[string]interface{}{
  191 + "cycleId": assessTaskDataAny.CycleId,
  192 + "beginDay": assessTaskDataAny.BeginDay,
  193 + "executorId": param.UserId,
  194 + "typesList": []string{string(domain.AssessSuper)},
  195 + "status": domain.StaffAssessCompleted,
  196 + "limit": 1,
  197 + })
  198 + if err != nil {
  199 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取已完成的评估环节"+err.Error())
  200 + }
  201 + if (cnnt + cnnt2) > 0 {
191 stepItem.Status = string(domain.StaffAssessCompleted) 202 stepItem.Status = string(domain.StaffAssessCompleted)
192 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime) 203 stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
193 - uncompletedNum := 0  
194 - for _, v := range assessSupperList {  
195 - if v.Status == domain.StaffAssessUncompleted {  
196 - uncompletedNum += 1  
197 - }  
198 - } 204 + uncompletedNum := cnnt
199 if uncompletedNum > 0 { 205 if uncompletedNum > 0 {
200 stepItem.Status = string(domain.StaffAssessUncompleted) 206 stepItem.Status = string(domain.StaffAssessUncompleted)
201 stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum) 207 stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
@@ -209,3 +215,416 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue @@ -209,3 +215,416 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
209 } 215 }
210 return &result, nil 216 return &result, nil
211 } 217 }
  218 +
  219 +//根据周期获取,我的自评任务添加的邀请人
  220 +func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInviteUserQuery) (*adapter.AssessInviteUserResp, error) {
  221 + transactionContext, err := factory.CreateTransactionContext(nil)
  222 + if err != nil {
  223 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  224 + }
  225 + if err := transactionContext.StartTransaction(); err != nil {
  226 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  227 + }
  228 + defer func() {
  229 + _ = transactionContext.RollbackTransaction()
  230 + }()
  231 +
  232 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  233 + "transactionContext": transactionContext,
  234 + })
  235 +
  236 + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  237 + "transactionContext": transactionContext,
  238 + })
  239 + _, myAssessTask, err := assessTaskRepo.Find(map[string]interface{}{
  240 + "cycleId": param.CycleId,
  241 + "beginDay": param.BeginDay,
  242 + "executorId": param.UserId,
  243 + "limit": 1,
  244 + })
  245 + if err != nil {
  246 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的自评任务不存在,"+err.Error())
  247 + }
  248 +
  249 + if len(myAssessTask) == 0 {
  250 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "未参与本次的自评")
  251 + }
  252 +
  253 + assessTaskData := myAssessTask[0]
  254 +
  255 + _, assessList, err := assessReps.Find(map[string]interface{}{
  256 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  257 + "staffAssessTaskId": assessTaskData.Id,
  258 + "targetUserId": param.UserId,
  259 + })
  260 + if err != nil {
  261 + return nil, application.ThrowError(application.ARG_ERROR, "获取个人邀请列表"+err.Error())
  262 + }
  263 + if err := transactionContext.CommitTransaction(); err != nil {
  264 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  265 + }
  266 +
  267 + result := adapter.AssessInviteUserResp{
  268 + AssessTaskId: assessTaskData.Id,
  269 + InviteDiffSuper: []domain.StaffDesc{},
  270 + InviteSameSuper: []domain.StaffDesc{},
  271 + }
  272 + for _, v := range assessTaskData.StepList {
  273 + if v.LinkNodeType != domain.LinkNodeAllInvite {
  274 + continue
  275 + }
  276 + result.LinkNodeId = v.LinkNodeId
  277 + result.LinkNodeName = v.LinkNodeName
  278 + result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
  279 + result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
  280 + break
  281 + }
  282 + for _, v := range assessList {
  283 + if v.Types == domain.AssessInviteDiffSuper {
  284 + result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
  285 + }
  286 + if v.Types == domain.AssessInviteSameSuper {
  287 + result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
  288 + }
  289 + }
  290 + return &result, nil
  291 +}
  292 +
  293 +// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
  294 +func (srv StaffAssessServeice) ListExecutorDayInviteAssess(param *query.ListExecutorAssessQuery) (
  295 + *adapter.ListInviteUserAssessResp, error) {
  296 + transactionContext, err := factory.CreateTransactionContext(nil)
  297 + if err != nil {
  298 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  299 + }
  300 + if err := transactionContext.StartTransaction(); err != nil {
  301 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  302 + }
  303 + defer func() {
  304 + _ = transactionContext.RollbackTransaction()
  305 + }()
  306 + //获取对应的评估任务
  307 + assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
  308 + "transactionContext": transactionContext,
  309 + })
  310 + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
  311 + "transactionContext": transactionContext,
  312 + })
  313 + //获取 executorId 对应的360评估任务 用户
  314 + condition := map[string]interface{}{
  315 + "beginDay": param.BeginDay,
  316 + "cycleId": param.CycleId,
  317 + "executorId": param.ExecutorId,
  318 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  319 + "limit": 20,
  320 + }
  321 + if len(param.UserName) > 0 {
  322 + condition["targetUserName"] = param.UserName
  323 + }
  324 + if param.PageSize > 0 {
  325 + condition["limit"] = param.PageSize
  326 + }
  327 + offset := (param.PageNumber - 1) * param.PageSize
  328 + if offset > 0 {
  329 + condition["offset"] = offset
  330 + }
  331 +
  332 + cnt, assessList, err := assessRepo.Find(condition)
  333 + if err != nil {
  334 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  335 + }
  336 + var assessContentList []*domain.StaffAssessContent
  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])
  345 + if err != nil {
  346 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
  347 + }
  348 + assessContentList = append(assessContentList, assessContentListTemp...)
  349 + }
  350 + //可变的表格列
  351 + changeableHeader := []adapter.ListTableHeader{}
  352 + //列名与字段对应
  353 + keyMap := map[string]string{}
  354 + for i, v := range assessContentList {
  355 + name := fmt.Sprintf("%s-%s", v.Category, v.Name)
  356 + key := fmt.Sprintf("k%d", i)
  357 + if _, ok := keyMap[name]; ok {
  358 + continue
  359 + }
  360 + keyMap[name] = key
  361 + changeableHeader = append(changeableHeader, adapter.ListTableHeader{
  362 + Key: key,
  363 + Name: name,
  364 + })
  365 + }
  366 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  367 + "transactionContext": transactionContext,
  368 + })
  369 + // 获取已经填报的内容
  370 + changeableRows := map[int]map[string]string{}
  371 + for _, v := range assessList {
  372 + _, contentList, err := assessContentRepo.Find(map[string]interface{}{
  373 + "staffAssessId": v.Id,
  374 + })
  375 + if err != nil {
  376 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error())
  377 + }
  378 + row := map[string]string{}
  379 + for _, vv := range contentList {
  380 + name := fmt.Sprintf("%s-%s", vv.Category, vv.Name)
  381 + if kk, ok := keyMap[name]; ok {
  382 + row[kk] = vv.Value
  383 + }
  384 + }
  385 + changeableRows[v.TargetUser.UserId] = row
  386 + }
  387 +
  388 + //获取360邀请评估完成情况
  389 + //我评估别人,被邀请评估
  390 + cnnt, _, err := assessRepo.Find(map[string]interface{}{
  391 + "beginDay": param.BeginDay,
  392 + "cycleId": param.CycleId,
  393 + "executorId": param.ExecutorId,
  394 + "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
  395 + "status": domain.StaffAssessUncompleted,
  396 + "limit": 1,
  397 + })
  398 + if err != nil {
  399 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
  400 + }
  401 +
  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 {
  412 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  413 + }
  414 +
  415 + //评估填写数据行转列
  416 + tableHeader := []adapter.ListTableHeader{
  417 + {Key: "userName", Name: "姓名"},
  418 + {Key: "status", Name: "状态"},
  419 + {Key: "types", Name: "360°评估关系"},
  420 + {Key: "endTime", Name: "360°评估截止日期"},
  421 + }
  422 + tableHeader = append(tableHeader, changeableHeader...)
  423 + listData := []map[string]string{}
  424 + for _, v := range assessList {
  425 + m := map[string]string{
  426 + "userName": v.TargetUser.UserName,
  427 + "userId": strconv.Itoa(v.TargetUser.UserId),
  428 + "status": string(v.Status),
  429 + "types": string(v.Types),
  430 + "endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
  431 + "assessId": strconv.Itoa(v.Id),
  432 + }
  433 + switch v.Status {
  434 + case domain.StaffAssessCompleted:
  435 + m["status"] = "已经完成"
  436 + case domain.StaffAssessUncompleted:
  437 + m["status"] = "未完成"
  438 + }
  439 + switch v.Types {
  440 + case domain.AssessInviteDiffSuper:
  441 + m["types"] = "不同上级同事"
  442 + case domain.AssessInviteSameSuper:
  443 + m["types"] = "相同上级同事"
  444 + }
  445 + if row, ok := changeableRows[v.TargetUser.UserId]; ok {
  446 + for k, v := range row {
  447 + m[k] = v
  448 + }
  449 + } else {
  450 + for _, v := range changeableHeader {
  451 + m[v.Key] = ""
  452 + }
  453 + }
  454 + listData = append(listData, m)
  455 + }
  456 + result := adapter.ListInviteUserAssessResp{
  457 + TableHeader: tableHeader,
  458 + List: listData,
  459 + Total: cnt,
  460 + }
  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 + }
  469 + }
  470 + return &result, nil
  471 +}
  472 +
  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 + })
  489 +
  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
  630 +}
@@ -381,8 +381,15 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa @@ -381,8 +381,15 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
381 return result, err 381 return result, err
382 } 382 }
383 383
  384 +type AssessCycleDayMe struct {
  385 + BeginDay string `json:"beginDay"`
  386 + CycleId int `json:"cycleId"`
  387 + CycleName string `json:"cycleName"`
  388 + AssessTaskId []int `json:"assessTaskId"`
  389 +}
  390 +
384 // 根据评估的人执行人id,搜索 executorId参与的评估周期 391 // 根据评估的人执行人id,搜索 executorId参与的评估周期
385 -func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDay, error) { 392 +func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, error) {
386 if limit < 0 { 393 if limit < 0 {
387 limit = 20 394 limit = 20
388 } 395 }
@@ -390,19 +397,23 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi @@ -390,19 +397,23 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
390 offset = 0 397 offset = 0
391 } 398 }
392 sqlStr := ` 399 sqlStr := `
393 - SELECT DISTINCT staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day 400 + 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
394 FROM staff_assess_task 403 FROM staff_assess_task
395 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id" 404 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
396 WHERE staff_assess.company_id=? 405 WHERE staff_assess.company_id=?
397 and staff_assess_task.deleted_at isnull 406 and staff_assess_task.deleted_at isnull
398 and staff_assess.executor->>'userId'='?' 407 and staff_assess.executor->>'userId'='?'
  408 + group by staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
399 order by staff_assess_task.begin_day desc 409 order by staff_assess_task.begin_day desc
  410 + limit ? offset ?
400 ` 411 `
401 tx := d.transactionContext.PgTx 412 tx := d.transactionContext.PgTx
402 condition := []interface{}{ 413 condition := []interface{}{
403 companyId, executorId, limit, offset, 414 companyId, executorId, limit, offset,
404 } 415 }
405 - result := []AssessCycleDay{} 416 + result := []AssessCycleDayMe{}
406 _, err := tx.Query(&result, sqlStr, condition...) 417 _, err := tx.Query(&result, sqlStr, condition...)
407 return result, err 418 return result, err
408 } 419 }
@@ -410,7 +421,7 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi @@ -410,7 +421,7 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
410 // 根据评估的人执行人id,统计executorId参与的评估周期 421 // 根据评估的人执行人id,统计executorId参与的评估周期
411 func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) { 422 func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
412 sqlStr := ` 423 sqlStr := `
413 - select count(DISTINCT (staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day )) as cnt 424 + select count(DISTINCT (staff_assess_task.cycle_id,staff_assess_task.begin_day )) as cnt
414 FROM staff_assess_task 425 FROM staff_assess_task
415 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id" 426 JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
416 WHERE staff_assess.company_id=? 427 WHERE staff_assess.company_id=?
@@ -144,6 +144,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in @@ -144,6 +144,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
144 if v, ok := queryOptions["staffAssessTaskId"]; ok { 144 if v, ok := queryOptions["staffAssessTaskId"]; ok {
145 query.Where(`staff_assess_task_id=?`, v) 145 query.Where(`staff_assess_task_id=?`, v)
146 } 146 }
  147 +
147 if v, ok := queryOptions["id"]; ok { 148 if v, ok := queryOptions["id"]; ok {
148 query.Where("id=?", v) 149 query.Where("id=?", v)
149 } 150 }
@@ -129,6 +129,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) @@ -129,6 +129,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
129 if v, ok := queryOptions["evaluationProjectId"]; ok { 129 if v, ok := queryOptions["evaluationProjectId"]; ok {
130 query.Where("evaluation_project_id=?", v) 130 query.Where("evaluation_project_id=?", v)
131 } 131 }
  132 + if v, ok := queryOptions["ids"]; ok {
  133 + query.Where("id in (?) ", pg.In(v))
  134 + }
132 count, err := query.SelectAndCount() 135 count, err := query.SelectAndCount()
133 if err != nil { 136 if err != nil {
134 return 0, nil, err 137 return 0, nil, err