作者 tangxvhui
... ... @@ -39,7 +39,7 @@ type EvaluationItemAdapter struct {
Score string `json:"score"` //计算的评定得分
Remark string `json:"remark"` //填写的内容反馈
EvaluatorId int `json:"evaluatorId"` //评估人id
//
EvaluatorName string `json:"evaluatorName"` //评估人名称
}
// 评级数量
... ...
package adapter
type TableHeader struct {
Key string `json:"key"`
Name string `json:"name"`
}
type SummaryEvaluationAdapter struct {
TableHeader []TableHeader `json:"tableHeader"`
List []map[string]interface{} `json:"list"`
Total int `json:"total"`
}
type SummaryEvaluationHRBPAdapter struct {
Id int `json:"id"` // 周期评估ID
TargetUserId int `json:"targetUserId"` // 目标用户ID
TargetUserName string `json:"targetUserName"` // 目标用户名称
Department string `json:"departmentVal"` // 部门(拼接文本)
Position string `json:"positionVal"` // 职位(拼接文本)
DutyTime string `json:"dutyTime"` // 入职时间(2006-01-02 15:04)
Status string `json:"statusVal"` // 完成状态(拼接文本)
EndTime string `json:"endTime"` // 截止时间(2006-01-02 15:04)
OverdueCount int `json:"overdueCount"` // 自评逾期次数
}
... ...
... ... @@ -13,13 +13,19 @@ type QueryEvaluation struct {
}
type QueryEvaluation360 struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
//SummaryEvaluationId int `json:"summaryEvaluationId,string"`
CycleId int `json:"cycleId,string"` // 周期ID
TargetUserId int `json:"targetUserId,string"` // 目标人ID
CompanyId int `json:"-"` // 公司ID
UserId int `json:"-"` // 用户ID
}
type QueryEvaluationHRBP struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
UserId int `json:"-"` // 用户ID
//SummaryEvaluationId int `json:"summaryEvaluationId,string"`
//UserId int `json:"-"` // 用户ID
CycleId int `json:"cycleId,string"` // 周期ID
TargetUserId int `json:"targetUserId,string"` // 目标人ID
CompanyId int `json:"-"` // 公司ID
}
// 获取上级评估详情
... ...
package command
// QueryEvaluation360List 360综评列表
type QueryEvaluation360List struct {
CycleId int `cname:"周期ID" json:"cycleId,string" valid:"Required"`
PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
SearchName string `cname:"用户名称" json:"searchName"`
CompanyId int `cname:"公司ID" json:"-"`
UserId int `cname:"用户ID" json:"-"`
}
// QueryEvaluationHRList 人资综评列表
type QueryEvaluationHRList struct {
CycleId int `cname:"周期ID" json:"cycleId,string" valid:"Required"`
PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
SearchName string `cname:"用户名称" json:"searchName"`
CompanyId int `cname:"公司ID" json:"-"`
UserId int `cname:"用户ID" json:"-"`
}
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"strings"
"time"
)
// GetEvaluation360 获取360综评详情
// Evaluation360List 获取360综评列表
func (srv *SummaryEvaluationService) Evaluation360List(param *command.QueryEvaluation360List) (*adapter.SummaryEvaluationAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
var searchTargetName string
if len(param.SearchName) > 0 {
searchTargetName = "%" + param.SearchName + "%"
} else {
searchTargetName = ""
}
limit := param.PageSize
offset := limit * (param.PageNumber - 1)
if offset < 0 {
offset = 0
}
count, list, err := evaluationRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"executorId": param.UserId,
"types": domain.Evaluation360,
"targetUserName": searchTargetName,
"limit": limit,
"offset": offset,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
ids := make([]int, 0)
projectIds := make([]int, 0)
for i := range list {
ids = append(ids, list[i].Id)
projectIds = append(projectIds, list[i].EvaluationProjectId)
}
// 固定列
changeableHeader := []adapter.TableHeader{
{Key: "targetUserName", Name: "姓名"},
{Key: "statusVal", Name: "状态"},
{Key: "relation", Name: "360°评估关系"},
{Key: "endTime", Name: "360°评估截止日期"},
}
changeableRowMap := map[int]map[string]interface{}{} // k,v(用户ID -> 数据集合)行数据内容
itemMap := map[int][]*domain.EvaluationItemUsed{} // k,v(项目ID -> 评估数组)归类评估内容
valueMap := map[string]*domain.SummaryEvaluationValue{} // k,v(周期+评估 -> 提交值)
uniqueColumnsMap := map[string]string{} // 列名称唯一
if len(ids) > 0 {
// 评估内容(注.使用自评模板,并过滤出360综评人的评估内容)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectIds": projectIds, "node_type": domain.LinkNodeSelfAssessment, "evaluatorId": param.UserId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 填写值
_, valueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": ids})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range valueList {
key := fmt.Sprintf("%d-%d", valueList[i].SummaryEvaluationId, valueList[i].EvaluationItemId)
valueMap[key] = valueList[i]
}
for i := range itemList {
item := itemList[i]
key := fmt.Sprintf("k%d", i)
name := fmt.Sprintf("%s-%s", item.Category, item.Name)
if _, ok := uniqueColumnsMap[name]; !ok {
changeableHeader = append(changeableHeader, adapter.TableHeader{Key: key, Name: name})
uniqueColumnsMap[name] = key
}
if pList, ok := itemMap[item.EvaluationProjectId]; !ok {
pList = make([]*domain.EvaluationItemUsed, 0)
itemMap[item.EvaluationProjectId] = pList
} else {
pList = append(pList, item)
}
}
}
now := time.Now().Local() // 当前时间
var rowMap map[string]interface{}
for i := range list {
v := list[i]
if rm, ok := changeableRowMap[v.TargetUser.UserId]; ok {
rowMap = rm
} else {
rowMap = map[string]interface{}{}
changeableRowMap[v.TargetUser.UserId] = rowMap
}
endTime := v.EndTime.Local()
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
} else {
if now.After(endTime) {
statusVal = "已逾期"
} else {
statusVal = "待完成"
}
}
rowMap["id"] = v.Id
rowMap["targetUserName"] = v.TargetUser.UserName
rowMap["statusVal"] = statusVal
rowMap["relation"] = "项目组员"
rowMap["endTime"] = endTime.Format("2006-01-02 15:04")
// 当前项目所有评估内容
if pList, ok := itemMap[v.EvaluationProjectId]; ok {
for _, item := range pList {
name := fmt.Sprintf("%s-%s", item.Category, item.Name)
if key, ok := uniqueColumnsMap[name]; ok { // 动态列用name -> key
valueKey := fmt.Sprintf("%d-%d", v.Id, item.Id)
if it, ok := valueMap[valueKey]; ok {
rowMap[key] = it.Score
} else {
rowMap[key] = ""
}
}
}
}
}
targetList := make([]map[string]interface{}, 0)
for _, v1 := range list {
rowMap := changeableRowMap[v1.TargetUser.UserId]
for _, v2 := range changeableHeader { // 填充部分动态列缺失字段
if _, ok := rowMap[v2.Key]; !ok {
rowMap[v2.Key] = ""
}
}
targetList = append(targetList, rowMap)
}
result := &adapter.SummaryEvaluationAdapter{
TableHeader: changeableHeader,
Total: count,
List: targetList,
}
return result, nil
}
// GetEvaluation360 获取360综评详情(登录人作为评估人,评估内容)
func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
... ... @@ -24,12 +186,26 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
//sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
//if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.Evaluation360},
)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
}
sEvaluation := evaluations[0]
// 自评评估内容(自评模板、筛选项目评估人)
// 360评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
... ... @@ -67,6 +243,98 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
return &result, nil
}
// GetEvaluation360All 获取360综评详情-上级综评(所有的评估人,评估内容)
func (srv *SummaryEvaluationService) GetEvaluation360All(param *command.QueryEvaluation360) (*adapter.EvaluationInfoAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.Evaluation360},
)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
}
sEvaluation := evaluations[0]
// 360评估内容(自评模板)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": sEvaluation.EvaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": sEvaluation.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估人ID -> User
evaluatorMap := map[int]*domain.User{}
evaluatorIds := make([]int, 0)
filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
for i := range itemList {
if itemList[i].EvaluatorId > 0 {
filterItemList = append(filterItemList, itemList[i])
evaluatorIds = append(evaluatorIds, itemList[i].EvaluatorId)
}
}
if len(evaluatorIds) > 0 {
_, users, err := userRepo.Find(map[string]interface{}{"ids": evaluatorIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range users {
evaluatorMap[int(users[i].Id)] = users[i]
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
if user, ok := evaluatorMap[itemValuesAdapter[i].EvaluatorId]; ok {
itemValuesAdapter[i].EvaluatorName = user.Name
}
}
result := adapter.EvaluationInfoAdapter{
SummaryEvaluationId: sEvaluation.Id,
CycleId: int(sEvaluation.CycleId),
CycleName: sEvaluation.CycleName,
EvaluationProjectId: sEvaluation.EvaluationProjectId,
EvaluationProjectName: sEvaluation.EvaluationProjectName,
LinkNodeId: sEvaluation.NodeId,
BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
TargetUserId: sEvaluation.TargetUser.UserId,
TargetUserName: sEvaluation.TargetUser.UserName,
Status: string(sEvaluation.Status),
EvaluationItems: itemValuesAdapter,
}
return &result, nil
}
// EditEvaluation360 编辑提交360综评
func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -166,6 +434,162 @@ func (srv *SummaryEvaluationService) EditEvaluation360(param *command.EditEvalua
}, nil
}
// EvaluationHRBPList 获取人资综评列表
func (srv *SummaryEvaluationService) EvaluationHRBPList(param *command.QueryEvaluationHRList) (map[string]interface{}, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 必须是HRBP权限的人才能编辑操作
hrbp, err := service.GetHRBP(transactionContext, param.CompanyId, param.UserId)
if hrbp != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
}
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
staffAssessDaoRepo := dao.NewStaffAssessDao(map[string]interface{}{"transactionContext": transactionContext})
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
positionRepo := factory.CreatePositionRepository(map[string]interface{}{"transactionContext": transactionContext})
var searchTargetName string
if len(param.SearchName) > 0 {
searchTargetName = "%" + param.SearchName + "%"
} else {
searchTargetName = ""
}
limit := param.PageSize
offset := limit * (param.PageNumber - 1)
if offset < 0 {
offset = 0
}
count, list, err := evaluationRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"executorId": -1,
"types": domain.EvaluationHrbp,
"targetUserName": searchTargetName,
"limit": limit,
"offset": offset,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
userIds := make([]int, 0)
positionIds := make([]int, 0)
projectIds := make([]int, 0)
projectCountMap := map[string]int{} // 自评逾期数量
userMap := map[int64]*domain.User{} // 用户
positionMap := map[int64]*domain.Position{} // 职位
for i := range list {
it := list[i]
userIds = append(userIds, it.TargetUser.UserId)
projectIds = append(projectIds, list[i].EvaluationProjectId)
}
_, users, err := userRepo.Find(map[string]interface{}{"ids": userIds, "companyId": param.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range users {
userMap[users[i].Id] = users[i]
for _, pid := range users[i].PositionId {
positionIds = append(positionIds, pid)
}
}
_, positions, err := positionRepo.Find(map[string]interface{}{"ids": positionIds, "companyId": param.CompanyId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range positions {
positionMap[positions[i].Id] = positions[i]
}
if len(projectIds) > 0 {
targetCount, err := staffAssessDaoRepo.CountUncompletedSelfAssess(param.CompanyId, projectIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for i := range targetCount {
key := fmt.Sprintf("%d-%d", targetCount[i].EvaluationProjectId, targetCount[i].TargetUserId)
projectCountMap[key] = targetCount[i].Cnt
}
}
now := time.Now().Local() // 当前时间
resultList := make([]*adapter.SummaryEvaluationHRBPAdapter, 0)
for i := range list {
v := list[i]
endTime := v.EndTime.Local()
// 状态
statusVal := ""
if v.Status == domain.EvaluationCompleted {
statusVal = "已完成"
} else {
if now.After(endTime) {
statusVal = "已逾期"
} else {
statusVal = "待完成"
}
}
// 部门拼接
var departmentBuild strings.Builder
departmentBuild.WriteString("")
for i2 := range v.TargetDepartment {
departmentBuild.WriteString(v.TargetDepartment[i2].DepartmentName)
if i2 != len(v.TargetDepartment)-1 {
departmentBuild.WriteString(",")
}
}
// 入职时间
entryTime := ""
// 职位拼接
var positionBuild strings.Builder
positionBuild.WriteString("")
if user, ok := userMap[int64(v.TargetUser.UserId)]; ok {
for i2 := range user.PositionId {
if position, ok := positionMap[int64(user.PositionId[i2])]; ok {
positionBuild.WriteString(position.Name)
if i2 != len(user.PositionId)-1 {
departmentBuild.WriteString(",")
}
}
}
entryTime = user.EntryTime
}
// 自评逾期数量
overdueCount := 0
key := fmt.Sprintf("%d-%d", v.EvaluationProjectId, v.TargetUser.UserId)
if cnt, ok := projectCountMap[key]; ok {
overdueCount = cnt
}
result := &adapter.SummaryEvaluationHRBPAdapter{
Id: v.Id,
TargetUserId: v.TargetUser.UserId,
TargetUserName: v.TargetUser.UserName,
Department: departmentBuild.String(),
Position: positionBuild.String(),
DutyTime: entryTime,
Status: statusVal,
EndTime: endTime.Format("2006-01-02 15:04"),
OverdueCount: overdueCount,
}
resultList = append(resultList, result)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return tool_funs.SimpleWrapGridMap(int64(count), resultList), nil
}
// GetEvaluationHRBP 获取人资综评详情
func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
... ... @@ -180,10 +604,21 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"limit": 1,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.EvaluationHrbp},
)
// sEvaluation, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "数据不存在")
}
sEvaluation := evaluations[0]
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
... ...
... ... @@ -1223,3 +1223,33 @@ group by level_value,category,"name" `
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
type CountUncompletedSelfAssess struct {
EvaluationProjectId int
TargetUserId int
Cnt int
}
// CountUncompletedSelfAssess 统计整个项目周期内,相关人自评未完成数量
func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds []int) ([]CountUncompletedSelfAssess, error) {
sqlStr := `
SELECT
staff_assess.evaluation_project_id,
staff_assess.target_user ->> 'userId' AS target_user_id,
COUNT ( staff_assess.ID ) AS cnt
FROM
staff_assess
WHERE
staff_assess.company_id = ?
AND staff_assess.types = 'self'
AND staff_assess.evaluation_project_id IN (?)
AND staff_assess.status = 'uncompleted'
GROUP BY
evaluation_project_id, target_user_id`
condition := []interface{}{companyId, pg.In(projectIds)}
tx := d.transactionContext.PgTx
result := make([]CountUncompletedSelfAssess, 0)
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ...
package repository
import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
... ... @@ -84,6 +85,10 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface
query.Where("evaluation_project_id=?", v)
}
if v, ok := queryOptions["evaluationProjectIds"]; ok {
query.Where("evaluation_project_id in(?)", pg.In(v))
}
if v, ok := queryOptions["nodeType"]; ok {
query.Where("node_type=?", v)
}
... ...
... ... @@ -128,6 +128,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
query.Offset(v)
}
if v, ok := queryOptions["companyId"]; ok {
query.Where("company_id=?", v)
}
if v, ok := queryOptions["types"]; ok {
query.Where("types=?", v)
}
... ...
... ... @@ -96,6 +96,40 @@ func (c *SummaryEvaluationController) GetTargetUserCycleList() {
c.Response(data, err)
}
// CountEvaluationSelfLevel 获取自评小结
func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
srv := service.NewSummaryEvaluationService()
paramReq := &command.QueryEvaluation{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.UserId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.CountEvaluationSelfLevel(paramReq)
c.Response(data, err)
}
func (c *SummaryEvaluationController) Evaluation360List() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360List{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
in.UserId = int(userReq.UserId)
data, err := srv.Evaluation360List(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluation360() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360{}
... ... @@ -106,27 +140,26 @@ func (c *SummaryEvaluationController) GetEvaluation360() {
return
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
in.UserId = int(userReq.UserId)
data, err := srv.GetEvaluation360(in)
c.Response(data, err)
}
// CountEvaluationSelfLevel 获取自评小结
func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
func (c *SummaryEvaluationController) GetEvaluation360All() {
srv := service.NewSummaryEvaluationService()
paramReq := &command.QueryEvaluation{}
err := c.BindJSON(paramReq)
in := &command.QueryEvaluation360{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.UserId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.CountEvaluationSelfLevel(paramReq)
in.CompanyId = int(userReq.CompanyId)
in.UserId = int(userReq.UserId)
data, err := srv.GetEvaluation360All(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) EditEvaluation360() {
... ... @@ -145,6 +178,22 @@ func (c *SummaryEvaluationController) EditEvaluation360() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) EvaluationHRBPList() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRList{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
in.UserId = int(userReq.UserId)
data, err := srv.EvaluationHRBPList(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluationHRBP() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRBP{}
... ... @@ -155,7 +204,8 @@ func (c *SummaryEvaluationController) GetEvaluationHRBP() {
return
}
userReq := middlewares.GetUser(c.Ctx)
in.UserId = int(userReq.UserId)
//in.UserId = int(userReq.UserId)
in.CompanyId = int(userReq.CompanyId)
data, err := srv.GetEvaluationHRBP(in)
c.Response(data, err)
}
... ...
... ... @@ -16,9 +16,12 @@ func init() {
web.NSCtrlPost("/evaluation-self", (*controllers.SummaryEvaluationController).GetEvaluationSelf),
web.NSCtrlPost("/evaluation-self/edit", (*controllers.SummaryEvaluationController).EditEvaluationSelf),
web.NSCtrlPost("/evaluation-360", (*controllers.SummaryEvaluationController).GetEvaluation360),
web.NSCtrlPost("/evaluation-360all", (*controllers.SummaryEvaluationController).GetEvaluation360All),
web.NSCtrlPost("/evaluation-360/edit", (*controllers.SummaryEvaluationController).EditEvaluation360),
web.NSCtrlPost("/evaluation-360/list", (*controllers.SummaryEvaluationController).Evaluation360List),
web.NSCtrlPost("/evaluation-hr", (*controllers.SummaryEvaluationController).GetEvaluationHRBP),
web.NSCtrlPost("/evaluation-hr/edit", (*controllers.SummaryEvaluationController).EditEvaluationHRBP),
web.NSCtrlPost("/evaluation-hr/list", (*controllers.SummaryEvaluationController).EvaluationHRBPList),
web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevel),
web.NSCtrlPost("/evaluation-super", (*controllers.SummaryEvaluationController).GetEvaluationSuper),
web.NSCtrlPost("/evaluation-super/edit", (*controllers.SummaryEvaluationController).EditEvaluationSuper),
... ...