作者 tangxvhui

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

…rformance into dev-tangxvhui
1 -package adapter  
2 -  
3 -import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"  
4 -  
5 -//评估内容详情  
6 -type AssessInfoResp struct {  
7 - AssessId int `json:"assessId"`  
8 - CycleId int64 `json:"cycleId,string"` //周期id  
9 - CycleName string `json:"cycleName"` //周期名称  
10 - EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id  
11 - EvaluationProjectName string `json:"evaluationProjectName"` //项目名称  
12 - LinkNodeId int `json:"linkNodeId,string"` //评估环节id  
13 - LinkNodeName string `json:"linkNodeName"` //评估环节名称  
14 - BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05  
15 - EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05  
16 - Status string `json:"status"` //完成状态  
17 - TargetUserId int `json:"targetUserId,string"` //目标用户  
18 - TargetUserName string `json:"targetUserName"` //目标用户名称  
19 - CompanyId int `json:"companyId,string,"` //公司id  
20 - CompanyLogo string `json:"companyLogo,string,"` //公司logo  
21 - CompanyName string `json:"companyName"` //公司名称  
22 - SupperUser string `json:"superUser"` //目标用户的上级  
23 - DutyTime string `json:"dutyTime"` //入职时间 //  
24 - AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容  
25 -}  
26 -  
27 -// 周期内的每日自评小结  
28 -type AssessCountLevelResp struct {  
29 - CycleId int64 `json:"cycleId,string"` //周期id  
30 - CycleName string `json:"cycleName"` //周期名称  
31 - EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id  
32 - EvaluationProjectName string `json:"evaluationProjectName"` //项目名称  
33 - TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的  
34 - TargetUserName string `json:"targetUserName"` //  
35 - CompanyLogo string `json:"companyLogo,"` //公司logo  
36 - CompanyName string `json:"companyName"` //公司名称  
37 - SupperUser string `json:"superUser"` //目标用户的上级  
38 - DutyTime string `json:"dutyTime"` //入职时间  
39 - EvaluationItems []AssessCountLeveltItem `json:"evaluationItems"` //评估项  
40 -}  
41 -  
42 -// 周期内的每日自评小结 评估项  
43 -type AssessCountLeveltItem struct {  
44 - EvaluationItemId int `json:"evaluationItemId,string"` //评估条目的id  
45 - SortBy int `json:"sortBy"` //排序  
46 - Category string `json:"category"` //类别  
47 - Name string `json:"name"` //名称  
48 - PromptTitle string `json:"promptTitle"` //提示项标题  
49 - PromptText string `json:"promptText"` //提示项正文  
50 - EntryItems []*domain.EntryItem `json:"entryItems"` //填写的反馈  
51 - RuleType int `json:"ruleType"` //评估方式(0评级、1评分)  
52 - Rule domain.EvaluationRule `json:"rule"` //评估的选项规则  
53 - Weight float64 `json:"weight"` //"权重"  
54 - Remark string `json:"remark"` //填写的内容反馈  
55 - EvaluatorId int `json:"evaluatorId"` //评估人id  
56 - LevelCount []LevalCodeCount `json:"levelCount"` //周期内每次评估的等级数量统计  
57 -}  
58 -  
59 -// 周期内的每日自评小结 评估项 评级数量  
60 -type LevalCodeCount struct {  
61 - Code string `json:"code"` //评级代码  
62 - Number int `json:"number"` //数量  
63 -} 1 +package adapter
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  4 +
  5 +//评估内容详情
  6 +type AssessInfoResp struct {
  7 + AssessId int `json:"assessId"`
  8 + CycleId int64 `json:"cycleId,string"` //周期id
  9 + CycleName string `json:"cycleName"` //周期名称
  10 + EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
  11 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  12 + LinkNodeId int `json:"linkNodeId,string"` //评估环节id
  13 + LinkNodeName string `json:"linkNodeName"` //评估环节名称
  14 + BeginTime string `json:"beginTime"` //开始时间 2006-01-02 15:04:05
  15 + EndTime string `json:"endTime"` //结束时间 2006-01-02 15:04:05
  16 + Status string `json:"status"` //完成状态
  17 + TargetUserId int `json:"targetUserId,string"` //目标用户
  18 + TargetUserName string `json:"targetUserName"` //目标用户名称
  19 + CompanyId int `json:"companyId,string,"` //公司id
  20 + CompanyLogo string `json:"companyLogo,string,"` //公司logo
  21 + CompanyName string `json:"companyName"` //公司名称
  22 + SupperUser string `json:"superUser"` //目标用户的上级
  23 + DutyTime string `json:"dutyTime"` //入职时间
  24 + AssessContent []*domain.StaffAssessContent `json:"assessContent"` //评估内容
  25 + TaskRecords []*domain.TaskRecord `json:"taskRecords"` //里程碑内容
  26 +}
  27 +
  28 +// 周期内的每日自评小结
  29 +type AssessCountLevelResp struct {
  30 + CycleId int64 `json:"cycleId,string"` //周期id
  31 + CycleName string `json:"cycleName"` //周期名称
  32 + EvaluationProjectId int `json:"evaluationProjectId,string"` //项目id
  33 + EvaluationProjectName string `json:"evaluationProjectName"` //项目名称
  34 + TargetUserId int `json:"targetUserId,string"` //被评估的目标用户,被执行的
  35 + TargetUserName string `json:"targetUserName"` //
  36 + CompanyLogo string `json:"companyLogo,"` //公司logo
  37 + CompanyName string `json:"companyName"` //公司名称
  38 + SupperUser string `json:"superUser"` //目标用户的上级
  39 + DutyTime string `json:"dutyTime"` //入职时间
  40 + EvaluationItems []AssessCountLeveltItem `json:"evaluationItems"` //评估项
  41 +}
  42 +
  43 +// 周期内的每日自评小结 评估项
  44 +type AssessCountLeveltItem struct {
  45 + EvaluationItemId int `json:"evaluationItemId,string"` //评估条目的id
  46 + SortBy int `json:"sortBy"` //排序
  47 + Category string `json:"category"` //类别
  48 + Name string `json:"name"` //名称
  49 + PromptTitle string `json:"promptTitle"` //提示项标题
  50 + PromptText string `json:"promptText"` //提示项正文
  51 + EntryItems []*domain.EntryItem `json:"entryItems"` //填写的反馈
  52 + RuleType int `json:"ruleType"` //评估方式(0评级、1评分)
  53 + Rule domain.EvaluationRule `json:"rule"` //评估的选项规则
  54 + Weight float64 `json:"weight"` //"权重"
  55 + Remark string `json:"remark"` //填写的内容反馈
  56 + EvaluatorId int `json:"evaluatorId"` //评估人id
  57 + LevelCount []LevalCodeCount `json:"levelCount"` //周期内每次评估的等级数量统计
  58 +}
  59 +
  60 +// 周期内的每日自评小结 评估项 评级数量
  61 +type LevalCodeCount struct {
  62 + Code string `json:"code"` //评级代码
  63 + Number int `json:"number"` //数量
  64 +}
