作者 郑周

Merge branch 'test' into dev-zhengzhou

package adapter
type MeInfo struct {
UserId int64 `json:"userId"` //用户名称
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"` //是否 是上级
}
... ...
package command
type GetMeInfo struct {
UserId int64 `json:"-"`
CompanyId int64 `json:"-"`
}
... ...
... ... @@ -2,6 +2,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"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"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
... ... @@ -156,3 +157,76 @@ func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[
}
return result, nil
}
// 获取我的
func (service *AuthService) MeInfo(param *command.GetMeInfo) (*adapter.MeInfo, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if errStart := transactionContext.StartTransaction(); errStart != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, errStart.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
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,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工数据"+err.Error())
}
_, parentUser, err := userRepository.Find(map[string]interface{}{
"parentId": userData.Id,
"limit": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工数据"+err.Error())
}
companyData, err := companyRepository.FindOne(map[string]interface{}{
"id": param.CompanyId,
})
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})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取角色信息列表"+err.Error())
}
_, userRoleList, err := roleUserRepo.Find(map[string]interface{}{"companyId": param.CompanyId, "userId": 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
}
}
}
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,
Phone: userData.Account,
Name: userData.Name,
IsHrbp: isHrbp,
IsParent: false,
}
if len(parentUser) > 0 {
info.IsParent = true
}
return &info, nil
}
... ...
package command
type GetUserMessageCommand struct {
UserId int `json:"-"`
}
... ...
package notify
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/command"
)
// 个人信息提示
type MessagePersonalService struct {
}
func NewMessagePersonalService() *MessagePersonalService {
newService := &MessagePersonalService{}
return newService
}
// 获取今天的周期综合自评消息提示
func (srv *MessagePersonalService) TodayMessageSummaryEvaluationSelf(param *command.GetUserMessageCommand) (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()
}()
// nowTime := time.Now()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
... ...
... ... @@ -2,6 +2,7 @@ package notify
import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
// 执行定时任务检查是否发送短信通知
var taskSmsNotify *notifySms
// 检查并发送短信通知
... ... @@ -11,7 +12,6 @@ func RunTaskSmsNotify() {
taskSmsNotify.regist(notifyStaffAssess{})
taskSmsNotify.regist(notifySummaryEvaluation{})
taskSmsNotify.runTask()
}
// 每日自评短信通知 ,预创建待发送的短信消息
... ...
... ... @@ -14,7 +14,7 @@ import (
// 导出数据
// 综合管理-周期评估
func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.QueryEvaluationList) (*excelize.File, error) {
func (srv *SummaryEvaluationService) ExportAllEvaluationFinish(param *command.QueryEvaluationList) (*excelize.File, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -56,7 +56,7 @@ func (srv *SummaryEvaluationService) ExportAllEvaluationSuper(param *command.Que
//获取评估列表信息
condition1 := map[string]interface{}{
"cycleId": param.CycleId,
"types": int(domain.EvaluationSuper),
"types": int(domain.EvaluationFinish),
"limit": limit,
}
if offset > 0 {
... ...
... ... @@ -177,6 +177,12 @@ func sendSummaryEvaluation(project *domain.EvaluationProject,
//确定上级评估
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 {
... ...
... ... @@ -200,11 +200,12 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
}
//查找当前周期,我的考核结果
_, myEvaluationSuper, _ := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationSuper),
_, myEvaluationFinish, _ := evaluationRepo.Find(map[string]interface{}{
"types": int(domain.EvaluationFinish),
"limit": 1,
"targetUserId": param.UserId,
"cycleId": param.CycleId,
"beginTime": time.Now(),
})
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -243,15 +244,13 @@ func (srv *SummaryEvaluationService) GetMenu(param *command.QueryMenu) (map[stri
}
menu1.Child = append(menu1.Child, menu1_1)
}
if len(myEvaluationSuper) > 0 {
if myEvaluationSuper[0].CheckResult == domain.EvaluationCheckCompleted {
if len(myEvaluationFinish) > 0 {
if myEvaluationFinish[0].CheckResult == domain.EvaluationCheckCompleted {
menu1_2.StatusName = "已完成"
} else {
menu1_2.StatusName = "未完成"
}
if myEvaluationSuper[0].Status == domain.EvaluationCompleted {
menu1.Child = append(menu1.Child, menu1_2)
}
menu1.Child = append(menu1.Child, menu1_2)
}
if len(selfEvaluation) > 0 {
... ... @@ -491,7 +490,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
// 编辑综合自评详情
func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, error) {
// xredis.NewLockSummaryEvaluation(param.SummaryEvaluationId)
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
... ... @@ -658,16 +656,13 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(param *domain.
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
// 获取考核结果阶段
finishEvaluation := *param
finishEvaluation.BeginTime = time.Now()
finishEvaluation.CreatedAt = time.Now()
finishEvaluation.UpdatedAt = time.Now()
finishEvaluation.Executor = domain.StaffDesc{}
finishEvaluation.Id = 0
finishEvaluation.Types = domain.EvaluationFinish
err = evaluationRepo.Save(&finishEvaluation)
if len(evaluationList) > 0 {
// 进入考核结果阶段
if evaluationList[0].BeginTime.After(nowTime) {
evaluationList[0].BeginTime = nowTime
}
evaluationList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
... ... @@ -728,7 +723,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
"targetUserId": param.TargetUser.UserId,
"typesList": []int{int(domain.EvaluationSuper)},
"cycleId": param.CycleId,
"limit": 10,
"limit": 1,
})
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -761,17 +756,12 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
finishEvaluation := *param
finishEvaluation.BeginTime = time.Now()
finishEvaluation.CreatedAt = time.Now()
finishEvaluation.UpdatedAt = time.Now()
finishEvaluation.Executor = domain.StaffDesc{}
finishEvaluation.Id = 0
finishEvaluation.Types = domain.EvaluationFinish
finishEvaluation.TotalScore = ""
finishEvaluation.TotalRating = []domain.RatingCodeNumber{}
err = evaluationRepo.Save(&finishEvaluation)
if len(evaluationList) > 0 {
if evaluationList[0].BeginTime.After(nowTime) {
evaluationList[0].BeginTime = nowTime
}
evaluationList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
... ... @@ -783,7 +773,7 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma
return nil
}
// 员工提交上级评估
// 员工提交上级评估
// 生成考核结果
func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error {
lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId)
... ... @@ -819,17 +809,13 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluationList) == 0 {
finishEvaluation := *param
finishEvaluation.BeginTime = time.Now()
finishEvaluation.CreatedAt = time.Now()
finishEvaluation.UpdatedAt = time.Now()
finishEvaluation.Executor = domain.StaffDesc{}
finishEvaluation.Id = 0
finishEvaluation.Types = domain.EvaluationFinish
finishEvaluation.TotalScore = ""
finishEvaluation.TotalRating = []domain.RatingCodeNumber{}
err = evaluationRepo.Save(&finishEvaluation)
nowTime := time.Now()
if len(evaluationList) > 0 {
if evaluationList[0].BeginTime.After(nowTime) {
evaluationList[0].BeginTime = nowTime
}
evaluationList[0].Status = domain.EvaluationCompleted
err = evaluationRepo.Save(evaluationList[0])
if err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
}
... ... @@ -1827,8 +1813,8 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command
return &eiAdapter, nil
}
// 获取周期综合评估下,周期评估列表
func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.QueryEvaluationList) (map[string]interface{}, error) {
// 按周期获取所有员工的评估考核结果
func (srv *SummaryEvaluationService) ListAllEvaluationFinish(param *command.QueryEvaluationList) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1872,7 +1858,7 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query
//获取评估列表信息
condition1 := map[string]interface{}{
"cycleId": param.CycleId,
"types": int(domain.EvaluationSuper),
"types": int(domain.EvaluationFinish),
"limit": limit,
"beginTime": time.Now(),
}
... ... @@ -1973,12 +1959,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
}
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
evaluationValueSlice := []*domain.SummaryEvaluationValue{}
evaluationData.TotalRating = nil //清空评级数量统计
for _, v := range evaluationItems {
newValue := &domain.SummaryEvaluationValue{}
newValue.SetBlankValue(evaluationData, v)
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = v
evaluationValueSlice = append(evaluationValueSlice, newValue)
//重置计数
evaluationData.ResetTotalRating(v)
}
... ... @@ -2036,10 +2024,14 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
}
}
//完全更新itemValueList
*itemValueList = (*itemValueList)[0:0]
for _, v := range evaluationValueMap {
*itemValueList = append(*itemValueList, v)
}
*itemValueList = evaluationValueSlice
// *itemValueList = (*itemValueList)[0:0]
// for _, v := range evaluationValueMap {
// *itemValueList = append(*itemValueList, v)
// }
// sort.Slice(*itemValueList, func(i, j int) bool {
// return (*itemValueList)[i].EvaluationItemId < (*itemValueList)[j].EvaluationItemId
// })
// 计算总得分
err := evaluationData.EvaluationTotalScore(*itemValueList)
if err != nil {
... ...
... ... @@ -803,3 +803,45 @@ func (srv *SummaryEvaluationService) EditEvaluationHRBP(param *command.EditEvalu
"evaluationItems": itemValueAdapter,
}, nil
}
func (srv *SummaryEvaluationService) SummaryEvaluationFinishNotUseSuper(
evaluation domain.SummaryEvaluation,
items []*domain.EvaluationItemUsed,
itemValue []*domain.SummaryEvaluationValue,
) []*domain.SummaryEvaluationValue {
typeSelf := map[int]*domain.SummaryEvaluationValue{}
typeHrbp360 := map[int]*domain.SummaryEvaluationValue{}
for _, v := range itemValue {
switch v.Types {
case domain.EvaluationSelf:
typeSelf[v.EvaluationItemId] = v
case domain.Evaluation360, domain.EvaluationHrbp:
typeHrbp360[v.EvaluationItemId] = v
}
}
newItemValue := []*domain.SummaryEvaluationValue{}
nowTime := time.Now()
for _, v := range items {
var itemValueTemp domain.SummaryEvaluationValue
if v.EvaluatorId == 0 {
if v2, ok := typeSelf[v.Id]; ok {
itemValueTemp = *v2
}
} else {
if v2, ok := typeHrbp360[v.Id]; ok {
itemValueTemp = *v2
}
}
if itemValueTemp.Id == 0 {
//360 hrbp,或者自评 都没有填写过
itemValueTemp.SetBlankValue(&evaluation, v)
}
//清理id信息
itemValueTemp.Id = 0
itemValueTemp.CreatedAt = nowTime
itemValueTemp.UpdatedAt = nowTime
newItemValue = append(newItemValue, &itemValueTemp)
}
return newItemValue
}
... ...
package domain
import "time"
// MessagePersonal 个人的消息提示
type MessagePersonal struct {
Id int //
Types string //消息类型
TargetUserId int //消息指向的用户
ReadFlag MessageReadFlag //1:已读、2:未读
Title string //消息的标题
Content string //消息的内容
CreatedAt time.Time
UpdatedAt time.Time
Payload string //消息的额外承载的数据
}
type MessageTypes string
const (
MessageTypesOther MessageTypes = "other"
)
type MessageReadFlag string
const (
MessageIsRead MessageReadFlag = "read"
MessageUnread MessageReadFlag = "unread"
)
... ...
... ... @@ -37,7 +37,7 @@ func (itemValue *SummaryEvaluationValue) SetBlankValue(evaluation *SummaryEvalua
itemValue.EvaluationItemId = item.Id
itemValue.SummaryEvaluationId = evaluation.Id
itemValue.Value = ""
itemValue.Score = ""
itemValue.Score = "0"
itemValue.Remark = ""
itemValue.Weight = item.Weight
itemValue.CreatedAt = time.Now()
... ...
... ... @@ -120,7 +120,7 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
if v, ok := queryOptions["types"]; ok {
query.Where("types=?", v)
}
query.Order("evaluation_item_id")
count, err := query.SelectAndCount()
if err != nil {
return 0, nil, err
... ...
... ... @@ -20,11 +20,16 @@ func (controller *AuthController) Login() {
controller.Response(resp, err)
}
// 获取个人信息
func (controller *AuthController) User() {
userAuth := controller.Ctx.Input.GetData(domain.UserAuth{}).(*domain.UserAuth)
controller.Response(map[string]interface{}{
"user": userAuth,
}, nil)
authService := &service.AuthService{}
param := &command.GetMeInfo{
UserId: userAuth.UserId,
CompanyId: userAuth.CompanyId,
}
resp, err := authService.MeInfo(param)
controller.Response(resp, err)
}
// Login 手机端登录
... ...
... ... @@ -321,7 +321,7 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
}
// 按周期获取上级评估列表
func (c *SummaryEvaluationController) ListAllEvaluationSuper() {
func (c *SummaryEvaluationController) ListAllEvaluationFinish() {
srv := service.NewSummaryEvaluationService()
param := &command.QueryEvaluationList{}
err := c.BindJSON(param)
... ... @@ -333,12 +333,12 @@ func (c *SummaryEvaluationController) ListAllEvaluationSuper() {
userReq := middlewares.GetUser(c.Ctx)
param.CompanyId = int(userReq.CompanyId)
param.UserId = int(userReq.UserId)
data, err := srv.ListAllEvaluationSuper(param)
data, err := srv.ListAllEvaluationFinish(param)
c.Response(data, err)
}
// 按周期 导出上级评估列表
func (c *SummaryEvaluationController) ExportAllEvaluationSuper() {
func (c *SummaryEvaluationController) ExportAllEvaluationFinish() {
srv := service.NewSummaryEvaluationService()
param := &command.QueryEvaluationList{}
err := c.BindJSON(param)
... ... @@ -350,7 +350,7 @@ func (c *SummaryEvaluationController) ExportAllEvaluationSuper() {
userReq := middlewares.GetUser(c.Ctx)
param.UserId = int(userReq.UserId)
param.CompanyId = int(userReq.CompanyId)
data, err := srv.ExportAllEvaluationSuper(param)
data, err := srv.ExportAllEvaluationFinish(param)
if err != nil {
c.Response(nil, err)
return
... ...
... ... @@ -29,8 +29,10 @@ func init() {
web.NSCtrlPost("/evaluation-super/list", (*controllers.SummaryEvaluationController).ListExecutorEvaluationSuper),
web.NSCtrlPost("/evaluation-super/confirm", (*controllers.SummaryEvaluationController).ConfirmScoreEvaluation),
web.NSCtrlPost("/target_user/evaluation-super", (*controllers.SummaryEvaluationController).GetTargetUserEvaluationSuper),
web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
web.NSCtrlPost("/evaluation-super/all/export", (*controllers.SummaryEvaluationController).ExportAllEvaluationSuper),
// web.NSCtrlPost("/evaluation-super/all", (*controllers.SummaryEvaluationController).ListAllEvaluationSuper),
web.NSCtrlPost("/evaluation-finish/all", (*controllers.SummaryEvaluationController).ListAllEvaluationFinish),
// 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),
//
)
... ...