作者 郑周

Merge remote-tracking branch 'origin/test' into test

# Conflicts:
#	pkg/application/staff_assess/service/service.go
package adapter
type AssessCycleDayResp struct {
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
BeginDay string `json:"beginDay"`
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
BeginDay string `json:"beginDay"`
AssessTaskId []int `json:"assessTaskId"`
}
... ...
... ... @@ -7,8 +7,8 @@ type ListSupperAssessResp struct {
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"` //入职时间
}
... ...
package query
type AssessCycleDescQuery struct {
CycleId int `json:"cycleId"` //评估任务的id
BeginDay string `json:"beginDay"` //开始时间 2022-01-02
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
... ... @@ -5,3 +5,10 @@ type AssessTaskDescQuery struct {
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
type AssessTaskDescV2Query struct {
CycleId int `json:"cycle"`
BeginDay string `json:"beginDay"`
UserId int `json:"userId"` //当前登录人的id
CompanyId int `json:"companyId"` //当前登录的公司
}
... ...
package query
type ListAssessInviteUserQuery struct {
CompanyId int `json:"companyId"` //对公司
UserId int `json:"userId"` //被评估的员工id
CycleId int `json:"CycleId"` //评估任务的周期id
BeginDay string `json:"beginDay"` //日期
}
... ...
package query
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
}
... ...
... ... @@ -246,7 +246,6 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
"limit": limit,
"endTime": time.Now(), //获取历史记录
}
// "status": string(domain.StaffAssessCompleted),
if offset > 0 {
condition["offset"] = offset
}
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"fmt"
"strconv"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
... ... @@ -12,8 +13,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
)
//获取我的项目周期
func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQuery) (map[string]interface{}, error) {
//获取我的项目周期列表
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())
... ... @@ -50,9 +51,10 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
var temp adapter.AssessCycleDayResp
for _, v := range assessCycleList {
temp = adapter.AssessCycleDayResp{
CycleId: v.CycleId,
CycleName: v.CycleName,
BeginDay: v.BeginDay,
CycleId: v.CycleId,
CycleName: v.CycleName,
BeginDay: v.BeginDay,
AssessTaskId: v.AssessTaskId,
}
listData = append(listData, temp)
}
... ... @@ -60,7 +62,7 @@ func (srv StaffAssessServeice) SearchAssessCycelMe(param *query.SearchAssessMeQu
}
//获取我的项目周期进度描述
func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQuery) (*adapter.AssessCycleDescResp, error) {
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())
... ... @@ -79,23 +81,20 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
staffAssessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskDataAny, err := staffAssessTaskRepo.FindOne(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"limit": 1,
_, 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())
}
_, myAssessTask, err := staffAssessTaskRepo.Find(map[string]interface{}{
"cycleId": param.CycleId,
"beginDay": param.BeginDay,
"executorId": param.UserId,
"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),
... ... @@ -117,56 +116,54 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
}
switch v.LinkNodeType {
case domain.LinkNodeSelfAssessment:
if len(myAssessTask) > 0 {
//个人自评完成情况
_, assessSelfData, err := staffAssessRepo.Find(map[string]interface{}{
"staffAssessTaskId": myAssessTask[0].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)
//个人自评完成情况
_, 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:
if len(myAssessTask) > 0 {
//邀请别人评估自己
_, 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())
}
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))
}
//邀请别人评估自己
_, 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{}{
"beginDay": param.BeginDay,
"executorId": param.UserId,
"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)
... ... @@ -179,23 +176,32 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
}
case domain.LinkNodeSuperiorAssessment:
//我评估别人,上级评估
_, assessSupperList, err := staffAssessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": assessTaskData.Id,
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())
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 len(assessSupperList) > 0 {
if (cnnt + cnnt2) > 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
}
}
uncompletedNum := cnnt
if uncompletedNum > 0 {
stepItem.Status = string(domain.StaffAssessUncompleted)
stepItem.Desc = fmt.Sprintf("截止日期:%s 待评估%d人", stepItem.EndTime, uncompletedNum)
... ... @@ -209,3 +215,416 @@ func (srv StaffAssessServeice) AssessCycleMeDesc(param *query.AssessCycleDescQue
}
return &result, nil
}
//根据周期获取,我的自评任务添加的邀请人
func (srv StaffAssessServeice) ListAssessInviteUserV2(param query.ListAssessInviteUserQuery) (*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.UserId,
"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.UserId,
})
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) ListExecutorDayInviteAssess(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,
})
assessTaskRepo := factory.CreateStaffAssessTaskRepository(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())
}
_, myAssessTaskData, err := assessTaskRepo.Find(map[string]interface{}{
"beginDay": param.BeginDay,
"cycleId": param.CycleId,
"executorId": param.ExecutorId,
"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),
"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(myAssessTaskData) > 0 {
for _, v := range myAssessTaskData[0].StepList {
if v.LinkNodeType == domain.LinkNodeAllAssessment {
result.LinkNodeId = v.LinkNodeId
result.LinkNodeName = v.LinkNodeName
result.LintNodeDesc = fmt.Sprintf("截止时间 %s 待评估%d人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
}
}
return &result, nil
}
//根据周期和日期获取我需要执行的上级评估成员列表
func (srv StaffAssessServeice) ListExecutorDaySupperAssess(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
if len(userIds) > 0 {
// d := dao.NewStaffAssessDao(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// inviteCompletedCount, err = d.CountInviteAssessByTargetUser(userIds, param.AssessTaskId)
// if err != nil {
// log.Logger.Error("获取员工邀请的人完成情况" + err.Error())
// }
}
assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessTaskData, err := assessTaskRepo.FindOne(map[string]interface{}{
// "id": param.AssessTaskId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "获取评估任务"+err.Error())
}
//我评估别人,被邀请评估
cnnt, _, err := assessRepo.Find(map[string]interface{}{
// "staffAssessTaskId": param.AssessTaskId,
"executorId": param.ExecutorId,
"typesList": []string{string(domain.AssessSuper)},
"status": string(domain.StaffAssessUncompleted),
})
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,
UsrId: 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["linkNodeName"] = ""
result["linkNodeId"] = ""
result["lintNodeDesc"] = ""
for _, v := range assessTaskData.StepList {
if v.LinkNodeType == domain.LinkNodeSuperiorAssessment {
result["linkNodeName"] = v.LinkNodeName
result["linkNodeId"] = fmt.Sprintf("%d", v.LinkNodeId)
result["lintNodeDesc"] = fmt.Sprintf("截止时间 %s 待评估 %d 人", v.EndTime.Local().Format("2006-01-02 15:04:05"), cnnt)
}
}
return result, nil
}
... ...
... ... @@ -381,8 +381,15 @@ func (d *StaffAssessDao) ExportDataUserAssess(param SearchConditin1) ([]ExportDa
return result, err
}
type AssessCycleDayMe struct {
BeginDay string `json:"beginDay"`
CycleId int `json:"cycleId"`
CycleName string `json:"cycleName"`
AssessTaskId []int `json:"assessTaskId"`
}
// 根据评估的人执行人id,搜索 executorId参与的评估周期
func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDay, error) {
func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayMe, error) {
if limit < 0 {
limit = 20
}
... ... @@ -390,19 +397,23 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
offset = 0
}
sqlStr := `
SELECT DISTINCT staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day
SELECT
jsonb_agg (staff_assess_task.id) as assess_task_id,
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 := []AssessCycleDay{}
result := []AssessCycleDayMe{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ... @@ -410,7 +421,7 @@ func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limi
// 根据评估的人执行人id,统计executorId参与的评估周期
func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
sqlStr := `
select count(DISTINCT (staff_assess_task.cycle_id ,staff_assess_task.cycle_name ,staff_assess_task.begin_day )) as cnt
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=?
... ...
... ... @@ -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)
}
... ...
... ... @@ -129,6 +129,9 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
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
... ...