@@ -7,8 +7,9 @@ import ( @@ -7,8 +7,9 @@ import (
7 7
8 // SaveAssessCacheCommand 保存待提交的评估数据(缓存) 8 // SaveAssessCacheCommand 保存待提交的评估数据(缓存)
9 type SaveAssessCacheCommand struct { 9 type SaveAssessCacheCommand struct {
10 - AssessId int64 `cname:"评估项ID" json:"assessId,string"`  
11 - AssessContent []domain.AssessContent `cname:"评估数据" json:"assessContent"` 10 + AssessId int64 `cname:"评估项ID" json:"assessId,string"`
  11 + AssessContent []domain.AssessContent `cname:"评估数据" json:"assessContent"`
  12 + AssessTaskStages []domain.AssessTaskStage `cname:"里程碑内容" json:"assessTaskStages"`
12 } 13 }
13 14
14 func (in *SaveAssessCacheCommand) Valid(validation *validation.Validation) { 15 func (in *SaveAssessCacheCommand) Valid(validation *validation.Validation) {
@@ -30,14 +30,16 @@ func (srv StaffAssessCacheService) SaveAssessCache(in *command.SaveAssessCacheCo @@ -30,14 +30,16 @@ func (srv StaffAssessCacheService) SaveAssessCache(in *command.SaveAssessCacheCo
30 } 30 }
31 var cache *domain.StaffAssessCache 31 var cache *domain.StaffAssessCache
32 if len(caches) == 0 { 32 if len(caches) == 0 {
33 - cache = &domain.StaffAssessCache{}  
34 - cache.Id = 0  
35 - cache.AssessId = in.AssessId  
36 - cache.AssessContent = in.AssessContent 33 + cache = &domain.StaffAssessCache{
  34 + Id: 0,
  35 + AssessId: in.AssessId,
  36 + }
37 } else { 37 } else {
38 cache = caches[0] 38 cache = caches[0]
39 - cache.AssessContent = in.AssessContent  
40 } 39 }
  40 + cache.AssessContent = in.AssessContent
  41 + cache.AssessTaskStages = in.AssessTaskStages
  42 +
41 if _, err = cacheRepository.Save(cache); err != nil { 43 if _, err = cacheRepository.Save(cache); err != nil {
42 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 44 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
43 } 45 }
@@ -1230,7 +1230,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1230,7 +1230,7 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1230 } 1230 }
1231 // 任务负责人才能提交里程碑数据 1231 // 任务负责人才能提交里程碑数据
1232 if project.PrincipalId != strconv.Itoa(in.ExecutorId) { 1232 if project.PrincipalId != strconv.Itoa(in.ExecutorId) {
1233 - return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户不能提交里程碑完成情况") 1233 + return nil, application.ThrowError(application.BUSINESS_ERROR, "当前用户没有里程碑提交权限")
1234 } 1234 }
1235 1235
1236 recordMap := map[int]domain.AssessTaskStage{} 1236 recordMap := map[int]domain.AssessTaskStage{}
@@ -1253,11 +1253,19 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand) @@ -1253,11 +1253,19 @@ func (srv StaffAssessServeice) SaveSelfAssess(in *command.SaveSelfAssessCommand)
1253 it.AssistLevel = v.AssistLevel // 更新上级辅导情况 1253 it.AssistLevel = v.AssistLevel // 更新上级辅导情况
1254 it.AssistContent = v.AssistContent // 更新上级辅导内容 1254 it.AssistContent = v.AssistContent // 更新上级辅导内容
1255 if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态 1255 if v.TaskStageId == it.TaskStageCheck.Id { // 更新里程碑状态
1256 - it.TaskStageCheck.Status = v.Status 1256 + if v.Check == domain.TaskStageUncompleted {
  1257 + it.TaskStageCheck.RealCompletedAt = 0
  1258 + } else {
  1259 + it.TaskStageCheck.RealCompletedAt = time.Now().Unix()
  1260 + }
1257 } 1261 }
1258 for j := range it.TaskStages { 1262 for j := range it.TaskStages {
1259 if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态 1263 if v.TaskStageId == it.TaskStages[j].Id { // 更新里程碑状态
1260 - it.TaskStages[j].Status = v.Status 1264 + if v.Check == domain.TaskStageUncompleted {
  1265 + it.TaskStages[j].RealCompletedAt = 0
  1266 + } else {
  1267 + it.TaskStages[j].RealCompletedAt = time.Now().Unix()
  1268 + }
1261 } 1269 }
1262 } 1270 }
1263 _, err := taskRecordRepository.Insert(it) 1271 _, err := taskRecordRepository.Insert(it)
@@ -1302,11 +1310,14 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran @@ -1302,11 +1310,14 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran
1302 return userData, nil 1310 return userData, nil
1303 } 1311 }
1304 1312
1305 -func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) { 1313 +func (srv StaffAssessServeice) recoverAssessCache(context application.TransactionContext, assessId int, dataArray []*domain.StaffAssessContent) *domain.StaffAssessCache {
1306 cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": context}) 1314 cacheRepository := factory.CreateStaffAssessCacheRepository(map[string]interface{}{"transactionContext": context})
1307 _, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessId, "limit": 1}) 1315 _, caches, err := cacheRepository.Find(map[string]interface{}{"assessId": assessId, "limit": 1})
1308 - if err != nil || len(caches) == 0 {  
1309 - return 1316 + if err != nil {
  1317 + return nil
  1318 + }
  1319 + if len(caches) == 0 {
  1320 + return nil
1310 } 1321 }
1311 cacheArray := caches[0].AssessContent 1322 cacheArray := caches[0].AssessContent
1312 cacheLen := len(cacheArray) 1323 cacheLen := len(cacheArray)
@@ -1326,6 +1337,27 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio @@ -1326,6 +1337,27 @@ func (srv StaffAssessServeice) recoverAssessCache(context application.Transactio
1326 } 1337 }
1327 } 1338 }
1328 } 1339 }
  1340 + return caches[0]
  1341 +}
  1342 +
  1343 +func (srv StaffAssessServeice) recoverCacheWithTaskRecord(cache *domain.StaffAssessCache, dataArray []*domain.TaskRecord) {
  1344 + if cache == nil || len(cache.AssessTaskStages) == 0 || len(dataArray) == 0 {
  1345 + return
  1346 + }
  1347 + cacheArray := cache.AssessTaskStages
  1348 + cacheMap := map[int]domain.AssessTaskStage{}
  1349 + for i := range cacheArray {
  1350 + it := cacheArray[i]
  1351 + cacheMap[it.TaskRecordId] = it
  1352 + }
  1353 +
  1354 + for i := range dataArray {
  1355 + it := dataArray[i]
  1356 + if item, ok := cacheMap[it.Id]; ok {
  1357 + it.AssistLevel = item.AssistLevel
  1358 + it.AssistContent = item.AssistContent
  1359 + }
  1360 + }
1329 } 1361 }
1330 1362
1331 // 获取目标员工自评周期列表 1363 // 获取目标员工自评周期列表
@@ -719,9 +719,8 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA @@ -719,9 +719,8 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
719 defer func() { 719 defer func() {
720 _ = transactionContext.RollbackTransaction() 720 _ = transactionContext.RollbackTransaction()
721 }() 721 }()
722 - assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{  
723 - "transactionContext": transactionContext,  
724 - }) 722 +
  723 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{"transactionContext": transactionContext})
