切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
662e31d3a78016ae8dab146d179cf80ab6a4cf5f
1 个父辈
713c81ea
更新综合自评
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
128 行增加
和
15 行删除
pkg/application/summary_evaluation/adapter/evaluation_info.go
pkg/application/summary_evaluation/command/edit_evaluation_value.go
pkg/application/summary_evaluation/service/service.go
pkg/domain/evaluation_item_used.go
pkg/domain/summary_evaluation.go
pkg/domain/summary_evaluation_value.go
pkg/infrastructure/repository/pg_evaluation_item_used_repository.go
pkg/infrastructure/repository/pg_summary_evaluation_value_repository.go
pkg/application/summary_evaluation/adapter/evaluation_info.go
查看文件 @
662e31d
...
...
@@ -12,7 +12,7 @@ type EvaluationInfoAdapter struct {
BeginTime
string
`json:"beginTime"`
//开始时间 2006-01-02 15:04:05
EndTime
string
`json:"endTime"`
//结束时间 2006-01-02 15:04:05
Status
string
`json:"status"`
//完成状态
EvaluationItems
[]
EvaluationItemAdapter
`json:"
assessContent
"`
EvaluationItems
[]
EvaluationItemAdapter
`json:"
evaluationItems
"`
}
type
EvaluationItemAdapter
struct
{
...
...
@@ -28,6 +28,6 @@ type EvaluationItemAdapter struct {
Weight
float64
`json:"weight"`
//"权重"
Required
int
`json:"required"`
// 必填项
Value
string
`json:"value"`
//评估填写的评分
Score
string
`json:"score"`
//评定得分
Score
string
`json:"score"`
//
计算的
评定得分
Remark
string
`json:"remark"`
//填写的内容反馈
}
...
...
pkg/application/summary_evaluation/command/edit_evaluation_value.go
查看文件 @
662e31d
...
...
@@ -7,6 +7,6 @@ type EditEvaluationValue struct {
EvaluationItems
[]
struct
{
Value
string
`json:"value"`
Remark
string
`json:"remark"`
EvaluationItemId
string
`json:"evaluationItemId
"`
EvaluationItemId
int
`json:"evaluationItemId,string
"`
}
`json:"evaluationItems"`
}
...
...
pkg/application/summary_evaluation/service/service.go
查看文件 @
662e31d
package
service
import
(
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
...
...
@@ -313,7 +315,6 @@ func (srv *SummaryEvaluationServeice) GetEvaluationSelf(param *command.QueryEval
_
,
itemList
,
err
:=
evaluationItemRepo
.
Find
(
map
[
string
]
interface
{}{
"evaluationProjectId"
:
evaluationData
.
EvaluationProjectId
,
"nodeType"
:
int
(
domain
.
LinkNodeSelfAssessment
),
"limit"
:
300
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -375,19 +376,64 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
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"
:
int
(
domain
.
LinkNodeSelfAssessment
),
"limit"
:
300
,
"evaluationProjectId"
:
evaluationData
.
EvaluationProjectId
,
})
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
())
}
_
=
itemValueRepo
_
=
evaluationData
_
=
itemList
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
{
updatedData
.
UpdatedAt
=
nowTime
updatedData
.
Value
=
v
.
Value
updatedData
.
Remark
=
v
.
Remark
}
}
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
)
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
return
nil
,
nil
itemValueAdapter
:=
srv
.
buildSummaryItemValue
(
itemList
,
evaluationValueList
)
return
map
[
string
][]
adapter
.
EvaluationItemAdapter
{
"EvaluationItems"
:
itemValueAdapter
,
},
nil
}
...
...
pkg/domain/evaluation_item_used.go
查看文件 @
662e31d
package
domain
import
"time"
import
(
"time"
)
// 实际被应用的评估条目
type
EvaluationItemUsed
struct
{
...
...
pkg/domain/summary_evaluation.go
查看文件 @
662e31d
package
domain
import
"time"
import
(
"fmt"
"time"
)
// 周综合评估
type
SummaryEvaluation
struct
{
...
...
@@ -56,3 +59,18 @@ type SummaryEvaluationRepository interface {
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
SummaryEvaluation
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
SummaryEvaluation
,
error
)
}
// 计算总分。TotalScore 保留1位小数
func
(
evaluation
*
SummaryEvaluation
)
EvaluationTotalScore
(
valueList
[]
*
SummaryEvaluationValue
)
error
{
var
totalScore
float64
for
_
,
v
:=
range
valueList
{
score
,
err
:=
v
.
SumScore
(
v
.
Weight
,
v
.
Value
)
if
err
!=
nil
{
return
err
}
totalScore
+=
score
}
evaluation
.
TotalScore
=
fmt
.
Sprintf
(
"%.2f"
,
totalScore
)
return
nil
}
...
...
pkg/domain/summary_evaluation_value.go
查看文件 @
662e31d
package
domain
import
"time"
import
(
"fmt"
"strconv"
"time"
)
// 周期综合评估填写的内容
type
SummaryEvaluationValue
struct
{
...
...
@@ -11,6 +15,7 @@ type SummaryEvaluationValue struct {
Score
string
`json:"score"`
//评定得分
Types
EvaluationType
`json:"types"`
//评估类型
Remark
string
`json:"remark"`
//填写的内容反馈
Weight
float64
`json:"weight"`
//"权重"
CreatedAt
time
.
Time
`json:"createdAt"`
//数据创建时间
UpdatedAt
time
.
Time
`json:"updatedAt"`
//数据更新时间
DeletedAt
*
time
.
Time
`json:"deletedAt"`
//数据删除时间
...
...
@@ -22,3 +27,42 @@ type SummaryEvaluationValueRepository interface {
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
SummaryEvaluationValue
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
SummaryEvaluationValue
,
error
)
}
// 计算周期评估
// 当指标项没有权重的时候,还是进行评级操作,不计算分数
// 分数保留2位小数
func
(
itemValue
*
SummaryEvaluationValue
)
SummaryEvaluationScore
()
error
{
//计算方式
score
,
err
:=
itemValue
.
SumScore
(
itemValue
.
Weight
,
itemValue
.
Value
)
if
err
!=
nil
{
return
err
}
itemValue
.
Score
=
fmt
.
Sprintf
(
"%.2f"
,
score
)
return
nil
}
func
(
item
*
SummaryEvaluationValue
)
SumScore
(
weight
float64
,
value
string
)
(
float64
,
error
)
{
if
item
.
Weight
==
0
{
return
0
,
nil
}
valueFloat
,
err
:=
strconv
.
ParseFloat
(
item
.
Value
,
64
)
if
err
!=
nil
{
return
0
,
fmt
.
Errorf
(
"条目%d系数值异常,%s"
,
item
.
Id
,
item
.
Value
)
}
//计算方式
score
:=
item
.
Weight
*
valueFloat
return
score
,
nil
}
// 初始化一个空的value
func
(
itemValue
*
SummaryEvaluationValue
)
SetBlankValue
(
evaluation
*
SummaryEvaluation
,
item
*
EvaluationItemUsed
)
{
itemValue
.
EvaluationItemId
=
item
.
Id
itemValue
.
SummaryEvaluationId
=
evaluation
.
Id
itemValue
.
Value
=
""
itemValue
.
Score
=
""
itemValue
.
Remark
=
""
itemValue
.
Types
=
evaluation
.
Types
itemValue
.
Weight
=
item
.
Weight
itemValue
.
CreatedAt
=
time
.
Now
()
itemValue
.
UpdatedAt
=
time
.
Now
()
}
...
...
pkg/infrastructure/repository/pg_evaluation_item_used_repository.go
查看文件 @
662e31d
...
...
@@ -71,7 +71,7 @@ func (repo *EvaluationItemUsedRepository) Find(queryOptions map[string]interface
tx
:=
repo
.
transactionContext
.
PgTx
var
m
[]
*
models
.
EvaluationItemUsed
query
:=
tx
.
Model
(
&
m
)
.
Where
(
"deleted_at isnull"
)
.
Limit
(
20
)
Where
(
"deleted_at isnull"
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
}
...
...
pkg/infrastructure/repository/pg_summary_evaluation_value_repository.go
查看文件 @
662e31d
...
...
@@ -98,13 +98,16 @@ func (repo *SummaryEvaluationValueRepository) Find(queryOptions map[string]inter
tx
:=
repo
.
transactionContext
.
PgTx
var
m
[]
*
models
.
SummaryEvaluationValue
query
:=
tx
.
Model
(
&
m
)
.
Where
(
"deleted_at isnull"
)
.
Limit
(
20
)
Where
(
"deleted_at isnull"
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
}
if
v
,
ok
:=
queryOptions
[
"summaryEvaluationId"
];
ok
{
query
.
Where
(
"summary_evaluation_id=?"
,
v
)
}
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
...
...
请
注册
或
登录
后发表评论