切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
702da2683f9bbd9fbbc48ec8ecabd583ff0a2894
1 个父辈
48aa8d68
1. 环节内容,增加必填项属性
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
141 行增加
和
129 行删除
pkg/application/staff_assess/service/service.go
pkg/domain/evaluation_template.go
pkg/domain/staff_assess_content.go
pkg/infrastructure/pg/models/staff_assess_content.go
pkg/infrastructure/repository/pg_staff_assess_content_repository.go
pkg/port/beego/controllers/import_controller.go
pkg/application/staff_assess/service/service.go
查看文件 @
702da26
此 diff 太大无法显示。
pkg/domain/evaluation_template.go
查看文件 @
702da26
...
...
@@ -19,6 +19,11 @@ const (
LinkNodeViewResult
int
=
5
// 环节-绩效结果查看
)
const
(
NodeRequiredNo
int
=
1
// 是否必填项-非必填
NodeRequiredYes
int
=
2
// 是否必填项-必填
)
type
EntryItem
struct
{
Title
string
`json:"title" comment:"填写标题"`
HintText
string
`json:"hintText" comment:"文本内容提示"`
...
...
@@ -35,6 +40,7 @@ type NodeContent struct {
PromptTitle
string
`json:"promptTitle" comment:"提示项标题"`
PromptText
string
`json:"promptText" comment:"提示项正文"`
EntryItems
[]
*
EntryItem
`json:"entryItems" comment:"填写项"`
Required
int
`json:"required" comment:"必填项"`
}
// LinkNode 评估流程、环节
...
...
pkg/domain/staff_assess_content.go
查看文件 @
702da26
package
domain
import
(
"errors"
"fmt"
"strconv"
"time"
)
//填写的评估内容
type
StaffAssessContent
struct
{
Id
int
`json:"id"`
//id
StaffAssessId
int
`json:"staffAssessId"`
//用户需要的评估项id
SortBy
int
`json:"sortBy"`
//排序
Category
string
`json:"category"`
//类别
Name
string
`json:"name"`
//名称
PromptTitle
string
`json:"promptTitle"`
//提示项标题
PromptText
string
`json:"promptText"`
//提示项正文
Remark
[]
AssessContemtRemark
`json:"remark"`
//填写的反馈
Value
string
`json:"value"`
//评估填写的值
ScoreValue
float64
`json:"scoreValue"`
// 填写值按规则Rule转换为相应的量化值
LevelValue
string
`json:"levelValue"`
// 填写值按规则Rule转换为相应的等级值
ReteResult
string
`json:"reteResult"`
//评估的结果
Rule
EvaluationRule
`json:"rule"`
//评估的选项规则
Weight
float64
`json:"weight" `
//"权重"
CreatedAt
time
.
Time
`json:"createdAt"`
//数据创建时间
UpdatedAt
time
.
Time
`json:"updatedAt"`
//数据更新时间
DeletedAt
*
time
.
Time
`json:"deletedAt"`
}
type
AssessContemtRemark
struct
{
Title
string
`json:"title"`
//comment:"填写标题"
HintText
string
`json:"hintText"`
// comment:"文本内容提示"
Definition
string
`json:"definition"`
//comment:"定义"
RemarkText
string
`json:"remarkText"`
// comment:"填写文本内容"
}
//TransformValue
//根据规则 rule 转换评填写的值
func
(
content
*
StaffAssessContent
)
TransformValue
()
error
{
switch
content
.
Rule
.
Type
{
case
EvaluationTypeRating
:
return
content
.
ratingValue
()
case
EvaluationTypeScore
:
return
content
.
scoreValue
()
}
return
nil
}
// 规则是评级方式
func
(
content
*
StaffAssessContent
)
ratingValue
()
error
{
levels
:=
content
.
Rule
.
Rating
.
Levels
for
_
,
v
:=
range
levels
{
if
v
.
Code
!=
content
.
Value
{
continue
}
content
.
LevelValue
=
v
.
Code
content
.
ScoreValue
=
v
.
QuantizedValue
content
.
ReteResult
=
v
.
Name
return
nil
}
return
errors
.
New
(
"评级填写的值错误"
)
}
// 规则是评分方式
func
(
content
*
StaffAssessContent
)
scoreValue
()
error
{
valueFloat
,
err
:=
strconv
.
ParseFloat
(
content
.
Value
,
64
)
if
err
!=
nil
{
return
errors
.
New
(
"评分填写的值错误"
)
}
rule
:=
&
content
.
Rule
if
valueFloat
<
rule
.
Score
.
Min
||
valueFloat
>
rule
.
Score
.
Max
{
return
fmt
.
Errorf
(
"评分填写的值超出限制,>=%f且<=%f"
,
rule
.
Score
.
Min
,
rule
.
Score
.
Max
)
}
//保留小数处理
fStr
:=
fmt
.
Sprintf
(
"%%.%df"
,
rule
.
Score
.
DecimalPlaces
)
valueStr
:=
fmt
.
Sprintf
(
fStr
,
valueFloat
)
content
.
Value
=
valueStr
if
rule
.
Score
.
IntervalState
==
0
{
// 未开启按分数子区间匹配等级
return
nil
}
for
_
,
v
:=
range
rule
.
Score
.
Levels
{
if
valueFloat
<
v
.
Start
||
valueFloat
>
v
.
End
{
continue
}
content
.
LevelValue
=
v
.
Code
content
.
ScoreValue
=
valueFloat
content
.
ReteResult
=
v
.
Name
return
nil
}
return
errors
.
New
(
"评分填写的值错误"
)
}
type
StaffAssessContentRepository
interface
{
Save
(
param
*
StaffAssessContent
)
(
*
StaffAssessContent
,
error
)
Remove
(
id
int
)
error
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
StaffAssessContent
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
StaffAssessContent
,
error
)
}
package
domain
import
(
"errors"
"fmt"
"strconv"
"time"
)
//填写的评估内容
type
StaffAssessContent
struct
{
Id
int
`json:"id"`
//id
StaffAssessId
int
`json:"staffAssessId"`
//用户需要的评估项id
SortBy
int
`json:"sortBy"`
//排序
Category
string
`json:"category"`
//类别
Name
string
`json:"name"`
//名称
PromptTitle
string
`json:"promptTitle"`
//提示项标题
PromptText
string
`json:"promptText"`
//提示项正文
Remark
[]
AssessContemtRemark
`json:"remark"`
//填写的反馈
Value
string
`json:"value"`
//评估填写的值
ScoreValue
float64
`json:"scoreValue"`
// 填写值按规则Rule转换为相应的量化值
LevelValue
string
`json:"levelValue"`
// 填写值按规则Rule转换为相应的等级值
ReteResult
string
`json:"reteResult"`
//评估的结果
Rule
EvaluationRule
`json:"rule"`
//评估的选项规则
Weight
float64
`json:"weight" `
//"权重"
Required
int
`json:"required"`
// 必填项
CreatedAt
time
.
Time
`json:"createdAt"`
//数据创建时间
UpdatedAt
time
.
Time
`json:"updatedAt"`
//数据更新时间
DeletedAt
*
time
.
Time
`json:"deletedAt"`
}
type
AssessContemtRemark
struct
{
Title
string
`json:"title"`
//comment:"填写标题"
HintText
string
`json:"hintText"`
// comment:"文本内容提示"
Definition
string
`json:"definition"`
//comment:"定义"
RemarkText
string
`json:"remarkText"`
// comment:"填写文本内容"
}
//TransformValue
//根据规则 rule 转换评填写的值
func
(
content
*
StaffAssessContent
)
TransformValue
()
error
{
switch
content
.
Rule
.
Type
{
case
EvaluationTypeRating
:
return
content
.
ratingValue
()
case
EvaluationTypeScore
:
return
content
.
scoreValue
()
}
return
nil
}
// 规则是评级方式
func
(
content
*
StaffAssessContent
)
ratingValue
()
error
{
levels
:=
content
.
Rule
.
Rating
.
Levels
for
_
,
v
:=
range
levels
{
if
v
.
Code
!=
content
.
Value
{
continue
}
content
.
LevelValue
=
v
.
Code
content
.
ScoreValue
=
v
.
QuantizedValue
content
.
ReteResult
=
v
.
Name
return
nil
}
return
errors
.
New
(
"评级填写的值错误"
)
}
// 规则是评分方式
func
(
content
*
StaffAssessContent
)
scoreValue
()
error
{
valueFloat
,
err
:=
strconv
.
ParseFloat
(
content
.
Value
,
64
)
if
err
!=
nil
{
return
errors
.
New
(
"评分填写的值错误"
)
}
rule
:=
&
content
.
Rule
if
valueFloat
<
rule
.
Score
.
Min
||
valueFloat
>
rule
.
Score
.
Max
{
return
fmt
.
Errorf
(
"评分填写的值超出限制,>=%f且<=%f"
,
rule
.
Score
.
Min
,
rule
.
Score
.
Max
)
}
//保留小数处理
fStr
:=
fmt
.
Sprintf
(
"%%.%df"
,
rule
.
Score
.
DecimalPlaces
)
valueStr
:=
fmt
.
Sprintf
(
fStr
,
valueFloat
)
content
.
Value
=
valueStr
if
rule
.
Score
.
IntervalState
==
0
{
// 未开启按分数子区间匹配等级
return
nil
}
for
_
,
v
:=
range
rule
.
Score
.
Levels
{
if
valueFloat
<
v
.
Start
||
valueFloat
>
v
.
End
{
continue
}
content
.
LevelValue
=
v
.
Code
content
.
ScoreValue
=
valueFloat
content
.
ReteResult
=
v
.
Name
return
nil
}
return
errors
.
New
(
"评分填写的值错误"
)
}
type
StaffAssessContentRepository
interface
{
Save
(
param
*
StaffAssessContent
)
(
*
StaffAssessContent
,
error
)
Remove
(
id
int
)
error
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
StaffAssessContent
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
StaffAssessContent
,
error
)
}
...
...
pkg/infrastructure/pg/models/staff_assess_content.go
查看文件 @
702da26
package
models
import
(
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 填写的评估内容
type
StaffAssessContent
struct
{
tableName
struct
{}
`pg:"staff_assess_content" comment:"填写的评估项"`
Id
int
`pg:",pk"`
//id
StaffAssessId
int
//用户需要的评估项id
SortBy
int
//排序
Category
string
//类别
Name
string
//名称
ScoreValue
float64
// 填写值按规则Rule转换为相应的量化值
LevelValue
string
// 填写值按规则Rule转换为相应的等级值
PromptTitle
string
//问题标题
PromptText
string
//提示项正文
Value
string
//评估填写的值
ReteResult
string
//评估的结果
Rule
domain
.
EvaluationRule
Remark
[]
domain
.
AssessContemtRemark
Weight
float64
`pg:",use_zero"`
//权重
CreatedAt
time
.
Time
//数据创建时间
UpdatedAt
time
.
Time
//数据更新时间
DeletedAt
*
time
.
Time
}
package
models
import
(
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 填写的评估内容
type
StaffAssessContent
struct
{
tableName
struct
{}
`pg:"staff_assess_content" comment:"填写的评估项"`
Id
int
`pg:",pk"`
//id
StaffAssessId
int
//用户需要的评估项id
SortBy
int
//排序
Category
string
//类别
Name
string
//名称
ScoreValue
float64
// 填写值按规则Rule转换为相应的量化值
LevelValue
string
// 填写值按规则Rule转换为相应的等级值
PromptTitle
string
//问题标题
PromptText
string
//提示项正文
Value
string
//评估填写的值
ReteResult
string
//评估的结果
Rule
domain
.
EvaluationRule
Remark
[]
domain
.
AssessContemtRemark
Weight
float64
`pg:",use_zero"`
//权重
Required
int
//必填项
CreatedAt
time
.
Time
//数据创建时间
UpdatedAt
time
.
Time
//数据更新时间
DeletedAt
*
time
.
Time
}
...
...
pkg/infrastructure/repository/pg_staff_assess_content_repository.go
查看文件 @
702da26
...
...
@@ -37,6 +37,7 @@ func (repo *StaffAssessContentRepository) TransformToDomain(d *models.StaffAsses
ReteResult
:
d
.
ReteResult
,
Rule
:
d
.
Rule
,
Weight
:
d
.
Weight
,
Required
:
d
.
Required
,
CreatedAt
:
d
.
CreatedAt
,
UpdatedAt
:
d
.
UpdatedAt
,
DeletedAt
:
nil
,
...
...
@@ -59,6 +60,7 @@ func (repo *StaffAssessContentRepository) Save(d *domain.StaffAssessContent) (*d
Rule
:
d
.
Rule
,
Remark
:
d
.
Remark
,
Weight
:
d
.
Weight
,
Required
:
d
.
Required
,
CreatedAt
:
d
.
CreatedAt
,
UpdatedAt
:
d
.
UpdatedAt
,
DeletedAt
:
nil
,
...
...
pkg/port/beego/controllers/import_controller.go
查看文件 @
702da26
...
...
@@ -120,6 +120,8 @@ func (controller *ImportController) parseTemplateNodeContent(data []*domain.Perf
})
}
// 必填项
nc
.
Required
=
domain
.
NodeRequiredNo
nodeContents
=
append
(
nodeContents
,
nc
)
}
}
...
...
请
注册
或
登录
后发表评论