725 // 获取员工的评估 724 // 获取员工的评估
726 _, assessList, err := assessReps.Find(map[string]interface{}{ 725 _, assessList, err := assessReps.Find(map[string]interface{}{
727 "companyId": param.CompanyId, 726 "companyId": param.CompanyId,
@@ -739,15 +738,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA @@ -739,15 +738,11 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
739 } 738 }
740 assessData := assessList[0] 739 assessData := assessList[0]
741 740
742 - assessContentList := []*domain.StaffAssessContent{} 741 + var assessContentList []*domain.StaffAssessContent
743 if assessData.Status == domain.StaffAssessCompleted { 742 if assessData.Status == domain.StaffAssessCompleted {
744 //已完成 743 //已完成
745 - assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{  
746 - "transactionContext": transactionContext,  
747 - })  
748 - _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{  
749 - "staffAssessId": assessData.Id,  
750 - }) 744 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{"transactionContext": transactionContext})
  745 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{"staffAssessId": assessData.Id})
751 if err != nil { 746 if err != nil {
752 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error()) 747 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
753 } 748 }
@@ -759,13 +754,37 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA @@ -759,13 +754,37 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
759 } 754 }
760 } 755 }
761 756
762 - // 恢复缓存数据 757 + //获取员工描述
  758 + staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))
  759 +
  760 + var cache *domain.StaffAssessCache
  761 + // 恢复缓存数据(填写内容)
