作者 tangxvhui

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

…rformance into dev-tangxvhui
... ... @@ -7,6 +7,7 @@ import (
"time"
service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
taskService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/service"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
... ... @@ -1146,16 +1147,13 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
}
assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext})
//待更新的评估填写信息
var assessContentList []*domain.StaffAssessContent
// 已完成
// 已完成会有评估内容数据
_, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
}
if len(assessContentList) == 0 {
// 未完成获取评估内容
if len(assessContentList) == 0 { // 未完成获取评估内容
assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
... ... @@ -1168,7 +1166,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
paramContentMap[key] = in.AssessContent[i]
}
//更新的评估填写信息
// 更新的评估填写信息
for _, v := range assessContentList {
key := fmt.Sprintf("%s-%s", v.Category, v.Name)
item, ok := paramContentMap[key]
... ... @@ -1184,8 +1182,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
v.Value = item.Value
if len(item.Value) > 0 {
// 转换填入的评估值
err = v.TransformValue()
err = v.TransformValue() // 转换评分评级填入的评估值
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error())
}
... ... @@ -1226,19 +1223,60 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
}
}
// 更新里程碑数据
if len(in.AssessTaskStages) > 0 {
tsIds := make([]int, 0)
for i := range in.AssessTaskStages {
tsId := in.AssessTaskStages[i].TaskStageId
if tsId > 0 {
tsIds = append(tsIds, tsId)
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())
}
// 任务负责人才能提交里程碑数据
if project.PrincipalId != strconv.Itoa(in.ExecutorId) {
return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户不能提交里程碑完成情况")
}
recordMap := map[int]domain.AssessTaskStage{}
recordIds := make([]int, 0)
for i := range in.AssessTaskStages {
it := in.AssessTaskStages[i]
recordIds = append(recordIds, it.TaskRecordId)
recordMap[it.TaskRecordId] = it
}
// 里程碑记录
//taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
//taskRecordRepository.Find()
if len(recordIds) > 0 {
taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
_, taskRecords, err := taskRecordRepository.Find(map[string]interface{}{"ids": recordIds})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
}
for i := range taskRecords {
it := taskRecords[i]
if v, ok := recordMap[it.Id]; ok {
it.AssistLevel = v.AssistLevel // 更新上级辅导情况
it.AssistContent = v.AssistContent // 更新上级辅导内容
if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态
it.TaskStageCheck.Status = v.Status
}
for j := range it.TaskStages {
if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态
it.TaskStages[j].Status = v.Status
}
}
_, err := taskRecordRepository.Insert(it)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑记录:"+err.Error())
}
}
}
if len(taskRecords) > 0 {
err := taskService.NewTaskService().ReplyTaskStage(transactionContext, taskRecords)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑数据:"+err.Error())
}
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -554,12 +554,12 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte
return result, nil
}
func (t TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.TaskStage) (bool, error) {
func (srv TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.TaskStage) (bool, error) {
return true, nil
}
// CancelAttention 用户取消关注某个任务
func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) error {
func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -590,7 +590,7 @@ func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) erro
}
// 员工绩效-任务管理-列表
func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]interface{}, error) {
func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -606,7 +606,7 @@ func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]int
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
if hrbpFlag == domain.RoleTypeSystem {
listData, err := t.listTask2ForHrbp(param)
listData, err := srv.listTask2ForHrbp(param)
return listData, err
}
var limit = 20
... ... @@ -693,7 +693,7 @@ func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]int
}
// 以hrbp角色权限获取任务列表
func (t TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
var limit = 20
var offset = 0
if param.PageSize > 0 {
... ... @@ -787,7 +787,7 @@ func (t TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[str
}
// ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
func (t TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord) error {
func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord) error {
taskRepo := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
... ...
... ... @@ -28,6 +28,7 @@ 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:"里程碑完成情况"`
AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
... ...
... ... @@ -14,7 +14,7 @@ type TaskRecord struct {
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"`
TaskId int `json:"taskId,string" comment:"任务ID"`
TaskName string `json:"taskName" comment:"任务名称"`
TaskAlias string `json:"taskAlias" comment:"任务别名"`
TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
... ...
... ... @@ -11,7 +11,7 @@ type TaskRecord struct {
Id int `comment:"ID" pg:"pk:id"`
CompanyId int `comment:"公司ID"`
StaffAssessId int `comment:"每日评估的ID"`
TaskId int `comment:"里程碑任务的ID"`
TaskId int `comment:"任务ID"`
TaskName string `comment:"任务名称"`
TaskAlias string `comment:"任务别名"`
TaskLeader domain.TaskLeader `comment:"任务负责人"`
... ...
... ... @@ -37,7 +37,8 @@ select
public."role"
where
"role".company_id = 416
and "role"."type" = 2);
and "role"."type" = 2
and "role".deleted_at isnull);
-- 超级管理员添加关联用户(不存在时插入新数据)(注.公司ID->416 用户ID->3337322891762688)
with temp_role as (
... ... @@ -75,5 +76,6 @@ where
where
"role_user".company_id = 416
and "role_user".user_id = 3337322891762688
and "role_user".role_id = temp_role."id");
and "role_user".role_id = temp_role."id"
and "role_user".deleted_at isnull);
--
\ No newline at end of file
... ...