切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
501ff4814ae61b88098969977f4403d06305ed1e
1 个父辈
7535d859
1. 优化时间以当天时间 0 点开始计算
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
20 行增加
和
13 行删除
pkg/application/evaluation_project/adapter/project_adapter.go
pkg/application/evaluation_project/project_service.go
pkg/application/node_task/node_task_service.go
pkg/utils/common.go
pkg/application/evaluation_project/adapter/project_adapter.go
查看文件 @
501ff48
...
...
@@ -17,6 +17,7 @@ type EvaluationProjectAdapter struct {
}
func
(
adapter
*
EvaluationProjectAdapter
)
TransformRecipientAdapter
(
recipients
[]
*
domain
.
User
)
{
adapter
.
RecipientList
=
make
([]
*
UserAdapter
,
0
)
for
i
:=
range
recipients
{
adapter
.
RecipientList
=
append
(
adapter
.
RecipientList
,
&
UserAdapter
{
Id
:
recipients
[
i
]
.
Id
,
...
...
@@ -26,6 +27,7 @@ func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []
}
func
(
adapter
*
EvaluationProjectAdapter
)
TransformPmpAdapter
(
pms
[]
*
domain
.
User
)
{
adapter
.
PmpList
=
make
([]
*
UserAdapter
,
0
)
for
i
:=
range
pms
{
adapter
.
PmpList
=
append
(
adapter
.
PmpList
,
&
UserAdapter
{
Id
:
pms
[
i
]
.
Id
,
...
...
@@ -46,6 +48,8 @@ func TransformProjectListAdapter(projects []*domain.EvaluationProject, users []*
epa
:=
&
EvaluationProjectAdapter
{}
epa
.
EvaluationProject
=
project
epa
.
PmpList
=
make
([]
*
UserAdapter
,
0
)
projectAdapters
=
append
(
projectAdapters
,
epa
)
for
j
:=
range
project
.
PmpIds
{
...
...
pkg/application/evaluation_project/project_service.go
查看文件 @
501ff48
...
...
@@ -185,18 +185,20 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
// 重新计算
if
task
.
NextSentAt
==
nil
{
// 环节起始和截止本地时间
startLocal
:=
task
.
TimeStart
endLocal
:=
task
.
TimeEnd
startLocal
:=
task
.
TimeStart
.
Local
()
sYear
,
sMonth
,
sDay
:=
startLocal
.
Date
()
startLocal
=
time
.
Date
(
sYear
,
sMonth
,
sDay
,
0
,
0
,
0
,
0
,
time
.
Local
)
// 开始时间以0点开始计算
endLocal
:=
task
.
TimeEnd
.
Local
()
// 在当前时间之前,则计算下一个周期时间
if
startLocal
.
Before
(
now
)
{
nextTime
:=
utils
.
NextTime
(
nowO
,
startLocal
,
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
else
{
task
.
NextSentAt
=
startLocal
task
.
NextSentAt
=
&
startLocal
}
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
After
(
endLocal
.
Local
()
)
{
if
task
.
NextSentAt
.
After
(
endLocal
)
{
task
.
NextSentAt
=
nil
}
}
else
{
...
...
@@ -435,6 +437,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}()
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
taskRepository
:=
factory
.
CreateNodeTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
project
,
err
:=
projectRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
...
...
@@ -456,8 +459,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
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秒时刻
...
...
@@ -479,18 +480,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}
// 环节起始和截止本地时间
startLocal
:=
node
.
TimeStart
endLocal
:=
node
.
TimeEnd
startLocal
:=
task
.
TimeStart
.
Local
()
sYear
,
sMonth
,
sDay
:=
startLocal
.
Date
()
startLocal
=
time
.
Date
(
sYear
,
sMonth
,
sDay
,
0
,
0
,
0
,
0
,
time
.
Local
)
// 开始时间以0点开始计算
endLocal
:=
task
.
TimeEnd
.
Local
()
// 在当前时间之前,则计算下一个周期时间
if
startLocal
.
Before
(
now
)
{
nextTime
:=
utils
.
NextTime
(
nowO
,
startLocal
,
node
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
else
{
task
.
NextSentAt
=
startLocal
task
.
NextSentAt
=
&
startLocal
}
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
After
(
endLocal
.
Local
()
)
{
if
task
.
NextSentAt
.
After
(
endLocal
)
{
task
.
NextSentAt
=
nil
}
...
...
pkg/application/node_task/node_task_service.go
查看文件 @
501ff48
...
...
@@ -87,7 +87,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
maxTime
:=
task
.
TimeEnd
.
Local
()
// 当前周起始时间和截止时间
var
cycleTimeStart
=
task
.
NextSentAt
var
cycleTimeStart
=
task
.
NextSentAt
.
Local
()
var
cycleTimeEnd
time
.
Time
// 下个周期起始时间
...
...
pkg/utils/common.go
查看文件 @
501ff48
...
...
@@ -37,7 +37,7 @@ func ValidateCommand(commandType interface{}) error {
}
// NextTime 0点时刻为标准计算
func
NextTime
(
now0
time
.
Time
,
start
*
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
func
NextTime
(
now0
time
.
Time
,
start
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
year
,
month
,
day
:=
start
.
Date
()
// 起始时间0点时刻
start0
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
...
...
@@ -141,7 +141,7 @@ func SubMonth(t1, t2 time.Time) (month int) {
}
// NextTimeInc 0点时刻为标准计算
func
NextTimeInc
(
start
*
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
func
NextTimeInc
(
start
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
year
,
month
,
day
:=
start
.
Date
()
// 起始时间0点时刻
start0
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
...
...
请
注册
或
登录
后发表评论