763 if param.AcquireCache != 0 { 762 if param.AcquireCache != 0 {
764 - srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList) 763 + cache = srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
  764 + }
  765 + // 获取项目信息
  766 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  767 + project, err := projectRepository.FindOne(map[string]interface{}{"id": assessData.EvaluationProjectId})
  768 + if err != nil {
  769 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目错误:"+err.Error())
  770 + }
  771 +
  772 + taskRecords := make([]*domain.TaskRecord, 0)
  773 + // 任务负责人才能显示里程碑数据
  774 + if project.PrincipalId == strconv.Itoa(param.TargetUserId) {
  775 + // 获取里程碑数据
  776 + taskRecordRepository := factory.CreateTaskRecordRepository(map[string]interface{}{"transactionContext": transactionContext})
  777 + _, taskRecords, err = taskRecordRepository.Find(map[string]interface{}{"staffAssessId": assessData.Id})
  778 + if err != nil {
  779 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取里程碑数据:"+err.Error())
  780 + }
  781 +
  782 + // 恢复缓存数据(里程碑记录)
  783 + if param.AcquireCache != 0 {
  784 + srv.recoverCacheWithTaskRecord(cache, taskRecords)
  785 + }
765 } 786 }
766 787
767 - //获取员工描述  
768 - staffDesc, _ := srv.getStaffDescrip(transactionContext, int64(param.TargetUserId))  
769 if err := transactionContext.CommitTransaction(); err != nil { 788 if err := transactionContext.CommitTransaction(); err != nil {
770 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 789 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
771 } 790 }
@@ -788,6 +807,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA @@ -788,6 +807,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
788 SupperUser: "", 807 SupperUser: "",
789 DutyTime: "", 808 DutyTime: "",
790 AssessContent: assessContentList, 809 AssessContent: assessContentList,
  810 + TaskRecords: taskRecords,
