切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
df3801b0c029ef1d2957f27af5ae532dac78925d
1 个父辈
ecd1aa5f
增加环节顺序,
消息发送优化
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
59 行增加
和
51 行删除
pkg/application/evaluation_project/project_service.go
pkg/application/node_task/node_task_service.go
pkg/domain/node_task.go
pkg/infrastructure/pg/models/node_task.go
pkg/infrastructure/repository/pg_evaluation_cycle_repository.go
pkg/infrastructure/repository/pg_evaluation_project_repository.go
pkg/infrastructure/repository/pg_node_task_repository.go
pkg/utils/common.go
pkg/application/evaluation_project/project_service.go
查看文件 @
df3801b
...
...
@@ -177,12 +177,12 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// FIXME 启动时,需要激活定时任务
if
in
.
Activate
==
1
{
if
len
(
in
.
Recipients
)
==
0
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"请添加被评估人"
)
}
project
.
State
=
domain
.
ProjectStateEnable
if
cycleTemplate
==
nil
||
cycleTemplate
.
Template
==
nil
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"请添加模板"
)
}
if
len
(
in
.
Recipients
)
==
0
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"请添加被评估人"
)
}
start
,
err
:=
time
.
ParseInLocation
(
"2006-01-02 15:04:05"
,
in
.
TimeStart
,
time
.
Local
)
...
...
@@ -209,6 +209,14 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"评估截至时间不能超出周期截至时间"
)
}
//// FIXME 启动时,需要激活定时任务
//if in.Activate == 1 {
// project.State = domain.ProjectStateEnable
//} else {
// project.State = domain.ProjectStateWaitActive
//}
project
.
State
=
domain
.
ProjectStateWaitActive
project
.
Recipients
=
in
.
Recipients
project
.
Template
=
cycleTemplate
.
Template
for
i
:=
range
project
.
Template
.
LinkNodes
{
...
...
@@ -348,7 +356,9 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
if
len
(
project
.
Recipients
)
==
0
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"请添加被评估人"
)
}
if
project
.
State
==
domain
.
TemplateStateEnable
{
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())
...
...
@@ -378,6 +388,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
NodeType
:
node
.
Type
,
NodeName
:
node
.
Name
,
NodeDescribe
:
node
.
Describe
,
NodeSort
:
i
+
1
,
TimeStart
:
node
.
TimeStart
,
TimeEnd
:
node
.
TimeEnd
,
KpiCycle
:
node
.
KpiCycle
,
...
...
pkg/application/node_task/node_task_service.go
查看文件 @
df3801b
...
...
@@ -39,9 +39,6 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleRepository
:=
factory
.
CreateEvaluationCycleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
//ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
//
projectIdsMap
:=
map
[
int64
]
*
domain
.
EvaluationProject
{}
cycleIdsMap
:=
map
[
int64
]
*
domain
.
EvaluationCycle
{}
for
i
:=
range
tasks
{
...
...
@@ -74,7 +71,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
cycleIdsMap
[
cycles
[
i
]
.
Id
]
=
cycles
[
i
]
}
staffAssess
TaskMap
:=
map
[
int64
]
*
command
.
CreateStaffAssessTask
{}
staffAssess
Service
:=
service
.
NewStaffAssessServeice
()
for
i
:=
range
tasks
{
task
:=
tasks
[
i
]
// 项目
...
...
@@ -108,47 +105,44 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
fmCycleStartTime
:=
cycleTimeStart
.
Format
(
"2006-1-2 15:04:05"
)
fmCycleTimeEnd
:=
cycleTimeEnd
.
Format
(
"2006-1-2 15:04:05"
)
var
csat
,
staffOk
=
staffAssessTaskMap
[
task
.
ProjectId
]
if
!
staffOk
{
csat
=
&
command
.
CreateStaffAssessTask
{
CompanyId
:
int
(
project
.
CompanyId
),
EvaluationProjectId
:
int
(
project
.
Id
),
EvaluationProjectName
:
project
.
Name
,
CycleId
:
project
.
CycleId
,
}
// 周期名称
if
cycle
,
ok
:=
cycleIdsMap
[
project
.
CycleId
];
ok
{
csat
.
CycleName
=
cycle
.
Name
}
// 接收人
csat
.
ExecutorId
=
make
([]
int
,
0
)
for
rIndex
:=
range
project
.
Recipients
{
vInt
,
_
:=
strconv
.
Atoi
(
project
.
Recipients
[
rIndex
])
csat
.
ExecutorId
=
append
(
csat
.
ExecutorId
,
vInt
)
}
// FIXME 这里设置时间可能会有歧义,目前原型设计时间均一致,所以直接选取第一个获取到的周期时间,作为本周期的起止和截止时间
csat
.
BeginTime
=
fmCycleStartTime
csat
.
EndTime
=
fmCycleTimeEnd
staffAssessTaskMap
[
task
.
ProjectId
]
=
csat
csat
:=
&
command
.
CreateStaffAssessTask
{
CompanyId
:
int
(
project
.
CompanyId
),
EvaluationProjectId
:
int
(
project
.
Id
),
EvaluationProjectName
:
project
.
Name
,
CycleId
:
project
.
CycleId
,
StepList
:
make
([]
command
.
AssessTaskStep
,
0
),
}
// 周期名称
if
cycle
,
ok
:=
cycleIdsMap
[
project
.
CycleId
];
ok
{
csat
.
CycleName
=
cycle
.
Name
}
if
csat
.
StepList
==
nil
{
csat
.
StepList
=
make
([]
command
.
AssessTaskStep
,
0
)
// 接收人
csat
.
ExecutorId
=
make
([]
int
,
0
)
for
rIndex
:=
range
project
.
Recipients
{
vInt
,
_
:=
strconv
.
Atoi
(
project
.
Recipients
[
rIndex
])
csat
.
ExecutorId
=
append
(
csat
.
ExecutorId
,
vInt
)
}
csat
.
BeginTime
=
fmCycleStartTime
csat
.
EndTime
=
fmCycleTimeEnd
csat
.
StepList
=
append
(
csat
.
StepList
,
command
.
AssessTaskStep
{
SortBy
:
i
,
SortBy
:
task
.
NodeSort
,
LinkNodeId
:
int
(
task
.
NodeId
),
LinkNodeName
:
task
.
NodeName
,
LinkNodeType
:
task
.
NodeType
,
BeginTime
:
fmCycleStartTime
,
EndTime
:
fmCycleTimeEnd
,
})
// 创建发送任务
_
,
err
:=
staffAssessService
.
CreateStaffAssessTask
(
transactionContext
,
csat
)
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
else
{
task
.
NextSentAt
=
nil
task
.
NextSentAt
=
nil
// 项目不存在,取消周期任务发送
}
task
,
err
:=
taskRepository
.
Insert
(
task
)
...
...
@@ -157,15 +151,6 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
}
}
staffAssessService
:=
service
.
NewStaffAssessServeice
()
for
i
:=
range
staffAssessTaskMap
{
staffAssessTask
:=
staffAssessTaskMap
[
i
]
_
,
err
:=
staffAssessService
.
CreateStaffAssessTask
(
transactionContext
,
staffAssessTask
)
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
())
}
...
...
pkg/domain/node_task.go
查看文件 @
df3801b
...
...
@@ -13,6 +13,7 @@ type NodeTask struct {
NodeType
int
`json:"nodeType" comment:"环节类型"`
NodeName
string
`json:"nodeName" comment:"环节名称"`
NodeDescribe
string
`json:"nodeDescribe" comment:"环节描述"`
NodeSort
int
`json:"nodeSort" comment:"环节顺序"`
TimeStart
*
time
.
Time
`json:"timeStart" comment:"起始时间"`
TimeEnd
*
time
.
Time
`json:"timeEnd" comment:"截至时间"`
KpiCycle
int
`json:"kpiCycle" comment:"考核周期(1日、2周、3月)"`
...
...
pkg/infrastructure/pg/models/node_task.go
查看文件 @
df3801b
...
...
@@ -14,6 +14,7 @@ type NodeTask struct {
NodeType
int
`comment:"环节类型"`
NodeName
string
`comment:"环节名称"`
NodeDescribe
string
`comment:"环节描述"`
NodeSort
int
`comment:"环节顺序"`
TimeStart
*
time
.
Time
`comment:"起始时间"`
TimeEnd
*
time
.
Time
`comment:"截至时间"`
KpiCycle
int
`comment:"考核周期(1日、2周、3月)"`
...
...
pkg/infrastructure/repository/pg_evaluation_cycle_repository.go
查看文件 @
df3801b
...
...
@@ -123,6 +123,10 @@ func (repo *EvaluationCycleRepository) Find(queryOptions map[string]interface{})
query
.
Where
(
"name LIKE ?"
,
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
)
}
...
...
pkg/infrastructure/repository/pg_evaluation_project_repository.go
查看文件 @
df3801b
...
...
@@ -131,6 +131,10 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
query
.
ExcludeColumn
(
excludeColumns
...
)
}
if
v
,
ok
:=
queryOptions
[
"ids"
];
ok
{
query
.
Where
(
"id in (?)"
,
pg
.
In
(
v
))
}
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name = ?"
,
v
)
}
...
...
pkg/infrastructure/repository/pg_node_task_repository.go
查看文件 @
df3801b
...
...
@@ -30,6 +30,7 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod
NodeType
:
m
.
NodeType
,
NodeName
:
m
.
NodeName
,
NodeDescribe
:
m
.
NodeDescribe
,
NodeSort
:
m
.
NodeSort
,
TimeStart
:
m
.
TimeStart
,
TimeEnd
:
m
.
TimeEnd
,
KpiCycle
:
m
.
KpiCycle
,
...
...
@@ -50,6 +51,7 @@ func (repo *NodeTaskRepository) TransformToModel(d *domain.NodeTask) models.Node
NodeType
:
d
.
NodeType
,
NodeName
:
d
.
NodeName
,
NodeDescribe
:
d
.
NodeDescribe
,
NodeSort
:
d
.
NodeSort
,
TimeStart
:
d
.
TimeStart
,
TimeEnd
:
d
.
TimeEnd
,
KpiCycle
:
d
.
KpiCycle
,
...
...
pkg/utils/common.go
查看文件 @
df3801b
...
...
@@ -43,7 +43,7 @@ func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time {
var
nextTime
time
.
Time
switch
kpiCycle
{
case
domain
.
KpiCycleDay
:
nextTime
=
timeconv
.
AddDate
(
now0
,
0
,
0
,
1
)
// 当前时间的下一天开始发送
nextTime
=
timeconv
.
AddDate
(
now0
,
0
,
0
,
1
)
// 当前时间的下一天
0点
开始发送
break
case
domain
.
KpiCycleWeek
:
offsetSeconds
:=
int64
(
now0
.
Sub
(
start0
)
.
Seconds
())
...
...
请
注册
或
登录
后发表评论