作者 Your Name

日常保存

... ... @@ -4,7 +4,7 @@ type AssessSelfList struct {
AssessId int `json:"assessId"` //用户执行的评估项id
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //开始时间 2006-01-02 15:04:05
CycleId int `json:"cycleId"` //周期id
CycleId int64 `json:"cycleId"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
... ...
... ... @@ -15,7 +15,7 @@ type AssessTaskStep struct {
LinkNodeName string `json:"linkNodeName"` //流程名称
BeginTime string `json:"beginTime"` //开始时间时间
EndTime string `json:"endTime"` //结束时间
LinkNodeType string `json:"linkNodeType"` //流程类型
LinkNodeType int `json:"linkNodeType"` //流程类型
Desc string `json:"desc"` //情况描述
Status int `json:"status"` //流程是否完成
Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成
}
... ...
package query
type AssessSelfListQuery struct {
UserId int `json:"userId"` //用户id
CompanyId int `json:"companyId"` //公司Id
PageSize int `json:"pageSize"` //每页的记录数
PageNumber int `json:"pageNumber"` //页码
}
... ...
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"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
"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/log"
)
// 员工评绩效评估
type StaffAssessServeice struct {
}
... ... @@ -76,15 +81,130 @@ func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) (
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 获取评估任务
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取个人参与的评估流程
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
"id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
}
//返回的数据结果
result := adapter.AssessTaskDescResp{
AssessTaskId: assessTaskData.Id,
EvaluationProjectId: assessTaskData.EvaluationProjectId,
EvaluationProjectName: assessTaskData.EvaluationProjectName,
CycleName: assessTaskData.CycleName,
BeginTime: assessTaskData.BeginTime.Local().Format("2006-01-02 15:04-05"),
EndTime: assessTaskData.EndTime.Local().Format("2006-01-02 15:04-05"),
StepList: []adapter.AssessTaskStep{},
}
for _, v := range assessTaskData.StepList {
stepItem := adapter.AssessTaskStep{
SortBy: v.SortBy,
LinkNodeName: v.LinkNodeName,
BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
LinkNodeType: v.LinkNodeType,
Desc: fmt.Sprintf("截止日期:%s", v.EndTime.Local().Format("2006-01-02 15:04:05")),
Status: "",
}
switch v.LinkNodeType {
case domain.LinkNodeSelfAssessment:
//个人自评完成情况
_, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSelf)},
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessSelfData) > 0 {
stepItem.Status = string(assessSelfData[0].Status)
}
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
case domain.LinkNodeAllInvite:
//邀请别人评估自己
_, assessInviteData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"targetUserId": param.UserId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 5,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
//待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
if len(assessInviteData) > 5 {
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
stepItem.Status = string(domain.StaffAssessCompleted)
} else {
stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
stepItem.Status = string(domain.StaffAssessUncompleted)
}
case domain.LinkNodeAllAssessment:
//我评估别人,被邀请评估
_, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessInviteList) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
for _, v := range assessInviteList {
if v.Status == domain.StaffAssessUncompleted {
stepItem.Status = string(domain.StaffAssessUncompleted)
break
}
}
}
case domain.LinkNodeSuperiorAssessment:
//我评估别人,上级评估
_, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": assessTaskData.Id,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取个人的评估环节"+err.Error())
}
if len(assessSupperList) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
uncompletedNum := 0
for _, v := range assessSupperList {
if v.Status == domain.StaffAssessUncompleted {
uncompletedNum += 1
}
}
if uncompletedNum > 0 {
stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
}
}
}
result.StepList = append(result.StepList, stepItem)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
return &result, nil
}
// 获取自评反馈列表
func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) (map[string]interface{}, error) {
// 获取个人的自评反馈历史记录列表
func (srv StaffAssessServeice) AssessSelfList(param query.AssessSelfListQuery) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -95,14 +215,81 @@ func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) (
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//获取个人参与的评估流程
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
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,
"typesList": []string{string(domain.AssessSelf)},
"limit": limit,
"status": string(domain.StaffAssessCompleted),
}
if offset > 0 {
condition["offset"] = offset
}
//获取历史列表
cnt, assessList, err := staffAssessRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务列表,"+err.Error())
}
//获取公司数据
companyRep := factory.CreateCompanyRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
companyData, err := companyRep.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
if err != nil {
log.Logger.Error("获取公司信息," + err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取公司信息,"+err.Error())
}
//获取用户数据
userRep := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
userData, err := userRep.FindOne(map[string]interface{}{
"id": param.UserId,
})
if err != nil {
log.Logger.Error("获取用户信息," + err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取用户信息,"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cnt int64
var listData []adapter.AssessSelfList
var userInfo adapter.StaffInfo
result := tool_funs.SimpleWrapGridMap(cnt, listData)
listData := make([]adapter.AssessSelfList, 0, len(assessList))
var itemTemp adapter.AssessSelfList
for _, v := range assessList {
itemTemp = adapter.AssessSelfList{
AssessId: v.Id,
BeginTime: v.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
CycleId: v.CycleId,
CycleName: v.CycleName,
EvaluationProjectId: v.EvaluationProjectId,
EvaluationProjectName: v.EvaluationProjectName,
}
listData = append(listData, itemTemp)
}
userInfo := adapter.StaffInfo{
UserName: userData.Name,
CompanyName: companyData.Name,
SupperUserName: "",
DutyTime: userData.CreateAt.Local().Format("2006-01-02 15:04:05"),
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), listData)
result["userInfo"] = userInfo
return result, nil
}
... ... @@ -125,3 +312,8 @@ func (srv StaffAssessServeice) CreateStaffAssessTask() error {
}
return nil
}
func (srv StaffAssessServeice) getStaffDesc(userId int) *domain.StaffDesc {
return &domain.StaffDesc{}
}
... ...
... ... @@ -28,7 +28,7 @@ type StaffAssess struct {
EvaluationProjectId int `json:"evaluationProjectId"` //对应的项目id
EvaluationProjectName string `json:"evaluationProjectName"` //对应的项目名称
CycleId int64 `json:"cycleId"` //对应的周期id
CycleName int64 `json:"cycleName"` //对应的周期名称
CycleName string `json:"cycleName"` //对应的周期名称
StaffAssessTaskId int `json:"staffAssessTaskId"` //执行评估的任务id
TargetUser StaffDesc `json:"targetUser"` //被评估的目标用户
TargetDepartment []StaffDepartment `json:"targetDepartment"` //被评估的目标用户所在的部门
... ...
... ... @@ -34,10 +34,12 @@ type StaffAssessTask struct {
//考评的流程
type AssessTaskStep struct {
SortBy int `json:"sortBy"` //排序
LinkNodeId int `json:"linkNodeId"` //考评的流程id
LinkNodeName string `json:"linkNodeName"` //流程名称
LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type
SortBy int `json:"sortBy"` //排序
LinkNodeId int `json:"linkNodeId"` //考评的流程id
LinkNodeName string `json:"linkNodeName"` //流程名称
LinkNodeType int `json:"linkNodeType"` //流程类型 同evaluation_template.go->LinkNode.Type
BeginTime time.Time `json:"beginTime"` //绩效考核开始时间
EndTime time.Time `json:"endTime"` //绩效考核截止时间
}
type StaffAssessTaskRepository interface {
... ...
... ... @@ -127,6 +127,16 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["cycleId"].(int64); ok && v > 0 {
query.Where(`cycle_id=?`, v)
}
if v, ok := queryOptions["staffAssessTaskId"]; ok {
query.Where(`staff_assess_task_id=?`, v)
}
if v, ok := queryOptions["typesList"].([]string); ok && len(v) > 0 {
query.Where("types in(?)", pg.Array(v))
}
if v, ok := queryOptions["status"].(string); ok && len(v) > 0 {
query.Where("status=?", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...