切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
1e3ffb44040bc77cddf6b3799ce9c0b8c03efa29
1 个父辈
be9ff5e5
1. 修复BUG,项目更新截止时间时,未同步更新表node_task中的任务时间!
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
61 行增加
和
56 行删除
pkg/application/evaluation_project/project_service.go
pkg/application/evaluation_project/project_service.go
查看文件 @
1e3ffb4
...
...
@@ -155,79 +155,28 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
if
end
.
After
(
maxTime
)
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"评估截至时间不能超出周期截至时间"
)
}
// 更新项目模板中的环节时间
if
project
.
Template
!=
nil
{
for
i
:=
range
project
.
Template
.
LinkNodes
{
node
:=
project
.
Template
.
LinkNodes
[
i
]
node
.
TimeEnd
=
&
end
}
}
//
项目起始
截止时间(暂时环节中的时间未分开)
//
更新项目
截止时间(暂时环节中的时间未分开)
project
.
EndTime
=
end
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
})
tasks
,
err
:=
taskRepository
.
Find
(
map
[
string
]
interface
{}{
"projectId"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
now
:=
time
.
Now
()
.
Local
()
year
,
month
,
day
:=
now
.
Date
()
nowO
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
// 当前时间0点0分0秒时刻
for
i
:=
range
tasks
{
task
:=
tasks
[
i
]
task
.
TimeEnd
=
&
end
// 重新计算
if
task
.
NextSentAt
==
nil
{
// 环节起始和截止本地时间
startLocal
:=
task
.
TimeStart
.
Local
()
sY
,
sM
,
sD
:=
startLocal
.
Date
()
startLocal
=
time
.
Date
(
sY
,
sM
,
sD
,
0
,
0
,
0
,
0
,
time
.
Local
)
// 开始时间以0点开始计算
endLocal
:=
task
.
TimeEnd
.
Local
()
// 在当前时间之前,则计算下一个周期时间
if
startLocal
.
Before
(
nowO
)
{
nextTime
:=
utils
.
NextTime
(
nowO
,
startLocal
,
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
else
{
task
.
NextSentAt
=
&
startLocal
}
// 注.最后一次发送时间和重新计算后的时间相同时,继续获取下一个周期
if
task
.
LastSentAt
!=
nil
{
nextY
,
nextM
,
nextD
:=
task
.
NextSentAt
.
Local
()
.
Date
()
lastY
,
lastM
,
lastD
:=
task
.
LastSentAt
.
Local
()
.
Date
()
if
nextY
==
lastY
&&
nextM
==
lastM
&&
nextD
==
lastD
{
nextTime
:=
utils
.
NextTimeInc
(
task
.
NextSentAt
.
Local
(),
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
}
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
After
(
endLocal
)
{
task
.
NextSentAt
=
nil
}
}
else
{
// 新的截止时间在下一次发送周期任务之前,则结束
if
end
.
Before
(
task
.
NextSentAt
.
Local
())
{
task
.
NextSentAt
=
nil
}
else
{
// do nothing
}
}
// 项目调整截止时间,同步更新任务时间
if
err
:=
rs
.
updateTaskTime
(
transactionContext
,
in
.
Id
,
end
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
project
,
nil
}
else
{
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
in
.
CompanyId
,
"cycleId"
:
in
.
CycleId
},
"template"
)
if
err
!=
nil
{
...
...
@@ -314,6 +263,62 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
}
}
// 更新项目截止时间,同步任务截止时间
func
(
rs
*
EvaluationProjectService
)
updateTaskTime
(
context
application
.
TransactionContext
,
projectId
int64
,
end
time
.
Time
)
error
{
// 查看任务过程,重新日计算任务截至期
taskRepository
:=
factory
.
CreateNodeTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
context
})
tasks
,
err
:=
taskRepository
.
Find
(
map
[
string
]
interface
{}{
"projectId"
:
projectId
})
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
now
:=
time
.
Now
()
.
Local
()
year
,
month
,
day
:=
now
.
Date
()
nowO
:=
time
.
Date
(
year
,
month
,
day
,
0
,
0
,
0
,
0
,
time
.
Local
)
// 当前时间0点0分0秒时刻
for
i
:=
range
tasks
{
task
:=
tasks
[
i
]
task
.
TimeEnd
=
&
end
// 先赋值
if
task
.
NextSentAt
==
nil
{
// 重新计算
// 环节起始和截止本地时间
startLocal
:=
task
.
TimeStart
.
Local
()
sY
,
sM
,
sD
:=
startLocal
.
Date
()
startLocal
=
time
.
Date
(
sY
,
sM
,
sD
,
0
,
0
,
0
,
0
,
time
.
Local
)
// 开始时间以0点开始计算
// 在当前时间之前,则计算下一个周期时间
if
startLocal
.
Before
(
nowO
)
{
nextTime
:=
utils
.
NextTime
(
nowO
,
startLocal
,
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
else
{
task
.
NextSentAt
=
&
startLocal
}
// 注.最后一次发送时间和重新计算后的时间相同时,继续获取下一个周期
if
task
.
LastSentAt
!=
nil
{
nextY
,
nextM
,
nextD
:=
task
.
NextSentAt
.
Local
()
.
Date
()
lastY
,
lastM
,
lastD
:=
task
.
LastSentAt
.
Local
()
.
Date
()
if
nextY
==
lastY
&&
nextM
==
lastM
&&
nextD
==
lastD
{
nextTime
:=
utils
.
NextTimeInc
(
task
.
NextSentAt
.
Local
(),
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
}
}
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
Local
()
.
After
(
task
.
TimeEnd
.
Local
())
{
task
.
NextSentAt
=
nil
}
// 更新任务
task
,
err
:=
taskRepository
.
Insert
(
task
)
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
return
nil
}
func
(
rs
*
EvaluationProjectService
)
Get
(
in
*
command
.
GetProjectCommand
)
(
interface
{},
error
)
{
transactionContext
,
err
:=
factory
.
ValidateStartTransaction
(
in
)
if
err
!=
nil
{
...
...
请
注册
或
登录
后发表评论