作者 tangxvhui

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

…rformance into dev-tangxvhui
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "time" 7 "time"
8 8
9 service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role" 9 service "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
  10 + taskService "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/task/service"
10 11
11 "github.com/linmadan/egglib-go/core/application" 12 "github.com/linmadan/egglib-go/core/application"
12 "github.com/linmadan/egglib-go/utils/tool_funs" 13 "github.com/linmadan/egglib-go/utils/tool_funs"
@@ -1146,16 +1147,13 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1146,16 +1147,13 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1146 } 1147 }
1147 assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext}) 1148 assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext})
1148 1149
1149 - //待更新的评估填写信息  
1150 var assessContentList []*domain.StaffAssessContent 1150 var assessContentList []*domain.StaffAssessContent
1151 - // 已完成 1151 + // 已完成会有评估内容数据
1152 _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id}) 1152 _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id})
1153 if err != nil { 1153 if err != nil {
1154 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1154 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
1155 } 1155 }
1156 -  
1157 - if len(assessContentList) == 0 {  
1158 - // 未完成获取评估内容 1156 + if len(assessContentList) == 0 { // 未完成获取评估内容
1159 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData) 1157 assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
1160 if err != nil { 1158 if err != nil {
1161 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 1159 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
@@ -1168,7 +1166,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1168,7 +1166,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1168 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1166 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1169 paramContentMap[key] = in.AssessContent[i] 1167 paramContentMap[key] = in.AssessContent[i]
1170 } 1168 }
1171 - //更新的评估填写信息 1169 + // 更新的评估填写信息
1172 for _, v := range assessContentList { 1170 for _, v := range assessContentList {
1173 key := fmt.Sprintf("%s-%s", v.Category, v.Name) 1171 key := fmt.Sprintf("%s-%s", v.Category, v.Name)
1174 item, ok := paramContentMap[key] 1172 item, ok := paramContentMap[key]
@@ -1184,8 +1182,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1184,8 +1182,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1184 1182
1185 v.Value = item.Value 1183 v.Value = item.Value
1186 if len(item.Value) > 0 { 1184 if len(item.Value) > 0 {
1187 - // 转换填入的评估值  
1188 - err = v.TransformValue() 1185 + err = v.TransformValue() // 转换评分评级填入的评估值
1189 if err != nil { 1186 if err != nil {
1190 return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error()) 1187 return nil, application.ThrowError(application.BUSINESS_ERROR, v.Category+"-"+v.Name+":"+err.Error())
1191 } 1188 }
@@ -1226,19 +1223,60 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1226,19 +1223,60 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1226 } 1223 }
1227 } 1224 }
1228 1225
  1226 + // 更新里程碑数据
1229 if len(in.AssessTaskStages) > 0 { 1227 if len(in.AssessTaskStages) > 0 {
1230 - tsIds := make([]int, 0) 1228 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  1229 + project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
  1230 + if err != nil {
  1231 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
  1232 + }
  1233 + // 任务负责人才能提交里程碑数据
  1234 + if project.PrincipalId != strconv.Itoa(in.ExecutorId) {
  1235 + return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户不能提交里程碑完成情况")
  1236 + }
  1237 +
  1238 + recordMap := map[int]domain.AssessTaskStage{}
  1239 + recordIds := make([]int, 0)
1231 for i := range in.AssessTaskStages { 1240 for i := range in.AssessTaskStages {
1232 - tsId := in.AssessTaskStages[i].TaskStageId  
1233 - if tsId > 0 {  
1234 - tsIds = append(tsIds, tsId)  
1235 - } 1241 + it := in.AssessTaskStages[i]
  1242 + recordIds = append(recordIds, it.TaskRecordId)
  1243 + recordMap[it.TaskRecordId] = it
1236 } 1244 }
  1245 + // 里程碑记录
  1246 + if len(recordIds) > 0 {
  1247 + taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
  1248 + _, taskRecords, err := taskRecordRepository.Find(map[string]interface{}{"ids": recordIds})
  1249 + if err != nil {
  1250 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
  1251 + }
  1252 + for i := range taskRecords {
  1253 + it := taskRecords[i]
  1254 + if v, ok := recordMap[it.Id]; ok {
  1255 + it.AssistLevel = v.AssistLevel // 更新上级辅导情况
  1256 + it.AssistContent = v.AssistContent // 更新上级辅导内容
  1257 + if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态
  1258 + it.TaskStageCheck.Status = v.Status
  1259 + }
  1260 + for j := range it.TaskStages {
  1261 + if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态
  1262 + it.TaskStages[j].Status = v.Status
  1263 + }
  1264 + }
  1265 + _, err := taskRecordRepository.Insert(it)
  1266 + if err != nil {
  1267 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑记录:"+err.Error())
  1268 + }
  1269 + }
  1270 + }
1237 1271
  1272 + if len(taskRecords) > 0 {
  1273 + err := taskService.NewTaskService().ReplyTaskStage(transactionContext, taskRecords)
  1274 + if err != nil {
  1275 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "更新里程碑数据:"+err.Error())
  1276 + }
  1277 + }
  1278 + }
