作者 tangxvhui

添加功能。修改周期考核结果

package adapter
type MeInfo struct {
UserId int64 `json:"userId"` //用户名称
CompanyLogo string `json:"companyLogo"` //图标
CompanyId int64 `json:"companyId"` //公司id
CompanyName string `json:"companyName"` //公司名称
Phone string `json:"phone"` // 手机号
Name string `json:"name"` // 员工名称
IsHrbp bool `json:"isHrbp"` //是否 是hrbp
IsParent bool `json:"isParent"` //是否 是上级
UserId int64 `json:"userId"` //用户名称
CompanyLogo string `json:"companyLogo"` //图标
CompanyId int64 `json:"companyId"` //公司id
CompanyName string `json:"companyName"` //公司名称
Phone string `json:"phone"` // 手机号
Name string `json:"name"` // 员工名称
IsHrbp bool `json:"isHrbp"` //是否 是hrbp
IsParent bool `json:"isParent"` //是否 是上级
IsSuperAdmin bool `json:"isSuperAdmin"` //是否 是超级角色
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
roleService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
... ... @@ -173,8 +174,6 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa
}()
userRepository := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
companyRepository := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
roleRepo := factory.CreateRoleRepository(map[string]interface{}{"transactionContext": transactionContext})
roleUserRepo := factory.CreateRoleUserRepository(map[string]interface{}{"transactionContext": transactionContext})
userData, err := userRepository.FindOne(map[string]interface{}{
"id": param.UserId,
})
... ... @@ -194,38 +193,34 @@ func (service *AuthService) MeInfo(param *command.GetMeInfo) (map[string]interfa
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取公司数据"+err.Error())
}
_, roleList, err := roleRepo.Find(map[string]interface{}{"type": domain.RoleTypeSystem, "companyId": param.CompanyId})
hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": param.CompanyId, "userId": param.UserId})
superAdminFlag, err := roleService.GetSuperAdmin(transactionContext, int(param.CompanyId), int(param.UserId))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息列表"+err.Error())
}
// 拥有HRBP权限
isHrbp := false
loop:
for _, v := range userRoleList {
for _, v2 := range roleList {
if v.RoleId == v2.Id {
isHrbp = true
break loop
}
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
//TODO 检查用户是否 超级角色
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
info := adapter.MeInfo{
UserId: userData.Id,
CompanyId: companyData.Id,
CompanyName: companyData.Name,
CompanyLogo: companyData.Logo,
Phone: userData.Account,
Name: userData.Name,
IsHrbp: isHrbp,
IsParent: false,
UserId: userData.Id,
CompanyId: companyData.Id,
CompanyName: companyData.Name,
CompanyLogo: companyData.Logo,
Phone: userData.Account,
Name: userData.Name,
IsHrbp: false,
IsParent: false,
IsSuperAdmin: false,
}
if hrbpFlag == domain.RoleTypeSystem {
info.IsHrbp = true
}
if superAdminFlag == domain.RoleTypeSuperAdmin {
info.IsSuperAdmin = true
}
if len(parentUser) > 0 {
info.IsParent = true
... ...
... ... @@ -37,7 +37,12 @@ func (notices *notifySms) regist(ifsend notifySendOrNot) {
}
func (notices *notifySms) addTask(task *domain.LogSms) {
notices.newSms <- task
// notices.newSms <- task
err := notices.addNewSms(task)
if err != nil {
e := fmt.Sprintf("添加短信通知任务:%+v %s", task, err)
log.Logger.Error(e)
}
}
// RunTask 执行短信通知任务
... ...
package command
// 员工确认 周期评估 分数
type ModifyFinishScore struct {
SummaryEvaluationId int `json:"summaryEvaluationId,string"`
Score float64 `json:"score"`
CompanyId int `json:"-"` //登录的公司
UserId int `json:"-"` //操作员id
}
... ...
package service
import (
"fmt"
"strconv"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
"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"
)
// sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务
// project 需要处理的项目
// userList 全体的员工数据 map[id]=>domain.User
// departmetList 全部的部门数据 map[id]=>domain.Department
func sendSummaryEvaluation(project *domain.EvaluationProject,
userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) {
//自评的时间范围
beginTimeSelf := project.EndTime
endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second)
//人资、360评估的时间范围
beginTime360 := endTimeSelf
endTime360 := endTimeSelf.Add(2 * 24 * time.Hour)
//上级评估的是时间范围
beginTimeSuper := endTime360
endTimeSuper := endTime360.Add(2 * 24 * time.Hour)
//
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, err
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
// func sendSummaryEvaluation(project *domain.EvaluationProject,
// userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) {
// //自评的时间范围
// beginTimeSelf := project.EndTime
// endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second)
// //人资、360评估的时间范围
// beginTime360 := endTimeSelf
// endTime360 := endTimeSelf.Add(2 * 24 * time.Hour)
// //上级评估的是时间范围
// beginTimeSuper := endTime360
// endTimeSuper := endTime360.Add(2 * 24 * time.Hour)
// //
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return nil, err
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return nil, err
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
// cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId})
if err != nil {
return nil, err
}
//确定 被评估的人
targetUserId := []int64{}
for _, v := range project.Recipients {
id, err := strconv.ParseInt(v, 10, 64)
if err == nil {
targetUserId = append(targetUserId, id)
}
}
if len(targetUserId) == 0 {
return nil, nil
}
//被评估的员工
targetUserMap := map[int64]*domain.User{}
// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
for _, v := range targetUserId {
u, ok := userMap[v]
if ok {
targetUserMap[v] = u
}
}
//确定360评估的执行人
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)})
if err != nil {
return nil, err
}
nodeId := 0
executor360Map := map[int64]*domain.User{}
hrbpExist := false
for _, v := range itemList {
nodeId = v.NodeId
if v.EvaluatorId < 0 {
hrbpExist = true
}
if v.EvaluatorId <= 0 {
continue
}
if u, ok := userMap[int64(v.EvaluatorId)]; ok {
executor360Map[u.Id] = u
}
}
//创建周期评估任务
var newEvaluationList []domain.SummaryEvaluation
evaluationTemp := domain.SummaryEvaluation{
Id: 0,
CompanyId: int(project.CompanyId),
EvaluationProjectId: int(project.Id),
EvaluationProjectName: project.Name,
CycleId: cycleData.Id,
CycleName: cycleData.Name,
NodeId: nodeId,
TargetUser: domain.StaffDesc{},
TargetDepartment: []domain.StaffDepartment{},
Executor: domain.StaffDesc{},
Types: 0,
Status: domain.EvaluationUncompleted,
CheckResult: domain.EvaluationCheckUncompleted,
BeginTime: time.Time{},
EndTime: time.Time{},
TotalScore: "",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
DeletedAt: nil,
}
// cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId})
// if err != nil {
// return nil, err
// }
// //确定 被评估的人
// targetUserId := []int64{}
// for _, v := range project.Recipients {
// id, err := strconv.ParseInt(v, 10, 64)
// if err == nil {
// targetUserId = append(targetUserId, id)
// }
// }
// if len(targetUserId) == 0 {
// return nil, nil
// }
// //被评估的员工
// targetUserMap := map[int64]*domain.User{}
//确定周期评估
// for _, v := range targetUserId {
// u, ok := userMap[v]
// if ok {
// targetUserMap[v] = u
// }
// }
// //确定360评估的执行人
// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)})
// if err != nil {
// return nil, err
// }
// nodeId := 0
// executor360Map := map[int64]*domain.User{}
// hrbpExist := false
// for _, v := range itemList {
// nodeId = v.NodeId
// if v.EvaluatorId < 0 {
// hrbpExist = true
// }
// if v.EvaluatorId <= 0 {
// continue
// }
// if u, ok := userMap[int64(v.EvaluatorId)]; ok {
// executor360Map[u.Id] = u
// }
// }
// //创建周期评估任务
// var newEvaluationList []domain.SummaryEvaluation
// evaluationTemp := domain.SummaryEvaluation{
// Id: 0,
// CompanyId: int(project.CompanyId),
// EvaluationProjectId: int(project.Id),
// EvaluationProjectName: project.Name,
// CycleId: cycleData.Id,
// CycleName: cycleData.Name,
// NodeId: nodeId,
// TargetUser: domain.StaffDesc{},
// TargetDepartment: []domain.StaffDepartment{},
// Executor: domain.StaffDesc{},
// Types: 0,
// Status: domain.EvaluationUncompleted,
// CheckResult: domain.EvaluationCheckUncompleted,
// BeginTime: time.Time{},
// EndTime: time.Time{},
// TotalScore: "",
// CreatedAt: time.Now(),
// UpdatedAt: time.Now(),
// DeletedAt: nil,
// }
for _, v := range targetUserMap {
//处理自评
evaluationTemp.TargetUser = domain.StaffDesc{
UserId: int(v.Id),
Account: v.Account,
UserName: v.Name,
}
evaluationTemp.Executor = domain.StaffDesc{
UserId: int(v.Id),
Account: v.Account,
UserName: v.Name,
}
evaluationTemp.BeginTime = beginTimeSelf
evaluationTemp.EndTime = endTimeSelf
evaluationTemp.TargetDepartment = []domain.StaffDepartment{}
evaluationTemp.Types = domain.EvaluationSelf
for _, departId := range v.DepartmentId {
depart, ok := departmentMap[int64(departId)]
if !ok {
continue
}
evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{
DepartmentId: int(depart.Id),
DepartmentName: depart.Name,
})
}
newEvaluationList = append(newEvaluationList, evaluationTemp)
if hrbpExist {
//处理人资评估
evaluationTemp.BeginTime = beginTime360
evaluationTemp.EndTime = endTime360
evaluationTemp.Executor = domain.StaffDesc{}
evaluationTemp.Types = domain.EvaluationHrbp
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
//处理360 评估
for _, v2 := range executor360Map {
evaluationTemp.BeginTime = beginTime360
evaluationTemp.EndTime = endTime360
evaluationTemp.Executor = domain.StaffDesc{
UserId: int(v2.Id),
Account: v2.Account,
UserName: v2.Name,
}
evaluationTemp.Types = domain.Evaluation360
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
// //确定周期评估
//处理上级评估
superUser, ok := userMap[v.ParentId]
if ok {
evaluationTemp.Types = domain.EvaluationSuper
evaluationTemp.Executor = domain.StaffDesc{
UserId: int(superUser.Id),
Account: superUser.Account,
UserName: superUser.Name,
}
evaluationTemp.BeginTime = beginTimeSuper
evaluationTemp.EndTime = endTimeSuper
//确定上级评估
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
// 确定 考核结果 的评估记录
evaluationTemp.Types = domain.EvaluationFinish
evaluationTemp.Executor = domain.StaffDesc{}
evaluationTemp.BeginTime = endTimeSuper
evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour)
newEvaluationList = append(newEvaluationList, evaluationTemp)
}
summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
for i := range newEvaluationList {
err = summaryEvaluationRepo.Save(&newEvaluationList[i])
if err != nil {
return nil, err
}
}
//回填 项目的状态
projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext})
err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes)
if err != nil {
return nil, err
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, err
}
return newEvaluationList, nil
}
// for _, v := range targetUserMap {
// //处理自评
// evaluationTemp.TargetUser = domain.StaffDesc{
// UserId: int(v.Id),
// Account: v.Account,
// UserName: v.Name,
// }
// evaluationTemp.Executor = domain.StaffDesc{
// UserId: int(v.Id),
// Account: v.Account,
// UserName: v.Name,
// }
// evaluationTemp.BeginTime = beginTimeSelf
// evaluationTemp.EndTime = endTimeSelf
// evaluationTemp.TargetDepartment = []domain.StaffDepartment{}
// evaluationTemp.Types = domain.EvaluationSelf
// for _, departId := range v.DepartmentId {
// depart, ok := departmentMap[int64(departId)]
// if !ok {
// continue
// }
// evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{
// DepartmentId: int(depart.Id),
// DepartmentName: depart.Name,
// })
// }
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// if hrbpExist {
// //处理人资评估
// evaluationTemp.BeginTime = beginTime360
// evaluationTemp.EndTime = endTime360
// evaluationTemp.Executor = domain.StaffDesc{}
// evaluationTemp.Types = domain.EvaluationHrbp
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
// //处理360 评估
// for _, v2 := range executor360Map {
// evaluationTemp.BeginTime = beginTime360
// evaluationTemp.EndTime = endTime360
// evaluationTemp.Executor = domain.StaffDesc{
// UserId: int(v2.Id),
// Account: v2.Account,
// UserName: v2.Name,
// }
// evaluationTemp.Types = domain.Evaluation360
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
func dayZeroTime(t time.Time) time.Time {
y, m, d := t.Local().Date()
t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
return t2
}
// //处理上级评估
// superUser, ok := userMap[v.ParentId]
// if ok {
// evaluationTemp.Types = domain.EvaluationSuper
// evaluationTemp.Executor = domain.StaffDesc{
// UserId: int(superUser.Id),
// Account: superUser.Account,
// UserName: superUser.Name,
// }
// evaluationTemp.BeginTime = beginTimeSuper
// evaluationTemp.EndTime = endTimeSuper
// //确定上级评估
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
// // 确定 考核结果 的评估记录
// evaluationTemp.Types = domain.EvaluationFinish
// evaluationTemp.Executor = domain.StaffDesc{}
// evaluationTemp.BeginTime = endTimeSuper
// evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour)
// newEvaluationList = append(newEvaluationList, evaluationTemp)
// }
// summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
// for i := range newEvaluationList {
// err = summaryEvaluationRepo.Save(&newEvaluationList[i])
// if err != nil {
// return nil, err
// }
// }
// //回填 项目的状态
// projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext})
// err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes)
// if err != nil {
// return nil, err
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return nil, err
// }
// return newEvaluationList, nil
// }
// 下发周期评估
func TaskSendSummaryEvaluation() error {
nowTime := time.Now()
defer func() {
str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds())
log.Logger.Info(str)
}()
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return err
}
if err := transactionContext.StartTransaction(); err != nil {
return err
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// func dayZeroTime(t time.Time) time.Time {
// y, m, d := t.Local().Date()
// t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
// return t2
// }
projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
// // 下发周期评估
// func TaskSendSummaryEvaluation() error {
// nowTime := time.Now()
// defer func() {
// str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds())
// log.Logger.Info(str)
// }()
// transactionContext, err := factory.CreateTransactionContext(nil)
// if err != nil {
// return err
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return err
// }
// defer func() {
// _ = transactionContext.RollbackTransaction()
// }()
userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext})
// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext})
_, projectList, err := projectRepo.Find(map[string]interface{}{
"endTime": time.Now(),
"summaryState": domain.ProjectSummaryStateNo,
"state": domain.ProjectStateEnable,
}, "template")
if err != nil {
return fmt.Errorf("获取可用的项目数据,%s", err)
}
companyIdMap := map[int64]struct{}{}
for _, v := range projectList {
companyIdMap[v.CompanyId] = struct{}{}
}
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext})
var createdEvalationList []domain.SummaryEvaluation
// _, projectList, err := projectRepo.Find(map[string]interface{}{
// "endTime": time.Now(),
// "summaryState": domain.ProjectSummaryStateNo,
// "state": domain.ProjectStateEnable,
// }, "template")
// if err != nil {
// return fmt.Errorf("获取可用的项目数据,%s", err)
// }
// companyIdMap := map[int64]struct{}{}
// for _, v := range projectList {
// companyIdMap[v.CompanyId] = struct{}{}
// }
//获取可执行的项目
for companyId := range companyIdMap {
//获取员工数据,部门数据
_, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId})
if err != nil {
log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error())
continue
}
_, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId})
if err != nil {
log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error())
continue
}
//转map
userMap := map[int64]*domain.User{}
for _, v := range userList {
userMap[v.Id] = v
}
departmentMap := map[int64]*domain.Department{}
for _, v := range departmentList {
departmentMap[v.Id] = v
}
for _, v := range projectList {
if v.CompanyId != companyId {
continue
}
evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap)
if err != nil {
log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error())
continue
}
createdEvalationList = append(createdEvalationList, evalationList...)
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return err
}
//添加待发送的短信通知
err = sendSmsEvalation(createdEvalationList)
return err
}
// var createdEvalationList []domain.SummaryEvaluation
// 添加待发送的短信通知
func sendSmsEvalation(param []domain.SummaryEvaluation) error {
for i := range param {
if param[i].Types == domain.EvaluationSelf {
notify.AddNotifySummaryEvaluation(&param[i])
}
}
return nil
}
// //获取可执行的项目
// for companyId := range companyIdMap {
// //获取员工数据,部门数据
// _, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId})
// if err != nil {
// log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error())
// continue
// }
// _, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId})
// if err != nil {
// log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error())
// continue
// }
// //转map
// userMap := map[int64]*domain.User{}
// for _, v := range userList {
// userMap[v.Id] = v
// }
// departmentMap := map[int64]*domain.Department{}
// for _, v := range departmentList {
// departmentMap[v.Id] = v
// }
// for _, v := range projectList {
// if v.CompanyId != companyId {
// continue
// }
// evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap)
// if err != nil {
// log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error())
// continue
// }
// createdEvalationList = append(createdEvalationList, evalationList...)
// }
// }
// if err := transactionContext.CommitTransaction(); err != nil {
// return err
// }
// //添加待发送的短信通知
// err = sendSmsEvalation(createdEvalationList)
// return err
// }
... ...
... ... @@ -7,6 +7,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
"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"
... ... @@ -119,6 +120,16 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error {
return nil
}
// // 添加待发送的短信通知
func sendSmsEvalation(param []domain.SummaryEvaluation) error {
for i := range param {
if param[i].Types == domain.EvaluationSelf {
notify.AddNotifySummaryEvaluation(&param[i])
}
}
return nil
}
// 下发周期综合评估
type summaryEvaluationPublisher struct {
userCache map[int64]*domain.User
... ...
... ... @@ -820,3 +820,43 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
"evaluationItems": itemValueAdapter,
}, nil
}
// 修改周期考核的分数
func (srv *SummaryEvaluationService) ModifyFinishScore(param *command.ModifyFinishScore) error {
//TODO 只有超级管理员可以使用的功能
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//获取周期评估任务finish
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
"id": []int{param.SummaryEvaluationId},
"companyId": param.CompanyId,
})
if err != nil {
return application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if len(evaluationList) == 0 {
return nil
}
evaluationData := evaluationList[0]
if evaluationData.Types != domain.EvaluationFinish {
return nil
}
scoreStr := fmt.Sprintf("%.2f", param.Score)
evaluationData.TotalScore = scoreStr
evaluationData.Status = domain.EvaluationCompleted
evaluationData.CheckResult = domain.EvaluationCheckCompleted
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}
... ...
... ... @@ -384,3 +384,17 @@ func (c *SummaryEvaluationController) SearchAssessRemark() {
data, err := srv.SearchAssessRemark(param)
c.Response(data, err)
}
// 修改周期考核结果的分数
func (c *SummaryEvaluationController) ModifyFinishScore() {
srv := service.NewSummaryEvaluationService()
param := &command.ModifyFinishScore{}
err := c.BindJSON(param)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
err = srv.ModifyFinishScore(param)
c.Response(nil, err)
}
... ...
... ... @@ -32,6 +32,7 @@ func init() {
//web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetEvaluationResult),
// web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
web.NSCtrlPost("/evaluation-finish/modify-score", (*controllers.SummaryEvaluationController).ModifyFinishScore),
// web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationFinish),
web.NSCtrlGet("/evaluation-self/now", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSelf),
... ...