作者 tangxvhui

更新 周期列表菜单

... ... @@ -3,6 +3,7 @@ package adapter
//综合评估的周期列表
type CycleList struct {
CycleId int `json:"cycleId,string"` //周期id
CycleId string `json:"cycleId"` //周期id
CycleName string `json:"cycleName"` //
ExecutorId string `json:"executorId "`
}
... ...
package adapter
type MenuList struct {
CycleId int `json:"cycleId,string"`
NodeName string `json:"nodeName"`
StatusName string `json:"statusName"`
Types string `json:"types"`
Child []MenuList `json:"child"`
}
... ...
package command
// 获取周期列表
type QueryCycleList struct {
UserId int `json:"userId,string"`
PageSize int `json:"pageSize"`
PageNumber int `json:"pageNumber"`
}
... ...
package command
// QueryMenuCommand
type QueryMenu struct {
CycleId int `json:"cycleId,string"`
UserId int `json:"userId,string"`
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"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"
)
type SummaryEvaluationServeice struct {
}
... ... @@ -8,9 +18,218 @@ func NewStaffAssessServeice() *SummaryEvaluationServeice {
return newService
}
// GetCycleList
// 获取周期列表
func (srv SummaryEvaluationServeice) GetCycleList() (map[string]interface{}, error) {
return nil, nil
func (srv *SummaryEvaluationServeice) GetCycleList(param *command.QueryCycleList) (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()
}()
evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{
"transactionContext": transactionContext,
})
limit := 300
offset := 0
if param.PageSize > 0 {
limit = param.PageSize
}
if param.PageNumber > 0 {
offset = (param.PageNumber - 1) * param.PageSize
}
cycleData, err := evaluationDao.GetPersonalCycleList(param.UserId, offset, limit)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取周期列表"+err.Error())
}
cnt, err := evaluationDao.CountPersonalCycleList(param.UserId)
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())
}
cycleList := []adapter.CycleList{}
for _, v := range cycleData {
m := adapter.CycleList{
CycleId: v.CycleId,
CycleName: v.CycleName,
ExecutorId: v.ExecutorId,
}
cycleList = append(cycleList, m)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), cycleList), nil
}
// 获取自评信息
// GetMenu
// 根据周期获取菜单显示
func (srv *SummaryEvaluationServeice) GetMenu(param *command.QueryMenu) (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()
}()
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//查找我的绩效
_, selfEvaluation, err := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationSelf),
"executorId": param.UserId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//查找360评估,统计未完成的
cnt360, _, err := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.Evaluation360),
"executorId": param.UserId,
"limit": 1,
"status": string(domain.EvaluationUncompleted),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//查询上级评估,统计未完成
cntSuper, _, err := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationSelf),
"executorId": param.UserId,
"limit": 1,
"status": string(domain.EvaluationUncompleted),
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//查询人资评估,统计未完成
cntHrbp, _, err := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationHrbp),
"executorId": param.UserId,
"limit": 1,
"status": string(domain.EvaluationUncompleted),
})
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
menuList := []adapter.MenuList{}
//模块-我的绩效
menu1 := adapter.MenuList{
CycleId: 0,
NodeName: "我的绩效",
StatusName: "",
Types: "",
Child: []adapter.MenuList{},
}
menu1_1 := adapter.MenuList{
CycleId: param.CycleId,
NodeName: "填写综合自评",
StatusName: "",
Types: "填写综合自评",
}
menu1_2 := adapter.MenuList{
CycleId: param.CycleId,
NodeName: "查看综合自评",
StatusName: "",
Types: "查看综合自评",
}
if len(selfEvaluation) > 0 {
if selfEvaluation[0].Status == domain.EvaluationCompleted {
menu1_1.StatusName = "已完成"
} else {
menu1_1.StatusName = "未完成"
}
if selfEvaluation[0].CheckResult == domain.EvaluationCheckCompleted {
menu1_2.StatusName = "已完成"
} else {
menu1_2.StatusName = "未完成"
}
}
menu1.Child = append(menu1.Child, menu1_1, menu1_2)
menuList = append(menuList, menu1)
menu2 := adapter.MenuList{
CycleId: 0,
NodeName: "给他人评估",
StatusName: "",
Types: "",
Child: []adapter.MenuList{},
}
menu2_1 := adapter.MenuList{
CycleId: param.CycleId,
NodeName: "360综评",
StatusName: "",
Types: "360综评",
}
if cnt360 > 0 {
menu2_1.StatusName = "未完成"
} else {
menu2_1.StatusName = "已完成"
}
menu2.Child = append(menu2.Child, menu2_1)
menuList = append(menuList, menu2)
menu3 := adapter.MenuList{
CycleId: 0,
NodeName: "人资评估",
StatusName: "",
Types: "",
Child: []adapter.MenuList{},
}
menu3_1 := adapter.MenuList{
CycleId: param.CycleId,
NodeName: "上级综评",
StatusName: "",
Types: "上级综评",
}
if cntHrbp > 0 {
menu3_1.StatusName = "未完成"
} else {
menu3_1.StatusName = "已完成"
}
menu3.Child = append(menu3.Child, menu3_1)
menuList = append(menuList, menu3)
menu4 := adapter.MenuList{
CycleId: 0,
NodeName: "我的团队绩效",
StatusName: "",
Types: "",
Child: []adapter.MenuList{},
}
menu4_1 := adapter.MenuList{
CycleId: param.CycleId,
NodeName: "上级综评",
StatusName: "",
Types: "上级综评",
}
if cntSuper > 0 {
menu4_1.StatusName = "未完成"
} else {
menu4_1.StatusName = "已完成"
}
menu4.Child = append(menu4.Child, menu4_1)
menuList = append(menuList, menu4)
result := map[string]interface{}{
"menus": menuList,
}
return result, nil
}
// 获取综合自评详情
func (srv *SummaryEvaluationServeice) GetEvaluationSelf() {}
// 编辑综合自评详情
func (srv *SummaryEvaluationServeice) EditEvaluationSelf() {}
... ...
... ... @@ -15,7 +15,7 @@ type SummaryEvaluation struct {
Executor StaffDesc //填写评估的用户,执行人
Types EvaluationType //评估类型
Status EvaluationStatus //评估的填写状态
CheckResult int //被执行的人确认评估结果
CheckResult EvaluationCheckResult //被执行的人确认评估结果
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
TotalScore string //最终上级评估得分.
... ...
package dao
import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type SummaryEvaluationDao struct {
transactionContext *pgTransaction.TransactionContext
}
func NewSummaryEvaluationDao(options map[string]interface{}) *SummaryEvaluationDao {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return &SummaryEvaluationDao{
transactionContext: transactionContext,
}
}
type PersonalCycle struct {
ExecutorId string `pg:"executor_id" ` //
CycleId string `pg:"cycle_id" ` //
CycleName string `pg:"cycle_name"` //
}
// GetPersonalCycleList 获取执行人拥有的周期列表
func (d *SummaryEvaluationDao) GetPersonalCycleList(executorId int, offset int, limit int) ([]PersonalCycle, error) {
sqlStr := `select
distinct
summary_evaluation.cycle_id ,
summary_evaluation.cycle_name ,
summary_evaluation.executor ->>'userId' as executor_id
from summary_evaluation
where summary_evaluation.executor ->>'userId'='?'
offset ? limit ?`
tx := d.transactionContext.PgTx
condition := []interface{}{
executorId, offset, limit,
}
result := []PersonalCycle{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
// CountPersonalCycleList 统计执行人拥有的周期列表
func (d *SummaryEvaluationDao) CountPersonalCycleList(executorId int) (int, error) {
sqlStr := `select count(
distinct summary_evaluation.cycle_id
) as cnt
from summary_evaluation
where summary_evaluation.executor ->>'userId'='?' `
tx := d.transactionContext.PgTx
condition := []interface{}{
executorId,
}
var cnt int
_, err := tx.QueryOne(pg.Scan(&cnt), sqlStr, condition...)
return cnt, err
}
... ...
... ... @@ -46,6 +46,9 @@ func init() {
&models.StaffAssessTask{},
&models.StaffAssessContent{},
&models.StaffAssessCache{},
&models.EvaluationItemUsed{},
&models.SummaryEvaluation{},
&models.SummaryEvaluationValue{},
}
for _, model := range tables {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
... ...
... ... @@ -20,7 +20,7 @@ type SummaryEvaluation struct {
Executor domain.StaffDesc //填写评估的用户,执行人
Types int //评估类型
Status string //评估的填写状态
CheckResult int //被执行的人确认评估结果
CheckResult string //被执行的人确认评估结果
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
TotalScore string //最终上级评估得分.
... ...
... ... @@ -4,7 +4,7 @@ import "time"
// 周期综合评估填写的内容
type SummaryEvaluationValue struct {
tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation"`
tableName struct{} `comment:"周期综合评估填写的内容" pg:"summary_evaluation_value"`
Id int //
EvaluationItemId int //评估条目的id
SummaryEvaluationId int //综合评估任务(SummaryEvaluation)的id
... ...
... ... @@ -34,7 +34,7 @@ func (repo *SummaryEvaluationRepository) TransformToDomain(d *models.SummaryEval
Executor: d.Executor,
Types: domain.EvaluationType(d.Types),
Status: domain.EvaluationStatus(d.Status),
CheckResult: d.CheckResult,
CheckResult: domain.EvaluationCheckResult(d.CheckResult),
BeginTime: d.BeginTime,
EndTime: d.EndTime,
TotalScore: d.TotalScore,
... ... @@ -57,7 +57,7 @@ func (repo *SummaryEvaluationRepository) Save(param *domain.SummaryEvaluation) e
Executor: param.Executor,
Types: int(param.Types),
Status: string(param.Status),
CheckResult: param.CheckResult,
CheckResult: string(param.CheckResult),
BeginTime: param.BeginTime,
EndTime: param.EndTime,
TotalScore: param.TotalScore,
... ... @@ -114,13 +114,33 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
tx := repo.transactionContext.PgTx
var m []*models.SummaryEvaluation
query := tx.Model(&m).
Where("deleted_at isnull").Limit(20)
Where("deleted_at isnull").
Limit(20)
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
}
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["types"]; ok {
query.Where("types=?", v)
}
if v, ok := queryOptions["status"]; ok {
query.Where("status=?", v)
}
if v, ok := queryOptions["targetUserId"]; ok {
query.Where(`summary_evaluation.target_user->>'userId'='?'`, v)
}
if v, ok := queryOptions["executorId"]; ok {
query.Where(`summary_evaluation.executor->>'userId'='?'`, v)
}
query.Order("id desc")
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...