作者 tangxvhui

Merge branch 'test'

正在显示 29 个修改的文件 包含 1184 行增加223 行删除
不能预览此文件类型
package adapter
type AssessCycleDayResp struct {
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
BeginDay string `json:"beginDay"`
}
... ...
package adapter
type AssessCycleDescResp struct {
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"` //周期名称
BeginDay string `json:"beginDay"` //开始的日期
StepList []AssessTaskStep `json:"stepList"` //考评流程
}
type AssessCycleStep struct {
SortBy int `json:"sortBy"` //排序
LinkNodeId int `json:"linkNodeId"` //流程id
LinkNodeName string `json:"linkNodeName"` //流程名称
BeginTime string `json:"beginTime"` //开始时间时间
EndTime string `json:"endTime"` //结束时间
LinkNodeType int `json:"linkNodeType"` //流程类型
Desc string `json:"desc"` //情况描述
Status string `json:"status"` //流程是否完成 "":未参加,"uncompleted":未完成,"completed":完成
}
... ...
... ... @@ -4,6 +4,8 @@ type ListInviteUserAssessResp struct {
LinkNodeName string `json:"linkNodeName"`
LinkNodeId int `json:"linkNodeId"`
LintNodeDesc string `json:"lintNodeDesc"`
BeginDay string `json:"beginDay"`
CycleId int `json:"cycleId"`
TableHeader []ListTableHeader `json:"tableHeader"`
List []map[string]string `json:"list"`
Total int `json:"total"`
... ...
package adapter
type ListSupperAssessResp struct {
AssessId int `json:"assessId"` //
UsrId int `json:"userId,string"`
AssessId int `json:"assessId"` //
CycleId int `json:"cycleId"` //周期id
BeginDay string `json:"beginDay"` //开始的日期
UserId int `json:"userId,string"` //用户id
UserName string `json:"userName"` //用户名称
EndTime string `json:"endTime"` //截止时间
InviteTotal int `json:"inviteTota"` //邀请总数
InviteCompleted int `json:"inviteCompleted"` //邀请未完成
Status string `json:"status"`
Department string `json:"department"` //部门
Position string `json:"position"` //职位
DutyTime string `json:"dutyTime"` //入职时间
Status string `json:"status"` //评估任务是否填写完成
Department string `json:"department"` //部门
Position string `json:"position"` //职位
DutyTime string `json:"dutyTime"` //入职时间
}
... ...
... ... @@ -5,3 +5,11 @@ type AssessTaskDescQuery struct {
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
//获取我的项目周期进度描述
type AssessTaskDescV2Query struct {
CycleId int `json:"cycleId"`
BeginDay string `json:"beginDay"`
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
... ...
package query
// 根据周期和日期,获取员工的自评内容
type GetExecutorSelfAssessQuery struct {
CompanyId int `json:"companyId"` //
TargetUserId int `json:"targetUserId,string"` //评估的执行人,必填
CycleId int `json:"cycleId"` //评估周期id 必填
BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
}
... ...
package query
// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
type ListExecutorAssessQuery struct {
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
UserName string `json:"userName"` //查询条件 员工的名称
CompanyId int `json:"companyId"` //
ExecutorId int `json:"executorId,string"` //评估的执行人,必填
CycleId int `json:"cycleId"` //评估周期id 必填
BeginDay string `json:"beginDay"` //评估任务的开始日期 2006-01-02
}
... ...
package query
//根据周期和日期,获取员工邀请评估的人员
type ListInviteUserQuery struct {
CompanyId int `json:"companyId"` //对公司
TargetUserId int `json:"targetUserId,string"` //被评估的员工id
CycleId int `json:"CycleId"` //评估任务的周期id
BeginDay string `json:"beginDay"` //日期
}
... ...
package query
// 获取我的项目周期列表
type SearchAssessMeQuery struct {
UserId int `json:"userId"` // 当前登录人的用户id
CompanyId int `json:"companyId"` //当前登录人的公司Id
... ...
package service
import (
"time"
"github.com/linmadan/egglib-go/core/application"
"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/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
//调试用,手动调用CreateStaffAssessTask
... ... @@ -32,79 +28,3 @@ func (srv StaffAssessServeice) InvokCreateStaffAssessTask(param *command.CreateS
}
return data, nil
}
//保存员工绩效评估填写过程中即写即存的内容
func (srv StaffAssessServeice) SaveAssessContentTemp(param *command.SaveAssessInfoCommand) (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()
}()
//获取旧的临时数据内容
contentTempRepo := factory.CreateStaffAssessContentTempRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取评估填写的内容
// assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessData, err := assessRepo.FindOne(map[string]interface{}{
"id": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
}
// staffAssessId
_, contentTempList, err := contentTempRepo.Find(map[string]interface{}{
"staffAssessId": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取临时保存的内容"+err.Error())
}
nowTime := time.Now()
if len(contentTempList) == 0 {
//获取评估模板
assessContentList, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估模板,"+err.Error())
}
//转填入临时的数据
for _, v := range assessContentList {
item := &domain.StaffAssessContentTemp{
Id: 0,
StaffAssessId: v.StaffAssessId,
SortBy: v.SortBy,
Category: v.Category,
Name: v.Name,
Remark: v.Remark,
Value: "",
CreatedAt: nowTime,
UpdatedAt: nowTime,
}
contentTempList = append(contentTempList, item)
}
}
//更新assessContentTemp
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
//获取员工绩效评估填写内容
//临时数据存在时就获取临时数据
//不存在就获取实际保存的数据
func (srv StaffAssessServeice) GetAssessContentTemp(param *command.SaveAssessInfoCommand) (*adapter.AssessInfoResp, error) {
//将临时保存的数据填入模板中
return nil, nil
}
... ...
... ... @@ -172,6 +172,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
}
changeableRows[v.TargetUserId]["targetUserName"] = v.TargetUserName
changeableRows[v.TargetUserId]["targetUserId"] = v.TargetUserId
changeableRows[v.TargetUserId]["assessId"] = v.AssessId
if v.ContentId > 0 {
name := fmt.Sprintf("%s-%s", v.Category, v.ContentName)
key := fmt.Sprintf("k%d", i)
... ... @@ -262,6 +263,7 @@ func (srv StaffAssessServeice) ExportUserAssess(param *query.ListAssessContentCy
CycleId: param.CycleId,
BeginDay: param.BeginDay,
TargetUserName: param.TargetUserName,
TargetUserId: param.TargetUserId,
Limit: 5000,
Offset: 0,
OperaterId: param.OperaterId,
... ...
package service
import (
"fmt"
"strconv"
"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/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
//获取我的项目周期列表
func (srv StaffAssessServeice) SearchAssessTaskMeV2(param *query.SearchAssessMeQuery) (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()
}()
staffAssessTaskRepo := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
var limit int = 200
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
}
offset = (param.PageNumber - 1) * param.PageSize
assessCycleList, err := staffAssessTaskRepo.SearchAssessCycleMe(param.UserId, param.CompanyId, limit, offset)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询评估周期"+err.Error())
}
cnt, err := staffAssessTaskRepo.CountAssessTaskMe(param.UserId, param.CompanyId)
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())
}
listData := make([]adapter.AssessCycleDayResp, 0, len(assessCycleList))
var temp adapter.AssessCycleDayResp
for _, v := range assessCycleList {
temp = adapter.AssessCycleDayResp{
CycleId: v.CycleId,
CycleName: v.CycleName,
BeginDay: v.BeginDay,
}
listData = append(listData, temp)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
}
//获取我的项目周期进度描述
func (srv StaffAssessServeice) AssessTaskDescV2(param *query.AssessTaskDescV2Query) (*adapter.AssessCycleDescResp, 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()
}()
// 获取评估任务
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取个人参与的评估流程
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, assessTaskList, err := staffAssessTaskRepo.Find(map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"companyId": param.CompanyId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "评估任务不存在,"+err.Error())
}
if len(assessTaskList) == 0 {
return &adapter.AssessCycleDescResp{}, nil
}
assessTaskDataAny := assessTaskList[0]
//返回的数据结果
result := adapter.AssessCycleDescResp{
CycleId: int(assessTaskDataAny.CycleId),
CycleName: assessTaskDataAny.CycleName,
BeginDay: assessTaskDataAny.BeginDay,
StepList: []adapter.AssessTaskStep{},
}
for _, v := range assessTaskDataAny.StepList {
stepItem := adapter.AssessTaskStep{
SortBy: v.SortBy,
LinkNodeName: v.LinkNodeName,
LinkNodeId: v.LinkNodeId,
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{}{
"cycleId": assessTaskDataAny.CycleId,
"beginDay": assessTaskDataAny.BeginDay,
"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{}{
"cycleId": assessTaskDataAny.CycleId,
"beginDay": assessTaskDataAny.BeginDay,
"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())
}
if len(assessInviteData) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
} else {
stepItem.Status = string(domain.StaffAssessUncompleted)
}
//待邀请人数,为5人减去已邀请的人数。若邀请人数已等于或大于5人,则只显示截止日期即可
if len(assessInviteData) > 5 {
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
} else {
stepItem.Desc = fmt.Sprintf("截止日期:%s 待邀请%d人", stepItem.EndTime, 5-len(assessInviteData))
}
case domain.LinkNodeAllAssessment:
//我评估别人,被邀请评估
_, assessInviteList, err := staffAssessRepo.Find(map[string]interface{}{
"cycleId": assessTaskDataAny.CycleId,
"beginDay": assessTaskDataAny.BeginDay,
"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:
//我评估别人,上级评估
cnnt, _, err := staffAssessRepo.Find(map[string]interface{}{
"cycleId": assessTaskDataAny.CycleId,
"beginDay": assessTaskDataAny.BeginDay,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
"status": domain.StaffAssessUncompleted,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取未完成的评估环节"+err.Error())
}
cnnt2, _, err := staffAssessRepo.Find(map[string]interface{}{
"cycleId": assessTaskDataAny.CycleId,
"beginDay": assessTaskDataAny.BeginDay,
"executorId": param.UserId,
"typesList": []string{string(domain.AssessSuper)},
"status": domain.StaffAssessCompleted,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取已完成的评估环节"+err.Error())
}
if (cnnt + cnnt2) > 0 {
stepItem.Status = string(domain.StaffAssessCompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s", stepItem.EndTime)
uncompletedNum := cnnt
if uncompletedNum > 0 {
stepItem.Status = string(domain.StaffAssessUncompleted)
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 &result, nil
}
//根据周期获取,我的自评任务添加的邀请人
func (srv StaffAssessServeice) ListAssessInviteUserV2(param *query.ListInviteUserQuery) (*adapter.AssessInviteUserResp, 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()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
_, myAssessTask, err := assessTaskRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"executorId": param.TargetUserId,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "我的自评任务不存在,"+err.Error())
}
if len(myAssessTask) == 0 {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "未参与本次的自评")
}
assessTaskData := myAssessTask[0]
_, assessList, err := assessReps.Find(map[string]interface{}{
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"staffAssessTaskId": assessTaskData.Id,
"targetUserId": param.TargetUserId,
})
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, "获取个人邀请列表"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessInviteUserResp{
AssessTaskId: assessTaskData.Id,
InviteDiffSuper: []domain.StaffDesc{},
InviteSameSuper: []domain.StaffDesc{},
}
for _, v := range assessTaskData.StepList {
if v.LinkNodeType != domain.LinkNodeAllInvite {
continue
}
result.LinkNodeId = v.LinkNodeId
result.LinkNodeName = v.LinkNodeName
result.BeginTime = v.BeginTime.Local().Format("2006-01-02 15:04:05")
result.EndTime = v.EndTime.Local().Format("2006-01-02 15:04:05")
break
}
for _, v := range assessList {
if v.Types == domain.AssessInviteDiffSuper {
result.InviteDiffSuper = append(result.InviteDiffSuper, v.Executor)
}
if v.Types == domain.AssessInviteSameSuper {
result.InviteSameSuper = append(result.InviteDiffSuper, v.Executor)
}
}
return &result, nil
}
// 根据周期和日期获取我要执行的的360评估,用户列表和评估填写的值
func (srv StaffAssessServeice) ListExecutorInviteAssessV2(param *query.ListExecutorAssessQuery) (
*adapter.ListInviteUserAssessResp, 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()
}()
//获取对应的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取 executorId 对应的360评估任务 用户
condition := map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"limit": 20,
}
if len(param.UserName) > 0 {
condition["targetUserName"] = param.UserName
}
if param.PageSize > 0 {
condition["limit"] = param.PageSize
}
offset := (param.PageNumber - 1) * param.PageSize
if offset > 0 {
condition["offset"] = offset
}
cnt, assessList, err := assessRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var assessContentList []*domain.StaffAssessContent
projectIdMap := map[int]struct{}{}
//获取评估用的所有评估项
for i := range assessList {
if _, ok := projectIdMap[assessList[i].EvaluationProjectId]; ok {
continue
}
projectIdMap[assessList[i].EvaluationProjectId] = struct{}{}
assessContentListTemp, err := srv.getAssessSelfInfoUncompleted(transactionContext, assessList[i])
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估任务"+err.Error())
}
assessContentList = append(assessContentList, assessContentListTemp...)
}
//可变的表格列
changeableHeader := []adapter.ListTableHeader{}
//列名与字段对应
keyMap := map[string]string{}
for i, v := range assessContentList {
name := fmt.Sprintf("%s-%s", v.Category, v.Name)
key := fmt.Sprintf("k%d", i)
if _, ok := keyMap[name]; ok {
continue
}
keyMap[name] = key
changeableHeader = append(changeableHeader, adapter.ListTableHeader{
Key: key,
Name: name,
})
}
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// 获取已经填报的内容
changeableRows := map[int]map[string]string{}
for _, v := range assessList {
_, contentList, err := assessContentRepo.Find(map[string]interface{}{
"staffAssessId": v.Id,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取评估内容"+err.Error())
}
row := map[string]string{}
for _, vv := range contentList {
name := fmt.Sprintf("%s-%s", vv.Category, vv.Name)
if kk, ok := keyMap[name]; ok {
row[kk] = vv.Value
}
}
changeableRows[v.TargetUser.UserId] = row
}
//获取360邀请评估完成情况
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
"status": domain.StaffAssessUncompleted,
"limit": 1,
})
if err != nil {
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())
}
//评估填写数据行转列
tableHeader := []adapter.ListTableHeader{
{Key: "userName", Name: "姓名"},
{Key: "status", Name: "状态"},
{Key: "types", Name: "360°评估关系"},
{Key: "endTime", Name: "360°评估截止日期"},
}
tableHeader = append(tableHeader, changeableHeader...)
listData := []map[string]string{}
for _, v := range assessList {
m := map[string]string{
"userName": v.TargetUser.UserName,
"userId": strconv.Itoa(v.TargetUser.UserId),
"status": string(v.Status),
"cycleId": strconv.FormatInt(v.CycleId, 10),
"beginDay": v.BeginTime.Local().Format("2006-01-02"),
"types": string(v.Types),
"endTime": v.EndTime.Local().Format("2006-01-02 15:04:05"),
"assessId": strconv.Itoa(v.Id),
}
switch v.Status {
case domain.StaffAssessCompleted:
m["status"] = "已经完成"
case domain.StaffAssessUncompleted:
m["status"] = "未完成"
}
switch v.Types {
case domain.AssessInviteDiffSuper:
m["types"] = "不同上级同事"
case domain.AssessInviteSameSuper:
m["types"] = "相同上级同事"
}
if row, ok := changeableRows[v.TargetUser.UserId]; ok {
for k, v := range row {
m[k] = v
}
} else {
for _, v := range changeableHeader {
m[v.Key] = ""
}
}
listData = append(listData, m)
}
result := adapter.ListInviteUserAssessResp{
TableHeader: tableHeader,
List: listData,
Total: cnt,
}
if len(assessList) > 0 {
result.BeginDay = assessList[0].BeginTime.Local().Format("2006-01-02")
result.CycleId = int(assessList[0].CycleId)
result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
return &result, nil
}
//根据周期和日期获取我需要执行的上级评估成员列表
func (srv StaffAssessServeice) ListExecutorSupperAssessV2(param *query.ListExecutorAssessQuery) (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()
}()
//获取对应的评估任务
assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
limit := 20
if param.PageSize > 0 {
limit = param.PageSize
}
condition := map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"limit": limit,
}
if len(param.UserName) > 0 {
condition["targetUserName"] = param.UserName
}
offset := (param.PageNumber - 1) * param.PageSize
if offset > 0 {
condition["offset"] = offset
}
//获取 executorId 对应的上级评估列表
cnt, assessList, err := assessRepo.Find(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//获取目标用户
userIds := []int{}
for _, v := range assessList {
userIds = append(userIds, v.TargetUser.UserId)
}
//获取员工信息
userRepo := factory.CreateUserRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
var targetUserList []*domain.User
if len(userIds) > 0 {
_, targetUserList, _ = userRepo.Find(map[string]interface{}{
"ids": userIds,
})
}
//获取职位信息
positionRepo := factory.CreatePositionRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
//获取员工的职位
userPositionMap := map[int64][]*domain.Position{}
for _, v := range targetUserList {
if len(v.PositionId) == 0 {
continue
}
_, positionList, _ := positionRepo.Find(map[string]interface{}{
"ids": v.PositionId,
})
userPositionMap[v.Id] = positionList
}
//获取目标员工邀请的人完成360评估的数量
var inviteCompletedCount []dao.CountData
d := dao.NewStaffAssessDao(map[string]interface{}{
"transactionContext": transactionContext,
})
if len(userIds) > 0 {
inviteCompletedCount, err = d.CountTargetUserInviteAssess1(userIds, param.CycleId, param.BeginDay)
if err != nil {
log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
}
}
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"status": string(domain.StaffAssessUncompleted),
"limit": 1,
})
if err != nil {
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())
}
resultList := []adapter.ListSupperAssessResp{}
for _, v := range assessList {
item := adapter.ListSupperAssessResp{
AssessId: v.Id,
CycleId: int(v.CycleId),
BeginDay: v.BeginTime.Local().Format("2006-01-02"),
UserId: v.TargetUser.UserId,
UserName: v.TargetUser.UserName,
EndTime: v.EndTime.Local().Format("2006-01-02 15:04:05"),
InviteCompleted: 0,
Status: string(v.Status),
InviteTotal: 5,
Department: "",
Position: "",
DutyTime: "",
}
//填入部门
for _, vv := range v.TargetDepartment {
item.Department += vv.DepartmentName + " "
}
for _, vv := range targetUserList {
if vv.Id != int64(v.TargetUser.UserId) {
continue
}
//填入入职时间
item.DutyTime = vv.CreatedAt.Local().Format("2006-01-02 15:04:05")
//填入职位
for _, vvv := range userPositionMap[vv.Id] {
item.Position += vvv.Name + " "
}
break
}
//
for _, vv := range inviteCompletedCount {
if v.TargetUser.UserId == vv.TargetUserId {
item.InviteCompleted = vv.InviteCompleted
item.InviteTotal = vv.InviteTotal
break
}
}
resultList = append(resultList, item)
}
result := tool_funs.SimpleWrapGridMap(int64(cnt), resultList)
result["lintNodeDesc"] = ""
if len(assessList) > 0 {
result["cycleId"] = assessList[0].CycleId
result["beginDay"] = assessList[0].BeginTime.Local().Format("2006-01-02")
result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", assessList[0].EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
return result, nil
}
//根据周期和日期,获取员工的自评内容
func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfAssessQuery) (*adapter.AssessInfoResp, 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()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// 获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
"executorId": param.TargetUserId,
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"typesList": []string{string(domain.AssessSelf)},
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "不存在员工的自评内容")
}
assessData := assessList[0]
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())
}
}
//获取员工描述
staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
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,
LinkNodeId: assessData.LinkNodeId,
LinkNodeName: assessData.LinkNodeName,
EvaluationProjectId: assessData.EvaluationProjectId,
EvaluationProjectName: assessData.EvaluationProjectName,
BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
Status: string(assessData.Status),
TargetUserId: assessData.TargetUser.UserId,
TargetUserName: assessData.TargetUser.UserName,
CompanyId: assessData.CompanyId,
CompanyName: "",
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
}
if staffDesc != nil {
result.CompanyName = staffDesc.CompanyName
result.SupperUser = staffDesc.SupperUserName
result.DutyTime = staffDesc.DutyTime
}
return &result, nil
}
... ...
... ... @@ -19,6 +19,11 @@ const (
LinkNodeViewResult int = 5 // 环节-绩效结果查看
)
const (
NodeRequiredYes int = 1 // 必填项-必填(默认)
NodeRequiredNo int = 2 // 必填项-非必填
)
type EntryItem struct {
Title string `json:"title" comment:"填写标题"`
HintText string `json:"hintText" comment:"文本内容提示"`
... ... @@ -31,10 +36,11 @@ type NodeContent struct {
Name string `json:"name" comment:"名称"`
RuleId int64 `json:"ruleId,string" comment:"评估规则ID"`
Rule *EvaluationRule `json:"rule" comment:"评估规则对象"`
Weight int `json:"weight" comment:"权重"`
Weight float64 `json:"weight" comment:"权重"`
PromptTitle string `json:"promptTitle" comment:"提示项标题"`
PromptText string `json:"promptText" comment:"提示项正文"`
EntryItems []*EntryItem `json:"entryItems" comment:"填写项"`
Required int `json:"required" comment:"必填项"`
}
// LinkNode 评估流程、环节
... ...
package domain
import (
"errors"
"fmt"
"strconv"
"time"
)
//填写的评估内容
type StaffAssessContent struct {
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"` //评估填写的值
ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值
LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值
ReteResult string `json:"reteResult"` //评估的结果
Rule EvaluationRule `json:"rule"` //评估的选项规则
Weight int `json:"weight" ` //"权重"
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"`
}
type AssessContemtRemark struct {
Title string `json:"title"` //comment:"填写标题"
HintText string `json:"hintText"` // comment:"文本内容提示"
Definition string `json:"definition"` //comment:"定义"
RemarkText string `json:"remarkText"` // comment:"填写文本内容"
}
//TransformValue
//根据规则 rule 转换评填写的值
func (content *StaffAssessContent) TransformValue() error {
switch content.Rule.Type {
case EvaluationTypeRating:
return content.ratingValue()
case EvaluationTypeScore:
return content.scoreValue()
}
return nil
}
// 规则是评级方式
func (content *StaffAssessContent) ratingValue() error {
levels := content.Rule.Rating.Levels
for _, v := range levels {
if v.Code != content.Value {
continue
}
content.LevelValue = v.Code
content.ScoreValue = v.QuantizedValue
content.ReteResult = v.Name
return nil
}
return errors.New("评级填写的值错误")
}
// 规则是评分方式
func (content *StaffAssessContent) scoreValue() error {
valueFloat, err := strconv.ParseFloat(content.Value, 64)
if err != nil {
return errors.New("评分填写的值错误")
}
rule := &content.Rule
if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
}
//保留小数处理
fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
valueStr := fmt.Sprintf(fStr, valueFloat)
content.Value = valueStr
if rule.Score.IntervalState == 0 {
// 未开启按分数子区间匹配等级
return nil
}
for _, v := range rule.Score.Levels {
if valueFloat < v.Start || valueFloat > v.End {
continue
}
content.LevelValue = v.Code
content.ScoreValue = valueFloat
content.ReteResult = v.Name
return nil
}
return errors.New("评分填写的值错误")
}
type StaffAssessContentRepository interface {
Save(param *StaffAssessContent) (*StaffAssessContent, error)
Remove(id int) error
FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error)
Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error)
}
package domain
import (
"errors"
"fmt"
"strconv"
"time"
)
//填写的评估内容
type StaffAssessContent struct {
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"` //评估填写的值
ScoreValue float64 `json:"scoreValue"` // 填写值按规则Rule转换为相应的量化值
LevelValue string `json:"levelValue"` // 填写值按规则Rule转换为相应的等级值
ReteResult string `json:"reteResult"` //评估的结果
Rule EvaluationRule `json:"rule"` //评估的选项规则
Weight float64 `json:"weight" ` //"权重"
Required int `json:"required"` // 必填项
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"`
}
type AssessContemtRemark struct {
Title string `json:"title"` //comment:"填写标题"
HintText string `json:"hintText"` // comment:"文本内容提示"
Definition string `json:"definition"` //comment:"定义"
RemarkText string `json:"remarkText"` // comment:"填写文本内容"
}
//TransformValue
//根据规则 rule 转换评填写的值
func (content *StaffAssessContent) TransformValue() error {
switch content.Rule.Type {
case EvaluationTypeRating:
return content.ratingValue()
case EvaluationTypeScore:
return content.scoreValue()
}
return nil
}
// 规则是评级方式
func (content *StaffAssessContent) ratingValue() error {
levels := content.Rule.Rating.Levels
for _, v := range levels {
if v.Code != content.Value {
continue
}
content.LevelValue = v.Code
content.ScoreValue = v.QuantizedValue
content.ReteResult = v.Name
return nil
}
return errors.New("评级填写的值错误")
}
// 规则是评分方式
func (content *StaffAssessContent) scoreValue() error {
valueFloat, err := strconv.ParseFloat(content.Value, 64)
if err != nil {
return errors.New("评分填写的值错误")
}
rule := &content.Rule
if valueFloat < rule.Score.Min || valueFloat > rule.Score.Max {
return fmt.Errorf("评分填写的值超出限制,>=%f且<=%f", rule.Score.Min, rule.Score.Max)
}
//保留小数处理
fStr := fmt.Sprintf("%%.%df", rule.Score.DecimalPlaces)
valueStr := fmt.Sprintf(fStr, valueFloat)
content.Value = valueStr
if rule.Score.IntervalState == 0 {
// 未开启按分数子区间匹配等级
return nil
}
for _, v := range rule.Score.Levels {
if valueFloat < v.Start || valueFloat > v.End {
continue
}
content.LevelValue = v.Code
content.ScoreValue = valueFloat
content.ReteResult = v.Name
return nil
}
return errors.New("评分填写的值错误")
}
type StaffAssessContentRepository interface {
Save(param *StaffAssessContent) (*StaffAssessContent, error)
Remove(id int) error
FindOne(queryOptions map[string]interface{}) (*StaffAssessContent, error)
Find(queryOptions map[string]interface{}) (int, []*StaffAssessContent, error)
}
... ...
... ... @@ -57,6 +57,34 @@ func (d *StaffAssessDao) CountInviteAssessByTargetUser(userIds []int, assessTask
return result, err
}
func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int, beginDay string) ([]CountData, error) {
sqlStr := `SELECT
staff_assess.target_user->>'userId' as target_user_id,
count(staff_assess."id") AS invite_total,
sum(
case WHEN staff_assess.status='completed' THEN 1
ELSE 0 END
) as invite_completed
FROM staff_assess
WHERE staff_assess.target_user->>'userId' IN(?)
AND staff_assess.types IN ('invite_same_super','invite_diff_super')
and to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD') = ?
and staff_assess.cycle_id =?
GROUP BY target_user_id`
userIdStr := []string{}
for _, v := range userIds {
str := strconv.Itoa(v)
userIdStr = append(userIdStr, str)
}
condition := []interface{}{
pg.In(userIdStr), beginDay, cycleId,
}
tx := d.transactionContext.PgTx
result := []CountData{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
// 根据评估的人执行人id,搜索 executorId参与的评估任务
func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {
... ... @@ -131,7 +159,8 @@ func (d *StaffAssessDao) AllAssessCycleList(companyId int) ([]AssessCycle, error
//获取评估周期中的绩效考核日期
type AssessCycleDay struct {
BeginDay string `json:"beginDay"`
CycleId string `json:"cycleId"`
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
CompanyId string `json:"companyId"`
}
... ... @@ -139,6 +168,7 @@ type AssessCycleDay struct {
func (d *StaffAssessDao) AllAssessCycleDayList(companyId int, cycleId int) ([]AssessCycleDay, error) {
sqlStr := `select distinct staff_assess_task.begin_day ,
staff_assess_task.cycle_id ,
staff_assess_task.cycle_name,
staff_assess_task.company_id
from staff_assess_task
where staff_assess_task.cycle_id = ?
... ... @@ -378,3 +408,57 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
type AssessCycleDayMe struct {
BeginDay string `json:"beginDay"`
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
}
// 根据评估的人执行人id,搜索 executorId参与的评估周期
func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, error) {
if limit < 0 {
limit = 20
}
if offset < 0 {
offset = 0
}
sqlStr := `
SELECT
staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
FROM staff_assess_task
JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
WHERE staff_assess.company_id=?
and staff_assess_task.deleted_at isnull
and staff_assess.executor->>'userId'='?'
group by staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
order by staff_assess_task.begin_day desc
limit ? offset ?
`
tx := d.transactionContext.PgTx
condition := []interface{}{
companyId, executorId, limit, offset,
}
result := []AssessCycleDayMe{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
// 根据评估的人执行人id,统计executorId参与的评估周期
func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
sqlStr := `
select count(DISTINCT (staff_assess_task.cycle_id,staff_assess_task.begin_day )) as cnt
FROM staff_assess_task
JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"
WHERE staff_assess.company_id=?
and staff_assess_task.deleted_at isnull
and staff_assess.executor->>'userId'='?'
`
tx := d.transactionContext.PgTx
condition := []interface{}{
companyId, executorId,
}
var result int
_, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)
return result, err
}
... ...
package models
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 //类别
Name string //名称
ScoreValue float64 // 填写值按规则Rule转换为相应的量化值
LevelValue string // 填写值按规则Rule转换为相应的等级值
PromptTitle string //问题标题
PromptText string //提示项正文
Value string //评估填写的值
ReteResult string //评估的结果
Rule domain.EvaluationRule
Remark []domain.AssessContemtRemark
Weight int `pg:",use_zero"` //权重
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time
}
package models
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 //类别
Name string //名称
ScoreValue float64 // 填写值按规则Rule转换为相应的量化值
LevelValue string // 填写值按规则Rule转换为相应的等级值
PromptTitle string //问题标题
PromptText string //提示项正文
Value string //评估填写的值
ReteResult string //评估的结果
Rule domain.EvaluationRule
Remark []domain.AssessContemtRemark
Weight float64 `pg:",use_zero"` //权重
Required int //必填项
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
DeletedAt *time.Time
}
... ...
... ... @@ -21,6 +21,17 @@ func NewEvaluationCycleTemplateRepository(transactionContext *pgTransaction.Tran
}
func (repo *EvaluationCycleTemplateRepository) TransformToDomain(m *models.EvaluationCycleTemplate) domain.EvaluationCycleTemplate {
// 历史旧数据,默认输出转成1
if m.Template != nil {
for i := range m.Template.LinkNodes {
node := m.Template.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].Required == 0 {
node.NodeContents[j].Required = domain.NodeRequiredYes
}
}
}
}
return domain.EvaluationCycleTemplate{
Id: m.Id,
Name: m.Name,
... ...
... ... @@ -21,6 +21,18 @@ func NewEvaluationProjectRepository(transactionContext *pgTransaction.Transactio
}
func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationProject) domain.EvaluationProject {
// 历史旧数据,默认输出转成1
if m.Template != nil {
for i := range m.Template.LinkNodes {
node := m.Template.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].Required == 0 {
node.NodeContents[j].Required = domain.NodeRequiredYes
}
}
}
}
return domain.EvaluationProject{
Id: m.Id,
Name: m.Name,
... ...
... ... @@ -21,6 +21,15 @@ func NewEvaluationTemplateRepository(transactionContext *pgTransaction.Transacti
}
func (repo *EvaluationTemplateRepository) TransformToDomain(m *models.EvaluationTemplate) domain.EvaluationTemplate {
// 历史旧数据,默认输出转成1
for i := range m.LinkNodes {
node := m.LinkNodes[i]
for j := range node.NodeContents {
if node.NodeContents[j].Required == 0 {
node.NodeContents[j].Required = domain.NodeRequiredYes
}
}
}
return domain.EvaluationTemplate{
Id: m.Id,
Name: m.Name,
... ...
... ... @@ -37,6 +37,7 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses
ReteResult: d.ReteResult,
Rule: d.Rule,
Weight: d.Weight,
Required: d.Required,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: nil,
... ... @@ -59,6 +60,7 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d
Rule: d.Rule,
Remark: d.Remark,
Weight: d.Weight,
Required: d.Required,
CreatedAt: d.CreatedAt,
UpdatedAt: d.UpdatedAt,
DeletedAt: nil,
... ...
... ... @@ -144,6 +144,7 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["staffAssessTaskId"]; ok {
query.Where(`staff_assess_task_id=?`, v)
}
if v, ok := queryOptions["id"]; ok {
query.Where("id=?", v)
}
... ... @@ -156,6 +157,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if v, ok := queryOptions["endTime"]; ok {
query.Where("end_time<=?", v)
}
if v, ok := queryOptions["beginDay"]; ok {
query.Where("to_char(staff_assess.begin_time at time zone 'PRC','YYYY-MM-DD')= ? ", v)
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -120,12 +120,18 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if v, ok := queryOptions["beginDay"]; ok {
query.Where("begin_day=?", v)
}
if v, ok := queryOptions["cycleId"]; ok {
query.Where("cycle_id=?", v)
}
if v, ok := queryOptions["executorId"].(int); ok && v > 0 {
query.Where(`executor_id @>'[?]'`, v)
}
if v, ok := queryOptions["evaluationProjectId"]; ok {
query.Where("evaluation_project_id=?", v)
}
if v, ok := queryOptions["ids"]; ok {
query.Where("id in (?) ", pg.In(v))
}
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
package controllers
import (
"strconv"
"strings"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"github.com/linmadan/egglib-go/web/beego"
... ... @@ -8,8 +11,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
"strconv"
"strings"
)
type ImportController struct {
... ... @@ -95,7 +96,7 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
nc.RuleId = ruleId // 规则ID
sIndex := strings.Index(module.Weight, "%") // 权重
if sIndex != -1 {
iWeight, _ := strconv.Atoi(module.Weight[:sIndex])
iWeight, _ := strconv.ParseFloat(module.Weight[:sIndex], 64)
nc.Weight = iWeight
} else {
nc.Weight = 0
... ... @@ -119,6 +120,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
})
}
// 必填项
nc.Required = domain.NodeRequiredYes
nodeContents = append(nodeContents, nc)
}
}
... ...
package controllers
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
type StaffAssessControllerV2 struct {
beego.BaseController
}
// 获取我的绩效任务列表
func (c *StaffAssessControllerV2) SearchAssessTaskMe() {
srv := service.NewStaffAssessServeice()
paramReq := &query.SearchAssessMeQuery{}
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.UserId = int(userReq.UserId)
data, err := srv.SearchAssessTaskMeV2(paramReq)
c.Response(data, err)
}
// 获取我的绩效任务各环节完成情况
func (c *StaffAssessControllerV2) AssessTaskMeDesc() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessTaskDescV2Query{}
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.UserId = int(userReq.UserId)
data, err := srv.AssessTaskDescV2(paramReq)
c.Response(data, err)
}
// 获取我要执行360评估,用户列表和评估填写的值
func (c *StaffAssessControllerV2) ListMeInviteUserAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListExecutorAssessQuery{}
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.ExecutorId = int(userReq.UserId)
data, err := srv.ListExecutorInviteAssessV2(paramReq)
c.Response(data, err)
}
// 获取我要执行的上级评估成员列表
func (c *StaffAssessControllerV2) ListMeSupperAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListExecutorAssessQuery{}
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.ExecutorId = int(userReq.UserId)
data, err := srv.ListExecutorSupperAssessV2(paramReq)
c.Response(data, err)
}
// 获取我邀请的人
func (c *StaffAssessControllerV2) GetAssessMeInviteUser() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListInviteUserQuery{}
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.ListAssessInviteUserV2(paramReq)
c.Response(data, err)
}
// 获取员工自评详情
func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.GetExecutorSelfAssessQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
// paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.GetAssessSelfInfoV2(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -10,9 +10,9 @@ import (
func init() {
assessTaskNS := web.NewNamespace("/v1/staff-assess-task",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
web.NSCtrlPost("/search/me", (*controllers.StaffAssessController).SearchAssessTaskMe), //获取我参与过的评估项目列表
web.NSCtrlPost("/desc/me", (*controllers.StaffAssessController).AssessTaskMeDesc), //获取我的项目评估进度描述
//web.NSCtrlPost("/", (*controllers.StaffAssessController).CreateStaffAssessTask), //创建员工的评估任务
web.NSCtrlGet("/cycle", (*controllers.StaffAssessController).ListAssessCycle), //获取周期列表
web.NSCtrlPost("/cycle/day", (*controllers.StaffAssessController).ListAssessCycleDay), //获取周期中的考核日期
web.NSCtrlPost("/cycle/day/content", (*controllers.StaffAssessController).ListAssessContentCycleDay), //根据周期里的考核日期,获取员工填写评估内容列表
... ... @@ -33,8 +33,24 @@ func init() {
web.NSCtrlPost("/target-user/invite/list", (*controllers.StaffAssessController).ListTargetUserInviteAssess), //获取被评估员工360评估的列表
web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessController).ListTargetUserMeSupperAssess), //获取我的上级评估的列表
web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessController).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
)
//v2 改版
assessTaskV2NS := web.NewNamespace("/v2/staff-assess-task",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/search/me", (*controllers.StaffAssessControllerV2).SearchAssessTaskMe), //获取我参与过的评估项目列表
web.NSCtrlPost("/desc/me", (*controllers.StaffAssessControllerV2).AssessTaskMeDesc),
)
assessV2NS := web.NewNamespace("/v2/staff-assess",
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/me/execute/invite/list", (*controllers.StaffAssessControllerV2).ListMeInviteUserAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/me/execute/supper/list", (*controllers.StaffAssessControllerV2).ListMeSupperAssess), //我要执行的360评估的用户列表
web.NSCtrlPost("/me/invite-user", (*controllers.StaffAssessControllerV2).GetAssessMeInviteUser), //获取邀请的员工
web.NSCtrlPost("/target-user/self/info", (*controllers.StaffAssessControllerV2).GetAssessTargetUserSelfInfo), //获取被评估员工的自评反馈详情
)
web.AddNamespace(assessTaskNS)
web.AddNamespace(assessNS)
web.AddNamespace(assessTaskV2NS)
web.AddNamespace(assessV2NS)
}
... ...
ALTER TABLE public.staff_assess_content ADD required int8 NULL DEFAULT 1;
\ No newline at end of file
... ...
ALTER TABLE public.staff_assess_content ALTER COLUMN weight TYPE float8 USING weight::float8;
... ...