作者 tangxvhui

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

... ... @@ -13,5 +13,7 @@ type ListSupperAssessResp struct {
Status string `json:"status"` //评估任务是否填写完成
Department string `json:"department"` //部门
Position string `json:"position"` //职位
CompanyName string `json:"companyName"` //公司名称
DutyTime string `json:"dutyTime"` //入职时间
ContentValue []string `json:"contentValue"` //评估填写的结果
}
... ...
... ... @@ -478,6 +478,14 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//公司存储
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
limit := 20
if param.PageSize > 0 {
... ... @@ -502,6 +510,7 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//获取目标用户
userIds := []int{}
for _, v := range assessList {
... ... @@ -556,10 +565,20 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
var allAssessId []int
for _, v := range assessList {
allAssessId = append(allAssessId, v.Id)
}
assessValueMap := d.SearchContentValueByAssessId(allAssessId)
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
companyName := ""
if companyInfo != nil {
companyName = companyInfo.Name
}
resultList := []adapter.ListSupperAssessResp{}
for _, v := range assessList {
item := adapter.ListSupperAssessResp{
... ... @@ -575,7 +594,12 @@ func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecu
InviteTotal: 5,
Department: "",
Position: "",
CompanyName: companyName,
DutyTime: "",
ContentValue: []string{},
}
if values, ok := assessValueMap[v.Id]; ok {
item.ContentValue = values
}
//填入部门
for _, vv := range v.TargetDepartment {
... ...
... ... @@ -1191,3 +1191,37 @@ func (d *StaffAssessDao) ExportDataUserAssess2(companyId int, cycleId int, opera
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
type ContentValue struct {
StaffAssessId int `pg:"staffAssessId"`
Value string `pg:"value"`
}
func (d *StaffAssessDao) SearchContentValueByAssessId(assessId []int) map[int][]string {
if len(assessId) == 0 {
return map[int][]string{}
}
sqlStr := `select
staff_assess_content.staff_assess_id ,
staff_assess_content.value
from staff_assess_content
where staff_assess_content.staff_assess_id in (?)`
tx := d.transactionContext.PgTx
result := []ContentValue{}
condition := []interface{}{pg.In(assessId)}
_, err := tx.Query(&result, sqlStr, condition...)
if err != nil {
return map[int][]string{}
}
valueMap := map[int][]string{}
for _, v := range result {
if _, ok := valueMap[v.StaffAssessId]; !ok {
valueMap[v.StaffAssessId] = []string{}
}
if len(v.Value) > 0 {
valueMap[v.StaffAssessId] = append(valueMap[v.StaffAssessId], v.Value)
}
}
return valueMap
}
... ...