791 } 811 }
792 if staffDesc != nil { 812 if staffDesc != nil {
793 result.CompanyName = staffDesc.CompanyName 813 result.CompanyName = staffDesc.CompanyName
@@ -2,12 +2,19 @@ package domain @@ -2,12 +2,19 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
  5 +type TaskStageCheck int
  6 +
  7 +const (
  8 + TaskStageUncompleted TaskStageCheck = 0 // 里程碑未完成
  9 + TaskStageCompleted TaskStageCheck = 1 // 里程碑完成
  10 +)
  11 +
5 // StaffAssessCache 填写评估数据(缓存暂未提交) 12 // StaffAssessCache 填写评估数据(缓存暂未提交)
6 type StaffAssessCache struct { 13 type StaffAssessCache struct {
7 Id int64 `json:"id,string" comment:"ID"` 14 Id int64 `json:"id,string" comment:"ID"`
8 AssessId int64 `json:"assessId,string" comment:"评估项ID"` 15 AssessId int64 `json:"assessId,string" comment:"评估项ID"`
9 AssessContent []AssessContent `json:"assessContent" comment:"评估项提交数据"` 16 AssessContent []AssessContent `json:"assessContent" comment:"评估项提交数据"`
10 - AssessTaskStages []AssessTaskStage `json:"assessTaskStages" comment:"里程碑内容"` 17 + AssessTaskStages []AssessTaskStage `json:"assessTaskStages" comment:"任务里程碑内容"`
11 CreatedAt time.Time `json:"createdAt" comment:"创建时间"` 18 CreatedAt time.Time `json:"createdAt" comment:"创建时间"`
12 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"` 19 UpdatedAt time.Time `json:"updatedAt" comment:"更新时间"`
13 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"` 20 DeletedAt *time.Time `json:"deletedAt" comment:"删除时间"`
@@ -26,11 +33,9 @@ type RemarkText struct { @@ -26,11 +33,9 @@ type RemarkText struct {
26 } 33 }
27 34
28 type AssessTaskStage struct { 35 type AssessTaskStage struct {
29 - Category string `json:"category"`  
30 - Name string `json:"name"`  
31 - TaskRecordId int `json:"taskRecordId" comment:"任务记录ID"`  
32 - TaskStageId int `json:"taskStageId" comment:"里程碑ID"`  
33 - Status TaskStageState `json:"status" comment:"里程碑完成情况"` 36 + TaskRecordId int `json:"taskRecordId,string" comment:"任务记录ID"`
  37 + TaskStageId int `json:"taskStageId,string" comment:"里程碑ID"`
  38 + Check TaskStageCheck `json:"check" comment:"里程碑完成情况"`
34 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"` 39 AssistLevel int `json:"assistLevel" comment:"上级辅导情况"`
35 AssistContent string `json:"assistContent" comment:"上级辅导内容"` 40 AssistContent string `json:"assistContent" comment:"上级辅导内容"`
36 } 41 }
@@ -11,10 +11,11 @@ const ( @@ -11,10 +11,11 @@ const (
11 11
12 // TaskRecord 任务反馈情况记录 12 // TaskRecord 任务反馈情况记录
13 type TaskRecord struct { 13 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 + TaskCategory string `json:"taskCategory" comment:"任务类别"`
18 TaskName string `json:"taskName" comment:"任务名称"` 19 TaskName string `json:"taskName" comment:"任务名称"`
19 TaskAlias string `json:"taskAlias" comment:"任务别名"` 20 TaskAlias string `json:"taskAlias" comment:"任务别名"`
20 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"` 21 TaskLeader TaskLeader `json:"taskLeader" comment:"任务负责人"`
@@ -2,26 +2,25 @@ package domain @@ -2,26 +2,25 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
5 -type TaskStageState int  
6 -  
7 -const (  
8 - TaskStageUncompleted TaskStageState = 1 //里程碑未完成  
9 - TaskStageCompleted TaskStageState = 2 //里程碑完成  
10 -  
11 -) 5 +//type TaskStageState int
  6 +//
  7 +//const (
  8 +// TaskStageUncompleted TaskStageState = 1 //里程碑未完成
  9 +// TaskStageCompleted TaskStageState = 2 //里程碑完成
  10 +//
  11 +//)
12 12
13 // 任务阶段 13 // 任务阶段
14 type TaskStage struct { 14 type TaskStage struct {
15 - Id int `json:"id"`  
16 - TaskId int `json:"taskId"`  
17 - CreatedAt time.Time `json:"createdAt"`  
18 - UpdatedAt time.Time `json:"updatedAt"`  
19 - DeletedAt *time.Time `json:"deletedAt"`  
20 - Name string `json:"name"` //里程碑名称  
21 - SortBy int `json:"sortBy"` //排序  
22 - // Status TaskStageState `json:"status"` //里程碑完成情况  
23 - PlanCompletedAt int64 `json:"planCompletedAt"` //计划完成时间戳,秒  
24 - RealCompletedAt int64 `json:"realCompletedAt"` //时间完成时间戳,秒 15 + Id int `json:"id,string"`
  16 + TaskId int `json:"taskId,string"`
  17 + CreatedAt time.Time `json:"createdAt"`
  18 + UpdatedAt time.Time `json:"updatedAt"`
  19 + DeletedAt *time.Time `json:"deletedAt"`
  20 + Name string `json:"name"` // 里程碑名称
  21 + SortBy int `json:"sortBy"` // 排序
  22 + PlanCompletedAt int64 `json:"planCompletedAt"` // 计划完成时间戳,秒
  23 + RealCompletedAt int64 `json:"realCompletedAt"` // 实际完成时间戳,秒
25 } 24 }
26 type TaskStageRepository interface { 25 type TaskStageRepository interface {
27 Save(param []*TaskStage) error 26 Save(param []*TaskStage) error
@@ -55,6 +55,7 @@ func init() { @@ -55,6 +55,7 @@ func init() {
55 &models.Task{}, 55 &models.Task{},
56 &models.TaskStage{}, 56 &models.TaskStage{},
57 &models.TaskIgnore{}, 57 &models.TaskIgnore{},
  58 + &models.TaskRecord{},
58 } 59 }
59 for _, model := range tables { 60 for _, model := range tables {
60 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{ 61 err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
@@ -12,6 +12,7 @@ type TaskRecord struct { @@ -12,6 +12,7 @@ type TaskRecord struct {
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 + TaskCategory string `comment:"任务类别"`
15 TaskName string `comment:"任务名称"` 16 TaskName string `comment:"任务名称"`
16 TaskAlias string `comment:"任务别名"` 17 TaskAlias string `comment:"任务别名"`
17 TaskLeader domain.TaskLeader `comment:"任务负责人"` 18 TaskLeader domain.TaskLeader `comment:"任务负责人"`
@@ -25,6 +25,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain @@ -25,6 +25,7 @@ func (repo *TaskRecordRepository) TransformToDomain(m *models.TaskRecord) domain
25 CompanyId: m.CompanyId, 25 CompanyId: m.CompanyId,
26 StaffAssessId: m.StaffAssessId, 26 StaffAssessId: m.StaffAssessId,
27 TaskId: m.TaskId, 27 TaskId: m.TaskId,
  28 + TaskCategory: m.TaskCategory,
28 TaskName: m.TaskName, 29 TaskName: m.TaskName,
29 TaskAlias: m.TaskAlias, 30 TaskAlias: m.TaskAlias,
30 TaskLeader: m.TaskLeader, 31 TaskLeader: m.TaskLeader,
@@ -44,6 +45,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models. @@ -44,6 +45,7 @@ func (repo *TaskRecordRepository) TransformToModel(d *domain.TaskRecord) models.
44 CompanyId: d.CompanyId, 45 CompanyId: d.CompanyId,
45 StaffAssessId: d.StaffAssessId, 46 StaffAssessId: d.StaffAssessId,
46 TaskId: d.TaskId, 47 TaskId: d.TaskId,
  48 + TaskCategory: d.TaskCategory,
47 TaskName: d.TaskName, 49 TaskName: d.TaskName,
48 TaskAlias: d.TaskAlias, 50 TaskAlias: d.TaskAlias,
49 TaskLeader: d.TaskLeader, 51 TaskLeader: d.TaskLeader,
@@ -140,9 +142,9 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int @@ -140,9 +142,9 @@ func (repo *TaskRecordRepository) Find(queryOptions map[string]interface{}) (int
140 query.Where("company_id = ?", v) 142 query.Where("company_id = ?", v)
141 } 143 }
142 144
143 - //if v, ok := queryOptions["state"]; ok && v.(int) >= 0 {  
144 - // query.Where("state = ?", v)  
145 - //} 145 + if v, ok := queryOptions["staffAssessId"]; ok {
  146 + query.Where("staff_assess_id = ?", v)
  147 + }
146 148
147 if v, ok := queryOptions["limit"].(int64); ok { 149 if v, ok := queryOptions["limit"].(int64); ok {
148 query.Limit(int(v)) 150 query.Limit(int(v))
@@ -114,6 +114,23 @@ func (c *StaffAssessController) SaveAssessInfo() { @@ -114,6 +114,23 @@ func (c *StaffAssessController) SaveAssessInfo() {
114 c.Response(data, err) 114 c.Response(data, err)
115 } 115 }
116 116
  117 +// SaveSelfAssess 提交自评反馈-当前登录用户
  118 +func (c *StaffAssessController) SaveSelfAssess() {
  119 + srv := service.NewStaffAssessServeice()
  120 + paramReq := &command.SaveSelfAssessCommand{}
  121 + err := c.BindJSON(paramReq)
  122 + if err != nil {
  123 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  124 + c.Response(nil, e)
  125 + return
  126 + }
  127 + userReq := middlewares.GetUser(c.Ctx)
  128 + paramReq.ExecutorId = int(userReq.UserId)
  129 + paramReq.CompanyId = int(userReq.CompanyId)
  130 + data, err := srv.SaveSelfAssess(paramReq)
  131 + c.Response(data, err)
  132 +}
  133 +
117 // 获取周期列表 134 // 获取周期列表
118 func (c *StaffAssessController) ListAssessCycle() { 135 func (c *StaffAssessController) ListAssessCycle() {
119 srv := service.NewStaffAssessServeice() 136 srv := service.NewStaffAssessServeice()
@@ -100,7 +100,7 @@ func (c *StaffAssessControllerV2) GetAssessMeInviteUser() { @@ -100,7 +100,7 @@ func (c *StaffAssessControllerV2) GetAssessMeInviteUser() {
100 c.Response(data, err) 100 c.Response(data, err)
101 } 101 }
102 102
103 -// 获取当前登录员工自评详情 103 +// GetAssessSelfMeInfo 获取自评详情-目标是登录员工
104 func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() { 104 func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() {
105 srv := service.NewStaffAssessServeice() 105 srv := service.NewStaffAssessServeice()
106 paramReq := &query.GetExecutorSelfAssessQuery{} 106 paramReq := &query.GetExecutorSelfAssessQuery{}
@@ -117,25 +117,24 @@ func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() { @@ -117,25 +117,24 @@ func (c *StaffAssessControllerV2) GetAssessSelfMeInfo() {
117 c.Response(data, err) 117 c.Response(data, err)
118 } 118 }
119 119
120 -// 被评估的员工的评估列表-360评估  
121 -func (c *StaffAssessControllerV2) ListTargetUserInviteAssess() { 120 +// GetAssessTargetUserSelfInfo 获取自评详情-目标是员工
  121 +func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
122 srv := service.NewStaffAssessServeice() 122 srv := service.NewStaffAssessServeice()
123 - paramReq := &query.ListTargetAssessQuery{} 123 + paramReq := &query.GetExecutorSelfAssessQuery{}
124 err := c.BindJSON(paramReq) 124 err := c.BindJSON(paramReq)
125 if err != nil { 125 if err != nil {
126 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 126 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
127 c.Response(nil, e) 127 c.Response(nil, e)
128 return 128 return
129 } 129 }
130 -  
131 userReq := middlewares.GetUser(c.Ctx) 130 userReq := middlewares.GetUser(c.Ctx)
132 paramReq.CompanyId = int(userReq.CompanyId) 131 paramReq.CompanyId = int(userReq.CompanyId)
133 - data, err := srv.ListTargetUserInviteAssess(paramReq) 132 + data, err := srv.GetAssessSelfInfoV2(paramReq)
134 c.Response(data, err) 133 c.Response(data, err)
135 } 134 }
136 135
137 -// 被评估的员工的评估列表-当前登录用户-上级评估  
138 -func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() { 136 +// 被评估的员工的评估列表-360评估
  137 +func (c *StaffAssessControllerV2) ListTargetUserInviteAssess() {
139 srv := service.NewStaffAssessServeice() 138 srv := service.NewStaffAssessServeice()
140 paramReq := &query.ListTargetAssessQuery{} 139 paramReq := &query.ListTargetAssessQuery{}
141 err := c.BindJSON(paramReq) 140 err := c.BindJSON(paramReq)
@@ -144,16 +143,15 @@ func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() { @@ -144,16 +143,15 @@ func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() {
144 c.Response(nil, e) 143 c.Response(nil, e)
145 return 144 return
146 } 145 }
147 - paramReq.CompanyId = 1 146 +
148 userReq := middlewares.GetUser(c.Ctx) 147 userReq := middlewares.GetUser(c.Ctx)
149 paramReq.CompanyId = int(userReq.CompanyId) 148 paramReq.CompanyId = int(userReq.CompanyId)
150 - paramReq.TargetUserId = int(userReq.UserId)  
151 - data, err := srv.ListTargetUserSuperAssess(paramReq) 149 + data, err := srv.ListTargetUserInviteAssess(paramReq)
152 c.Response(data, err) 150 c.Response(data, err)
153 } 151 }
154 152
155 -// 被评估的员工的评估列表-上级评估  
156 -func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() { 153 +// 被评估的员工的评估列表-当前登录用户-上级评估
  154 +func (c *StaffAssessControllerV2) ListTargetUserMeSupperAssess() {
157 srv := service.NewStaffAssessServeice() 155 srv := service.NewStaffAssessServeice()
158 paramReq := &query.ListTargetAssessQuery{} 156 paramReq := &query.ListTargetAssessQuery{}
159 err := c.BindJSON(paramReq) 157 err := c.BindJSON(paramReq)
@@ -165,23 +163,25 @@ func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() { @@ -165,23 +163,25 @@ func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() {
165 paramReq.CompanyId = 1 163 paramReq.CompanyId = 1
166 userReq := middlewares.GetUser(c.Ctx) 164 userReq := middlewares.GetUser(c.Ctx)
167 paramReq.CompanyId = int(userReq.CompanyId) 165 paramReq.CompanyId = int(userReq.CompanyId)
  166 + paramReq.TargetUserId = int(userReq.UserId)
168 data, err := srv.ListTargetUserSuperAssess(paramReq) 167 data, err := srv.ListTargetUserSuperAssess(paramReq)
169 c.Response(data, err) 168 c.Response(data, err)
170 } 169 }
171 170
172 -// 获取员工自评详情  
173 -func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() { 171 +// 被评估的员工的评估列表-上级评估
  172 +func (c *StaffAssessControllerV2) ListTargetUserSupperAssess() {
174 srv := service.NewStaffAssessServeice() 173 srv := service.NewStaffAssessServeice()
175 - paramReq := &query.GetExecutorSelfAssessQuery{} 174 + paramReq := &query.ListTargetAssessQuery{}
176 err := c.BindJSON(paramReq) 175 err := c.BindJSON(paramReq)
177 if err != nil { 176 if err != nil {
178 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error()) 177 e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
179 c.Response(nil, e) 178 c.Response(nil, e)
180 return 179 return
181 } 180 }
  181 + paramReq.CompanyId = 1
182 userReq := middlewares.GetUser(c.Ctx) 182 userReq := middlewares.GetUser(c.Ctx)
183 paramReq.CompanyId = int(userReq.CompanyId) 183 paramReq.CompanyId = int(userReq.CompanyId)
184 - data, err := srv.GetAssessSelfInfoV2(paramReq) 184 + data, err := srv.ListTargetUserSuperAssess(paramReq)
185 c.Response(data, err) 185 c.Response(data, err)
186 } 186 }
187 187
@@ -29,6 +29,7 @@ func init() { @@ -29,6 +29,7 @@ func init() {
29 web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工 29 web.NSCtrlPost("/me/invite-user/select", (*controllers.StaffAssessController).SelectAssessInviteUser), //选择我邀请的员工
30 web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情 30 web.NSCtrlPost("/info", (*controllers.StaffAssessController).GetAssessInfo), //通用获取员工评估的详情
31 web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情 31 web.NSCtrlPut("/info", (*controllers.StaffAssessController).SaveAssessInfo), //通用保存员工评估的详情
  32 + web.NSCtrlPut("/info-self", (*controllers.StaffAssessController).SaveSelfAssess), //提交自评反馈-当前登录用户
32 web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存) 33 web.NSCtrlPut("/info-cache", (*controllers.StaffAssessController).SaveAssessCache), //通用保存员工评估的详情(缓存)
33 web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览 34 web.NSCtrlPost("/summary", (*controllers.StaffAssessController).QuerySummary), //员工绩效-项目管理-总览
34 web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表 35 web.NSCtrlPost("/summary/users", (*controllers.StaffAssessController).QueryMemberSummary), //员工绩效-综合管理-成员列表
@@ -5,4 +5,8 @@ COMMENT ON COLUMN public.evaluation_item_used.indicator_type IS '指标类型'; @@ -5,4 +5,8 @@ COMMENT ON COLUMN public.evaluation_item_used.indicator_type IS '指标类型';
5 5
6 -- 增加项目表-任务负责人ID 6 -- 增加项目表-任务负责人ID
7 ALTER TABLE public.evaluation_project ADD principal_id text NULL; 7 ALTER TABLE public.evaluation_project ADD principal_id text NULL;
8 -COMMENT ON COLUMN public.evaluation_project.principal_id IS '任务负责人ID';  
  8 +COMMENT ON COLUMN public.evaluation_project.principal_id IS '任务负责人ID';
  9 +
  10 +-- 增加评估Cache数据缓存表-任务里程碑JSON
  11 +ALTER TABLE public.staff_assess_cache ADD assess_task_stages jsonb NULL;
  12 +COMMENT ON COLUMN public.staff_assess_cache.assess_task_stages IS '任务里程碑内容';