作者 Your Name

更新

... ... @@ -137,10 +137,10 @@ func CreateStaffAssessContentRepository(options map[string]interface{}) domain.S
return repository.NewStaffAssessContentRepository(transactionContext)
}
func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessContentRepository {
func CreateStaffAssessTaskRepository(options map[string]interface{}) domain.StaffAssessTaskRepository {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewStaffAssessContentRepository(transactionContext)
return repository.NewStaffAssessTaskRepository(transactionContext)
}
... ...
... ... @@ -4,7 +4,7 @@ type SearchAssessMeResp struct {
AssessTaskId int `json:"assessTaskId"`
BeginTime string `json:"beginTime"`
EndTime string `json:"endTime"`
CycleId int `json:"cycleId"`
CycleId int64 `json:"cycleId"`
CycleName string `json:"cycleName"`
EvaluationProjectId int `json:"evaluationProjectId"`
EvaluationProjectName string `json:"evaluationProjectName"`
... ...
package query
type AssessTaskDescQuery struct {
AssessTaskId int
AssessTaskId int `json:"assessTaskId"` //评估任务的id
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
... ...
package query
type SearchAssessMeQuery struct {
UserId int // 当前登录人的用户id
CompanyId int //当前登录人的公司Id
CurrentTime string // 日期 2006-01-02
UserId int `json:"userId"` // 当前登录人的用户id
CompanyId int `json:"companyId"` //当前登录人的公司Id
PageSize int `json:"pageSize"` //每页的记录数
PageNumber int `json:"pageNumber"` //页码
}
... ...
package service
import (
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
... ... @@ -13,8 +11,8 @@ import (
type StaffAssessServeice struct {
}
// 获取我参与过的评估项目列表
func (srv StaffAssessServeice) SearchAssessMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
// 获取我参与过的评估任务列表
func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -25,35 +23,45 @@ func (srv StaffAssessServeice) SearchAssessMe(param *query.SearchAssessMeQuery)
defer func() {
_ = transactionContext.RollbackTransaction()
}()
cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
currentTime, err := time.ParseInLocation("2006-01-02", param.CurrentTime, time.Local)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "时间条件填写错误")
}
//获取param.CurrentTime 对应的周期
_, cycleList, err := cycleRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"timeStart": currentTime,
"timeEnd": currentTime,
"limit": 1,
})
var limit int = 20
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
}
offset = (param.PageNumber - 1) * param.PageSize
condition := map[string]interface{}{
"executorId": param.UserId,
"companyId": param.CompanyId,
"limit": limit,
}
if offset > 0 {
condition["offset"] = offset
}
cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询周期"+err.Error())
}
if len(cycleList) == 0 {
listData := []adapter.SearchAssessMeResp{}
return tool_funs.SimpleWrapGridMap(0, listData), nil
}
//更具周期和param.UserId 获取评估项目列表
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cnt int64
var listData []adapter.SearchAssessMeResp
return tool_funs.SimpleWrapGridMap(cnt, listData), nil
listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
var temp adapter.SearchAssessMeResp
for _, v := range assessTaskList {
temp = adapter.SearchAssessMeResp{
AssessTaskId: v.Id,
BeginTime: v.BeginTime.Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
CycleId: v.CycleId,
CycleName: v.CycleName,
EvaluationProjectId: v.EvaluationProjectId,
EvaluationProjectName: v.EvaluationProjectName,
}
listData = append(listData, temp)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
}
// 获取项目评估进度描述
... ... @@ -98,3 +106,22 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) (
result["userInfo"] = userInfo
return result, nil
}
// 更具项目评估的配置,创建员工的评估任务
func (srv StaffAssessServeice) CreateStaffAssessTask() error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}
... ...
... ... @@ -21,7 +21,7 @@ const (
StaffAssessCompleted StaffAssessStatus = "completed" //已完成
)
// 记录用户需要的评估项
// 记录用户需要的评估项
type StaffAssess struct {
Id int `json:"id"` //id
CompanyId int `json:"companyId"` //公司id
... ...
... ... @@ -26,6 +26,7 @@ type StaffAssessTask struct {
BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
EndTime time.Time `json:"endTime"` //绩效考核截止时间
StepList []AssessTaskStep `json:"steps"` //考评的流程
ExecutorId []int `json:"executorId"` //参与此次考评的人
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt time.Time `json:"deletedAt"` //数据删除时间
... ...
package models
import "time"
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 执行评估的任务列表
type StaffAssessTask struct {
tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"`
Id int `pg:",pk"`
CompanyId int `` //公司id
EvaluationProjectId int `` //项目id
EvaluationProjectName string `` //项目名称
CycleId int64 //对应的周期id
CycleName string //对应周期的名称
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt time.Time //数据删除时间
tableName struct{} `pg:"staff_assess_task" comment:"执行评估的任务列表"`
Id int `pg:",pk"`
CompanyId int `` //公司id
EvaluationProjectId int `` //项目id
EvaluationProjectName string `` //项目名称
CycleId int64 //对应的周期id
CycleName string //对应周期的名称
ExecutorId []int //参与考评的人
StepList []domain.AssessTaskStep `` //考评的流程
BeginTime time.Time //开始时间
EndTime time.Time //截止时间
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt time.Time //数据删除时间
}
... ...
... ... @@ -107,7 +107,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
tx := repo.transactionContext.PgTx
var m []*models.StaffAssess
query := tx.Model(&m).
Where("deleted_at isnull").Limit(20)
Where("deleted_at isnull")
if companyId, ok := queryOptions["companyId"]; ok {
query.Where("company_id = ?", companyId)
}
... ... @@ -117,7 +117,16 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["targetUserId"].(int); ok && v > 0 {
query.Where(`target_user->>'userId'='?'`, v)
}
if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
query.Where(`executor->>'userId'='?'`, v)
}
if v, ok := queryOptions["cycleId"].(int64); ok && v > 0 {
query.Where(`cycle_id=?`, v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -111,7 +111,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if v, ok := queryOptions["offset"].(int); ok {
query.Offset(v)
}
if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
query.Where(`executorId @>[?]`, v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...