作者 tangxvhui

更新接口 我要执行的上级评估的用户列表

@@ -13,5 +13,7 @@ type ListSupperAssessResp struct { @@ -13,5 +13,7 @@ type ListSupperAssessResp struct {
13 Status string `json:"status"` //评估任务是否填写完成 13 Status string `json:"status"` //评估任务是否填写完成
14 Department string `json:"department"` //部门 14 Department string `json:"department"` //部门
15 Position string `json:"position"` //职位 15 Position string `json:"position"` //职位
  16 + CompanyName string `json:"companyName"` //公司名称
16 DutyTime string `json:"dutyTime"` //入职时间 17 DutyTime string `json:"dutyTime"` //入职时间
  18 + ContentValue []string `json:"contentValue"` //评估填写的结果
17 } 19 }
@@ -478,6 +478,14 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu @@ -478,6 +478,14 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
478 assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ 478 assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
479 "transactionContext": transactionContext, 479 "transactionContext": transactionContext,
480 }) 480 })
  481 + //公司存储
  482 + companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
  483 + "transactionContext": transactionContext,
  484 + })
  485 +
  486 + companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
  487 + "id": param.CompanyId,
  488 + })
481 489
482 limit := 20 490 limit := 20
483 if param.PageSize > 0 { 491 if param.PageSize > 0 {
@@ -502,6 +510,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu @@ -502,6 +510,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
502 if err != nil { 510 if err != nil {
503 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 511 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
504 } 512 }
  513 +
505 //获取目标用户 514 //获取目标用户
506 userIds := []int{} 515 userIds := []int{}
507 for _, v := range assessList { 516 for _, v := range assessList {
@@ -556,10 +565,20 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu @@ -556,10 +565,20 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
556 if err != nil { 565 if err != nil {
557 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error()) 566 return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
558 } 567 }
  568 + var allAssessId []int
  569 + for _, v := range assessList {
  570 + allAssessId = append(allAssessId, v.Id)
  571 + }
  572 +
  573 + assessValueMap := d.SearchContentValueByAssessId(allAssessId)
  574 +
559 if err := transactionContext.CommitTransaction(); err != nil { 575 if err := transactionContext.CommitTransaction(); err != nil {
560 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 576 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
561 } 577 }
562 - 578 + companyName := ""
  579 + if companyInfo != nil {
  580 + companyName = companyInfo.Name
  581 + }
563 resultList := []adapter.ListSupperAssessResp{} 582 resultList := []adapter.ListSupperAssessResp{}
564 for _, v := range assessList { 583 for _, v := range assessList {
565 item := adapter.ListSupperAssessResp{ 584 item := adapter.ListSupperAssessResp{
@@ -575,7 +594,12 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu @@ -575,7 +594,12 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
575 InviteTotal: 5, 594 InviteTotal: 5,
576 Department: "", 595 Department: "",
577 Position: "", 596 Position: "",
  597 + CompanyName: companyName,
578 DutyTime: "", 598 DutyTime: "",
  599 + ContentValue: []string{},
  600 + }
  601 + if values, ok := assessValueMap[v.Id]; ok {
  602 + item.ContentValue = values
579 } 603 }
580 //填入部门 604 //填入部门
581 for _, vv := range v.TargetDepartment { 605 for _, vv := range v.TargetDepartment {
@@ -1191,3 +1191,37 @@ func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, opera @@ -1191,3 +1191,37 @@ func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, opera
1191 _, err := tx.Query(&result, sqlStr, condition...) 1191 _, err := tx.Query(&result, sqlStr, condition...)
1192 return result, err 1192 return result, err
1193 } 1193 }
  1194 +
  1195 +type ContentValue struct {
  1196 + StaffAssessId int `pg:"staffAssessId"`
  1197 + Value string `pg:"value"`
  1198 +}
  1199 +
  1200 +func (d *StaffAssessDao) SearchContentValueByAssessId(assessId []int) map[int][]string {
  1201 + if len(assessId) == 0 {
  1202 + return map[int][]string{}
  1203 + }
  1204 + sqlStr := `select
  1205 + staff_assess_content.staff_assess_id ,
  1206 + staff_assess_content.value
  1207 + from staff_assess_content
  1208 + where staff_assess_content.staff_assess_id in (?)`
  1209 + tx := d.transactionContext.PgTx
  1210 + result := []ContentValue{}
  1211 + condition := []interface{}{pg.In(assessId)}
  1212 + _, err := tx.Query(&result, sqlStr, condition...)
  1213 + if err != nil {
  1214 + return map[int][]string{}
  1215 + }
  1216 + valueMap := map[int][]string{}
  1217 + for _, v := range result {
  1218 + if _, ok := valueMap[v.StaffAssessId]; !ok {
  1219 + valueMap[v.StaffAssessId] = []string{}
  1220 + }
  1221 + if len(v.Value) > 0 {
  1222 + valueMap[v.StaffAssessId] = append(valueMap[v.StaffAssessId], v.Value)
  1223 + }
  1224 + }
  1225 +
  1226 + return valueMap
  1227 +}