service.go
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package service
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
)
type StaffAssessServeice struct {
}
// 获取我参与过的评估任务列表
func (srv StaffAssessServeice) SearchAssessTaskMe(param *query.SearchAssessMeQuery) (map[string]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()
}()
staffAssessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
var limit int = 20
var offset int = 0
if param.PageSize > 0 {
limit = param.PageSize
}
offset = (param.PageNumber - 1) * param.PageSize
condition := map[string]interface{}{
"executorId": param.UserId,
"companyId": param.CompanyId,
"limit": limit,
}
if offset > 0 {
condition["offset"] = offset
}
cnt, assessTaskList, err := staffAssessTaskRepo.Find(condition)
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())
}
listData := make([]adapter.SearchAssessMeResp, 0, len(assessTaskList))
var temp adapter.SearchAssessMeResp
for _, v := range assessTaskList {
temp = adapter.SearchAssessMeResp{
AssessTaskId: v.Id,
BeginTime: v.BeginTime.Format("2006-01-02 15:04:05"),
EndTime: v.EndTime.Format("2006-01-02 15:04:05"),
CycleId: v.CycleId,
CycleName: v.CycleName,
EvaluationProjectId: v.EvaluationProjectId,
EvaluationProjectName: v.EvaluationProjectName,
}
listData = append(listData, temp)
}
return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
}
// 获取项目评估进度描述
func (srv StaffAssessServeice) AssessTaskDesc(param query.AssessTaskDescQuery) (*adapter.AssessTaskDescResp, 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()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
}
// 获取自评反馈列表
func (srv StaffAssessServeice) AssessSelfList(param query.AssessTaskDescQuery) (map[string]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()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
var cnt int64
var listData []adapter.AssessSelfList
var userInfo adapter.StaffInfo
result := tool_funs.SimpleWrapGridMap(cnt, listData)
result["userInfo"] = userInfo
return result, nil
}
// 更具项目评估的配置,创建员工的评估任务
func (srv StaffAssessServeice) CreateStaffAssessTask() error {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil
}