作者 tangxvhui

日常保存

... ... @@ -23,3 +23,41 @@ type AssessInfoResp struct {
DutyTime string `json:"dutyTime"` //入职时间 //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
}
// 周期内的每日自评小结
type AssessCountLevelResp struct {
CycleId int64 `json:"cycleId,string"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的
TargetUserName string `json:"targetUserName"` //
CompanyLogo string `json:"companyLogo,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间
EvaluationItems []AssessCountLeveltItem `json:"evaluationItems"`
}
type AssessCountLeveltItem struct {
EvaluationItemId int `json:"evaluationItemId,string"` //评估条目的id
SortBy int `json:"sortBy"` //排序
Category string `json:"category"` //类别
Name string `json:"name"` //名称
PromptTitle string `json:"promptTitle"` //提示项标题
PromptText string `json:"promptText"` //提示项正文
EntryItems []*domain.EntryItem `json:"entryItems"` //填写的反馈
RuleType int `json:"ruleType"` //评估方式(0评级、1评分)
Rule domain.EvaluationRule `json:"rule"` //评估的选项规则
Weight float64 `json:"weight"` //"权重"
Remark string `json:"remark"` //填写的内容反馈
EvaluatorId int `json:"evaluatorId"` //评估人id
LevelCount []LevalCodeCount `json:"levelCount"` //周期内每次评估的等级数量统计
}
// 评级数量
type LevalCodeCount struct {
Code string `json:"code"` //评级代码
Number int `json:"number"` //数量
ItemList []string `json:"itemList"` //对应的评估项名称
}
... ...
package query
type ListTargetUserCycleQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
CompanyId int `json:"companyId"` //
TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
}
... ...
... ... @@ -14,3 +14,10 @@ type ExportUserAssess2Commad struct {
OperatorId int `cname:"操作人ID" json:"operatorId"`
ExportUserId []string `cname:"指定员工数据导出" json:"exportUserId"`
}
type StaffAsessSelfCountLevel struct {
CompanyId int `cname:"公司ID" json:"-"`
TargetUserId int `json:"targetUserId"`
ProjectId int `json:"projectId,string"`
CycleId int `cname:"周期ID" json:"cycleId,string"`
}
... ...
... ... @@ -63,7 +63,7 @@ func (srv *StaffAssessServeice) ExportUserAssess2V2(param *query.ExportUserAsses
if len(uname) == 0 {
continue
}
tableHeader, ok := eData.tableHeader[k1+val2]
tableHeader, ok := eData.tableHeader[eData.tableHeaderKey(k1, val2)]
if !ok {
continue
}
... ... @@ -180,7 +180,7 @@ func (e *exportData3) FormatTableHead(param []dao.DataEvaluationItemUsed2) {
}
}
//每个员工对应的日期列表
key1 := val.TargetUserId + "+" + val.EvaluationProjectId
key1 := e.tableHeaderKey(val.TargetUserId, val.EvaluationProjectId)
if _, ok := e.tableHeader[key1]; !ok {
e.tableHeader[key1] = &HeaderLevel{
Name: "个人绩效评估等级统计表",
... ... @@ -243,3 +243,7 @@ func (e *exportData3) data23Key(userId string, category string, weight string, c
func (e *exportData3) userDayKey(userId string, projectId string) string {
return fmt.Sprintf("%s-%s", userId, projectId)
}
func (e *exportData3) tableHeaderKey(targetUserId, evaluationProjectId string) string {
return targetUserId + "-" + evaluationProjectId
}
... ...
... ... @@ -14,6 +14,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
... ... @@ -1124,3 +1125,167 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio
}
}
}
// 获取目标员工自评周期列表
func (srv StaffAssessServeice) ListTargetUserSelfCycle(param *query.ListTargetUserCycleQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
staffAssessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
var limit int = 360
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
}
offset = (param.PageNumber - 1) * param.PageSize
cycleList, err := staffAssessDao.SearchTargetUserCycleProject(param.CompanyId, param.TargetUserId, limit, offset)
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())
}
return tool_funs.SimpleWrapGridMap(int64(len(cycleList)), cycleList), nil
}
// 按照周期获取员工的每日自评小结
func (srv StaffAssessServeice) GetStaffAsessSelfCountLevel(param *query.StaffAsessSelfCountLevel) (*adapter.AssessCountLevelResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 统计周期内,评估项等级的数量
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.ProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": param.ProjectId,
"nodeType": int(domain.LinkNodeSelfAssessment),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
"limit": 1,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"evaluationProjectId": param.ProjectId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(assessList) == 0 {
return &adapter.AssessCountLevelResp{
EvaluationProjectId: param.ProjectId,
CycleId: int64(param.CycleId),
TargetUserId: param.TargetUserId,
}, nil
}
assessData := assessList[0]
targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
if err != nil {
log.Logger.Error("获取员工描述" + err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessCountLevelResp{
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
EvaluationProjectId: assessData.EvaluationProjectId,
EvaluationProjectName: assessData.EvaluationProjectName,
TargetUserId: assessData.TargetUser.UserId,
TargetUserName: assessData.TargetUser.UserName,
CompanyLogo: "",
CompanyName: "",
SupperUser: "",
DutyTime: "",
EvaluationItems: []adapter.AssessCountLeveltItem{},
}
if targetUserDesc != nil {
result.CompanyName = targetUserDesc.CompanyName
result.SupperUser = targetUserDesc.SupperUserName
result.CompanyLogo = targetUserDesc.CompanyLogo
result.DutyTime = targetUserDesc.DutyTime
}
levelCodeMap := map[int][]adapter.LevalCodeCount{}
for _, v := range itemList {
codes := v.Rule.GetLevelCodes()
levelCode := []adapter.LevalCodeCount{}
for _, v2 := range codes {
levelCode = append(levelCode, adapter.LevalCodeCount{
Code: v2,
Number: 0,
})
}
levelCodeMap[v.Id] = levelCode
}
levelCodeCountMap := map[string]int{}
for _, v := range levelCodeCountList {
key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
levelCodeCountMap[key] = v.Cnt
}
for _, v := range itemList {
itemCount := adapter.AssessCountLeveltItem{
EvaluationItemId: v.Id,
SortBy: v.SortBy,
Category: v.Category,
Name: v.Name,
PromptTitle: v.PromptTitle,
PromptText: v.PromptText,
EntryItems: v.EntryItems,
RuleType: v.RuleType,
Rule: v.Rule,
Weight: v.Weight,
EvaluatorId: v.EvaluatorId,
LevelCount: []adapter.LevalCodeCount{},
}
levelCodes := levelCodeMap[v.Id]
for i2 := range levelCodes {
key := fmt.Sprintf("%s-%s-%s",
itemCount.Category,
itemCount.Name,
levelCodes[i2].Code,
)
if mVal, ok := levelCodeCountMap[key]; ok {
levelCodes[i2].Number = mVal
}
}
itemCount.LevelCount = levelCodes
result.EvaluationItems = append(result.EvaluationItems, itemCount)
}
return &result, nil
}
... ...
... ... @@ -435,7 +435,7 @@ func (srv StaffAssessServeice) QueryPerformanceIndicator(param *query.ListAssess
Hrbp: hrbp,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计总数"+err.Error())
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())
... ...
... ... @@ -875,7 +875,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query
return tool_funs.SimpleWrapGridMap(int64(cnt), cycleList), nil
}
// 自评小结详情
// 周期综合自评小结详情
func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoCountCodeAdapter, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -887,16 +887,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//统计周期内,评估项等级的数量
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.TargetUserId, domain.AssessSelf, param.CycleId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ... @@ -919,6 +913,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
evaluationData := evaluationList[0]
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(evaluationData.EvaluationProjectId, param.TargetUserId, domain.AssessSelf, param.CycleId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationData.EvaluationProjectId,
"nodeType": int(domain.LinkNodeSelfAssessment),
... ...
... ... @@ -9,8 +9,8 @@ import (
func TestGenerateToken(t *testing.T) {
ut := UserAuth{
CompanyId: 8,
UserId: 3422052542754304,
Phone: "13678998765",
UserId: 3422174102828544,
Phone: "17708397664",
PlatformId: 29,
AdminType: 1,
}
... ...
... ... @@ -1199,7 +1199,7 @@ type AssessContentLevelCode struct {
Name string `pg:"name"` //名称
}
func (d *StaffAssessDao) CountAssessContentLevelCode(targetUserId int, assessType domain.StaffAssessType, cycleId int) ([]AssessContentLevelCode, error) {
func (d *StaffAssessDao) CountAssessContentLevelCode(projectId int, targetUserId int, assessType domain.StaffAssessType, cycleId int) ([]AssessContentLevelCode, error) {
sqlStr := `
select
count(staff_assess_content.level_value) as cnt ,
... ... @@ -1208,16 +1208,18 @@ staff_assess_content.category ,
staff_assess_content."name"
from staff_assess_content
join staff_assess on staff_assess_content.staff_assess_id = staff_assess.id
where 1=1 and staff_assess.deleted_at isnull
where 1=1
and staff_assess.deleted_at isnull
and target_user ->>'userId'='?'
and staff_assess."types" = ?
and staff_assess_content.level_value notnull
and staff_assess.cycle_id =?
and staff_assess.evaluation_project_id=?
group by level_value,category,"name" `
var result []AssessContentLevelCode
condition := []interface{}{
targetUserId, string(assessType), cycleId,
projectId, targetUserId, string(assessType), cycleId,
}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, condition...)
... ...
... ... @@ -42,7 +42,7 @@ func (d *StaffAssessDao) SearchStaffAssessContent2(companyId int, cycleId int, o
staff_assess_content.category ,
staff_assess_content."name" as content_name ,
staff_assess_content.weight,
staff_assess_content.prompt_text ,
staff_assess_content.prompt_text,
staff_assess_content.remark
from staff_assess
join staff_assess_content on staff_assess.id = staff_assess_content.staff_assess_id
... ... @@ -58,7 +58,7 @@ and staff_assess.evaluation_project_id in (
condition = append(condition, pg.In(exportUserIds))
}
sqlStr = withSql + sqlStr
sqlStr = withSql + sqlStr + ` order by staff_assess.begin_time `
result := []DataStaffAssessContent2{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, condition...)
... ... @@ -103,7 +103,7 @@ join evaluation_item_used on evaluation_item_used.evaluation_project_id = staf
where 1=1
and staff_assess.cycle_id =? and "types" ='self'
and staff_assess.evaluation_project_id in (
select evaluation_project.id from evaluation_project limit 10
select t_project_4.project_id from t_project_4
) `
condition := []interface{}{cycleId}
if len(exportUserIds) > 0 {
... ... @@ -172,3 +172,37 @@ func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int,
return fmt.Sprintf(withSql, params...)
}
type TargetUserCycleProject struct {
CycleId string `pg:"cycle_id" json:"cycleId"` //周期id
CycleName string `pg:"cycle_name" json:"cycleName"` //周期名称
EvaluationProjectIds []string `pg:"evaluation_project_ids" json:"evaluationProjectIds"`
}
// 获取目标员工的自评周期和项目
func (d *StaffAssessDao) SearchTargetUserCycleProject(companyId int, targetUserId int, limit int, offset int) ([]TargetUserCycleProject, error) {
sqlStr := ` with t_staff_assess as (
select distinct staff_assess.cycle_id ,
staff_assess.cycle_name,
staff_assess.evaluation_project_id
from staff_assess
where 1=1
and staff_assess."types" ='self'
and staff_assess.deleted_at isnull
and staff_assess.target_user ->>'userId'='?'
and staff_assess.company_id=?
)
select
t_staff_assess.cycle_id,
t_staff_assess.cycle_name,
array_agg(to_char(t_staff_assess.evaluation_project_id,'9999999999999999999')) as evaluation_project_ids
from t_staff_assess
group by cycle_id,cycle_name
limit ? offset ?
`
condition := []interface{}{companyId, targetUserId, limit, offset}
result := []TargetUserCycleProject{}
tx := d.transactionContext.PgTx
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ...
... ... @@ -161,6 +161,9 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["beginDay"]; ok {
query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v)
}
if v, ok := queryOptions["evaluationProjectId"]; ok {
query.Where("staff_assess.evaluation_project_id=?", v)
}
query.Order("staff_assess.id DESC")
count, err := query.SelectAndCount()
if err != nil {
... ...
... ... @@ -324,3 +324,20 @@ func (c *StaffAssessController) ExportUserAssess2() {
c.Ctx.Output.Header("Expires", "0")
data.Write(c.Ctx.ResponseWriter)
}
// ListTargetUserSelfCycle 获取目标员工自评周期列表
func (c *StaffAssessController) ListTargetUserSelfCycle() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetUserCycleQuery{}
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.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.ListTargetUserSelfCycle(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -90,8 +90,6 @@ func (c *SummaryEvaluationController) GetTargetUserCycleList() {
c.Response(nil, e)
return
}
// userReq := middlewares.GetUser(c.Ctx)
// paramReq.UserId = int(userReq.UserId)
data, err := srv.GetTargetUserCycleList(paramReq)
c.Response(data, err)
}
... ... @@ -110,7 +108,6 @@ func (c *SummaryEvaluationController) CountEvaluationSelfLevel() {
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.CountEvaluationSelfLevel(paramReq)
c.Response(data, err)
}
func (c *SummaryEvaluationController) Evaluation360List() {
... ...
... ... @@ -35,6 +35,7 @@ func init() {
web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表
web.NSCtrlPost("/summary/users-indicator", (*controllers.StaffAssessController).QueryMemberPerformanceIndicator), //员工绩效-综合管理-绩效导出指标
web.NSCtrlPost("/summary/export-indicator", (*controllers.StaffAssessController).ExportPerformanceIndicator), //员工绩效-综合管理-绩效导出指标
web.NSCtrlPost("/target_user/self/cycle", (*controllers.StaffAssessController).ListTargetUserSelfCycle), //获取员工自评的周期下拉列表
)
//v2 改版
assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
... ...