切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
86b37cecf8424240646be09d599675d98de03869
1 个父辈
077f2b4c
master
...
dev-pushdata
dev-tangxvhui
dev-zhengzhou
test
v1.3.2-fix
v1.4.0
v2.2.0-fix
20230410
20230403
20230331
20230324
20230315
v2.2.0
v2.0.0
v1.3.2
v1.3.2-fix
v1.3.1
v1.3.0
v1.2.4
更新上级评估
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
448 行增加
和
44 行删除
pkg/application/summary_evaluation/adapter/evaluation_info.go
pkg/application/summary_evaluation/command/get_evaluation.go
pkg/application/summary_evaluation/service/service.go
pkg/domain/evaluation_item_used.go
pkg/infrastructure/repository/pg_summary_evaluation_repository.go
pkg/infrastructure/repository/pg_summary_evaluation_value_repository.go
pkg/application/summary_evaluation/adapter/evaluation_info.go
查看文件 @
86b37ce
...
...
@@ -22,6 +22,7 @@ type EvaluationInfoAdapter struct {
EvaluationItems
[]
EvaluationItemAdapter
`json:"evaluationItems"`
}
// 评估填写项
type
EvaluationItemAdapter
struct
{
EvaluationItemId
int
`json:"evaluationItemId,string"`
//评估条目的id
SortBy
int
`json:"sortBy"`
//排序
...
...
@@ -37,11 +38,57 @@ type EvaluationItemAdapter struct {
Value
string
`json:"value"`
//评估填写的评分
Score
string
`json:"score"`
//计算的评定得分
Remark
string
`json:"remark"`
//填写的内容反馈
LevelCount
[]
LevalCodeCount
`json:"levelCount"`
//周期内每次评估的等级数量统计
EvaluatorId
int
`json:"evaluatorId"`
//评估人id
//
}
// 评级数量
type
LevalCodeCount
struct
{
Code
string
`json:"code"`
Number
int
`json:"number"`
Code
string
`json:"code"`
//评级代码
Number
int
`json:"number"`
//数量
ItemList
[]
string
`json:"itemList"`
//对应的评估项名称
}
// 评估任务的基本信息
type
EvaluationBaseAdapter
struct
{
SummaryEvaluationId
int
`json:"summaryEvaluationId"`
//
CycleId
int
`json:"cycleId,string"`
//周期id
CycleName
string
`json:"cycleName"`
//周期名称
EvaluationProjectId
int
`json:"evaluationProjectId"`
//项目id
EvaluationProjectName
string
`json:"evaluationProjectName"`
//项目名称
LinkNodeId
int
`json:"linkNodeId,string"`
//评估环节id
BeginTime
string
`json:"beginTime"`
//开始时间 2006-01-02 15:04:05
EndTime
string
`json:"endTime"`
//结束时间 2006-01-02 15:04:05
TargetUserId
int
`json:"targetUserId"`
//被评估的目标用户,被执行的
TargetUserName
string
`json:"targetUserName"`
//
CompanyLogo
string
`json:"companyLogo,string,"`
//公司logo
CompanyName
string
`json:"companyName"`
//公司名称
SupperUser
string
`json:"superUser"`
//目标用户的上级
DutyTime
string
`json:"dutyTime"`
//入职时间
Status
string
`json:"status"`
//完成状态
}
// 自评估内容详情
type
EvaluationInfoSelfAdapter
struct
{
EvaluationBaseAdapter
EvaluationItems
[]
EvaluationItemAdapter
`json:"evaluationItems"`
}
// 自评小结展示,每个评估项
type
EvaluationItemCountCodeAdapter
struct
{
EvaluationItemAdapter
LevelCount
[]
LevalCodeCount
`json:"levelCount"`
//周期内每次评估的等级数量统计
}
// 自评小结展示
type
EvaluationInfoCountCodeAdapter
struct
{
EvaluationBaseAdapter
EvaluationItems
[]
EvaluationItemCountCodeAdapter
`json:"evaluationItems"`
}
// 上级评估详情
type
EvaluationInfoSuperAdapter
struct
{
EvaluationBaseAdapter
LevelCount
[]
*
LevalCodeCount
`json:"levelCount"`
//周期内每次评估的等级数量统计
EvaluationItems
[]
EvaluationItemAdapter
`json:"evaluationItems"`
}
...
...
pkg/application/summary_evaluation/command/get_evaluation.go
查看文件 @
86b37ce
...
...
@@ -21,3 +21,9 @@ type QueryEvaluationHRBP struct {
SummaryEvaluationId
int
`json:"summaryEvaluationId,string"`
UserId
int
`json:"-"`
// 用户ID
}
// 获取上级评估详情
type
QueryEvaluationSuper
struct
{
SummaryEvaluationId
int
`json:"summaryEvaluationId,string"`
CompanyId
int
`json:"-"`
}
...
...
pkg/application/summary_evaluation/service/service.go
查看文件 @
86b37ce
...
...
@@ -264,6 +264,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev
Value
:
""
,
Score
:
""
,
Remark
:
""
,
EvaluatorId
:
v
.
EvaluatorId
,
}
value
,
ok
:=
valueMap
[
v
.
Id
]
if
ok
{
...
...
@@ -277,7 +278,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev
}
// 获取综合自评详情
func
(
srv
*
SummaryEvaluationService
)
GetEvaluationSelf
(
param
*
command
.
QueryEvaluation
)
(
*
adapter
.
EvaluationInfoAdapter
,
error
)
{
func
(
srv
*
SummaryEvaluationService
)
GetEvaluationSelf
(
param
*
command
.
QueryEvaluation
)
(
*
adapter
.
EvaluationInfo
Self
Adapter
,
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
...
...
@@ -299,7 +300,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu
})
_
,
evaluationList
,
err
:=
evaluationRepo
.
Find
(
map
[
string
]
interface
{}{
"limit"
:
1
,
"cycleId"
:
param
.
C
ompany
Id
,
"cycleId"
:
param
.
C
ycle
Id
,
"executorId"
:
param
.
UserId
,
"types"
:
domain
.
EvaluationSelf
,
})
...
...
@@ -325,18 +326,23 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
result
:=
srv
.
getSummaryEvaluation
(
transactionContext
,
evaluationData
)
//获取组装基本信息
evaluationBase
:=
srv
.
getSummaryEvaluation
(
transactionContext
,
evaluationData
)
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
itemValuesAdapter
:=
srv
.
buildSummaryItemValue
(
itemList
,
itemValues
)
result
:=
adapter
.
EvaluationInfoSelfAdapter
{
EvaluationBaseAdapter
:
evaluationBase
,
}
result
.
EvaluationItems
=
itemValuesAdapter
return
result
,
nil
return
&
result
,
nil
}
func
(
srv
*
SummaryEvaluationService
)
getSummaryEvaluation
(
transactionContext
application
.
TransactionContext
,
evaluationData
*
domain
.
SummaryEvaluation
)
*
adapter
.
EvaluationInfoAdapter
{
result
:=
adapter
.
EvaluationInfoAdapter
{
func
(
srv
*
SummaryEvaluationService
)
getSummaryEvaluation
(
transactionContext
application
.
TransactionContext
,
evaluationData
*
domain
.
SummaryEvaluation
)
adapter
.
EvaluationBaseAdapter
{
result
:=
adapter
.
EvaluationBaseAdapter
{
SummaryEvaluationId
:
evaluationData
.
Id
,
CycleId
:
int
(
evaluationData
.
CycleId
),
CycleName
:
evaluationData
.
CycleName
,
...
...
@@ -352,7 +358,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
SupperUser
:
""
,
DutyTime
:
""
,
Status
:
string
(
evaluationData
.
Status
),
EvaluationItems
:
[]
adapter
.
EvaluationItemAdapter
{},
}
//获取用户信息
companyRepo
:=
factory
.
CreateCompanyRepository
(
map
[
string
]
interface
{}{
...
...
@@ -367,30 +372,30 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
})
if
err
!=
nil
{
return
&
result
return
result
}
userData
,
err
:=
userRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
evaluationData
.
TargetUser
.
UserId
,
})
if
err
!=
nil
{
return
&
result
return
result
}
result
.
DutyTime
=
userData
.
EntryTime
result
.
CompanyLogo
=
companyData
.
Logo
result
.
CompanyName
=
companyData
.
Name
if
userData
.
ParentId
<=
0
{
return
&
result
return
result
}
pUserData
,
err
:=
userRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
userData
.
ParentId
,
})
if
err
!=
nil
{
return
&
result
return
result
}
result
.
SupperUser
=
pUserData
.
Name
return
&
result
return
result
}
// 编辑综合自评详情
...
...
@@ -556,23 +561,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query
}
// 自评小结详情
func
(
srv
*
SummaryEvaluationService
)
CountEvaluationSelfLevel
(
param
*
command
.
QueryEvaluation
)
(
*
adapter
.
EvaluationInfoAdapter
,
error
)
{
evaluationInfo
,
err
:=
srv
.
GetEvaluationSelf
(
param
)
if
err
!=
nil
{
return
nil
,
err
}
levelCodeMap
:=
map
[
int
][]
adapter
.
LevalCodeCount
{}
for
_
,
v
:=
range
evaluationInfo
.
EvaluationItems
{
codes
:=
v
.
Rule
.
GetLevelCodes
()
levelCode
:=
[]
adapter
.
LevalCodeCount
{}
for
_
,
v2
:=
range
codes
{
levelCode
=
append
(
levelCode
,
adapter
.
LevalCodeCount
{
Code
:
v2
,
Number
:
0
,
})
}
levelCodeMap
[
v
.
EvaluationItemId
]
=
levelCode
}
func
(
srv
*
SummaryEvaluationService
)
CountEvaluationSelfLevel
(
param
*
command
.
QueryEvaluation
)
(
*
adapter
.
EvaluationInfoCountCodeAdapter
,
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
...
...
@@ -593,43 +582,396 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationRepo
:=
factory
.
CreateSummaryEvaluationRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
evaluationItemRepo
:=
factory
.
CreateEvaluationItemUsedRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
itemValueRepo
:=
factory
.
CreateSummaryEvaluationValueRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
_
,
evaluationList
,
err
:=
evaluationRepo
.
Find
(
map
[
string
]
interface
{}{
"limit"
:
1
,
"cycleId"
:
param
.
CycleId
,
"executorId"
:
param
.
UserId
,
"types"
:
domain
.
EvaluationSelf
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
len
(
evaluationList
)
==
0
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationData
:=
evaluationList
[
0
]
_
,
itemList
,
err
:=
evaluationItemRepo
.
Find
(
map
[
string
]
interface
{}{
"evaluationProjectId"
:
evaluationData
.
EvaluationProjectId
,
"nodeType"
:
int
(
domain
.
LinkNodeSelfAssessment
),
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
_
,
itemValues
,
err
:=
itemValueRepo
.
Find
(
map
[
string
]
interface
{}{
"summaryEvaluationId"
:
evaluationData
.
Id
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 获取组装基本信息
evaluationBase
:=
srv
.
getSummaryEvaluation
(
transactionContext
,
evaluationData
)
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationItems
:=
srv
.
buildSummaryItemValue
(
itemList
,
itemValues
)
levelCodeMap
:=
map
[
int
][]
adapter
.
LevalCodeCount
{}
for
_
,
v
:=
range
evaluationItems
{
codes
:=
v
.
Rule
.
GetLevelCodes
()
levelCode
:=
[]
adapter
.
LevalCodeCount
{}
for
_
,
v2
:=
range
codes
{
levelCode
=
append
(
levelCode
,
adapter
.
LevalCodeCount
{
Code
:
v2
,
Number
:
0
,
})
}
levelCodeMap
[
v
.
EvaluationItemId
]
=
levelCode
}
levelCodeCountMap
:=
map
[
string
]
int
{}
for
_
,
v
:=
range
levelCodeCountList
{
key
:=
fmt
.
Sprintf
(
"%s-%s-%s"
,
v
.
Category
,
v
.
Name
,
v
.
LevelValue
)
levelCodeCountMap
[
key
]
=
v
.
Cnt
}
for
i
:=
range
evaluationInfo
.
EvaluationItems
{
itemId
:=
evaluationInfo
.
EvaluationItems
[
i
]
.
EvaluationItemId
evaluationItemCount
:=
[]
adapter
.
EvaluationItemCountCodeAdapter
{}
for
i
:=
range
evaluationItems
{
itemCount
:=
adapter
.
EvaluationItemCountCodeAdapter
{
EvaluationItemAdapter
:
evaluationItems
[
i
],
LevelCount
:
[]
adapter
.
LevalCodeCount
{},
}
evaluationItemCount
=
append
(
evaluationItemCount
,
itemCount
)
itemId
:=
evaluationItems
[
i
]
.
EvaluationItemId
levelCodes
,
ok
:=
levelCodeMap
[
itemId
]
if
!
ok
{
continue
}
evaluationI
nfo
.
EvaluationItems
[
i
]
.
LevelCount
=
levelCodes
evaluationI
temCount
[
i
]
.
LevelCount
=
levelCodes
for
i2
:=
range
levelCodes
{
key
:=
fmt
.
Sprintf
(
"%s-%s-%s"
,
evaluationInfo
.
EvaluationItems
[
i
]
.
Category
,
evaluationInfo
.
EvaluationItems
[
i
]
.
Name
,
evaluationItems
[
i
]
.
Category
,
evaluationItems
[
i
]
.
Name
,
levelCodes
[
i2
]
.
Code
,
)
if
mVal
,
ok
:=
levelCodeCountMap
[
key
];
ok
{
levelCodes
[
i2
]
.
Number
=
mVal
}
}
}
evaluationInfo
:=
adapter
.
EvaluationInfoCountCodeAdapter
{
EvaluationBaseAdapter
:
evaluationBase
,
EvaluationItems
:
evaluationItemCount
,
}
return
&
evaluationInfo
,
nil
}
// GetEvaluationSuper 根据执行人获取上级评估详情
func
(
srv
*
SummaryEvaluationService
)
GetEvaluationSuper
(
param
*
command
.
QueryEvaluationSuper
)
(
*
adapter
.
EvaluationInfoSuperAdapter
,
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
()
}()
evaluationRepo
:=
factory
.
CreateSummaryEvaluationRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
evaluationItemRepo
:=
factory
.
CreateEvaluationItemUsedRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
itemValueRepo
:=
factory
.
CreateSummaryEvaluationValueRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
evaluationData
,
err
:=
evaluationRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
param
.
SummaryEvaluationId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
evaluationData
.
Types
==
domain
.
EvaluationSuper
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"没有操作权限"
)
}
if
evaluationData
.
CompanyId
==
param
.
CompanyId
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"没有操作权限"
)
}
_
,
itemList
,
err
:=
evaluationItemRepo
.
Find
(
map
[
string
]
interface
{}{
"evaluationProjectId"
:
evaluationData
.
EvaluationProjectId
,
"nodeType"
:
int
(
domain
.
LinkNodeSelfAssessment
),
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//获取已填写的评估内容
_
,
itemValues
,
err
:=
itemValueRepo
.
Find
(
map
[
string
]
interface
{}{
"summaryEvaluationId"
:
evaluationData
.
Id
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
len
(
itemValues
)
==
0
{
//上级还未填写评估,获取 360 ,人资评估
_
,
evaluationListOther
,
err
:=
evaluationRepo
.
Find
(
map
[
string
]
interface
{}{
"typesList"
:
[]
int
{
int
(
domain
.
Evaluation360
),
int
(
domain
.
EvaluationHrbp
)},
"targetUserId"
:
evaluationData
.
TargetUser
.
UserId
,
"cycleId"
:
evaluationData
.
CycleId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationIds
:=
[]
int
{}
for
_
,
v
:=
range
evaluationListOther
{
evaluationIds
=
append
(
evaluationIds
,
v
.
Id
)
}
if
len
(
evaluationIds
)
>
0
{
_
,
itemValues
,
err
=
itemValueRepo
.
Find
(
map
[
string
]
interface
{}{
"summaryEvaluationIdList"
:
evaluationIds
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
}
evaluationBase
:=
srv
.
getSummaryEvaluation
(
transactionContext
,
evaluationData
)
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
evaluationInfo
,
nil
//组合 评估填写的值和评估项
itemValuesAdapter
:=
srv
.
buildSummaryItemValue
(
itemList
,
itemValues
)
codeList
:=
[]
*
adapter
.
LevalCodeCount
{}
codeMap
:=
map
[
string
]
*
adapter
.
LevalCodeCount
{}
for
_
,
v
:=
range
itemValuesAdapter
{
if
v
.
Weight
>
0
{
continue
}
if
_
,
ok
:=
codeMap
[
v
.
Value
];
!
ok
{
code
:=
&
adapter
.
LevalCodeCount
{
Code
:
v
.
Value
,
Number
:
0
,
ItemList
:
[]
string
{},
}
codeMap
[
v
.
Value
]
=
code
codeList
=
append
(
codeList
,
code
)
}
codeMap
[
v
.
Value
]
.
ItemList
=
append
(
codeMap
[
v
.
Value
]
.
ItemList
,
v
.
Name
)
codeMap
[
v
.
Value
]
.
Number
+=
1
}
result
:=
adapter
.
EvaluationInfoSuperAdapter
{
EvaluationBaseAdapter
:
evaluationBase
,
LevelCount
:
codeList
,
EvaluationItems
:
itemValuesAdapter
,
}
return
&
result
,
nil
}
// GetEvaluationSuper 根据执行人获取上级评估详情
func
(
srv
*
SummaryEvaluationService
)
GetEvaluationSuper
()
{
// EditEvaluationSuper 更新上级评估内容
func
(
srv
*
SummaryEvaluationService
)
EditEvaluationSuper
(
param
*
command
.
EditEvaluationValue
)
(
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
()
}()
evaluationRepo
:=
factory
.
CreateSummaryEvaluationRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
itemUsedRepo
:=
factory
.
CreateEvaluationItemUsedRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
itemValueRepo
:=
factory
.
CreateSummaryEvaluationValueRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
evaluationData
,
err
:=
evaluationRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
param
.
SummaryEvaluationId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
evaluationData
.
Types
!=
domain
.
EvaluationSuper
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"没有操作权限"
)
}
if
evaluationData
.
Executor
.
UserId
!=
param
.
ExecutorId
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"没有操作权限"
)
}
if
evaluationData
.
CompanyId
!=
param
.
CompanyId
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"没有操作权限"
)
}
_
,
itemList
,
err
:=
itemUsedRepo
.
Find
(
map
[
string
]
interface
{}{
"evaluationProjectId"
:
evaluationData
.
EvaluationProjectId
,
"nodeType"
:
domain
.
LinkNodeSelfAssessment
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//获取已填写的评估内容
_
,
itemValueList
,
err
:=
itemValueRepo
.
Find
(
map
[
string
]
interface
{}{
"summaryEvaluationId"
:
evaluationData
.
Id
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//记录人资评估或者360评估的 填写项id
hrbpOr360ItemValue
,
err
:=
srv
.
getEvaluationSuperDefaultValue
(
transactionContext
,
evaluationData
)
if
err
!=
nil
{
return
nil
,
err
}
evaluationValueMap
:=
map
[
int
]
*
domain
.
SummaryEvaluationValue
{}
for
_
,
v
:=
range
itemList
{
newValue
:=
&
domain
.
SummaryEvaluationValue
{}
newValue
.
SetBlankValue
(
evaluationData
,
v
)
evaluationValueMap
[
v
.
Id
]
=
newValue
}
for
_
,
v
:=
range
itemValueList
{
if
mValue
,
ok
:=
evaluationValueMap
[
v
.
EvaluationItemId
];
ok
{
mValue
.
Id
=
v
.
Id
}
}
nowTime
:=
time
.
Now
()
for
_
,
v
:=
range
param
.
EvaluationItems
{
updatedData
,
ok
:=
evaluationValueMap
[
v
.
EvaluationItemId
]
if
!
ok
{
continue
}
if
defaultValue
,
ok
:=
hrbpOr360ItemValue
[
v
.
EvaluationItemId
];
ok
{
updatedData
.
Value
=
defaultValue
.
Value
}
else
{
updatedData
.
Value
=
v
.
Value
}
updatedData
.
UpdatedAt
=
nowTime
updatedData
.
Remark
=
v
.
Remark
//计算得分
err
=
updatedData
.
SummaryEvaluationScore
()
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
err
.
Error
())
}
}
evaluationValueList
:=
[]
*
domain
.
SummaryEvaluationValue
{}
for
_
,
v
:=
range
evaluationValueMap
{
//保存填写值
err
=
itemValueRepo
.
Save
(
v
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationValueList
=
append
(
evaluationValueList
,
v
)
}
//计算总得分
err
=
evaluationData
.
EvaluationTotalScore
(
evaluationValueList
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationData
.
UpdatedAt
=
nowTime
evaluationData
.
Status
=
domain
.
EvaluationCompleted
//保存填写值
err
=
evaluationRepo
.
Save
(
evaluationData
)
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
())
}
itemValueAdapter
:=
srv
.
buildSummaryItemValue
(
itemList
,
evaluationValueList
)
return
map
[
string
][]
adapter
.
EvaluationItemAdapter
{
"EvaluationItems"
:
itemValueAdapter
,
},
nil
}
// EditEvaluationSuper 更新上级评估
func
(
srv
*
SummaryEvaluationService
)
EditEvaluationSuper
()
{
// getEvaluationSuperDefaultValue
// 按照权限设置,是否获取上级评估内容的默认值
func
(
srv
*
SummaryEvaluationService
)
getEvaluationSuperDefaultValue
(
transactionContext
application
.
TransactionContext
,
evaluationData
*
domain
.
SummaryEvaluation
)
(
map
[
int
]
*
domain
.
SummaryEvaluationValue
,
error
)
{
evaluationRepo
:=
factory
.
CreateSummaryEvaluationRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
itemValueRepo
:=
factory
.
CreateSummaryEvaluationValueRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
permissionRepository
:=
factory
.
CreatePermissionRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 获取权限配置
_
,
permissionList
,
err
:=
permissionRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
evaluationData
.
CompanyId
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
len
(
permissionList
)
==
0
{
return
nil
,
nil
}
permissionData
:=
permissionList
[
0
]
if
permissionData
.
OptEvalScore
==
domain
.
PermissionOn
&&
permissionData
.
OptHrScore
==
domain
.
PermissionOn
{
return
nil
,
nil
}
// 获取360评估,人资评估填写的值
_
,
evaluationListOther
,
err
:=
evaluationRepo
.
Find
(
map
[
string
]
interface
{}{
"typesList"
:
[]
int
{
int
(
domain
.
Evaluation360
),
int
(
domain
.
EvaluationHrbp
)},
"targetUserId"
:
evaluationData
.
TargetUser
.
UserId
,
"cycleId"
:
evaluationData
.
CycleId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
evaluationIds
:=
[]
int
{}
for
_
,
v
:=
range
evaluationListOther
{
evaluationIds
=
append
(
evaluationIds
,
v
.
Id
)
}
if
len
(
evaluationIds
)
==
0
{
return
nil
,
nil
}
// 将360评估,人资评估填写的值 作为默认值
_
,
itemValuesOther
,
err
:=
itemValueRepo
.
Find
(
map
[
string
]
interface
{}{
"summaryEvaluationIdList"
:
evaluationIds
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 记录人资评估或者360评估的 填写项id
hrbpOr360ItemValue
:=
map
[
int
]
*
domain
.
SummaryEvaluationValue
{}
result
:=
map
[
int
]
*
domain
.
SummaryEvaluationValue
{}
if
permissionData
.
OptEvalScore
==
domain
.
PermissionOff
{
//上级是否可以修改360°综评分数
//获取360综合评分
for
_
,
v
:=
range
itemValuesOther
{
//记录人资评估或者360评估的填写值
if
v
.
Types
!=
domain
.
Evaluation360
{
continue
}
hrbpOr360ItemValue
[
v
.
EvaluationItemId
]
=
v
}
}
if
permissionData
.
OptHrScore
==
domain
.
PermissionOff
{
//上级是否可以修改人资综评分数
//获取人资综合评分
for
_
,
v
:=
range
itemValuesOther
{
//记录人资评估或者360评估的填写值
if
v
.
Types
!=
domain
.
EvaluationHrbp
{
continue
}
hrbpOr360ItemValue
[
v
.
EvaluationItemId
]
=
v
}
}
return
result
,
nil
}
...
...
pkg/domain/evaluation_item_used.go
查看文件 @
86b37ce
...
...
@@ -21,7 +21,7 @@ type EvaluationItemUsed struct {
Rule
EvaluationRule
//评估的选项规则
Weight
float64
//"权重"
Required
int
// 必填项
EvaluatorId
int
// 项目评估人ID ( 0=无评估人、-1=HRBP )
EvaluatorId
int
// 项目评估人ID ( 0=无评估人、-1=HRBP
、 >0 =员工的id
)
CreatedAt
time
.
Time
//数据创建时间
UpdatedAt
time
.
Time
//数据更新时间
}
...
...
pkg/infrastructure/repository/pg_summary_evaluation_repository.go
查看文件 @
86b37ce
...
...
@@ -129,6 +129,10 @@ func (repo *SummaryEvaluationRepository) Find(queryOptions map[string]interface{
query
.
Where
(
"types=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"typesList"
];
ok
{
query
.
Where
(
"types in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"cycleId"
];
ok
{
query
.
Where
(
"cycle_id=?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_summary_evaluation_value_repository.go
查看文件 @
86b37ce
...
...
@@ -108,6 +108,11 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
if
v
,
ok
:=
queryOptions
[
"summaryEvaluationId"
];
ok
{
query
.
Where
(
"summary_evaluation_id=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"summaryEvaluationIdList"
];
ok
{
query
.
Where
(
"summary_evaluation_id in(?)"
,
pg
.
In
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
...
...
请
注册
或
登录
后发表评论