切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
庄敏学
2 years ago
提交
971e4c143e26d68eaadfc6a20c356c049dfde509
2 个父辈
913ae62d
96bb5ff3
master
...
dev-pushdata
dev-tangxvhui
dev-zhengzhou
test
v1.3.2-fix
v1.4.0
v2.2.0-fix
20230410
20230403
20230331
20230324
20230315
20230203
20230112
20221208
20221205
v2.2.0
v2.0.0
v1.3.2
v1.3.2-fix
v1.3.1
v1.3.0
v1.2.4
合并
隐藏空白字符变更
内嵌
并排对比
正在显示
54 个修改的文件
包含
1470 行增加
和
303 行删除
go.mod
go.sum
go_build_main_go
main.go
pkg/application/evaluation_cycle/command/cycle_create.go
pkg/application/evaluation_cycle/command/cycle_query.go
pkg/application/evaluation_cycle/command/cycle_update.go
pkg/application/evaluation_cycle/cycle_service.go
pkg/application/evaluation_project/command/project_update.go
pkg/application/evaluation_project/project_service.go
pkg/application/evaluation_template/command/template_query.go
pkg/application/evaluation_template/command/template_update.go
pkg/application/evaluation_template/template_service.go
pkg/application/factory/reposetory.go
pkg/application/node_task/node_task_service.go
pkg/application/role/role_user_service.go
pkg/application/staff_assess/adapter/assess_info.go
pkg/application/staff_assess/adapter/list_invite_user_assess.go
pkg/application/staff_assess/adapter/list_supper_assess.go
pkg/application/staff_assess/command/create_staff_assess_task.go
pkg/application/staff_assess/command/save_assess_info.go
pkg/application/staff_assess/query/List_supper_assess.go
pkg/application/staff_assess/query/assess_self_info.go
pkg/application/staff_assess/query/list_invite_user_assess copy.go
pkg/application/staff_assess/query/list_invite_user_assess.go
pkg/application/staff_assess/query/list_target_user_assess.go
pkg/application/staff_assess/service/service.go
pkg/domain/evaluation_template.go
pkg/domain/node_timer_task.go → pkg/domain/node_task.go
pkg/domain/position.go
pkg/domain/staff_assess.go
pkg/domain/staff_assess_task.go
pkg/domain/staff_desc.go
pkg/infrastructure/dao/staff_assess_dao.go
pkg/infrastructure/pg/init.go
pkg/infrastructure/pg/models/node_task.go
pkg/infrastructure/pg/models/staff_assess_task.go
pkg/infrastructure/repository/pg_evaluation_cycle_repository.go
pkg/infrastructure/repository/pg_evaluation_cycle_template_repository.go
pkg/infrastructure/repository/pg_evaluation_project_repository.go
pkg/infrastructure/repository/pg_evaluation_rule_repository.go
pkg/infrastructure/repository/pg_evaluation_template_repository.go
pkg/infrastructure/repository/pg_node_task_repository.go
pkg/infrastructure/repository/pg_position_repository.go
pkg/infrastructure/repository/pg_role_repository.go
pkg/infrastructure/repository/pg_role_user_repository.go
pkg/infrastructure/repository/pg_staff_assess_repository.go
pkg/infrastructure/repository/pg_staff_assess_task_repository.go
pkg/infrastructure/repository/pg_user_repository.go
pkg/port/beego/controllers/evaluation_cycle_controller.go
pkg/port/beego/controllers/staff_assess_controller.go
pkg/port/beego/routers/evaluation_cycle_router.go
pkg/port/beego/routers/staff_assess_router.go
pkg/utils/common.go
go.mod
查看文件 @
971e4c1
...
...
@@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/allied-creation/performance
go 1.16
require (
github.com/Andrew-M-C/go.timeconv v0.4.0
github.com/Shopify/sarama v1.25.0
github.com/beego/beego/v2 v2.0.5
github.com/bwmarrin/snowflake v0.3.0
...
...
go.sum
查看文件 @
971e4c1
...
...
@@ -31,6 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Andrew-M-C/go.timeconv v0.4.0 h1:jwSSP1Nru7Hh+XDxIy8Bt/a2kdjqW/xIKkLFhBc/bmA=
github.com/Andrew-M-C/go.timeconv v0.4.0/go.mod h1:qKsoTE6tDyot1aOcAESJA5GBDxl3sns9YesrA8gBLVo=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
...
...
go_build_main_go
已删除
100755 → 0
查看文件 @
913ae62
不能预览此文件类型
main.go
查看文件 @
971e4c1
...
...
@@ -2,11 +2,16 @@ package main
import
(
"github.com/beego/beego/v2/server/web"
service
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
_
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer"
"time"
)
func
main
()
{
startNodeTask
()
// tree := web.PrintTree()
// methods := tree["Data"].(web.M)
// for k, v := range methods {
...
...
@@ -15,3 +20,17 @@ func main() {
go
consumer
.
Run
()
web
.
Run
()
}
// 定时任务-间隔发送评估环节
func
startNodeTask
()
{
go
func
()
{
nodeTaskService
:=
service
.
NewNodeTaskService
()
for
{
timer
:=
time
.
NewTimer
(
time
.
Second
*
60
)
<-
timer
.
C
if
err
:=
nodeTaskService
.
SendEvaluationNode
();
err
!=
nil
{
log
.
Logger
.
Error
(
err
.
Error
())
}
}
}()
}
...
...
pkg/application/evaluation_cycle/command/cycle_create.go
查看文件 @
971e4c1
...
...
@@ -2,17 +2,16 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
CreateCycleCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CreatorId
int64
`cname:"创建人ID" json:"creatorId"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
*
time
.
Time
`cname:"起始时间" json:"timeStart"`
TimeEnd
*
time
.
Time
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CreatorId
int64
`cname:"创建人ID" json:"creatorId"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
string
`cname:"起始时间" json:"timeStart"`
TimeEnd
string
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
}
func
(
in
*
CreateCycleCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
@@ -25,19 +24,24 @@ func (in *CreateCycleCommand) Valid(validation *validation.Validation) {
return
}
if
len
(
in
.
Name
)
>
40
{
validation
.
SetError
(
"name"
,
"
角色
名称最大长度40个字符"
)
validation
.
SetError
(
"name"
,
"名称最大长度40个字符"
)
return
}
if
in
.
TimeStart
==
nil
{
if
in
.
KpiCycle
==
0
{
validation
.
SetError
(
"kpiCycle"
,
"请选择考核周期"
)
return
}
if
len
(
in
.
TimeStart
)
==
0
{
validation
.
SetError
(
"timeStart"
,
"请选择考核周期的开始时间"
)
return
}
if
in
.
TimeEnd
==
nil
{
if
len
(
in
.
TimeEnd
)
==
0
{
validation
.
SetError
(
"timeEnd"
,
"请选择考核周期的结束时间"
)
return
}
if
len
(
in
.
TemplateIds
)
==
0
{
validation
.
SetError
(
"templates"
,
"请
选择周期内使用的
评估模板"
)
validation
.
SetError
(
"templates"
,
"请
添加
评估模板"
)
return
}
}
...
...
pkg/application/evaluation_cycle/command/cycle_query.go
查看文件 @
971e4c1
...
...
@@ -19,8 +19,7 @@ type CycleTemplateListCommand struct {
}
type
CycleTemplateCommand
struct
{
CycleId
int64
`cname:"周期ID" json:"cycleId,string" valid:"Required"`
TemplateId
int64
`cname:"模板ID" json:"templateId,string" valid:"Required"`
Id
int64
`cname:"模板ID" json:"id,string" valid:"Required"`
}
func
(
in
*
QueryCycleCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
pkg/application/evaluation_cycle/command/cycle_update.go
查看文件 @
971e4c1
...
...
@@ -2,17 +2,16 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
UpdateCycleCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Id
int64
`cname:"周期ID" json:"id,string" valid:"Required"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
*
time
.
Time
`cname:"起始时间" json:"timeStart"`
TimeEnd
*
time
.
Time
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Id
int64
`cname:"周期ID" json:"id,string" valid:"Required"`
Name
string
`cname:"周期名称" json:"name" valid:"Required"`
TimeStart
string
`cname:"起始时间" json:"timeStart"`
TimeEnd
string
`cname:"截至时间" json:"timeEnd"`
KpiCycle
int
`cname:"考核周期(0日、1周、2月)" json:"kpiCycle" valid:"Required"`
TemplateIds
[]
string
`cname:"周期使用模板ID" json:"templateIds"`
}
func
(
in
*
UpdateCycleCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
@@ -20,11 +19,11 @@ func (in *UpdateCycleCommand) Valid(validation *validation.Validation) {
validation
.
SetError
(
"name"
,
"角色名称最大长度40个字符"
)
return
}
if
in
.
TimeStart
==
nil
{
if
len
(
in
.
TimeStart
)
==
0
{
validation
.
SetError
(
"timeStart"
,
"请选择考核周期的开始时间"
)
return
}
if
in
.
TimeEnd
==
nil
{
if
len
(
in
.
TimeEnd
)
==
0
{
validation
.
SetError
(
"timeEnd"
,
"请选择考核周期的结束时间"
)
return
}
...
...
pkg/application/evaluation_cycle/cycle_service.go
查看文件 @
971e4c1
...
...
@@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"strconv"
"time"
)
type
EvaluationCycleService
struct
{
...
...
@@ -38,7 +39,7 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
count
>
0
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"
名称已存在
"
)
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"
已存在相同名称的周期
"
)
}
_
,
templates
,
err
:=
templateRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"ids"
:
in
.
TemplateIds
})
...
...
@@ -49,12 +50,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"模板不存在, 请重新选择"
)
}
start
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeStart
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
end
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeEnd
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 生成新周期数据
newCycle
:=
&
domain
.
EvaluationCycle
{
Id
:
0
,
Name
:
in
.
Name
,
TimeStart
:
in
.
TimeStart
,
TimeEnd
:
in
.
TimeEnd
,
TimeStart
:
&
start
,
TimeEnd
:
&
end
,
CompanyId
:
in
.
CompanyId
,
CreatorId
:
in
.
CreatorId
,
KpiCycle
:
in
.
KpiCycle
,
...
...
@@ -65,19 +75,27 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
}
// 获取所有模板中的规则对象数据
ruleIds
:=
make
([]
int64
,
0
)
ruleMap
:=
map
[
int64
]
*
domain
.
EvaluationRule
{}
ruleIdsMap
:=
map
[
int64
]
int64
{}
for
i
:=
range
templates
{
v
:=
templates
[
i
]
for
j
:=
range
v
.
LinkNodes
{
node
:=
v
.
LinkNodes
[
j
]
for
k
:=
range
node
.
NodeContents
{
nodeContent
:=
node
.
NodeContents
[
k
]
ruleIds
=
append
(
ruleIds
,
nodeContent
.
RuleId
)
if
nodeContent
.
RuleId
!=
0
{
ruleIdsMap
[
nodeContent
.
RuleId
]
=
nodeContent
.
RuleId
}
}
}
}
ruleIds
:=
make
([]
int64
,
0
)
for
k
:=
range
ruleIdsMap
{
ruleIds
=
append
(
ruleIds
,
k
)
}
_
,
rules
,
err
:=
ruleRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
ruleIds
,
"companyId"
:
in
.
CompanyId
})
ruleMap
:=
map
[
int64
]
*
domain
.
EvaluationRule
{}
for
i
:=
range
rules
{
ruleMap
[
rules
[
i
]
.
Id
]
=
rules
[
i
]
}
...
...
@@ -202,9 +220,18 @@ func (rs *EvaluationCycleService) Update(in *command.UpdateCycleCommand) (interf
}
}
start
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeStart
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
end
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeEnd
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
cycle
.
Name
=
in
.
Name
cycle
.
TimeStart
=
in
.
TimeStart
cycle
.
TimeEnd
=
in
.
TimeEnd
cycle
.
TimeStart
=
&
start
cycle
.
TimeEnd
=
&
end
cycle
.
KpiCycle
=
in
.
KpiCycle
cycle
,
err
=
cycleRepository
.
Insert
(
cycle
)
if
err
!=
nil
{
...
...
@@ -313,6 +340,10 @@ func (rs *EvaluationCycleService) List(in *command.QueryCycleCommand) (interface
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
tool_funs
.
SimpleWrapGridMap
(
total
,
cycles
),
nil
}
...
...
@@ -325,7 +356,7 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
transactionContext
.
RollbackTransaction
()
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
projects
,
err
:=
projectRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
),
"
linkNodes
"
)
_
,
projects
,
err
:=
projectRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
),
"
template
"
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
@@ -339,8 +370,8 @@ func (rs *EvaluationCycleService) StatisticCycleUser(in *command.StatisticCycleP
userIdMap
[
userId
]
=
userId
}
}
for
_
,
v
:=
range
userIdMap
{
userIds
=
append
(
userIds
,
v
)
for
k
:=
range
userIdMap
{
userIds
=
append
(
userIds
,
k
)
}
userTotal
:=
0
...
...
@@ -404,7 +435,7 @@ func (rs *EvaluationCycleService) CycleTemplate(in *command.CycleTemplateCommand
}()
cycleTemplateRepository
:=
factory
.
CreateEvaluationCycleTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleTemplate
,
err
:=
cycleTemplateRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Template
Id
})
cycleTemplate
,
err
:=
cycleTemplateRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
pkg/application/evaluation_project/command/project_update.go
查看文件 @
971e4c1
...
...
@@ -2,7 +2,6 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
UpdateProjectCommand
struct
{
...
...
@@ -17,16 +16,16 @@ type UpdateProjectCommand struct {
}
type
UpdateProjectTemplateCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CycleId
int64
`cname:"周期ID" json:"cycleId,string" valid:"Required"`
Id
int64
`cname:"项目ID" json:"id,string" valid:"Required"`
TemplateId
int64
`cname:"模板ID" json:"templateId,string"`
Recipients
[]
string
`cname:"被评估人ID" json:"recipients"`
TimeStart
*
time
.
Time
`cname:"自评起始时间" json:"timeStart" valid:"Required"`
TimeEnd
*
time
.
Time
`cname:"自评截止时间" json:"timeEnd" valid:"Required"`
KpiCycle
int
`cname:"评估周期" json:"kpiCycle" valid:"Required"`
KpiResultStart
*
time
.
Time
`cname:"绩效结果开始查看时间" json:"kpiResultStart"`
Activate
int
`cname:"启动项目" json:"activate"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
CycleId
int64
`cname:"周期ID" json:"cycleId,string" valid:"Required"`
Id
int64
`cname:"项目ID" json:"id,string" valid:"Required"`
TemplateId
int64
`cname:"模板ID" json:"templateId,string"`
Recipients
[]
string
`cname:"被评估人ID" json:"recipients"`
TimeStart
string
`cname:"自评起始时间" json:"timeStart" valid:"Required"`
TimeEnd
string
`cname:"自评截止时间" json:"timeEnd" valid:"Required"`
KpiCycle
int
`cname:"评估周期" json:"kpiCycle" valid:"Required"`
KpiResultStart
string
`cname:"绩效结果开始查看时间" json:"kpiResultStart"`
Activate
int
`cname:"启动项目" json:"activate"`
}
type
CheckRecipientCommand
struct
{
...
...
@@ -48,4 +47,13 @@ func (in *UpdateProjectTemplateCommand) Valid(validation *validation.Validation)
validation
.
SetError
(
"recipients"
,
"请添加被评估人"
)
return
}
if
len
(
in
.
TimeStart
)
==
0
{
validation
.
SetError
(
"timeEnd"
,
"请选择开始时间"
)
return
}
if
len
(
in
.
TimeEnd
)
==
0
{
validation
.
SetError
(
"timeEnd"
,
"请选择结束时间"
)
return
}
}
...
...
pkg/application/evaluation_project/project_service.go
查看文件 @
971e4c1
...
...
@@ -8,7 +8,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_project/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"strconv"
"time"
)
type
EvaluationProjectService
struct
{
...
...
@@ -130,9 +132,15 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleRepository
:=
factory
.
CreateEvaluationCycleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleTemplateRepository
:=
factory
.
CreateEvaluationCycleTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"cycleId"
:
in
.
CycleId
},
"linkNodes"
)
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"cycleId"
:
in
.
CycleId
},
"template"
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
cycle
,
err
:=
cycleRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
CycleId
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
@@ -177,18 +185,42 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
project
.
State
=
domain
.
ProjectStateEnable
}
start
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeStart
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
end
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeEnd
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
kpiStart
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
KpiResultStart
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
minTime
:=
time
.
Date
(
cycle
.
TimeStart
.
Year
(),
cycle
.
TimeStart
.
Month
(),
cycle
.
TimeStart
.
Day
(),
cycle
.
TimeStart
.
Hour
(),
cycle
.
TimeStart
.
Minute
(),
0
,
0
,
time
.
Local
)
maxTime
:=
time
.
Date
(
cycle
.
TimeEnd
.
Year
(),
cycle
.
TimeEnd
.
Month
(),
cycle
.
TimeEnd
.
Day
(),
cycle
.
TimeEnd
.
Hour
(),
cycle
.
TimeEnd
.
Minute
(),
0
,
0
,
time
.
Local
)
if
start
.
Before
(
minTime
)
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"评估起始时间不能超出周期起始时间"
)
}
if
end
.
After
(
maxTime
)
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"评估截至时间不能超出周期截至时间"
)
}
project
.
Recipients
=
in
.
Recipients
project
.
Template
=
cycleTemplate
.
Template
for
i
:=
range
project
.
Template
.
LinkNodes
{
node
:=
project
.
Template
.
LinkNodes
[
i
]
node
.
KpiCycle
=
in
.
KpiCycle
// 设置周期
if
node
.
Type
==
domain
.
LinkNodeViewResult
{
if
in
.
KpiResultStart
!=
nil
{
node
.
TimeStart
=
in
.
KpiResultStart
if
len
(
in
.
KpiResultStart
)
>
0
{
node
.
TimeStart
=
&
kpiStart
}
}
else
{
node
.
TimeStart
=
in
.
TimeStart
node
.
TimeEnd
=
in
.
TimeEnd
node
.
TimeStart
=
&
start
node
.
TimeEnd
=
&
end
}
}
...
...
@@ -271,7 +303,7 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
total
,
projects
,
err
:=
projectRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
),
"
linkNodes
"
)
total
,
projects
,
err
:=
projectRepository
.
Find
(
tool_funs
.
SimpleStructToMap
(
in
),
"
template
"
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
@@ -303,6 +335,8 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
//cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
project
,
err
:=
projectRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -316,17 +350,96 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"请添加被评估人"
)
}
//cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": project.CycleId})
//if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
//startMin := cycle.TimeStart
//maxTime := cycle.TimeEnd
project
.
State
=
domain
.
TemplateStateEnable
project
,
err
=
projectRepository
.
Insert
(
project
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
taskRepository
:=
factory
.
CreateNodeTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
now
:=
time
.
Now
()
.
Local
()
nowO
:=
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
Day
(),
0
,
0
,
0
,
0
,
time
.
Local
)
// 当前时间0点0分0秒时刻
for
i
:=
range
project
.
Template
.
LinkNodes
{
node
:=
project
.
Template
.
LinkNodes
[
i
]
task
:=
&
domain
.
NodeTask
{
Id
:
0
,
CompanyId
:
project
.
CompanyId
,
CycleId
:
project
.
CycleId
,
ProjectId
:
project
.
Id
,
NodeId
:
node
.
Id
,
KpiCycle
:
node
.
KpiCycle
,
BeginAt
:
node
.
TimeStart
,
EndAt
:
node
.
TimeEnd
,
}
// 在当前时间之前,则计算下一个周期时间
if
node
.
TimeStart
.
Before
(
now
)
{
nextTime
:=
utils
.
NextTime
(
nowO
,
node
.
TimeStart
,
node
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
else
{
task
.
NextSentAt
=
node
.
TimeStart
}
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
After
(
*
node
.
TimeEnd
)
{
task
.
NextSentAt
=
nil
}
task
,
err
:=
taskRepository
.
Insert
(
task
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
project
,
nil
}
//
//// 0点时刻为标准计算
//func (rs *EvaluationProjectService) nextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time {
// // 起始时间0点时刻
// start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local)
//
// var nextTime time.Time
// switch kpiCycle {
// case domain.KpiCycleDay:
// nextTime = timeconv.AddDate(now0, 0, 0, 1) // 当前时间的下一天开始发送
// break
// case domain.KpiCycleWeek:
// offsetSeconds := int64(now0.Sub(start0).Seconds())
// offsetDay := offsetSeconds / (24 * 60 * 60)
// cycleCount := int(offsetDay)/7 + 1
// nextTime = timeconv.AddDate(start0, 0, 0, cycleCount*7)
// break
// case domain.KpiCycleOneMonth:
// nextTime = timeconv.AddDate(start0, 0, 1, 0)
// break
// case domain.KpiCycleTwoMonth:
// nextTime = timeconv.AddDate(start0, 0, 2, 0)
// break
// case domain.KpiCycleThreeMonth:
// nextTime = timeconv.AddDate(start0, 0, 3, 0)
// break
// case domain.KpiCycleSixMonth:
// nextTime = timeconv.AddDate(start0, 0, 6, 0)
// break
// case domain.KpiCycleYear:
// nextTime = timeconv.AddDate(start0, 1, 0, 0)
// break
// }
// return nextTime
//}
func
(
rs
*
EvaluationProjectService
)
Copy
(
in
*
command
.
CopyProjectCommand
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
...
...
@@ -371,7 +484,7 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"cycleId"
:
in
.
CycleId
},
"
linkNodes
"
)
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"cycleId"
:
in
.
CycleId
},
"
template
"
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
@@ -404,5 +517,5 @@ func (rs *EvaluationProjectService) CheckRecipients(in *command.CheckRecipientCo
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
repeatNum
,
nil
return
map
[
string
]
interface
{}{
"repeatNum"
:
repeatNum
}
,
nil
}
...
...
pkg/application/evaluation_template/command/template_query.go
查看文件 @
971e4c1
...
...
@@ -2,16 +2,15 @@ package command
import
(
"github.com/beego/beego/v2/core/validation"
"time"
)
type
QueryTemplateCommand
struct
{
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name"`
State
int
`cname:"模板状态" json:"state"`
CreatedAt
*
time
.
Time
`cname:"创建时间" json:"createdAt"`
PageNumber
int64
`cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize
int64
`cname:"分页数量" json:"pageSize" valid:"Required"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name"`
State
int
`cname:"模板状态" json:"state"`
CreatedAt
string
`cname:"创建时间" json:"createdAt"`
PageNumber
int64
`cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize
int64
`cname:"分页数量" json:"pageSize" valid:"Required"`
}
func
(
in
*
QueryTemplateCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
pkg/application/evaluation_template/command/template_update.go
查看文件 @
971e4c1
...
...
@@ -6,11 +6,12 @@ import (
)
type
UpdateTemplateCommand
struct
{
Id
int64
`cname:"模板ID" json:"id,string" valid:"Required"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name" valid:"Required"`
Describe
string
`cname:"模板描述" json:"describe"`
LinkNodes
[]
*
domain
.
LinkNode
`cname:"评估流程" json:"linkNodes"`
Id
int64
`cname:"模板ID" json:"id,string" valid:"Required"`
CompanyId
int64
`cname:"公司ID" json:"companyId"`
Name
string
`cname:"模板名称" json:"name" valid:"Required"`
Describe
string
`cname:"模板描述" json:"describe"`
LinkNodes
[]
*
domain
.
LinkNode
`cname:"评估流程" json:"linkNodes"`
FinishConfig
int
`cname:"配置" json:"finishConfig"`
}
func
(
in
*
UpdateTemplateCommand
)
Valid
(
validation
*
validation
.
Validation
)
{
...
...
pkg/application/evaluation_template/template_service.go
查看文件 @
971e4c1
...
...
@@ -125,6 +125,11 @@ func (rs *EvaluationTemplateService) Update(in *command.UpdateTemplateCommand) (
template
.
Describe
=
in
.
Describe
template
.
LinkNodes
=
in
.
LinkNodes
// 完成配置保存,更新状态
if
in
.
FinishConfig
==
1
&&
template
.
State
==
domain
.
TemplateStateWaitConfig
{
template
.
State
=
domain
.
TemplateStateWaitActive
}
template
,
err
=
templateRepository
.
Insert
(
template
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -190,7 +195,7 @@ func (rs *EvaluationTemplateService) List(in *command.QueryTemplateCommand) (int
}()
queryOptions
:=
tool_funs
.
SimpleStructToMap
(
in
)
if
in
.
CreatedAt
==
nil
{
if
len
(
in
.
CreatedAt
)
==
0
{
delete
(
queryOptions
,
"createdAt"
)
// 删除创建时间
}
...
...
pkg/application/factory/reposetory.go
查看文件 @
971e4c1
...
...
@@ -129,6 +129,14 @@ func CreateEvaluationProjectRepository(options map[string]interface{}) domain.Ev
return
repository
.
NewEvaluationProjectRepository
(
transactionContext
)
}
func
CreateNodeTaskRepository
(
options
map
[
string
]
interface
{})
domain
.
NodeTaskRepository
{
var
transactionContext
*
pg
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
transactionContext
=
value
.
(
*
pg
.
TransactionContext
)
}
return
repository
.
NewNodeTaskRepository
(
transactionContext
)
}
func
CreateStaffAssessRepository
(
options
map
[
string
]
interface
{})
domain
.
StaffAssessRepository
{
var
transactionContext
*
pg
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
...
...
pkg/application/node_task/node_task_service.go
0 → 100644
查看文件 @
971e4c1
package
service
import
(
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"time"
)
type
NodeTaskService
struct
{
}
func
NewNodeTaskService
()
*
NodeTaskService
{
newRoleService
:=
&
NodeTaskService
{}
return
newRoleService
}
// SendEvaluationNode 发送评估环节
func
(
rs
*
NodeTaskService
)
SendEvaluationNode
()
error
{
transactionContext
,
err
:=
factory
.
StartTransaction
()
if
err
!=
nil
{
return
err
}
defer
func
()
{
transactionContext
.
RollbackTransaction
()
}()
taskRepository
:=
factory
.
CreateNodeTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
//cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
tasks
,
err
:=
taskRepository
.
Find
(
map
[
string
]
interface
{}{
"now"
:
time
.
Now
()
.
Local
()})
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
//
projectIdsMap
:=
map
[
int64
]
*
domain
.
EvaluationProject
{}
cycleIdsMap
:=
map
[
int64
]
*
domain
.
EvaluationCycle
{}
for
i
:=
range
tasks
{
task
:=
tasks
[
i
]
projectIdsMap
[
task
.
ProjectId
]
=
nil
cycleIdsMap
[
task
.
CycleId
]
=
nil
}
projectIds
:=
make
([]
int64
,
0
)
cycleIds
:=
make
([]
int64
,
0
)
for
k
:=
range
projectIdsMap
{
projectIds
=
append
(
projectIds
,
k
)
}
for
k
:=
range
cycleIdsMap
{
cycleIds
=
append
(
cycleIds
,
k
)
}
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
projectIds
})
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//_, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds})
//if err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}
for
i
:=
range
projects
{
projectIdsMap
[
projects
[
i
]
.
Id
]
=
projects
[
i
]
}
//staffAssessService := service.NewStaffAssessServeice()
for
i
:=
range
tasks
{
task
:=
tasks
[
i
]
//if project, ok := projectIdsMap[task.ProjectId]; ok {
//csat := &command.CreateStaffAssessTask{
// CompanyId: project.CompanyId,
// EvaluationProjectId: project.Id,
// EvaluationProjectName: project.Name,
// CycleId: project.CycleId,
//}
//
//staffAssessService.CreateStaffAssessTask(csat)
//}
// 下一次发送时间
nextTime
:=
utils
.
NextTimeInc
(
task
.
NextSentAt
,
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
After
(
*
task
.
EndAt
)
{
task
.
NextSentAt
=
nil
}
task
,
err
:=
taskRepository
.
Insert
(
task
)
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
nil
}
...
...
pkg/application/role/role_user_service.go
查看文件 @
971e4c1
...
...
@@ -34,7 +34,7 @@ func (rs *RoleUserService) Create(in *command.UserRoleCreateCommand) (interface{
// int64Array = append(int64Array, int64Num)
//}
// 检测已存在的关联用户
_
,
rus
,
err
:=
roleUserRepository
.
Find
(
map
[
string
]
interface
{}{
"roleId"
:
in
.
RoleId
,
"companyId"
:
in
.
CompanyId
,
"userIds"
:
in
.
UserIds
,
"limit"
:
9999999
})
_
,
rus
,
err
:=
roleUserRepository
.
Find
(
map
[
string
]
interface
{}{
"roleId"
:
in
.
RoleId
,
"companyId"
:
in
.
CompanyId
,
"userIds"
:
in
.
UserIds
,
"limit"
:
int64
(
9999999
)
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
pkg/application/staff_assess/adapter/assess_info.go
查看文件 @
971e4c1
...
...
@@ -9,16 +9,18 @@ type AssessInfoResp struct {
CycleName
string
`json:"cycleName"`
//周期名称
EvaluationProjectId
int
`json:"evaluationProjectId"`
//项目id
EvaluationProjectName
string
`json:"evaluationProjectName"`
//项目名称
BeginTime
string
`json:"beginTime"`
//开始时间 2006-01-02 15:04:05
EndTime
string
`json:"endTime"`
//结束时间 2006-01-02 15:04:05
Status
string
`json:"status"`
//完成状态
TargetUserId
int
`json:"targetUser"`
//目标用户
TargetUserName
string
`json:"targetUserName"`
//目标用户名称
CompanyId
int
`json:"companyId,string"`
//
CompanyName
string
`json:"companyName"`
//公司名称
SupperUser
string
`json:"superUser"`
//目标用户的上级
DutyTime
string
`json:"dutyTime"`
//入职时间 //
AssessContent
[]
*
domain
.
StaffAssessContent
`json:"assessContent"`
//评估内容
LinkNodeId
int
`json:"linkNodeId"`
LinkNodeName
string
`json:"linkNodeName"`
BeginTime
string
`json:"beginTime"`
//开始时间 2006-01-02 15:04:05
EndTime
string
`json:"endTime"`
//结束时间 2006-01-02 15:04:05
Status
string
`json:"status"`
//完成状态
TargetUserId
int
`json:"targetUser"`
//目标用户
TargetUserName
string
`json:"targetUserName"`
//目标用户名称
CompanyId
int
`json:"companyId,string,"`
//
CompanyName
string
`json:"companyName"`
//公司名称
SupperUser
string
`json:"superUser"`
//目标用户的上级
DutyTime
string
`json:"dutyTime"`
//入职时间 //
AssessContent
[]
*
domain
.
StaffAssessContent
`json:"assessContent"`
//评估内容
}
type
AssessContent
struct
{
...
...
pkg/application/staff_assess/adapter/list_invite_user_assess.go
查看文件 @
971e4c1
package
adapter
type
ListInviteUserAssessResp
struct
{
TableHeader
[]
ListTableHeader
List
[]
map
[
string
]
string
Total
int
LinkNodeName
string
`json:"linkNodeName"`
LinkNodeId
int
`json:"linkNodeId"`
LintNodeDesc
string
`json:"lintNodeDesc"`
TableHeader
[]
ListTableHeader
`json:"tableHeader"`
List
[]
map
[
string
]
string
`json:"list"`
Total
int
`json:"total"`
}
type
ListTableHeader
struct
{
Key
string
Name
string
Key
string
`json:"key"`
Name
string
`json:"name"`
}
...
...
pkg/application/staff_assess/adapter/list_supper_assess.go
查看文件 @
971e4c1
package
adapter
type
ListSupperAssessResp
struct
{
AssessId
int
`json:"assessId"`
//
UserName
string
`json:"userName"`
//用户名称
EndTime
string
`json:"endTime"`
//截止时间
InviteTotal
int
`json:"inviteCompleted"`
//邀请总数
InviteUncompleted
int
`json:"inviteUncompleted"`
//邀请未完成
Department
string
`json:"department"`
//部门
Position
string
`json:"position"`
//职位
DutyTime
string
`json:"dutyTime"`
//入职时间
AssessId
int
`json:"assessId"`
//
UsrId
int
`json:"userId"`
UserName
string
`json:"userName"`
//用户名称
EndTime
string
`json:"endTime"`
//截止时间
InviteTotal
int
`json:"inviteTota"`
//邀请总数
InviteCompleted
int
`json:"inviteCompleted"`
//邀请未完成
Status
string
`json:"status"`
Department
string
`json:"department"`
//部门
Position
string
`json:"position"`
//职位
DutyTime
string
`json:"dutyTime"`
//入职时间
}
...
...
pkg/application/staff_assess/command/create_staff_assess_task.go
查看文件 @
971e4c1
...
...
@@ -6,8 +6,8 @@ type CreateStaffAssessTask struct {
EvaluationProjectName
string
`json:"evaluationProjectName"`
//项目名称
CycleId
int64
`json:"cycleId"`
//对应的周期id
CycleName
string
`json:"cycleName"`
//对应周期的名称
BeginTime
string
`json:"beginTime"`
//绩效考核开始时间
EndTime
string
`json:"endTime"`
//绩效考核截止时间
BeginTime
string
`json:"beginTime"`
//绩效考核开始时间 2006-01-02 15:04:05
EndTime
string
`json:"endTime"`
//绩效考核截止时间 2006-01-02 15:04:05
StepList
[]
AssessTaskStep
`json:"steps"`
//考评的流程
ExecutorId
[]
int
`json:"executorId"`
//参与此次考评的人
}
...
...
pkg/application/staff_assess/command/save_assess_info.go
0 → 100644
查看文件 @
971e4c1
package
command
//保存员工填写评估内容
type
SaveAssessInfoCommand
struct
{
AssessId
int
`json:"assessId"`
AssessContent
[]
AssesssContent
`json:"assessContent"`
}
type
AssesssContent
struct
{
Category
string
`json:"category"`
Name
string
`json:"name"`
Value
string
`json:"value"`
Remark
[]
RemarkText
`json:"remark"`
}
type
RemarkText
struct
{
Title
string
`json:"title"`
RemarkText
string
`json:"remarkText"`
}
...
...
pkg/application/staff_assess/query/List_supper_assess.go
0 → 100644
查看文件 @
971e4c1
package
query
type
ListSupperAssessQuery
struct
{
PageNumber
int
`json:"pageNumber"`
PageSize
int
`json:"pageSize"`
UserName
string
`json:"userName"`
//查询条件 员工的名称
CompanyId
int
`json:"companyId"`
//
ExecutorId
int
`json:"executorId"`
//评估的执行人
AssessTaskId
int
`json:"assessTaskId"`
//评估任务id
}
...
...
pkg/application/staff_assess/query/assess_self_info.go
查看文件 @
971e4c1
...
...
@@ -2,7 +2,7 @@ package query
//获取员工自评填写详情
type
AssessSelfInfoQuery
struct
{
AssessTaskId
int
`json:"assessTaskId"`
//
StaffAssess
的id
AssessTaskId
int
`json:"assessTaskId"`
//
assessTaskId
的id
TargetUserId
int
`json:"targetUserId"`
//被评估的人id
CompanyId
int
`json:"companyId"`
//公司id
...
...
pkg/application/staff_assess/query/list_invite_user_assess copy.go
已删除
100644 → 0
查看文件 @
913ae62
package
query
type
ListSupperAssessQuery
struct
{
PageNumber
int
`json:"pageNumber"`
PageSize
int
`json:"pageSize"`
UserName
string
`json:"userName"`
//查询条件 员工的名称
CompanyId
int
`json:"companyId"`
//
ExecutorId
int
`json:"executorId"`
//评估的执行人
AssessTaskkId
int
`json:"assessTaskId"`
//评估任务id
}
pkg/application/staff_assess/query/list_invite_user_assess.go
查看文件 @
971e4c1
package
query
type
ListInviteUserAssessQuery
struct
{
PageNumber
int
`json:"pageNumber"`
PageSize
int
`json:"pageSize"`
UserName
string
`json:"userName"`
//查询条件 员工的名称
CompanyId
int
`json:"companyId"`
//
ExecutorId
int
`json:"executorId"`
//评估的执行人
AssessTaskkId
int
`json:"assessTaskId"`
//评估任务id
PageNumber
int
`json:"pageNumber"`
PageSize
int
`json:"pageSize"`
UserName
string
`json:"userName"`
//查询条件 员工的名称
CompanyId
int
`json:"companyId"`
//
ExecutorId
int
`json:"executorId"`
//评估的执行人,必填
AssessTaskId
int
`json:"assessTaskId"`
//评估任务id 必填
}
...
...
pkg/application/staff_assess/query/list_target_user_assess.go
0 → 100644
查看文件 @
971e4c1
package
query
//获取员工 被评估的列表
type
ListTargetUserAssessQuery
struct
{
AssessTaskId
int
`json:"assessTaskId"`
TargetUserId
int
`json:"targetUserId"`
CompanyId
int
`json:"companyId"`
Types
[]
string
`json:"tyspes"`
}
...
...
pkg/application/staff_assess/service/service.go
查看文件 @
971e4c1
...
...
@@ -12,6 +12,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
...
...
@@ -321,16 +322,15 @@ func (srv StaffAssessServeice) AssessSelfList(param *query.AssessSelfListQuery)
DutyTime
:
userData
.
CreatedAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
}
for
_
,
v
:=
range
supperUserList
{
userInfo
.
SupperUserName
=
userInfo
.
SupperUserName
+
v
.
Name
+
"
;
"
userInfo
.
SupperUserName
=
userInfo
.
SupperUserName
+
v
.
Name
+
"
"
}
result
:=
tool_funs
.
SimpleWrapGridMap
(
int64
(
cnt
),
listData
)
result
[
"userInfo"
]
=
userInfo
return
result
,
nil
}
//
更具
项目评估的配置,创建员工的评估任务
//
根据
项目评估的配置,创建员工的评估任务
func
(
srv
StaffAssessServeice
)
CreateStaffAssessTask
(
param
*
command
.
CreateStaffAssessTask
)
(
map
[
string
]
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
...
...
@@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
assessTaskRepo
:=
factory
.
CreateStaffAssessTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
taskBeginTime
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
param
.
BeginTime
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
"任务开始时间填写错误,"
+
param
.
BeginTime
)
...
...
@@ -351,24 +353,45 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
"任务结束时间填写错误,"
+
param
.
EndTime
)
}
nowTime
:=
time
.
Now
()
//建立评估任务
assessTask
:=
domain
.
StaffAssessTask
{
Id
:
0
,
CompanyId
:
param
.
CompanyId
,
EvaluationProjectId
:
param
.
EvaluationProjectId
,
EvaluationProjectName
:
param
.
EvaluationProjectName
,
CycleId
:
param
.
CycleId
,
CycleName
:
param
.
CycleName
,
BeginTime
:
taskBeginTime
,
EndTime
:
taskEndTime
,
StepList
:
[]
domain
.
AssessTaskStep
{},
ExecutorId
:
nil
,
CreatedAt
:
nowTime
,
UpdatedAt
:
nowTime
,
DeletedAt
:
nil
,
var
assessTaskData
*
domain
.
StaffAssessTask
_
,
assassessTaskList
,
err
:=
assessTaskRepo
.
Find
(
map
[
string
]
interface
{}{
"evaluationProjectId"
:
param
.
EvaluationProjectId
,
"beginDay"
:
taskBeginTime
.
Local
()
.
Format
(
"2006-01-02"
),
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"查询同日期已存在评估任务"
+
err
.
Error
())
}
// 获取旧数据
if
len
(
assassessTaskList
)
>
0
{
assessTaskData
=
assassessTaskList
[
0
]
assessTaskData
.
UpdatedAt
=
nowTime
}
else
{
//建立评估任务
assessTaskData
=
&
domain
.
StaffAssessTask
{
Id
:
0
,
CompanyId
:
param
.
CompanyId
,
EvaluationProjectId
:
param
.
EvaluationProjectId
,
EvaluationProjectName
:
param
.
EvaluationProjectName
,
CycleId
:
param
.
CycleId
,
CycleName
:
param
.
CycleName
,
BeginTime
:
taskBeginTime
,
EndTime
:
taskEndTime
,
StepList
:
[]
domain
.
AssessTaskStep
{},
ExecutorId
:
nil
,
CreatedAt
:
nowTime
,
UpdatedAt
:
nowTime
,
DeletedAt
:
nil
,
}
}
//填充评估环节
for
_
,
v
:=
range
param
.
StepList
{
for
_
,
vv
:=
range
assessTaskData
.
StepList
{
if
vv
.
LinkNodeType
==
v
.
LinkNodeType
{
continue
}
}
stepBeginTime
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
param
.
BeginTime
,
time
.
Local
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
"评估环节开始时间填写错误,"
+
param
.
BeginTime
)
...
...
@@ -385,41 +408,56 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA
BeginTime
:
stepBeginTime
,
EndTime
:
stepEndTime
,
}
assessTask
.
StepList
=
append
(
assessTask
.
StepList
,
step
)
assessTask
Data
.
StepList
=
append
(
assessTaskData
.
StepList
,
step
)
}
assessTaskRepo
:=
factory
.
CreateStaffAssessTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
_
,
err
=
assessTaskRepo
.
Save
(
&
assessTask
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"保存评估任务"
+
err
.
Error
())
}
assessList
,
err
:=
srv
.
createStaffAssess
(
transactionContext
,
&
assessTask
)
assessList
,
err
:=
srv
.
createStaffAssess
(
transactionContext
,
assessTaskData
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"生成个人评估项"
+
err
.
Error
())
}
//评估的参与人
executorIds
:=
[]
int
{}
executorIdMap
:=
map
[
int
]
struct
{}{}
//过滤重复的用户
for
_
,
v
:=
range
param
.
ExecutorId
{
if
_
,
ok
:=
executorIdMap
[
v
];
ok
{
continue
}
executorIds
=
append
(
executorIds
,
v
)
}
//过滤就数据
for
_
,
v
:=
range
assessTaskData
.
ExecutorId
{
if
_
,
ok
:=
executorIdMap
[
v
];
ok
{
continue
}
executorIds
=
append
(
executorIds
,
v
)
}
assessRepo
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
assessTaskData
.
ExecutorId
=
executorIds
_
,
err
=
assessTaskRepo
.
Save
(
assessTaskData
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"保存评估任务"
+
err
.
Error
())
}
for
i
:=
range
assessList
{
assessList
[
i
]
.
StaffAssessTaskId
=
assessTaskData
.
Id
_
,
err
=
assessRepo
.
Save
(
&
assessList
[
i
])
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
())
}
return
map
[
string
]
interface
{}{
"assessTaskId"
:
assessTask
.
Id
,
"assessTaskId"
:
assessTask
Data
.
Id
,
},
nil
}
// 添加
自评
节点任务
// 添加节点任务
func
(
srv
StaffAssessServeice
)
createStaffAssess
(
transactionContext
application
.
TransactionContext
,
param
*
domain
.
StaffAssessTask
)
([]
domain
.
StaffAssess
,
error
)
{
//评估的参与人
selfUserId
:=
[]
int
{}
...
...
@@ -540,13 +578,49 @@ func (srv StaffAssessServeice) createStaffAssessSupper(
assessTemp
domain
.
StaffAssess
,
userList
[]
*
domain
.
User
,
userDepartmentMap
map
[
int64
][]
*
domain
.
Department
,
)
([]
domain
.
StaffAssess
,
error
)
{
var
assessList
[]
domain
.
StaffAssess
// 获取员工的上级用户
return
nil
,
nil
userRepo
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
for
_
,
v
:=
range
userList
{
departmentList
,
ok
:=
userDepartmentMap
[
v
.
Id
]
if
!
ok
{
continue
}
for
_
,
vv2
:=
range
departmentList
{
if
len
(
vv2
.
ChargeUserIds
)
==
0
{
continue
}
_
,
chargeUserList
,
err
:=
userRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
vv2
.
ChargeUserIds
,
"limit"
:
40
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
"获取部门主管信息"
+
err
.
Error
())
}
for
_
,
vvv3
:=
range
chargeUserList
{
assessTemp
.
TargetDepartment
=
[]
domain
.
StaffDepartment
{
{
DepartmentId
:
int
(
vv2
.
Id
),
DepartmentName
:
vv2
.
Name
},
}
assessTemp
.
TargetUser
=
domain
.
StaffDesc
{
UserId
:
int
(
v
.
Id
),
Account
:
v
.
Account
,
UserName
:
v
.
Name
,
}
assessTemp
.
Executor
=
domain
.
StaffDesc
{
UserId
:
int
(
vvv3
.
Id
),
Account
:
vvv3
.
Account
,
UserName
:
vvv3
.
Name
,
}
assessList
=
append
(
assessList
,
assessTemp
)
}
}
}
return
assessList
,
nil
}
// 获取某个员工360邀请的人员
// 获取某个员工360
评估
邀请的人员
func
(
srv
StaffAssessServeice
)
GetAssessInviteUser
(
param
*
query
.
GetAssessInviteUserQuery
)
(
*
adapter
.
AssessInviteUserResp
,
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
...
...
@@ -877,14 +951,18 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取项目填写内容"
+
err
.
Error
())
}
}
//获取员工描述
staffDesc
,
_
:=
srv
.
getStaffDescrip
(
transactionContext
,
int64
(
param
.
TargetUserId
))
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
result
:=
adapter
.
AssessInfoResp
{
AssessId
:
assessData
.
Id
,
CycleId
:
assessData
.
CycleId
,
CycleName
:
assessData
.
CycleName
,
LinkNodeId
:
assessData
.
LinkNodeId
,
LinkNodeName
:
assessData
.
LinkNodeName
,
EvaluationProjectId
:
assessData
.
EvaluationProjectId
,
EvaluationProjectName
:
assessData
.
EvaluationProjectName
,
BeginTime
:
assessData
.
BeginTime
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
...
...
@@ -892,8 +970,17 @@ func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessSelfInfoQuer
Status
:
string
(
assessData
.
Status
),
TargetUserId
:
assessData
.
TargetUser
.
UserId
,
TargetUserName
:
assessData
.
TargetUser
.
UserName
,
CompanyId
:
assessData
.
CompanyId
,
CompanyName
:
""
,
SupperUser
:
""
,
DutyTime
:
""
,
AssessContent
:
assessContentList
,
}
if
staffDesc
!=
nil
{
result
.
CompanyName
=
staffDesc
.
CompanyName
result
.
SupperUser
=
staffDesc
.
SupperUserName
result
.
DutyTime
=
staffDesc
.
DutyTime
}
return
&
result
,
nil
}
...
...
@@ -998,13 +1085,14 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
departmentRepo
:=
factory
.
CreateDepartmentRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
_
,
targetUserDepartment
,
err
:=
departmentRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
targetUser
.
DepartmentId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取部门信息"
+
err
.
Error
())
var
targetUserDepartment
[]
*
domain
.
Department
if
len
(
targetUser
.
DepartmentId
)
>
0
{
_
,
targetUserDepartment
,
err
=
departmentRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
targetUser
.
DepartmentId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取部门信息"
+
err
.
Error
())
}
}
//获取部门主管的id
targetUserCharge
:=
map
[
int64
]
struct
{}{}
...
...
@@ -1060,8 +1148,8 @@ func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessI
return
tool_funs
.
SimpleWrapGridMap
(
int64
(
cnt
),
listData
),
nil
}
// 获取我的360评估,用户列表和评估填写的值
func
(
srv
StaffAssessServeice
)
ListInviteUserAssess
(
param
*
query
.
ListInviteUserAssessQuery
)
(
// 获取我要执行的的360评估,用户列表和评估填写的值
func
(
srv
StaffAssessServeice
)
ListExecutorInviteAssess
(
param
*
query
.
ListInviteUserAssessQuery
)
(
*
adapter
.
ListInviteUserAssessResp
,
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
...
...
@@ -1077,49 +1165,140 @@ func (srv StaffAssessServeice) ListInviteUserAssess(param *query.ListInviteUserA
assessRepo
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
assessTaskRepo
:=
factory
.
CreateStaffAssessTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
//获取 executorId 对应的360评估任务 用户
cnt
,
assessList
,
err
:=
assessRepo
.
Find
(
map
[
string
]
interface
{}{
"staffAssessTaskId"
:
param
.
AssessTaskkId
,
condition
:=
map
[
string
]
interface
{}{
"staffAssessTaskId"
:
param
.
AssessTaskId
,
"executorId"
:
param
.
ExecutorId
,
"typesList"
:
[]
string
{
string
(
domain
.
AssessInviteDiffSuper
),
string
(
domain
.
AssessInviteSameSuper
)},
})
"limit"
:
20
,
}
if
param
.
PageSize
>
0
{
condition
[
"limit"
]
=
param
.
PageSize
}
offset
:=
(
param
.
PageNumber
-
1
)
*
param
.
PageSize
if
offset
>
0
{
condition
[
"offset"
]
=
offset
}
cnt
,
assessList
,
err
:=
assessRepo
.
Find
(
condition
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
var
assessContentList
[]
*
domain
.
StaffAssessContent
if
len
(
assessList
)
>
0
{
//获取评估用的所有评估项
assessContentList
,
err
=
srv
.
getAssessSelfInfoUncompleted
(
transactionContext
,
assessList
[
0
])
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取评估任务"
+
err
.
Error
())
}
}
//可变的表格列
changeableHeader
:=
[]
adapter
.
ListTableHeader
{}
//列名与字段对应
keyMap
:=
map
[
string
]
string
{}
for
i
,
v
:=
range
assessContentList
{
name
:=
fmt
.
Sprintf
(
"%s-%s"
,
v
.
Category
,
v
.
Name
)
key
:=
fmt
.
Sprintf
(
"k%d"
,
i
)
keyMap
[
name
]
=
key
changeableHeader
=
append
(
changeableHeader
,
adapter
.
ListTableHeader
{
Key
:
key
,
Name
:
name
,
})
}
assessContentRepo
:=
factory
.
CreateStaffAssessContentRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
// 获取已经填报的内容
changeableRows
:=
map
[
int
]
map
[
string
]
string
{}
for
_
,
v
:=
range
assessList
{
_
,
contentList
,
err
:=
assessContentRepo
.
Find
(
map
[
string
]
interface
{}{
"staffAssessId"
:
v
.
Id
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取评估内容"
+
err
.
Error
())
}
row
:=
map
[
string
]
string
{}
for
_
,
vv
:=
range
contentList
{
name
:=
fmt
.
Sprintf
(
"%s-%s"
,
vv
.
Category
,
vv
.
Name
)
if
kk
,
ok
:=
keyMap
[
name
];
ok
{
row
[
kk
]
=
vv
.
Value
}
}
changeableRows
[
v
.
TargetUser
.
UserId
]
=
row
}
//获取360邀请评估完成情况
//我评估别人,被邀请评估
cnnt
,
_
,
err
:=
assessRepo
.
Find
(
map
[
string
]
interface
{}{
"staffAssessTaskId"
:
param
.
AssessTaskId
,
"executorId"
:
param
.
ExecutorId
,
"typesList"
:
[]
string
{
string
(
domain
.
AssessInviteDiffSuper
),
string
(
domain
.
AssessInviteSameSuper
)},
"status"
:
domain
.
StaffAssessUncompleted
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"获取个人的评估环节"
+
err
.
Error
())
}
assessTaskData
,
err
:=
assessTaskRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
param
.
AssessTaskId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"获取评估任务"
+
err
.
Error
())
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//
TODO
评估填写数据行转列
//评估填写数据行转列
tableHeader
:=
[]
adapter
.
ListTableHeader
{
{
Key
:
"userName"
,
Name
:
"姓名"
},
{
Key
:
"status"
,
Name
:
"状态"
},
{
Key
:
"types"
,
Name
:
"360°评估关系"
},
{
Key
:
"endTime"
,
Name
:
"360°评估截止日期"
},
}
tableHeader
=
append
(
tableHeader
,
changeableHeader
...
)
listData
:=
[]
map
[
string
]
string
{}
for
_
,
v
:=
range
assessList
{
m
:=
map
[
string
]
string
{
"userName"
:
v
.
TargetUser
.
UserName
,
"userId"
:
strconv
.
Itoa
(
v
.
TargetUser
.
UserId
),
"status"
:
string
(
v
.
Status
),
"types"
:
string
(
v
.
Types
),
"endTime"
:
v
.
EndTime
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
"assessId"
:
strconv
.
Itoa
(
v
.
Id
),
}
if
row
,
ok
:=
changeableRows
[
v
.
TargetUser
.
UserId
];
ok
{
for
k
,
v
:=
range
row
{
m
[
k
]
=
v
}
}
else
{
for
_
,
v
:=
range
changeableHeader
{
m
[
v
.
Key
]
=
""
}
}
listData
=
append
(
listData
,
m
)
}
_
=
tableHeader
result
:=
adapter
.
ListInviteUserAssessResp
{
TableHeader
:
tableHeader
,
List
:
listData
,
Total
:
cnt
,
}
for
_
,
v
:=
range
assessTaskData
.
StepList
{
if
v
.
LinkNodeType
==
domain
.
LinkNodeAllAssessment
{
result
.
LinkNodeId
=
v
.
LinkNodeId
result
.
LinkNodeName
=
v
.
LinkNodeName
result
.
LintNodeDesc
=
fmt
.
Sprintf
(
"截止时间 %s 待评估%d人"
,
v
.
EndTime
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
cnnt
)
}
}
return
&
result
,
nil
}
// 获取上级评估成员列表
func
(
srv
StaffAssessServeice
)
ListSupperAssess
(
param
*
query
.
ListSupperAssessQuery
)
(
map
[
string
]
interface
{},
error
)
{
// 获取我需要执行的上级评估成员列表
func
(
srv
StaffAssessServeice
)
ListExecutorSupperAssess
(
param
*
query
.
ListSupperAssessQuery
)
(
map
[
string
]
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
...
...
@@ -1134,15 +1313,70 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue
assessRepo
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
//获取 executorId 对应的上级评估列表
cnt
,
assessList
,
err
:=
assessRepo
.
Find
(
map
[
string
]
interface
{}{
"staffAssessTaskId"
:
param
.
AssessTaskkId
,
limit
:=
20
if
param
.
PageSize
>
0
{
limit
=
param
.
PageSize
}
condition
:=
map
[
string
]
interface
{}{
"staffAssessTaskId"
:
param
.
AssessTaskId
,
"executorId"
:
param
.
ExecutorId
,
"typesList"
:
[]
string
{
string
(
domain
.
AssessSuper
)},
})
"limit"
:
limit
,
"targetUserName"
:
param
.
UserName
,
}
offset
:=
(
param
.
PageNumber
-
1
)
*
param
.
PageSize
if
offset
>
0
{
condition
[
"offset"
]
=
offset
}
//获取 executorId 对应的上级评估列表
cnt
,
assessList
,
err
:=
assessRepo
.
Find
(
condition
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
userIds
:=
[]
int
{}
for
_
,
v
:=
range
assessList
{
userIds
=
append
(
userIds
,
v
.
TargetUser
.
UserId
)
}
//获取员工信息
userRepo
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
var
targetUserList
[]
*
domain
.
User
if
len
(
userIds
)
>
0
{
_
,
targetUserList
,
_
=
userRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
userIds
,
})
}
//获取职位信息
positionRepo
:=
factory
.
CreatePositionRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
//获取员工的职位
userPositionMap
:=
map
[
int64
][]
*
domain
.
Position
{}
for
_
,
v
:=
range
targetUserList
{
if
len
(
v
.
PositionId
)
==
0
{
continue
}
_
,
positionList
,
_
:=
positionRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
v
.
PositionId
,
})
userPositionMap
[
v
.
Id
]
=
positionList
}
//获取员工邀请的人完成360评估的数量
var
inviteCompletedCount
[]
dao
.
CountData
if
len
(
userIds
)
>
0
{
d
:=
dao
.
NewStaffAssessDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
inviteCompletedCount
,
err
=
d
.
CountInviteAssessByTargetUser
(
userIds
,
param
.
AssessTaskId
)
if
err
!=
nil
{
log
.
Logger
.
Error
(
"获取员工邀请的人完成情况"
+
err
.
Error
())
}
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
@@ -1150,19 +1384,41 @@ func (srv StaffAssessServeice) ListSupperAssess(param *query.ListSupperAssessQue
resultList
:=
[]
adapter
.
ListSupperAssessResp
{}
for
_
,
v
:=
range
assessList
{
item
:=
adapter
.
ListSupperAssessResp
{
AssessId
:
v
.
Id
,
UserName
:
v
.
TargetUser
.
UserName
,
EndTime
:
v
.
EndTime
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
InviteUncompleted
:
0
,
InviteTotal
:
5
,
Department
:
""
,
Position
:
""
,
DutyTime
:
""
,
AssessId
:
v
.
Id
,
UsrId
:
v
.
TargetUser
.
UserId
,
UserName
:
v
.
TargetUser
.
UserName
,
EndTime
:
v
.
EndTime
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
InviteCompleted
:
0
,
Status
:
string
(
v
.
Status
),
InviteTotal
:
5
,
Department
:
""
,
Position
:
""
,
DutyTime
:
""
,
}
//填入部门
for
_
,
vv
:=
range
v
.
TargetDepartment
{
item
.
Department
+=
vv
.
DepartmentName
+
" "
}
for
_
,
vv
:=
range
targetUserList
{
if
vv
.
Id
!=
int64
(
v
.
TargetUser
.
UserId
)
{
continue
}
//填入入职时间
item
.
DutyTime
=
vv
.
CreatedAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
)
//填入职位
for
_
,
vvv
:=
range
userPositionMap
[
vv
.
Id
]
{
item
.
Position
+=
vvv
.
Name
+
" "
}
break
}
//
for
_
,
vv
:=
range
inviteCompletedCount
{
if
v
.
TargetUser
.
UserId
==
vv
.
TargetUserId
{
item
.
InviteCompleted
=
vv
.
InviteCompleted
item
.
InviteTotal
=
vv
.
InviteTotal
break
}
}
resultList
=
append
(
resultList
,
item
)
}
return
tool_funs
.
SimpleWrapGridMap
(
int64
(
cnt
),
resultList
),
nil
...
...
@@ -1214,6 +1470,11 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取项目填写内容"
+
err
.
Error
())
}
}
targetUserDesc
,
err
:=
srv
.
getStaffDescrip
(
transactionContext
,
int64
(
assessData
.
TargetUser
.
UserId
))
if
err
!=
nil
{
log
.
Logger
.
Error
(
"获取员工描述"
+
err
.
Error
())
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
...
...
@@ -1222,6 +1483,8 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
AssessId
:
assessData
.
Id
,
CycleId
:
assessData
.
CycleId
,
CycleName
:
assessData
.
CycleName
,
LinkNodeId
:
assessData
.
LinkNodeId
,
LinkNodeName
:
assessData
.
LinkNodeName
,
EvaluationProjectId
:
assessData
.
EvaluationProjectId
,
EvaluationProjectName
:
assessData
.
EvaluationProjectName
,
BeginTime
:
assessData
.
BeginTime
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
...
...
@@ -1229,13 +1492,192 @@ func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*ada
Status
:
string
(
assessData
.
Status
),
TargetUserId
:
assessData
.
TargetUser
.
UserId
,
TargetUserName
:
assessData
.
TargetUser
.
UserName
,
CompanyId
:
assessData
.
CompanyId
,
CompanyName
:
""
,
SupperUser
:
""
,
DutyTime
:
""
,
AssessContent
:
assessContentList
,
}
if
len
(
assessContentList
)
==
0
{
result
.
AssessContent
=
[]
*
domain
.
StaffAssessContent
{}
}
if
targetUserDesc
!=
nil
{
result
.
CompanyName
=
targetUserDesc
.
CompanyName
result
.
SupperUser
=
targetUserDesc
.
SupperUserName
result
.
DutyTime
=
targetUserDesc
.
DutyTime
}
return
&
result
,
nil
}
// 获取员工的某次评估任务的360评估记录录
// assessTaskId targetUserId
func
(
srv
StaffAssessServeice
)
AssessInviteList
()
error
{
return
nil
// 获取员工信息描述
func
(
srv
*
StaffAssessServeice
)
getStaffDescrip
(
transactionContext
application
.
TransactionContext
,
userid
int64
)
(
*
adapter
.
StaffInfo
,
error
)
{
//获取用户数据
userRepo
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
userData
,
err
:=
userRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
userid
,
})
if
err
!=
nil
{
log
.
Logger
.
Error
(
"获取用户信息,"
+
err
.
Error
())
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"获取用户信息,"
+
err
.
Error
())
}
//获取公司数据
companyRep
:=
factory
.
CreateCompanyRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
companyData
,
err
:=
companyRep
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
userData
.
CompanyId
,
})
if
err
!=
nil
{
log
.
Logger
.
Error
(
"获取公司信息,"
+
err
.
Error
())
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"获取公司信息,"
+
err
.
Error
())
}
departmentRepo
:=
factory
.
CreateDepartmentRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
var
supperUserList
[]
*
domain
.
User
if
len
(
userData
.
DepartmentId
)
>
0
{
_
,
departmentList
,
err
:=
departmentRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
userData
.
DepartmentId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"获取部门信息,"
+
err
.
Error
())
}
var
chargeUserIds
[]
int64
for
_
,
v
:=
range
departmentList
{
chargeUserIds
=
append
(
chargeUserIds
,
v
.
ChargeUserIds
...
)
}
if
len
(
chargeUserIds
)
>
0
{
_
,
supperUserList
,
err
=
userRepo
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
chargeUserIds
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"获取员工上级信息,"
+
err
.
Error
())
}
}
}
userInfo
:=
adapter
.
StaffInfo
{
UserName
:
userData
.
Name
,
CompanyName
:
companyData
.
Name
,
SupperUserName
:
""
,
DutyTime
:
userData
.
CreatedAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
}
for
_
,
v
:=
range
supperUserList
{
userInfo
.
SupperUserName
=
userInfo
.
SupperUserName
+
v
.
Name
+
" "
}
return
&
userInfo
,
nil
}
// 提交评估数据
func
(
srv
StaffAssessServeice
)
SaveAssessInfo
(
param
*
command
.
SaveAssessInfoCommand
)
(
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
()
}()
assessReps
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
//获取员工的评估
assessData
,
err
:=
assessReps
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
param
.
AssessId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取员工的评估"
+
err
.
Error
())
}
assessContentRepo
:=
factory
.
CreateStaffAssessContentRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
//待更新的评估填写信息
assessContentList
:=
[]
*
domain
.
StaffAssessContent
{}
if
assessData
.
Status
==
domain
.
StaffAssessCompleted
{
//已完成
_
,
assessContentList
,
err
=
assessContentRepo
.
Find
(
map
[
string
]
interface
{}{
"staffAssessId"
:
assessData
.
Id
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取项目填写内容"
+
err
.
Error
())
}
}
else
if
assessData
.
Status
==
domain
.
StaffAssessUncompleted
{
//未完成
assessContentList
,
err
=
srv
.
getAssessSelfInfoUncompleted
(
transactionContext
,
assessData
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取项目填写内容"
+
err
.
Error
())
}
}
//处理提交上来的数据
paramContentMap
:=
map
[
string
]
command
.
AssesssContent
{}
for
i
,
v
:=
range
param
.
AssessContent
{
key
:=
fmt
.
Sprintf
(
"%s-%s"
,
v
.
Category
,
v
.
Name
)
paramContentMap
[
key
]
=
param
.
AssessContent
[
i
]
}
//更新的评估填写信息
for
_
,
v
:=
range
assessContentList
{
key
:=
fmt
.
Sprintf
(
"%s-%s"
,
v
.
Category
,
v
.
Name
)
item
,
ok
:=
paramContentMap
[
key
]
if
!
ok
{
continue
}
v
.
Value
=
item
.
Value
for
ii
:=
range
v
.
Remark
{
for
_
,
vvv
:=
range
item
.
Remark
{
if
v
.
Remark
[
ii
]
.
Title
==
vvv
.
Title
{
v
.
Remark
[
ii
]
.
RemarkText
=
vvv
.
RemarkText
break
}
}
}
}
//保存信息
for
i
:=
range
assessContentList
{
_
,
err
=
assessContentRepo
.
Save
(
assessContentList
[
i
])
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
())
}
return
map
[
string
]
interface
{}{
"assessId"
:
assessData
.
Id
,
},
nil
}
// 获取员工被评估的列表
func
(
srv
StaffAssessServeice
)
ListTargetUserAssess
(
param
*
query
.
ListTargetUserAssessQuery
)
(
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
()
}()
assessReps
:=
factory
.
CreateStaffAssessRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
})
//获取员工的评估
cnt
,
assessList
,
err
:=
assessReps
.
Find
(
map
[
string
]
interface
{}{
"assessTaskId"
:
param
.
AssessTaskId
,
"companyId"
:
param
.
CompanyId
,
"targetUserId"
:
param
.
TargetUserId
,
})
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
())
}
return
tool_funs
.
SimpleWrapGridMap
(
int64
(
cnt
),
assessList
),
nil
}
...
...
pkg/domain/evaluation_template.go
查看文件 @
971e4c1
...
...
@@ -60,8 +60,6 @@ type LinkNode struct {
TimeStart
*
time
.
Time
`json:"timeStart" comment:"起始时间"`
TimeEnd
*
time
.
Time
`json:"timeEnd" comment:"截至时间"`
KpiCycle
int
`json:"kpiCycle" comment:"考核周期(1日、2周、3月)"`
//NodeAllInvite *NodeAllInvite `json:"nodeAllInvite" comment:"360°邀请人员"`
}
// 评估模板
...
...
pkg/domain/node_t
imer_t
ask.go → pkg/domain/node_task.go
查看文件 @
971e4c1
...
...
@@ -4,23 +4,24 @@ import (
"time"
)
type
NodeT
imerT
ask
struct
{
type
NodeTask
struct
{
Id
int64
`json:"id,string" comment:"ID"`
CompanyId
int64
`json:"companyId,string" comment:"公司ID"`
CycleId
int64
`json:"cycleId,string" comment:"周期ID"`
ProjectId
int64
`json:"projectId,string" comment:"项目ID"`
NodeId
int64
`json:"nodeId,string" comment:"节点ID"`
LastSentAt
*
time
.
Time
`json:"lastSentAt" comment:"最后一次发送时间"`
KpiCycle
int
`json:"kpiCycle" comment:"周期"`
BeginAt
*
time
.
Time
`json:"beginAt" comment:"起始时间"`
EndAt
*
time
.
Time
`json:"endAt" comment:"截至时间"`
NextSentAt
*
time
.
Time
`json:"nextSentAt" comment:"下一次发送时间"`
CreatedAt
time
.
Time
`json:"createdAt" comment:"创建时间"`
UpdatedAt
time
.
Time
`json:"updatedAt" comment:"更新时间"`
DeletedAt
*
time
.
Time
`json:"deletedAt" comment:"删除时间"`
}
type
NodeTimerTaskRepository
interface
{
Insert
(
template
*
NodeTimerTask
)
(
*
NodeTimerTask
,
error
)
Remove
(
template
*
NodeTimerTask
)
(
*
NodeTimerTask
,
error
)
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
NodeTimerTask
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{},
excludeColumns
...
string
)
(
int64
,
[]
*
NodeTimerTask
,
error
)
Count
(
queryOptions
map
[
string
]
interface
{})
(
int64
,
error
)
type
NodeTaskRepository
interface
{
Insert
(
task
*
NodeTask
)
(
*
NodeTask
,
error
)
Remove
(
task
*
NodeTask
)
(
*
NodeTask
,
error
)
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
NodeTask
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
([]
*
NodeTask
,
error
)
}
...
...
pkg/domain/position.go
查看文件 @
971e4c1
...
...
@@ -20,4 +20,5 @@ type PositionRepository interface {
Update
(
position
*
Position
)
(
*
Position
,
error
)
Remove
(
ids
[]
int64
)
error
FindOne
(
queryOption
map
[
string
]
interface
{})
(
*
Position
,
error
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
Position
,
error
)
}
...
...
pkg/domain/staff_assess.go
查看文件 @
971e4c1
...
...
@@ -7,7 +7,7 @@ type StaffAssessType string
const
(
AssessSelf
StaffAssessType
=
"self"
//自评
AssessSuper
StaffAssessType
=
"sup
er"
//上级评估
AssessSuper
StaffAssessType
=
"sup
per"
//上级评估
AssessInviteSameSuper
StaffAssessType
=
"invite_same_super"
//360 邀请评估-相同上级的同事
AssessInviteDiffSuper
StaffAssessType
=
"invite_diff_super"
//360 邀请评估-不同上级的同事
)
...
...
pkg/domain/staff_assess_task.go
查看文件 @
971e4c1
...
...
@@ -2,19 +2,6 @@ package domain
import
"time"
//评估任务重复执行的方式
// type AssessTaskRepeatWay string
// const (
// AssessTaskRepeatDay AssessTaskRepeatWay = "day" //按天重复
// AssessTaskRepeatWeek AssessTaskRepeatWay = "week" //按周重复
// AssessTaskRepeatMonth AssessTaskRepeatWay = "month" //按月
// AssessTaskRepeatMonthDouble AssessTaskRepeatWay = "month_double" //按双月
// AssessTaskRepeatQuarter AssessTaskRepeatWay = "quarter" //按季度
// AssessTaskRepeatYearHalf AssessTaskRepeatWay = "year_half" //按半年
// AssessTaskRepeatYear AssessTaskRepeatWay = "year" //按年
// )
// 执行评估的任务列表
type
StaffAssessTask
struct
{
Id
int
`json:"id"`
...
...
@@ -23,6 +10,7 @@ type StaffAssessTask struct {
EvaluationProjectName
string
`json:"evaluationProjectName"`
//项目名称
CycleId
int64
`json:"cycleId"`
//对应的周期id
CycleName
string
`json:"cycleName"`
//对应周期的名称
BeginDay
string
`json:"beginDay"`
//绩效考核日期
BeginTime
time
.
Time
`json:"beginTime"`
//绩效考核开始时间
EndTime
time
.
Time
`json:"endTime"`
//绩效考核截止时间
StepList
[]
AssessTaskStep
`json:"stepList"`
//考评的流程
...
...
pkg/domain/staff_desc.go
查看文件 @
971e4c1
...
...
@@ -12,3 +12,8 @@ type StaffDepartment struct {
DepartmentId
int
`json:"departmentId"`
//部门id
DepartmentName
string
`json:"departmentName"`
//部门名称
}
type
StaffPosition
struct
{
PositionId
int
`json:"positionId"`
PositionName
string
`json:"positionName"`
}
...
...
pkg/infrastructure/dao/staff_assess_dao.go
0 → 100644
查看文件 @
971e4c1
package
dao
import
(
"strconv"
"github.com/go-pg/pg/v10"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
)
type
StaffAssessDao
struct
{
transactionContext
*
pgTransaction
.
TransactionContext
}
func
NewStaffAssessDao
(
options
map
[
string
]
interface
{})
*
StaffAssessDao
{
var
transactionContext
*
pgTransaction
.
TransactionContext
if
value
,
ok
:=
options
[
"transactionContext"
];
ok
{
transactionContext
=
value
.
(
*
pgTransaction
.
TransactionContext
)
}
return
&
StaffAssessDao
{
transactionContext
:
transactionContext
,
}
}
type
CountData
struct
{
TargetUserId
int
InviteTotal
int
InviteCompleted
int
}
// 获取员工邀请的人完成360评估的数量
func
(
d
*
StaffAssessDao
)
CountInviteAssessByTargetUser
(
userIds
[]
int
,
assessTaskId
int
)
([]
CountData
,
error
)
{
sqlStr
:=
`SELECT staff_assess.target_user->>'userId' as target_user_id,
count(staff_assess."id") AS invite_total,
sum(
case WHEN staff_assess.status='completed' THEN 1
ELSE 0 END
) as invite_completed
FROM staff_assess
WHERE staff_assess.target_user->>'userId' IN(?)
AND staff_assess.types IN ('invite_same_super','invite_diff_super')
AND staff_assess.staff_assess_task_id = ?
GROUP BY userId`
userIdList
:=
[]
string
{}
for
_
,
v
:=
range
userIds
{
uid
:=
strconv
.
Itoa
(
v
)
userIdList
=
append
(
userIdList
,
uid
)
}
condition
:=
[]
interface
{}{
pg
.
In
(
userIdList
),
assessTaskId
,
}
tx
:=
d
.
transactionContext
.
PgTx
result
:=
[]
CountData
{}
_
,
err
:=
tx
.
Query
(
&
result
,
sqlStr
,
condition
...
)
return
result
,
err
}
...
...
pkg/infrastructure/pg/init.go
查看文件 @
971e4c1
...
...
@@ -40,6 +40,7 @@ func init() {
&
models
.
EvaluationCycle
{},
&
models
.
EvaluationCycleTemplate
{},
&
models
.
EvaluationProject
{},
&
models
.
NodeTask
{},
&
models
.
StaffAssess
{},
&
models
.
StaffAssessTask
{},
&
models
.
StaffAssessContent
{},
...
...
pkg/infrastructure/pg/models/node_task.go
0 → 100644
查看文件 @
971e4c1
package
models
import
(
"time"
)
type
NodeTask
struct
{
tableName
struct
{}
`comment:"环节任务" pg:"node_task"`
Id
int64
`comment:"ID" pg:"pk:id"`
CompanyId
int64
`comment:"公司ID"`
CycleId
int64
`comment:"周期ID"`
ProjectId
int64
`comment:"项目ID"`
NodeId
int64
`comment:"环节ID"`
KpiCycle
int
`comment:"周期"`
BeginAt
*
time
.
Time
`comment:"起始时间"`
EndAt
*
time
.
Time
`comment:"截止时间"`
NextSentAt
*
time
.
Time
`comment:"下一次发送时间"`
CreatedAt
time
.
Time
`comment:"创建时间"`
UpdatedAt
time
.
Time
`comment:"更新时间"`
DeletedAt
*
time
.
Time
`comment:"删除时间"`
}
...
...
pkg/infrastructure/pg/models/staff_assess_task.go
查看文件 @
971e4c1
...
...
@@ -17,6 +17,7 @@ type StaffAssessTask struct {
CycleName
string
//对应周期的名称
ExecutorId
[]
int
//参与考评的人
StepList
[]
domain
.
AssessTaskStep
``
//考评的流程
BeginDay
string
//日期 天 2006-01-02
BeginTime
time
.
Time
//开始时间
EndTime
time
.
Time
//截止时间
CreatedAt
time
.
Time
//数据创建时间
...
...
pkg/infrastructure/repository/pg_evaluation_cycle_repository.go
查看文件 @
971e4c1
...
...
@@ -119,7 +119,7 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
query
:=
tx
.
Model
(
&
m
)
.
Where
(
"deleted_at isnull"
)
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
&&
len
(
v
.
(
string
)
)
>
0
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name LIKE ?"
,
v
)
}
...
...
@@ -127,11 +127,11 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
query
.
Where
(
"company_id = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"timeStart"
];
ok
{
...
...
@@ -170,7 +170,7 @@ func (repo *EvaluationCycleRepository) Count(queryOptions map[string]interface{}
query
.
Where
(
"id != ?"
,
notId
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_evaluation_cycle_template_repository.go
查看文件 @
971e4c1
...
...
@@ -153,11 +153,11 @@ func (repo *EvaluationCycleTemplateRepository) Find(queryOptions map[string]inte
query
.
Where
(
"cycle_id = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
...
...
@@ -186,7 +186,7 @@ func (repo *EvaluationCycleTemplateRepository) Count(queryOptions map[string]int
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_evaluation_project_repository.go
查看文件 @
971e4c1
...
...
@@ -131,7 +131,7 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
query
.
ExcludeColumn
(
excludeColumns
...
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
@@ -159,11 +159,11 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
}
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
...
...
@@ -192,7 +192,7 @@ func (repo *EvaluationProjectRepository) Count(queryOptions map[string]interface
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_evaluation_rule_repository.go
查看文件 @
971e4c1
...
...
@@ -127,7 +127,7 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
query
.
Where
(
"id in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
@@ -143,11 +143,11 @@ func (repo *EvaluationRuleRepository) Find(queryOptions map[string]interface{})
query
.
Where
(
"type = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
...
...
@@ -176,7 +176,7 @@ func (repo *EvaluationRuleRepository) Count(queryOptions map[string]interface{})
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_evaluation_template_repository.go
查看文件 @
971e4c1
...
...
@@ -129,7 +129,7 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
&&
len
(
v
.
(
string
)
)
>
0
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name LIKE ?"
,
v
)
}
...
...
@@ -142,19 +142,22 @@ func (repo *EvaluationTemplateRepository) Find(queryOptions map[string]interface
}
if
v
,
ok
:=
queryOptions
[
"createdAt"
];
ok
{
t
:=
v
.
(
*
time
.
Time
)
year
,
month
,
day
:=
t
.
Date
()
begin
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
end
:=
time
.
Date
(
year
,
month
,
day
,
23
,
59
,
59
,
0
,
time
.
Local
)
query
.
Where
(
"created_at >= ?"
,
begin
)
query
.
Where
(
"created_at <= ?"
,
end
)
ts
:=
v
.
(
string
)
t
,
err
:=
time
.
ParseInLocation
(
"2006-01-02"
,
ts
,
time
.
Local
)
if
err
==
nil
{
year
,
month
,
day
:=
t
.
Date
()
begin
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
end
:=
time
.
Date
(
year
,
month
,
day
,
23
,
59
,
59
,
0
,
time
.
Local
)
query
.
Where
(
"created_at >= ?"
,
begin
)
query
.
Where
(
"created_at <= ?"
,
end
)
}
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
...
...
@@ -183,7 +186,7 @@ func (repo *EvaluationTemplateRepository) Count(queryOptions map[string]interfac
query
.
Where
(
"id != ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_node_task_repository.go
0 → 100644
查看文件 @
971e4c1
package
repository
import
(
"errors"
"fmt"
"github.com/go-pg/pg/v10"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
"time"
)
type
NodeTaskRepository
struct
{
transactionContext
*
pgTransaction
.
TransactionContext
}
func
NewNodeTaskRepository
(
transactionContext
*
pgTransaction
.
TransactionContext
)
*
NodeTaskRepository
{
return
&
NodeTaskRepository
{
transactionContext
:
transactionContext
}
}
func
(
repo
*
NodeTaskRepository
)
TransformToDomain
(
m
*
models
.
NodeTask
)
domain
.
NodeTask
{
return
domain
.
NodeTask
{
Id
:
m
.
Id
,
CompanyId
:
m
.
CompanyId
,
CycleId
:
m
.
CycleId
,
ProjectId
:
m
.
ProjectId
,
NodeId
:
m
.
NodeId
,
KpiCycle
:
m
.
KpiCycle
,
BeginAt
:
m
.
BeginAt
,
EndAt
:
m
.
EndAt
,
NextSentAt
:
m
.
NextSentAt
,
CreatedAt
:
m
.
CreatedAt
,
UpdatedAt
:
m
.
UpdatedAt
,
DeletedAt
:
m
.
DeletedAt
,
}
}
func
(
repo
*
NodeTaskRepository
)
TransformToModel
(
d
*
domain
.
NodeTask
)
models
.
NodeTask
{
return
models
.
NodeTask
{
Id
:
d
.
Id
,
CompanyId
:
d
.
CompanyId
,
CycleId
:
d
.
CycleId
,
ProjectId
:
d
.
ProjectId
,
NodeId
:
d
.
NodeId
,
KpiCycle
:
d
.
KpiCycle
,
BeginAt
:
d
.
BeginAt
,
EndAt
:
d
.
EndAt
,
NextSentAt
:
d
.
NextSentAt
,
CreatedAt
:
d
.
CreatedAt
,
UpdatedAt
:
d
.
UpdatedAt
,
DeletedAt
:
d
.
DeletedAt
,
}
}
func
(
repo
*
NodeTaskRepository
)
nextIdentify
()
(
int64
,
error
)
{
return
utils
.
NewSnowflakeId
()
}
func
(
repo
*
NodeTaskRepository
)
Insert
(
d
*
domain
.
NodeTask
)
(
*
domain
.
NodeTask
,
error
)
{
var
isCreate
=
d
.
Id
==
0
if
isCreate
{
id
,
err
:=
repo
.
nextIdentify
()
if
err
!=
nil
{
return
d
,
err
}
d
.
Id
=
id
d
.
CreatedAt
=
time
.
Now
()
d
.
UpdatedAt
=
d
.
CreatedAt
}
else
{
d
.
UpdatedAt
=
time
.
Now
()
}
m
:=
repo
.
TransformToModel
(
d
)
tx
:=
repo
.
transactionContext
.
PgTx
var
err
error
if
isCreate
{
_
,
err
=
tx
.
Model
(
&
m
)
.
Returning
(
"id"
)
.
Insert
()
}
else
{
_
,
err
=
tx
.
Model
(
&
m
)
.
Returning
(
"id"
)
.
WherePK
()
.
Update
()
// 更新和删除必须增加条件
}
if
err
!=
nil
{
return
nil
,
err
}
d
.
Id
=
m
.
Id
return
d
,
nil
}
func
(
repo
*
NodeTaskRepository
)
Remove
(
d
*
domain
.
NodeTask
)
(
*
domain
.
NodeTask
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
nowTime
:=
time
.
Now
()
m
:=
repo
.
TransformToModel
(
d
)
m
.
DeletedAt
=
&
nowTime
if
_
,
err
:=
tx
.
Model
(
&
m
)
.
WherePK
()
.
Update
();
err
!=
nil
{
return
d
,
err
}
return
d
,
nil
}
func
(
repo
*
NodeTaskRepository
)
FindOne
(
queryOptions
map
[
string
]
interface
{})
(
*
domain
.
NodeTask
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
m
:=
new
(
models
.
NodeTask
)
query
:=
tx
.
Model
(
m
)
query
.
Where
(
"deleted_at isnull"
)
if
id
,
ok
:=
queryOptions
[
"id"
];
ok
{
query
.
Where
(
"id=?"
,
id
)
}
if
err
:=
query
.
First
();
err
!=
nil
{
if
errors
.
Is
(
err
,
pg
.
ErrNoRows
)
{
return
nil
,
fmt
.
Errorf
(
"没有此资源"
)
}
else
{
return
nil
,
err
}
}
u
:=
repo
.
TransformToDomain
(
m
)
return
&
u
,
nil
}
func
(
repo
*
NodeTaskRepository
)
Find
(
queryOptions
map
[
string
]
interface
{})
([]
*
domain
.
NodeTask
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
var
m
[]
*
models
.
NodeTask
query
:=
tx
.
Model
(
&
m
)
.
Where
(
"deleted_at isnull"
)
if
v
,
ok
:=
queryOptions
[
"now"
]
.
(
time
.
Time
);
ok
{
query
.
Where
(
"next_sent_at <= ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"ids"
];
ok
{
query
.
Where
(
"id in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"companyId"
];
ok
{
query
.
Where
(
"company_id = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"cycleId"
];
ok
{
query
.
Where
(
"cycle_id = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"projectId"
];
ok
{
query
.
Where
(
"project_id = ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"nodeId"
];
ok
{
query
.
Where
(
"node_id = ?"
,
v
)
}
err
:=
query
.
Select
()
if
err
!=
nil
{
return
nil
,
err
}
var
arrays
[]
*
domain
.
NodeTask
for
_
,
v
:=
range
m
{
d
:=
repo
.
TransformToDomain
(
v
)
arrays
=
append
(
arrays
,
&
d
)
}
return
arrays
,
nil
}
...
...
pkg/infrastructure/repository/pg_position_repository.go
查看文件 @
971e4c1
package
repository
import
(
"time"
"github.com/go-pg/pg/v10"
pgTransaction
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/pg/models"
"time"
)
type
PositionRepository
struct
{
...
...
@@ -66,6 +67,37 @@ func (repository *PositionRepository) FindOne(queryOption map[string]interface{}
return
repository
.
transferToDomain
(
position
),
nil
}
func
(
repo
*
PositionRepository
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
domain
.
Position
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
positionModel
:=
[]
models
.
Position
{}
query
:=
tx
.
Model
(
&
positionModel
)
if
v
,
ok
:=
queryOptions
[
"id"
];
ok
{
query
.
Where
(
"id=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"ids"
];
ok
{
query
.
Where
(
"id in(?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"companyId"
];
ok
{
query
.
Where
(
"company_id=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"offset"
];
ok
{
query
.
Offset
(
v
.
(
int
))
}
if
v
,
ok
:=
queryOptions
[
"limit"
];
ok
{
query
.
Limit
(
v
.
(
int
))
}
cnt
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
}
var
resultList
[]
*
domain
.
Position
for
i
:=
range
positionModel
{
result
:=
repo
.
transferToDomain
(
&
positionModel
[
i
])
resultList
=
append
(
resultList
,
result
)
}
return
cnt
,
resultList
,
nil
}
func
(
repository
*
PositionRepository
)
transferToDomain
(
model
*
models
.
Position
)
*
domain
.
Position
{
return
&
domain
.
Position
{
Id
:
model
.
Id
,
...
...
pkg/infrastructure/repository/pg_role_repository.go
查看文件 @
971e4c1
...
...
@@ -113,19 +113,19 @@ func (repo *RoleRepository) Find(queryOptions map[string]interface{}) (int64, []
var
m
[]
*
models
.
Role
query
:=
tx
.
Model
(
&
m
)
.
Where
(
"deleted_at isnull"
)
if
name
,
ok
:=
queryOptions
[
"name"
];
ok
{
query
.
Where
(
"name = ?"
,
name
)
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
if
companyId
,
ok
:=
queryOptions
[
"companyId"
];
ok
{
query
.
Where
(
"company_id = ?"
,
companyId
)
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
...
...
@@ -154,8 +154,8 @@ func (repo *RoleRepository) Count(queryOptions map[string]interface{}) (int64, e
query
.
Where
(
"id != ?"
,
notId
)
}
if
name
,
ok
:=
queryOptions
[
"name"
];
ok
{
query
.
Where
(
"name = ?"
,
name
)
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
if
companyId
,
ok
:=
queryOptions
[
"companyId"
];
ok
{
...
...
pkg/infrastructure/repository/pg_role_user_repository.go
查看文件 @
971e4c1
...
...
@@ -128,11 +128,11 @@ func (repo *RoleUserRepository) Find(queryOptions map[string]interface{}) (int64
query
.
Where
(
"user_id in (?)"
,
pg
.
In
(
userIds
))
}
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int64
);
ok
{
query
.
Limit
(
int
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
count
,
err
:=
query
.
SelectAndCount
()
...
...
@@ -161,8 +161,8 @@ func (repo *RoleUserRepository) Count(queryOptions map[string]interface{}) (int6
query
.
Where
(
"id != ?"
,
notId
)
}
if
name
,
ok
:=
queryOptions
[
"name"
];
ok
{
query
.
Where
(
"name = ?"
,
name
)
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
if
companyId
,
ok
:=
queryOptions
[
"companyId"
];
ok
{
...
...
pkg/infrastructure/repository/pg_staff_assess_repository.go
查看文件 @
971e4c1
...
...
@@ -130,6 +130,10 @@ func (repo *StaffAssessRepository) Find(queryOptions map[string]interface{}) (in
if
v
,
ok
:=
queryOptions
[
"targetUserId"
]
.
(
int
);
ok
&&
v
>
0
{
query
.
Where
(
`target_user->>'userId'='?'`
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"targetUserName"
]
.
(
int
);
ok
&&
v
>
0
{
query
.
Where
(
`target_user->>'userName' like ?`
,
fmt
.
Sprintf
(
"%%%v%%"
,
v
))
}
if
v
,
ok
:=
queryOptions
[
"executorId"
]
.
(
int
);
ok
&&
v
>
0
{
query
.
Where
(
`executor->>'userId'='?'`
,
v
)
}
...
...
pkg/infrastructure/repository/pg_staff_assess_task_repository.go
查看文件 @
971e4c1
...
...
@@ -29,6 +29,7 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa
EvaluationProjectName
:
d
.
EvaluationProjectName
,
CycleId
:
d
.
CycleId
,
CycleName
:
d
.
CycleName
,
BeginDay
:
d
.
BeginDay
,
BeginTime
:
d
.
BeginTime
,
EndTime
:
d
.
EndTime
,
StepList
:
d
.
StepList
,
...
...
@@ -47,6 +48,7 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain.
EvaluationProjectName
:
d
.
EvaluationProjectName
,
CycleId
:
d
.
CycleId
,
CycleName
:
d
.
CycleName
,
BeginDay
:
d
.
BeginDay
,
ExecutorId
:
d
.
ExecutorId
,
StepList
:
d
.
StepList
,
BeginTime
:
d
.
BeginTime
,
...
...
@@ -115,9 +117,15 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{})
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
}
if
v
,
ok
:=
queryOptions
[
"beginDay"
];
ok
{
query
.
Where
(
"begin_day=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"executorId"
]
.
(
int
);
ok
&&
v
>
0
{
query
.
Where
(
`executor_id @>'[?]'`
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"evaluationProjectId"
];
ok
{
query
.
Where
(
"evaluation_project_id=?"
,
v
)
}
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
...
...
pkg/infrastructure/repository/pg_user_repository.go
查看文件 @
971e4c1
...
...
@@ -116,7 +116,7 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
if
v
,
ok
:=
queryOptions
[
"account"
];
ok
{
query
.
Where
(
"account like ?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
;
ok
{
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name like ?"
,
fmt
.
Sprintf
(
"%%%v%%"
,
v
))
}
if
v
,
ok
:=
queryOptions
[
"offset"
];
ok
{
...
...
pkg/port/beego/controllers/evaluation_cycle_controller.go
查看文件 @
971e4c1
...
...
@@ -21,8 +21,6 @@ func (controller *CycleController) CreateCycle() {
ua
:=
middlewares
.
GetUser
(
controller
.
Ctx
)
in
.
CompanyId
=
ua
.
CompanyId
in
.
CreatorId
=
ua
.
UserId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
//in.CreatorId = middlewares.GetUserId(controller.Ctx)
controller
.
Response
(
ruService
.
Create
(
in
))
}
}
...
...
@@ -101,9 +99,10 @@ func (controller *CycleController) CycleTemplateList() {
func
(
controller
*
CycleController
)
CycleTemplate
()
{
ruService
:=
service
.
NewEvaluationCycleService
()
in
:=
&
command
.
CycleTemplateCommand
{}
if
err
:=
controller
.
Unmarshal
(
in
);
err
!=
nil
{
if
id
,
err
:=
controller
.
GetInt64
(
":Id"
);
err
!=
nil
{
controller
.
Response
(
nil
,
application
.
ThrowError
(
application
.
ARG_ERROR
,
err
.
Error
()))
}
else
{
in
.
Id
=
id
controller
.
Response
(
ruService
.
CycleTemplate
(
in
))
}
}
...
...
pkg/port/beego/controllers/staff_assess_controller.go
查看文件 @
971e4c1
...
...
@@ -6,6 +6,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/service"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego/middlewares"
)
type
StaffAssessController
struct
{
...
...
@@ -22,9 +24,10 @@ func (c *StaffAssessController) SearchAssessTaskMe() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
UserId
=
1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
UserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
SearchAssessTaskMe
(
paramReq
)
c
.
Response
(
data
,
err
)
}
...
...
@@ -39,9 +42,9 @@ func (c *StaffAssessController) AssessTaskMeDesc() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
UserId
=
1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
UserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
AssessTaskDesc
(
paramReq
)
c
.
Response
(
data
,
err
)
}
...
...
@@ -56,9 +59,9 @@ func (c *StaffAssessController) AssessSelfMeList() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
UserId
=
1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
UserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
AssessSelfList
(
paramReq
)
c
.
Response
(
data
,
err
)
}
...
...
@@ -88,17 +91,15 @@ func (c *StaffAssessController) GetAssessSelfMeInfo() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
TargetUserId
=
1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
TargetUserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
GetAssessSelfInfo
(
paramReq
)
c
.
Response
(
data
,
err
)
}
//保存员工自评填写内容
// 获取员工邀请的人
func
(
c
*
StaffAssessController
)
GetAssessInviteUser
()
{
// 获取我邀请的人
func
(
c
*
StaffAssessController
)
GetAssessMeInviteUser
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
query
.
GetAssessInviteUserQuery
{}
err
:=
c
.
BindJSON
(
paramReq
)
...
...
@@ -107,15 +108,15 @@ func (c *StaffAssessController) GetAssessInviteUser() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
UserId
=
1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
UserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
GetAssessInviteUser
(
paramReq
)
c
.
Response
(
data
,
err
)
}
// 保持员工邀请的人
func
(
c
*
StaffAssessController
)
SaveAssessInviteUser
()
{
// 保持我邀请的员工
func
(
c
*
StaffAssessController
)
SaveAssessMeInviteUser
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
command
.
SaveAssessInvite
{}
err
:=
c
.
BindJSON
(
paramReq
)
...
...
@@ -141,15 +142,17 @@ func (c *StaffAssessController) SelectAssessInviteUser() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
TargetUserId
=
1
// paramReq.CompanyId = 1
// paramReq.TargetUserId = 1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
TargetUserId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
SelectAssessInviteUser
(
paramReq
)
c
.
Response
(
data
,
err
)
}
// 获取我要执行360评估,用户列表和评估填写的值
func
(
c
*
StaffAssessController
)
ListInviteUserAssess
()
{
func
(
c
*
StaffAssessController
)
List
Me
InviteUserAssess
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
query
.
ListInviteUserAssessQuery
{}
err
:=
c
.
BindJSON
(
paramReq
)
...
...
@@ -158,15 +161,18 @@ func (c *StaffAssessController) ListInviteUserAssess() {
c
.
Response
(
nil
,
e
)
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
ExecutorId
=
1
data
,
err
:=
srv
.
ListInviteUserAssess
(
paramReq
)
//获取当前用户信息
// paramReq.CompanyId = 1
// paramReq.ExecutorId = 1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
ExecutorId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
ListExecutorInviteAssess
(
paramReq
)
c
.
Response
(
data
,
err
)
}
// 获取上级评估成员列表
func
(
c
*
StaffAssessController
)
ListSupperAssess
()
{
// 获取我要执行的上级评估成员列表
func
(
c
*
StaffAssessController
)
ListMeSupperAssess
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
query
.
ListSupperAssessQuery
{}
err
:=
c
.
BindJSON
(
paramReq
)
...
...
@@ -176,14 +182,17 @@ func (c *StaffAssessController) ListSupperAssess() {
return
}
//TODO 获取当前用户信息
paramReq
.
CompanyId
=
1
paramReq
.
ExecutorId
=
1
data
,
err
:=
srv
.
ListSupperAssess
(
paramReq
)
// paramReq.CompanyId = 1
// paramReq.ExecutorId = 1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
ExecutorId
=
int
(
userReq
.
UserId
)
data
,
err
:=
srv
.
ListExecutorSupperAssess
(
paramReq
)
c
.
Response
(
data
,
err
)
}
// 获取员工自评详情
func
(
c
*
StaffAssessController
)
GetAssessSelfInfo
()
{
func
(
c
*
StaffAssessController
)
GetAssess
TargetUser
SelfInfo
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
query
.
AssessSelfInfoQuery
{}
err
:=
c
.
BindJSON
(
paramReq
)
...
...
@@ -192,7 +201,9 @@ func (c *StaffAssessController) GetAssessSelfInfo() {
c
.
Response
(
nil
,
e
)
return
}
paramReq
.
CompanyId
=
1
// paramReq.CompanyId = 1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
data
,
err
:=
srv
.
GetAssessSelfInfo
(
paramReq
)
c
.
Response
(
data
,
err
)
}
...
...
@@ -207,7 +218,41 @@ func (c *StaffAssessController) GetAssessInfo() {
c
.
Response
(
nil
,
e
)
return
}
paramReq
.
CompanyId
=
1
// paramReq.CompanyId = 1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
data
,
err
:=
srv
.
GetAssessInfo
(
paramReq
)
c
.
Response
(
data
,
err
)
}
// 保存评估内容详情
func
(
c
*
StaffAssessController
)
SaveAssessInfo
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
command
.
SaveAssessInfoCommand
{}
err
:=
c
.
BindJSON
(
paramReq
)
if
err
!=
nil
{
e
:=
application
.
ThrowError
(
application
.
ARG_ERROR
,
"json 解析错误"
+
err
.
Error
())
c
.
Response
(
nil
,
e
)
return
}
data
,
err
:=
srv
.
SaveAssessInfo
(
paramReq
)
c
.
Response
(
data
,
err
)
}
// 被评估的员工的评估列表-360评估
func
(
c
*
StaffAssessController
)
ListTargetUserInviteAssess
()
{
srv
:=
service
.
NewStaffAssessServeice
()
paramReq
:=
&
query
.
ListTargetUserAssessQuery
{}
err
:=
c
.
BindJSON
(
paramReq
)
if
err
!=
nil
{
e
:=
application
.
ThrowError
(
application
.
ARG_ERROR
,
"json 解析错误"
+
err
.
Error
())
c
.
Response
(
nil
,
e
)
return
}
// paramReq.CompanyId = 1
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
paramReq
.
Types
=
[]
string
{
string
(
domain
.
AssessInviteSameSuper
),
string
(
domain
.
AssessInviteDiffSuper
)}
data
,
err
:=
srv
.
ListTargetUserAssess
(
paramReq
)
c
.
Response
(
data
,
err
)
}
...
...
pkg/port/beego/routers/evaluation_cycle_router.go
查看文件 @
971e4c1
...
...
@@ -17,6 +17,7 @@ func init() {
web
.
NSRouter
(
"/list"
,
&
controllers
.
CycleController
{},
"Post:ListCycle"
),
web
.
NSRouter
(
"/statistic"
,
&
controllers
.
CycleController
{},
"Post:StatisticCycleUser"
),
web
.
NSRouter
(
"/templates"
,
&
controllers
.
CycleController
{},
"Post:CycleTemplateList"
),
web
.
NSRouter
(
"/template/:Id"
,
&
controllers
.
CycleController
{},
"Get:CycleTemplate"
),
)
web
.
AddNamespace
(
ns
)
}
...
...
pkg/port/beego/routers/staff_assess_router.go
查看文件 @
971e4c1
...
...
@@ -15,13 +15,18 @@ func init() {
// /v1/staff-assess/self/me/list
assessNS
:=
web
.
NewNamespace
(
"/v1/staff-assess"
,
// web.NSBefore(filters.AllowCors(), middlewares.CheckToken()),
web
.
NSCtrlPost
(
"/self/me/list"
,
(
*
controllers
.
StaffAssessController
)
.
AssessSelfMeList
),
//获取我的自评反馈列表
web
.
NSCtrlPost
(
"/self/me/info"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessSelfMeInfo
),
//获取我的自评反馈详情
web
.
NSCtrlPost
(
"/me/invite-user"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessInviteUser
),
//获取邀请的员工
web
.
NSCtrlPost
(
"/me/save-invite-user"
,
(
*
controllers
.
StaffAssessController
)
.
SaveAssessInviteUser
),
//保存我邀请的员工
web
.
NSCtrlPost
(
"/me/invite-user/select"
,
(
*
controllers
.
StaffAssessController
)
.
SelectAssessInviteUser
),
//选择我邀请的员工
web
.
NSCtrlPost
(
"/self/info"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessSelfInfo
),
//获取我的自评反馈详情
web
.
NSCtrlPost
(
"/info"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessInfo
),
//获取我的自评反馈详情
web
.
NSCtrlPost
(
"/self/me/list"
,
(
*
controllers
.
StaffAssessController
)
.
AssessSelfMeList
),
//获取我的自评反馈列表
web
.
NSCtrlPost
(
"/self/me/info"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessSelfMeInfo
),
//获取我的自评反馈详情
web
.
NSCtrlPost
(
"/me/invite-user"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessMeInviteUser
),
//获取邀请的员工
web
.
NSCtrlPost
(
"/me/save-invite-user"
,
(
*
controllers
.
StaffAssessController
)
.
SaveAssessMeInviteUser
),
//保存我邀请的员工
web
.
NSCtrlPost
(
"/me/invite-user/select"
,
(
*
controllers
.
StaffAssessController
)
.
SelectAssessInviteUser
),
//选择我邀请的员工
web
.
NSCtrlPost
(
"/me/execute/invite/list"
,
(
*
controllers
.
StaffAssessController
)
.
ListMeInviteUserAssess
),
//我要执行的360评估的用户列表
web
.
NSCtrlPost
(
"/me/execute/supper/list"
,
(
*
controllers
.
StaffAssessController
)
.
ListMeSupperAssess
),
//我要执行的360评估的用户列表
web
.
NSCtrlPost
(
"/info"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessInfo
),
//通用获取员工评估的详情
web
.
NSCtrlPut
(
"/info"
,
(
*
controllers
.
StaffAssessController
)
.
SaveAssessInfo
),
//通用保存员工评估的详情
web
.
NSCtrlPost
(
"/target-user/invite/list"
,
(
*
controllers
.
StaffAssessController
)
.
ListTargetUserInviteAssess
),
//获取被评估员工评估的详情
web
.
NSCtrlPost
(
"/target-user/self/info"
,
(
*
controllers
.
StaffAssessController
)
.
GetAssessTargetUserSelfInfo
),
//获取被评估员工的自评反馈详情
)
web
.
AddNamespace
(
assessTaskNS
)
web
.
AddNamespace
(
assessNS
)
...
...
pkg/utils/common.go
查看文件 @
971e4c1
...
...
@@ -2,9 +2,12 @@ package utils
import
(
"fmt"
timeconv
"github.com/Andrew-M-C/go.timeconv"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"reflect"
"strings"
"time"
)
// ValidateCommand 验证输入参数
...
...
@@ -31,3 +34,70 @@ func ValidateCommand(commandType interface{}) error {
}
return
nil
}
// NextTime 0点时刻为标准计算
func
NextTime
(
now0
time
.
Time
,
start
*
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
// 起始时间0点时刻
start0
:=
time
.
Date
(
start
.
Year
(),
start
.
Month
(),
start
.
Day
(),
0
,
0
,
0
,
0
,
time
.
Local
)
var
nextTime
time
.
Time
switch
kpiCycle
{
case
domain
.
KpiCycleDay
:
nextTime
=
timeconv
.
AddDate
(
now0
,
0
,
0
,
1
)
// 当前时间的下一天开始发送
break
case
domain
.
KpiCycleWeek
:
offsetSeconds
:=
int64
(
now0
.
Sub
(
start0
)
.
Seconds
())
offsetDay
:=
offsetSeconds
/
(
24
*
60
*
60
)
cycleCount
:=
int
(
offsetDay
)
/
7
+
1
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
0
,
cycleCount
*
7
)
break
case
domain
.
KpiCycleOneMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
1
,
0
)
break
case
domain
.
KpiCycleTwoMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
2
,
0
)
break
case
domain
.
KpiCycleThreeMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
3
,
0
)
break
case
domain
.
KpiCycleSixMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
6
,
0
)
break
case
domain
.
KpiCycleYear
:
nextTime
=
timeconv
.
AddDate
(
start0
,
1
,
0
,
0
)
break
}
return
nextTime
}
// NextTimeInc 0点时刻为标准计算
func
NextTimeInc
(
start
*
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
// 起始时间0点时刻
start0
:=
time
.
Date
(
start
.
Year
(),
start
.
Month
(),
start
.
Day
(),
0
,
0
,
0
,
0
,
time
.
Local
)
var
nextTime
time
.
Time
switch
kpiCycle
{
case
domain
.
KpiCycleDay
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
0
,
1
)
// 当前时间的下一天开始发送
break
case
domain
.
KpiCycleWeek
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
0
,
7
)
break
case
domain
.
KpiCycleOneMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
1
,
0
)
break
case
domain
.
KpiCycleTwoMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
2
,
0
)
break
case
domain
.
KpiCycleThreeMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
3
,
0
)
break
case
domain
.
KpiCycleSixMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
6
,
0
)
break
case
domain
.
KpiCycleYear
:
nextTime
=
timeconv
.
AddDate
(
start0
,
1
,
0
,
0
)
break
}
return
nextTime
}
...
...
请
注册
或
登录
后发表评论