1238 } 1279 }
1239 - // 里程碑记录  
1240 - //taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})  
1241 - //taskRecordRepository.Find()  
1242 1280
1243 if err := transactionContext.CommitTransaction(); err != nil { 1281 if err := transactionContext.CommitTransaction(); err != nil {
1244 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1282 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -554,12 +554,12 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte @@ -554,12 +554,12 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte
554 return result, nil 554 return result, nil
555 } 555 }
556 556
557 -func (t TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.TaskStage) (bool, error) { 557 +func (srv TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.TaskStage) (bool, error) {
558 return true, nil 558 return true, nil
559 } 559 }
560 560
561 // CancelAttention 用户取消关注某个任务 561 // CancelAttention 用户取消关注某个任务
562 -func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) error { 562 +func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) error {
563 transactionContext, err := factory.CreateTransactionContext(nil) 563 transactionContext, err := factory.CreateTransactionContext(nil)
564 if err != nil { 564 if err != nil {
565 return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 565 return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -590,7 +590,7 @@ func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) erro @@ -590,7 +590,7 @@ func (t TaskService) CancelAttention(param *command.CancelAttentionCommand) erro
590 } 590 }
591 591
592 // 员工绩效-任务管理-列表 592 // 员工绩效-任务管理-列表
593 -func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]interface{}, error) { 593 +func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]interface{}, error) {
594 transactionContext, err := factory.CreateTransactionContext(nil) 594 transactionContext, err := factory.CreateTransactionContext(nil)
595 if err != nil { 595 if err != nil {
596 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 596 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -606,7 +606,7 @@ func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]int @@ -606,7 +606,7 @@ func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]int
606 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error()) 606 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
607 } 607 }
608 if hrbpFlag == domain.RoleTypeSystem { 608 if hrbpFlag == domain.RoleTypeSystem {
609 - listData, err := t.listTask2ForHrbp(param) 609 + listData, err := srv.listTask2ForHrbp(param)
610 return listData, err 610 return listData, err
611 } 611 }
612 var limit = 20 612 var limit = 20
@@ -693,7 +693,7 @@ func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]int @@ -693,7 +693,7 @@ func (t TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]int
693 } 693 }
694 694
695 // 以hrbp角色权限获取任务列表 695 // 以hrbp角色权限获取任务列表
696 -func (t TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) { 696 +func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {
697 var limit = 20 697 var limit = 20
698 var offset = 0 698 var offset = 0
699 if param.PageSize > 0 { 699 if param.PageSize > 0 {
@@ -787,7 +787,7 @@ func (t TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[str @@ -787,7 +787,7 @@ func (t TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[str
787 } 787 }
788 788
789 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑 789 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
790 -func (t TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord) error { 790 +func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord) error {
791 taskRepo := factory.CreateTaskRepository(map[string]interface{}{ 791 taskRepo := factory.CreateTaskRepository(map[string]interface{}{
792 "transactionContext": transactionContext, 792 "transactionContext": transactionContext,
793 }) 793 })
@@ -28,6 +28,7 @@ type RemarkText struct { @@ -28,6 +28,7 @@ type RemarkText struct {
28 type AssessTaskStage struct { 28 type AssessTaskStage struct {
29 Category string `json:"category"` 29 Category string `json:"category"`
30 Name string `json:"name"` 30 Name string `json:"name"`
  31 + TaskRecordId int `json:"taskRecordId" comment:"任务记录ID"`
31 TaskStageId int `json:"taskStageId" comment:"里程碑ID"` 32 TaskStageId int `json:"taskStageId" comment:"里程碑ID"`
32 Status TaskStageState `json:"status" comment:"里程碑完成情况"` 33 Status TaskStageState `json:"status" comment:"里程碑完成情况"`
33 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` 34 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
@@ -14,7 +14,7 @@ type TaskRecord struct { @@ -14,7 +14,7 @@ type TaskRecord struct {
14 Id int `json:"id,string" comment:"ID"` 14 Id int `json:"id,string" comment:"ID"`
15 CompanyId int `json:"companyId,string" comment:"公司ID"` 15 CompanyId int `json:"companyId,string" comment:"公司ID"`
16 StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"` 16 StaffAssessId int `json:"staffAssessId,string" comment:"每日评估的ID"`
17 - TaskId int `json:"taskId,string" comment:"里程碑任务的ID"` 17 + TaskId int `json:"taskId,string" comment:"任务ID"`
18 TaskName string `json:"taskName" comment:"任务名称"` 18 TaskName string `json:"taskName" comment:"任务名称"`
19 TaskAlias string `json:"taskAlias" comment:"任务别名"` 19 TaskAlias string `json:"taskAlias" comment:"任务别名"`
20 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"` 20 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
@@ -11,7 +11,7 @@ type TaskRecord struct { @@ -11,7 +11,7 @@ type TaskRecord struct {
11 Id int `comment:"ID" pg:"pk:id"` 11 Id int `comment:"ID" pg:"pk:id"`
12 CompanyId int `comment:"公司ID"` 12 CompanyId int `comment:"公司ID"`
13 StaffAssessId int `comment:"每日评估的ID"` 13 StaffAssessId int `comment:"每日评估的ID"`
14 - TaskId int `comment:"里程碑任务的ID"` 14 + TaskId int `comment:"任务ID"`
15 TaskName string `comment:"任务名称"` 15 TaskName string `comment:"任务名称"`
16 TaskAlias string `comment:"任务别名"` 16 TaskAlias string `comment:"任务别名"`
17 TaskLeader domain.TaskLeader `comment:"任务负责人"` 17 TaskLeader domain.TaskLeader `comment:"任务负责人"`
@@ -37,7 +37,8 @@ select @@ -37,7 +37,8 @@ select
37 public."role" 37 public."role"
38 where 38 where
39 "role".company_id = 416 39 "role".company_id = 416
40 - and "role"."type" = 2); 40 + and "role"."type" = 2
  41 + and "role".deleted_at isnull);
41 42
42 -- 超级管理员添加关联用户(不存在时插入新数据)(注.公司ID->416 用户ID->3337322891762688) 43 -- 超级管理员添加关联用户(不存在时插入新数据)(注.公司ID->416 用户ID->3337322891762688)
43 with temp_role as ( 44 with temp_role as (
@@ -75,5 +76,6 @@ where @@ -75,5 +76,6 @@ where
75 where 76 where
76 "role_user".company_id = 416 77 "role_user".company_id = 416
77 and "role_user".user_id = 3337322891762688 78 and "role_user".user_id = 3337322891762688
78 - and "role_user".role_id = temp_role."id"); 79 + and "role_user".role_id = temp_role."id"
  80 + and "role_user".deleted_at isnull);
79 -- 81 --