切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
b6017b6a924f610cbdfbe0991b389eedde81ab11
2 个父辈
18694690
897b9a1d
Merge branch 'test' of
http://gitlab.fjmaimaimai.com/allied-creation/performance
into test
显示空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
29 行增加
和
20 行删除
pkg/application/evaluation_project/adapter/project_adapter.go
pkg/application/evaluation_project/project_service.go
pkg/application/node_task/node_task_service.go
pkg/application/user/user.go
pkg/domain/user.go
pkg/infrastructure/repository/pg_node_task_repository.go
pkg/infrastructure/repository/pg_user_repository.go
pkg/utils/common.go
pkg/application/evaluation_project/adapter/project_adapter.go
查看文件 @
b6017b6
...
...
@@ -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
查看文件 @
b6017b6
...
...
@@ -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
查看文件 @
b6017b6
...
...
@@ -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/application/user/user.go
查看文件 @
b6017b6
...
...
@@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type
UserService
struct
{}
...
...
@@ -26,6 +27,7 @@ func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (inter
count
,
list
,
err
:=
userRepo
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
listUserQuery
.
CompanyId
,
"name"
:
listUserQuery
.
Name
,
"status"
:
domain
.
UserStatusEnable
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
pkg/domain/user.go
查看文件 @
b6017b6
...
...
@@ -24,7 +24,7 @@ const (
UserTypeCommon
int
=
1
UserTypeManager
int
=
2
UserStatusEnable
int
=
1
UserStatusEnable
int
=
1
// 正常用户 2禁用用户
)
type
UserRepository
interface
{
...
...
pkg/infrastructure/repository/pg_node_task_repository.go
查看文件 @
b6017b6
...
...
@@ -21,9 +21,6 @@ func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext)
}
func
(
repo
*
NodeTaskRepository
)
TransformToDomain
(
m
*
models
.
NodeTask
)
domain
.
NodeTask
{
timeStart
:=
m
.
TimeStart
.
Local
()
timeEnd
:=
m
.
TimeEnd
.
Local
()
nextSentAt
:=
m
.
NextSentAt
.
Local
()
return
domain
.
NodeTask
{
Id
:
m
.
Id
,
CompanyId
:
m
.
CompanyId
,
...
...
@@ -34,10 +31,10 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod
NodeName
:
m
.
NodeName
,
NodeDescribe
:
m
.
NodeDescribe
,
NodeSort
:
m
.
NodeSort
,
TimeStart
:
&
timeStart
,
TimeEnd
:
&
timeEnd
,
TimeStart
:
m
.
TimeStart
,
TimeEnd
:
m
.
TimeEnd
,
KpiCycle
:
m
.
KpiCycle
,
NextSentAt
:
&
n
extSentAt
,
NextSentAt
:
m
.
N
extSentAt
,
CreatedAt
:
m
.
CreatedAt
.
Local
(),
UpdatedAt
:
m
.
UpdatedAt
.
Local
(),
DeletedAt
:
m
.
DeletedAt
,
...
...
pkg/infrastructure/repository/pg_user_repository.go
查看文件 @
b6017b6
...
...
@@ -119,6 +119,9 @@ 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
[
"status"
];
ok
{
query
.
Where
(
"status=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"name"
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
query
.
Where
(
"name like ?"
,
fmt
.
Sprintf
(
"%%%v%%"
,
v
))
}
...
...
pkg/utils/common.go
查看文件 @
b6017b6
...
...
@@ -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
)
...
...
请
注册
或
登录
后发表评论