作者 Your Name

更新

... ... @@ -4,22 +4,31 @@ import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
//评估内容详情
type AssessInfoResp struct {
CycleId int64 `json:"cycleId"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUser"` //
TargetUserName string `json:"targetUserName"` //
AssessContent []AssessContent `json:"assessContent"` //评估内容
AssessId int `json:"assessId"`
CycleId int64 `json:"cycleId"` //周期id
CycleName string `json:"cycleName"` //周期名称
EvaluationProjectId int `json:"evaluationProjectId"` //项目id
EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
Status string `json:"status"` //完成状态
TargetUserId int `json:"targetUser"` //
TargetUserName string `json:"targetUserName"` //
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
}
type AssessContent struct {
Category string `json:"category" comment:"类别"`
Name string `json:"name" comment:"名称"`
PromptTitle string `json:"promptTitle" comment:"提示项标题"`
PromptText string `json:"promptText" comment:"提示项正文"`
EntryItems []*domain.EntryItem `json:"entryItems" comment:"填写项"`
Category string `json:"category"` //comment:"类别"
Name string `json:"name"` // comment:"名称"
PromptTitle string `json:"promptTitle"` //comment:"提示项标题"
PromptText string `json:"promptText"` // comment:"提示项正文"
Rule AssessContentRule `json:"rules"` //评定规则
Value string `json:"value"` // 实际填写评定值
Remark []domain.AssessContemtRemark `json:"entryItems"` // comment:"填写反馈"
}
type AssessContentRule struct {
Types int `json:"types"` //评估方式(0评级、1评分)
Rating domain.Rating `json:"rating"` //评级
Score domain.Score `json:"score"` //评分
}
... ...
... ... @@ -2,6 +2,6 @@ package query
type GetAssessInviteUserQuery struct {
CompanyId int `json:"companyId"` //对公司
UsrId int `json:"usrId"` //被评估的员工id
UserId int `json:"userId"` //被评估的员工id
AssessTaskId int `json:"assessTaskId"` //评估任务的id
}
... ...
... ... @@ -575,7 +575,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
_, assessList, err := assessReps.Find(map[string]interface{}{
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"staffAssessTaskId": param.AssessTaskId,
"targetUserId": param.UsrId,
"targetUserId": param.UserId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
... ... @@ -585,7 +585,9 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
}
result := adapter.AssessInviteUserResp{
AssessTaskId: assessTaskData.Id,
AssessTaskId: assessTaskData.Id,
InviteDiffSuper: []domain.StaffDesc{},
InviteSameSuper: []domain.StaffDesc{},
}
for _, v := range assessTaskData.StepList {
if v.LinkNodeType != domain.LinkNodeAllInvite {
... ... @@ -608,7 +610,7 @@ func (srv StaffAssessServeice) GetAssessInviteUser(param *query.GetAssessInviteU
return &result, nil
}
// 获取某个员工360邀请的人员
// 保存某个员工360邀请的人员
func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInvite) (*adapter.AssessInviteUserResp, error) {
inviteSameSuperId := []int{}
InviteDiffSuperId := []int{}
... ... @@ -713,19 +715,22 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
})
}
}
_ = assessReps
//获取员工邀请的人
_, assessList, err := assessReps.Find(map[string]interface{}{
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"staffAssessTaskId": param.AssessTaskId,
"targetUserId": param.TargetUserId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取员工邀请的人"+err.Error())
}
//比对新旧数据
_ = assessList
_ = targetUser
_ = inviteSameSuper
_ = inviteDiffSuper
_ = targetUserDepartment
// _, assessList, err := assessReps.Find(map[string]interface{}{
// "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
// "staffAssessTaskId": param.AssessTaskId,
// "targetUserId": param.TargetUserId,
// })
// if err != nil {
// return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
// }
// TODO
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -770,7 +775,6 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
... ... @@ -785,43 +789,32 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
projectData, err := projectRepo.FindOne(map[string]interface{}{
"id": assessData.EvaluationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error())
}
if projectData.Template == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板")
}
var selfLinkNode *domain.LinkNode
for _, v := range projectData.Template.LinkNodes {
if v.Type == domain.LinkNodeSelfAssessment {
selfLinkNode = v
break
assessContentList := []*domain.StaffAssessContent{}
if assessData.Status == domain.StaffAssessCompleted {
//已完成
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
"staffAssessId": assessData.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
} else if assessData.Status == domain.StaffAssessUncompleted {
//未完成
assessContentList, err = srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
}
if selfLinkNode == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置")
}
//获取员工评估的填写内容
// assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// _, assessContentList, err := assessContentReps.Find(map[string]interface{}{
// "staffAssessId": assessData.Id,
// })
// 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())
}
result := adapter.AssessInfoResp{
AssessId: assessData.Id,
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
EvaluationProjectId: assessData.EvaluationProjectId,
... ... @@ -831,18 +824,83 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (
Status: string(assessData.Status),
TargetUserId: assessData.TargetUser.UserId,
TargetUserName: assessData.TargetUser.UserName,
AssessContent: nil,
}
assessContent := make([]adapter.AssessContent, 0)
for _, v := range selfLinkNode.NodeContents {
assessContent = append(assessContent, adapter.AssessContent{
Category: v.Category,
Name: v.Name,
PromptTitle: v.PromptTitle,
PromptText: v.PromptText,
EntryItems: v.EntryItems,
})
AssessContent: assessContentList,
}
result.AssessContent = assessContent
return &result, nil
}
// 获取未完成的员工评估内容
func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext application.TransactionContext,
assess *domain.StaffAssess) ([]*domain.StaffAssessContent, error) {
projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
projectData, err := projectRepo.FindOne(map[string]interface{}{
"id": assess.EvaluationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
var linkNode *domain.LinkNode
for _, v := range projectData.Template.LinkNodes {
if v.Id == int64(assess.LinkNodeId) {
linkNode = v
break
}
}
if linkNode == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获得评估环节配置"+err.Error())
}
ruleRepo := factory.CreateEvaluationRuleRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
ruleMap := map[string]*domain.EvaluationRule{}
for _, v := range linkNode.NodeContents {
if _, ok := ruleMap[v.RuleId]; ok {
continue
}
rid, _ := strconv.Atoi(v.RuleId)
ruleData, err := ruleRepo.FindOne(map[string]interface{}{
"id": rid,
})
if err == nil {
ruleMap[v.RuleId] = ruleData
}
}
var contentList []*domain.StaffAssessContent
nowTime := time.Now()
for i, v := range linkNode.NodeContents {
item := &domain.StaffAssessContent{
Id: 0,
StaffAssessId: assess.Id,
SortBy: i + 1,
Category: v.Category,
Name: v.Name,
PromptTitle: v.PromptTitle,
PromptText: v.PromptText,
Remark: nil,
Value: "",
ReteResult: "",
CreatedAt: nowTime,
UpdatedAt: nowTime,
DeletedAt: nil,
// Rule: ,
}
if ruleVal, ok := ruleMap[v.RuleId]; ok {
item.Rule = *ruleVal
}
var remarks []domain.AssessContemtRemark
for _, vv := range v.EntryItems {
ritem := domain.AssessContemtRemark{
Title: vv.Title,
HintText: vv.HintText,
RemarkText: "",
}
remarks = append(remarks, ritem)
}
item.Remark = remarks
contentList = append(contentList, item)
}
return contentList, nil
}
... ...
... ... @@ -4,22 +4,26 @@ import "time"
//填写的评估内容
type StaffAssessContent struct {
Id int `json:"id"` //id
StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id
SortBy int `json:"sortBy"` //排序
Category string `json:"category"` //类别
Title string `json:"title"` //问题标题
Remark string `json:"remark"` //填写的反馈
Rate string `json:"rate"` //评估填写的值
ReteResult string `json:"reteResult"` //评估的结果
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
//TODO
Id int `json:"id"` //id
StaffAssessId int `json:"staffAssessId"` //用户需要的评估项id
SortBy int `json:"sortBy"` //排序
Category string `json:"category"` //类别
Name string `json:"name"` //名称
PromptTitle string `json:"promptTitle"` //提示项标题
PromptText string `json:"promptText"` //提示项正文
Remark []AssessContemtRemark `json:"remark"` //填写的反馈
Value string `json:"value"` //评估填写的值
ReteResult string `json:"reteResult"` //评估的结果
Rule EvaluationRule `json:"rule"` //评估的选项规则
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"`
}
type AssessContemtRemark struct {
Title string `json:"title"` //comment:"填写标题"
RemarkText string `json:"hintText"` // comment:"填写文本内容"
Title string `json:"title"` //comment:"填写标题"
HintText string `json:"hintText"` // comment:"文本内容提示"
RemarkText string `json:"remarkText"` // comment:"填写文本内容"
}
type StaffAssessContentRepository interface {
... ...
... ... @@ -42,6 +42,7 @@ func init() {
&models.EvaluationProject{},
&models.StaffAssess{},
&models.StaffAssessTask{},
&models.StaffAssessContent{},
}
for _, model := range tables {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
... ...
package models
import "time"
import (
"time"
//填写的评估内容
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 填写的评估内容
type StaffAssessContent struct {
tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"`
Id int `pg:",pk"` //id
StaffAssessId int //用户需要的评估项id
SortBy int //排序
Category string //类别
Title string //问题标题
Remark string //填写的反馈
Rate string //评估填写的值
ReteResult string //评估的结果
tableName struct{} `pg:"staff_assess_content" comment:"填写的评估项"`
Id int `pg:",pk"` //id
StaffAssessId int //用户需要的评估项id
SortBy int //排序
Category string //类别
Name string //名称
PromptTitle string //问题标题
PromptText string //提示项正文
Value string //评估填写的值
ReteResult string //评估的结果
Rule domain.EvaluationRule
Remark []domain.AssessContemtRemark
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time
}
type StaffAssessContentRepository interface {
... ...
... ... @@ -22,12 +22,40 @@ func NewStaffAssessContentRepository(transactionContext *pgTransaction.Transacti
}
func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAssessContent) *domain.StaffAssessContent {
return &domain.StaffAssessContent{}
return &domain.StaffAssessContent{
Id: d.Id,
StaffAssessId: d.StaffAssessId,
SortBy: d.SortBy,
Category: d.Category,
Name: d.Name,
PromptTitle: d.PromptTitle,
PromptText: d.PromptText,
Remark: d.Remark,
Value: d.Value,
ReteResult: d.ReteResult,
Rule: d.Rule,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: nil,
}
}
func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*domain.StaffAssessContent, error) {
saveModel := models.StaffAssess{
Id: d.Id,
saveModel := models.StaffAssessContent{
Id: d.Id,
StaffAssessId: d.StaffAssessId,
SortBy: d.SortBy,
Category: d.Category,
Name: d.Name,
PromptTitle: d.PromptTitle,
PromptText: d.PromptText,
Remark: d.Remark,
Value: d.Value,
ReteResult: d.ReteResult,
Rule: d.Rule,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: nil,
}
tx := repo.transactionContext.PgTx
var err error
... ... @@ -79,7 +107,7 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
tx := repo.transactionContext.PgTx
var m []*models.StaffAssessContent
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)
}
... ...
... ... @@ -78,10 +78,40 @@ func (c *StaffAssessController) CreateStaffAssessTask() {
c.Response(data, err)
}
//获取员工自评详情
// 获取员工自评详情
func (c *StaffAssessController) GetAssessSelfInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
paramReq.CompanyId = 1
paramReq.TargetUserId = 1
data, err := srv.GetAssessSelfInfo(paramReq)
c.Response(data, err)
}
//保存员工自评填写内容
//获取员工邀请的人
// 获取员工邀请的人
func (c *StaffAssessController) GetAssessInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &query.GetAssessInviteUserQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
//TODO 获取当前用户信息
paramReq.CompanyId = 1
paramReq.UserId = 1
data, err := srv.GetAssessInviteUser(paramReq)
c.Response(data, err)
}
//保持员工邀请的人
... ...
... ... @@ -15,8 +15,9 @@ func init() {
// /v1/staff-assess/self/me/list
assessNS := web.NewNamespace("/v1/staff-assess",
// web.NSBefore(filters.AllowCors(), middlewares.CheckToken()),
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
// web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).AssessSelfMeList),
web.NSCtrlPost("/self/me/list", (*controllers.StaffAssessController).AssessSelfMeList), //获取我的自评反馈列表
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessController).GetAssessSelfInfo), //获取我的自评反馈详情
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessController).GetAssessInviteUser),
)
web.AddNamespace(assessTaskNS)
web.AddNamespace(assessNS)
... ...