作者 tangxvhui

Merge branch 'dev-tangxvhui' of http://gitlab.fjmaimaimai.com/allied-creation/pe…

…rformance into dev-tangxvhui
... ... @@ -20,8 +20,9 @@ type AssessInfoResp struct {
CompanyLogo string `json:"companyLogo,string,"` //公司logo
CompanyName string `json:"companyName"` //公司名称
SupperUser string `json:"superUser"` //目标用户的上级
DutyTime string `json:"dutyTime"` //入职时间 //
DutyTime string `json:"dutyTime"` //入职时间
AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
TaskRecords []*domain.TaskRecord `json:"taskRecords"` //里程碑内容
}
// 周期内的每日自评小结
... ...
... ... @@ -9,6 +9,7 @@ import (
type SaveAssessCacheCommand struct {
AssessId int64 `cname:"评估项ID" json:"assessId,string"`
AssessContent []domain.AssessContent `cname:"评估数据" json:"assessContent"`
AssessTaskStages []domain.AssessTaskStage `cname:"里程碑内容" json:"assessTaskStages"`
}
func (in *SaveAssessCacheCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -30,14 +30,16 @@ func (srv StaffAssessCacheService) SaveAssessCache(in *command.SaveAssessCacheCo
}
var cache *domain.StaffAssessCache
if len(caches) == 0 {
cache = &domain.StaffAssessCache{}
cache.Id = 0
cache.AssessId = in.AssessId
cache.AssessContent = in.AssessContent
cache = &domain.StaffAssessCache{
Id: 0,
AssessId: in.AssessId,
}
} else {
cache = caches[0]
cache.AssessContent = in.AssessContent
}
cache.AssessContent = in.AssessContent
cache.AssessTaskStages = in.AssessTaskStages
if _, err = cacheRepository.Save(cache); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -1230,7 +1230,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
}
// 任务负责人才能提交里程碑数据
if project.PrincipalId != strconv.Itoa(in.ExecutorId) {
return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户不能提交里程碑完成情况")
return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户没有里程碑提交权限")
}
recordMap := map[int]domain.AssessTaskStage{}
... ... @@ -1253,11 +1253,19 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
it.AssistLevel = v.AssistLevel // 更新上级辅导情况
it.AssistContent = v.AssistContent // 更新上级辅导内容
if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态
it.TaskStageCheck.Status = v.Status
if v.Check == domain.TaskStageUncompleted {
it.TaskStageCheck.RealCompletedAt = 0
} else {
it.TaskStageCheck.RealCompletedAt = time.Now().Unix()
}
}
for j := range it.TaskStages {
if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态
it.TaskStages[j].Status = v.Status
if v.Check == domain.TaskStageUncompleted {
it.TaskStages[j].RealCompletedAt = 0
} else {
it.TaskStages[j].RealCompletedAt = time.Now().Unix()
}
}
}
_, err := taskRecordRepository.Insert(it)
... ... @@ -1302,11 +1310,14 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran
return userData, nil
}
func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) {
func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) *domain.StaffAssessCache {
cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": context})
_, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessId, "limit": 1})
if err != nil || len(caches) == 0 {
return
if err != nil {
return nil
}
if len(caches) == 0 {
return nil
}
cacheArray := caches[0].AssessContent
cacheLen := len(cacheArray)
... ... @@ -1326,6 +1337,27 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio
}
}
}
return caches[0]
}
func (srv StaffAssessServeice) recoverCacheWithTaskRecord(cache *domain.StaffAssessCache, dataArray []*domain.TaskRecord) {
if cache == nil || len(cache.AssessTaskStages) == 0 || len(dataArray) == 0 {
return
}
cacheArray := cache.AssessTaskStages
cacheMap := map[int]domain.AssessTaskStage{}
for i := range cacheArray {
it := cacheArray[i]
cacheMap[it.TaskRecordId] = it
}
for i := range dataArray {
it := dataArray[i]
if item, ok := cacheMap[it.Id]; ok {
it.AssistLevel = item.AssistLevel
it.AssistContent = item.AssistContent
}
}
}
// 获取目标员工自评周期列表
... ...
... ... @@ -719,9 +719,8 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
defer func() {
_ = transactionContext.RollbackTransaction()
}()
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
// 获取员工的评估
_, assessList, err := assessReps.Find(map[string]interface{}{
"companyId": param.CompanyId,
... ... @@ -739,15 +738,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
}
assessData := assessList[0]
assessContentList := []*domain.StaffAssessContent{}
var 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,
})
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())
}
... ... @@ -759,13 +754,37 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
}
}
// 恢复缓存数据
//获取员工描述
staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
var cache *domain.StaffAssessCache
// 恢复缓存数据(填写内容)
if param.AcquireCache != 0 {
srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
cache = srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
}
// 获取项目信息
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
}
taskRecords := make([]*domain.TaskRecord, 0)
// 任务负责人才能显示里程碑数据
if project.PrincipalId == strconv.Itoa(param.TargetUserId) {
// 获取里程碑数据
taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
_, taskRecords, err = taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
// 恢复缓存数据(里程碑记录)
if param.AcquireCache != 0 {
srv.recoverCacheWithTaskRecord(cache, taskRecords)
}
}
//获取员工描述
staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -788,6 +807,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
SupperUser: "",
DutyTime: "",
AssessContent: assessContentList,
TaskRecords: taskRecords,
}
if staffDesc != nil {
result.CompanyName = staffDesc.CompanyName
... ...
... ... @@ -2,12 +2,19 @@ package domain
import "time"
type TaskStageCheck int
const (
TaskStageUncompleted TaskStageCheck = 0 // 里程碑未完成
TaskStageCompleted TaskStageCheck = 1 // 里程碑完成
)
// StaffAssessCache 填写评估数据(缓存暂未提交)
type StaffAssessCache struct {
Id int64 `json:"id,string" comment:"ID"`
AssessId int64 `json:"assessId,string" comment:"评估项ID"`
AssessContent []AssessContent `json:"assessContent" comment:"评估项提交数据"`
AssessTaskStages []AssessTaskStage `json:"assessTaskStages" comment:"里程碑内容"`
AssessTaskStages []AssessTaskStage `json:"assessTaskStages" comment:"任务里程碑内容"`
CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
... ... @@ -26,11 +33,9 @@ type RemarkText struct {
}
type AssessTaskStage struct {
Category string `json:"category"`
Name string `json:"name"`
TaskRecordId int `json:"taskRecordId" comment:"任务记录ID"`
TaskStageId int `json:"taskStageId" comment:"里程碑ID"`
Status TaskStageState `json:"status" comment:"里程碑完成情况"`
TaskRecordId int `json:"taskRecordId,string" comment:"任务记录ID"`
TaskStageId int `json:"taskStageId,string" comment:"里程碑ID"`
Check TaskStageCheck `json:"check" comment:"里程碑完成情况"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
AssistContent string `json:"assistContent" comment:"上级辅导内容"`
}
... ...
... ... @@ -11,10 +11,11 @@ const (
// TaskRecord 任务反馈情况记录
type TaskRecord struct {
Id int `json:"id,string" comment:"ID"`
Id int `json:"id,string" comment:"记录ID"`
CompanyId int `json:"companyId,string" comment:"公司ID"`
StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"`
TaskId int `json:"taskId,string" comment:"任务ID"`
TaskCategory string `json:"taskCategory" comment:"任务类别"`
TaskName string `json:"taskName" comment:"任务名称"`
TaskAlias string `json:"taskAlias" comment:"任务别名"`
TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
... ...
... ... @@ -2,26 +2,25 @@ package domain
import "time"
type TaskStageState int
const (
TaskStageUncompleted TaskStageState = 1 //里程碑未完成
TaskStageCompleted TaskStageState = 2 //里程碑完成
)
//type TaskStageState int
//
//const (
// TaskStageUncompleted TaskStageState = 1 //里程碑未完成
// TaskStageCompleted TaskStageState = 2 //里程碑完成
//
//)
// 任务阶段
type TaskStage struct {
Id int `json:"id"`
TaskId int `json:"taskId"`
Id int `json:"id,string"`
TaskId int `json:"taskId,string"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
Name string `json:"name"` //里程碑名称
SortBy int `json:"sortBy"` //排序
// Status TaskStageState `json:"status"` //里程碑完成情况
PlanCompletedAt int64 `json:"planCompletedAt"` //计划完成时间戳,秒
RealCompletedAt int64 `json:"realCompletedAt"` //时间完成时间戳,秒
Name string `json:"name"` // 里程碑名称
SortBy int `json:"sortBy"` // 排序
PlanCompletedAt int64 `json:"planCompletedAt"` // 计划完成时间戳,秒
RealCompletedAt int64 `json:"realCompletedAt"` // 实际完成时间戳,秒
}
type TaskStageRepository interface {
Save(param []*TaskStage) error
... ...
... ... @@ -55,6 +55,7 @@ func init() {
&models.Task{},
&models.TaskStage{},
&models.TaskIgnore{},
&models.TaskRecord{},
}
for _, model := range tables {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
... ...
... ... @@ -12,6 +12,7 @@ type TaskRecord struct {
CompanyId int `comment:"公司ID"`
StaffAssessId int `comment:"每日评估的ID"`
TaskId int `comment:"任务ID"`
TaskCategory string `comment:"任务类别"`
TaskName string `comment:"任务名称"`
TaskAlias string `comment:"任务别名"`
TaskLeader domain.TaskLeader `comment:"任务负责人"`
... ...
... ... @@ -25,6 +25,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
CompanyId: m.CompanyId,
StaffAssessId: m.StaffAssessId,
TaskId: m.TaskId,
TaskCategory: m.TaskCategory,
TaskName: m.TaskName,
TaskAlias: m.TaskAlias,
TaskLeader: m.TaskLeader,
... ... @@ -44,6 +45,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.
CompanyId: d.CompanyId,
StaffAssessId: d.StaffAssessId,
TaskId: d.TaskId,
TaskCategory: d.TaskCategory,
TaskName: d.TaskName,
TaskAlias: d.TaskAlias,
TaskLeader: d.TaskLeader,
... ... @@ -140,9 +142,9 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int
query.Where("company_id = ?", v)
}
//if v, ok := queryOptions["state"]; ok && v.(int) >= 0 {
// query.Where("state = ?", v)
//}
if v, ok := queryOptions["staffAssessId"]; ok {
query.Where("staff_assess_id = ?", v)
}
if v, ok := queryOptions["limit"].(int64); ok {
query.Limit(int(v))
... ...
... ... @@ -114,6 +114,23 @@ func (c *StaffAssessController) SaveAssessInfo() {
c.Response(data, err)
}
// SaveSelfAssess 提交自评反馈-当前登录用户
func (c *StaffAssessController) SaveSelfAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &command.SaveSelfAssessCommand{}
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.ExecutorId = int(userReq.UserId)
paramReq.CompanyId = int(userReq.CompanyId)
data, err := srv.SaveSelfAssess(paramReq)
c.Response(data, err)
}
// 获取周期列表
func (c *StaffAssessController) ListAssessCycle() {
srv := service.NewStaffAssessServeice()
... ...
... ... @@ -100,7 +100,7 @@ func (c *StaffAssessControllerV2) GetAssessMeInviteUser() {
c.Response(data, err)
}
// 获取当前登录员工自评详情
// GetAssessSelfMeInfo 获取自评详情-目标是登录员工
func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.GetExecutorSelfAssessQuery{}
... ... @@ -117,25 +117,24 @@ func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() {
c.Response(data, err)
}
// 被评估的员工的评估列表-360评估
func (c *StaffAssessControllerV2) ListTargetUserInviteAssess() {
// GetAssessTargetUserSelfInfo 获取自评详情-目标是员工
func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetAssessQuery{}
paramReq := &query.GetExecutorSelfAssessQuery{}
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.ListTargetUserInviteAssess(paramReq)
data, err := srv.GetAssessSelfInfoV2(paramReq)
c.Response(data, err)
}
// 被评估的员工的评估列表-当前登录用户-上级评估
func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() {
// 被评估的员工的评估列表-360评估
func (c *StaffAssessControllerV2) ListTargetUserInviteAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetAssessQuery{}
err := c.BindJSON(paramReq)
... ... @@ -144,16 +143,15 @@ func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() {
c.Response(nil, e)
return
}
paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.ListTargetUserSuperAssess(paramReq)
data, err := srv.ListTargetUserInviteAssess(paramReq)
c.Response(data, err)
}
// 被评估的员工的评估列表-上级评估
func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() {
// 被评估的员工的评估列表-当前登录用户-上级评估
func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.ListTargetAssessQuery{}
err := c.BindJSON(paramReq)
... ... @@ -165,23 +163,25 @@ func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() {
paramReq.CompanyId = 1
userReq := middlewares.GetUser(c.Ctx)
paramReq.CompanyId = int(userReq.CompanyId)
paramReq.TargetUserId = int(userReq.UserId)
data, err := srv.ListTargetUserSuperAssess(paramReq)
c.Response(data, err)
}
// 获取员工自评详情
func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
// 被评估的员工的评估列表-上级评估
func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() {
srv := service.NewStaffAssessServeice()
paramReq := &query.GetExecutorSelfAssessQuery{}
paramReq := &query.ListTargetAssessQuery{}
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)
data, err := srv.ListTargetUserSuperAssess(paramReq)
c.Response(data, err)
}
... ...
... ... @@ -29,6 +29,7 @@ func init() {
web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
web.NSCtrlPut("/info-self", (*controllers.StaffAssessController).SaveSelfAssess), //提交自评反馈-当前登录用户
web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存)
web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览
web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表
... ...
... ... @@ -6,3 +6,7 @@ COMMENT ON COLUMN public.evaluation_item_used.indicator_type IS '指标类型';
-- 增加项目表-任务负责人ID
ALTER TABLE public.evaluation_project ADD principal_id text NULL;
COMMENT ON COLUMN public.evaluation_project.principal_id IS '任务负责人ID';
-- 增加评估Cache数据缓存表-任务里程碑JSON
ALTER TABLE public.staff_assess_cache ADD assess_task_stages jsonb NULL;
COMMENT ON COLUMN public.staff_assess_cache.assess_task_stages IS '任务里程碑内容';
\ No newline at end of file
... ...