作者 tangxvhui

新加接口

... ... @@ -986,37 +986,298 @@ func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext app
return contentList, nil
}
// 展示360评估内容
func (srv StaffAssessServeice) StaffAssess360Show() (*adapter.AssessInfoResp, error) {
return nil, nil
}
// 展示360评估内容,未填写的评估项不展示
func (srv StaffAssessServeice) StaffAssess360Show(param *query.AssessInfoQuery) (*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,
"id": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return &adapter.AssessInfoResp{}, nil
}
if assessList[0].Types != domain.AssessInviteSameSuper &&
assessList[0].Types != domain.AssessInviteDiffSuper {
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
//已完成
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())
}
targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
if err != nil {
log.Logger.Error("获取员工描述" + err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessInfoResp{
AssessId: assessData.Id,
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
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: []*domain.StaffAssessContent{},
}
if targetUserDesc != nil {
result.CompanyName = targetUserDesc.CompanyName
result.SupperUser = targetUserDesc.SupperUserName
result.CompanyLogo = targetUserDesc.CompanyLogo
result.DutyTime = targetUserDesc.DutyTime
}
// 展示上级评估内容
func (srv StaffAssessServeice) StaffAssessSuperShow() (*adapter.AssessInfoResp, error) {
return nil, nil
for _, val := range assessContentList {
if len(val.Value) == 0 {
//跳过不展示未填写的
continue
}
result.AssessContent = append(result.AssessContent, val)
}
return &result, nil
}
// 展示自评评估内容
func (srv StaffAssessServeice) StaffAssessSelfShow() (*adapter.AssessInfoResp, error) {
return nil, nil
// 展示上级评估内容,未填写的评估项不展示
func (srv StaffAssessServeice) StaffAssessSuperShow(param *query.AssessInfoQuery) (*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,
"id": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return &adapter.AssessInfoResp{}, nil
}
if assessList[0].Types != domain.AssessSuper {
return &adapter.AssessInfoResp{}, nil
}
assessData := assessList[0]
//已完成
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())
}
targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
if err != nil {
log.Logger.Error("获取员工描述" + err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessInfoResp{
AssessId: assessData.Id,
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
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: []*domain.StaffAssessContent{},
}
if targetUserDesc != nil {
result.CompanyName = targetUserDesc.CompanyName
result.SupperUser = targetUserDesc.SupperUserName
result.CompanyLogo = targetUserDesc.CompanyLogo
result.DutyTime = targetUserDesc.DutyTime
}
for _, val := range assessContentList {
if len(val.Value) == 0 {
//跳过不展示未填写的
continue
}
result.AssessContent = append(result.AssessContent, val)
}
return &result, nil
}
// 360评估内容编辑前
func (srv StaffAssessServeice) StaffAssess360BeforeEdit() (*adapter.AssessInfoResp, error) {
return nil, nil
func (srv StaffAssessServeice) StaffAssess360BeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
result, err := srv.getStaffAssessBeforeEdit(param)
if err != nil {
return &adapter.AssessInfoResp{}, err
}
//360评估全部是选填项
for i := range result.AssessContent {
result.AssessContent[i].Required = domain.NodeRequiredNo
}
return result, nil
}
// 上级评估内容编辑前
func (srv StaffAssessServeice) StaffAssessSuperBeforeEdit() (*adapter.AssessInfoResp, error) {
return nil, nil
func (srv StaffAssessServeice) StaffAssessSuperBeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
result, err := srv.getStaffAssessBeforeEdit(param)
if err != nil {
return &adapter.AssessInfoResp{}, err
}
//上级评估全部是选填项
for i := range result.AssessContent {
result.AssessContent[i].Required = domain.NodeRequiredNo
}
return result, nil
}
// 自评评估内容编辑前
func (srv StaffAssessServeice) StaffAssessSelfBeforeEdit() (*adapter.AssessInfoResp, error) {
return nil, nil
// func (srv StaffAssessServeice) StaffAssessSelfBeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
// result, err := srv.GetAssessInfo(param)
// if err != nil {
// return &adapter.AssessInfoResp{}, err
// }
// return result, nil
// }
func (srv StaffAssessServeice) getStaffAssessBeforeEdit(param *query.AssessInfoQuery) (*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,
"id": param.AssessId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return &adapter.AssessInfoResp{}, nil
}
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.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
}
// 恢复缓存数据
srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
if err != nil {
log.Logger.Error("获取员工描述" + err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
result := adapter.AssessInfoResp{
AssessId: assessData.Id,
CycleId: assessData.CycleId,
CycleName: assessData.CycleName,
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 len(assessContentList) == 0 {
result.AssessContent = []*domain.StaffAssessContent{}
}
if targetUserDesc != nil {
result.CompanyName = targetUserDesc.CompanyName
result.SupperUser = targetUserDesc.SupperUserName
result.CompanyLogo = targetUserDesc.CompanyLogo
result.DutyTime = targetUserDesc.DutyTime
}
return &result, nil
}
// 获取未完成评估任务的执行人员名单
func (srv StaffAssessServeice) ExcutorListUncompleted() error {
func (srv StaffAssessServeice) ListExcutorUncompleted() error {
return nil
}
... ...
... ... @@ -23,7 +23,7 @@ type StaffAssessContent struct {
ReteResult string `json:"reteResult"` //评估的结果
Rule EvaluationRule `json:"rule"` //评估的选项规则
Weight float64 `json:"weight" ` //"权重"
Required int `json:"required"` // 必填项
Required int `json:"required"` // 必填项 同EvaluationTemplate.go->NodeRequiredYes;NodeContent.Required
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"`
... ...
... ... @@ -184,3 +184,67 @@ func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
data, err := srv.GetAssessSelfInfoV2(paramReq)
c.Response(data, err)
}
// 展示360评估内容
func (c *StaffAssessControllerV2) StaffAssess360Show() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.StaffAssess360Show(paramReq)
c.Response(data, err)
}
// 展示上级评估内容
func (c *StaffAssessControllerV2) StaffAssessSuperShow() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.StaffAssessSuperShow(paramReq)
c.Response(data, err)
}
// 360评估内容编辑前
func (c *StaffAssessControllerV2) StaffAssess360BeforeEdit() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.StaffAssess360BeforeEdit(paramReq)
c.Response(data, err)
}
// 上级评估内容编辑前
func (c *StaffAssessControllerV2) StaffAssessSuperBeforeEdit() {
srv := service.NewStaffAssessServeice()
paramReq := &query.AssessInfoQuery{}
err := c.BindJSON(paramReq)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.StaffAssessSuperBeforeEdit(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -54,6 +54,10 @@ func init() {
web.NSCtrlPost("/target-user/supper/list", (*controllers.StaffAssessControllerV2).ListTargetUserSupperAssess), //获取被评估员工被上级评估的列表
web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessControllerV2).GetAssessSelfMeInfo), //获取当前周期里我的自评反馈详情
web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessControllerV2).ListTargetUserMeSupperAssess), //获取我被上级评估的列表
web.NSCtrlPost("/360/show", (*controllers.StaffAssessControllerV2).StaffAssess360Show), //展示360评估内容
web.NSCtrlPost("/super/show", (*controllers.StaffAssessControllerV2).StaffAssessSuperShow), //展示上级评估内容
web.NSCtrlPost("/360/befor-edit", (*controllers.StaffAssessControllerV2).StaffAssess360BeforeEdit), //360评估内容编辑前
web.NSCtrlPost("/super/befor-edit", (*controllers.StaffAssessControllerV2).StaffAssessSuperBeforeEdit), //上级评估内容编辑前
)
web.AddNamespace(assessTaskNS)
... ...