切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
郑周
2 years ago
提交
bb7ab4324e4516833a6d76a7688fec75f6a67fa2
1 个父辈
718105b6
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
1.修复已知BUG
显示空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
224 行增加
和
107 行删除
pkg/application/evaluation_cycle/cycle_service.go
pkg/application/evaluation_project/command/project_update.go
pkg/application/evaluation_project/project_service.go
pkg/domain/evaluation_project.go
pkg/infrastructure/pg/models/evaluation_project.go
pkg/infrastructure/pg/models/node_timer_task.go
pkg/infrastructure/repository/pg_evaluation_project_repository.go
pkg/port/beego/controllers/evaluation_project_controller.go
pkg/utils/common.go
pkg/application/evaluation_cycle/cycle_service.go
查看文件 @
bb7ab43
...
...
@@ -88,17 +88,21 @@ func (rs *EvaluationCycleService) Create(in *command.CreateCycleCommand) (interf
}
}
}
ruleMap
:=
map
[
int64
]
*
domain
.
EvaluationRule
{}
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
{}
if
len
(
ruleIds
)
>
0
{
if
_
,
rules
,
err
:=
ruleRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
ruleIds
,
"companyId"
:
in
.
CompanyId
});
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
else
{
for
i
:=
range
rules
{
ruleMap
[
rules
[
i
]
.
Id
]
=
rules
[
i
]
}
}
}
ctAdapter
:=
&
adapter
.
CycleTemplateAdapter
{}
ctAdapter
.
EvaluationCycle
=
cycle
...
...
@@ -307,7 +311,10 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
cycleRepository
:=
factory
.
CreateEvaluationCycleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cycleTemplateRepository
:=
factory
.
CreateEvaluationCycleTemplateRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
projectRepository
:=
factory
.
CreateEvaluationProjectRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
taskRepository
:=
factory
.
CreateNodeTaskRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
// 删除周期
cycle
,
err
:=
cycleRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -316,11 +323,34 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//
FIXME 删除周期关联的所有模板... 还需要删除关联的定时内容
//
删除周期关联的所有模板,真删
if
err
:=
cycleTemplateRepository
.
BatchDeleteByCycleId
(
cycle
.
Id
);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 删除周期下的所有项目
_
,
projects
,
err
:=
projectRepository
.
Find
(
map
[
string
]
interface
{}{
"cycleId"
:
in
.
Id
},
"template"
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
for
i
:=
range
projects
{
if
_
,
err
:=
projectRepository
.
Remove
(
projects
[
i
]);
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
// 删除周期下的所有任务
tasks
,
err
:=
taskRepository
.
Find
(
map
[
string
]
interface
{}{
"cycleId"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
for
i
:=
range
tasks
{
if
_
,
err
:=
taskRepository
.
Remove
(
tasks
[
i
]);
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
())
}
...
...
pkg/application/evaluation_project/command/project_update.go
查看文件 @
bb7ab43
...
...
@@ -25,8 +25,6 @@ type UpdateProjectTemplateCommand struct {
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
{
...
...
pkg/application/evaluation_project/project_service.go
查看文件 @
bb7ab43
...
...
@@ -135,7 +135,14 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
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
},
"template"
)
project
,
err
:=
projectRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 如果是已经启用的项目,只能编辑环节的截至时间
if
project
.
State
==
domain
.
ProjectStateEnable
{
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
())
}
...
...
@@ -144,7 +151,74 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
maxTime
:=
cycle
.
TimeEnd
.
Local
()
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
()
nowO
:=
time
.
Date
(
now
.
Year
(),
now
.
Month
(),
now
.
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
()
endLocal
:=
task
.
TimeEnd
.
Local
()
// 在当前时间之前,则计算下一个周期时间
if
startLocal
.
Before
(
now
)
{
nextTime
:=
utils
.
NextTime
(
nowO
,
startLocal
,
task
.
KpiCycle
)
task
.
NextSentAt
=
&
nextTime
}
else
{
task
.
NextSentAt
=
&
startLocal
}
// 如果超出截至时间,则周期置空
if
task
.
NextSentAt
.
After
(
endLocal
)
{
task
.
NextSentAt
=
nil
}
}
else
{
// 新的截止时间在下一次发送周期任务之前,则结束
if
end
.
Before
(
task
.
NextSentAt
.
Local
())
{
task
.
NextSentAt
=
nil
}
else
{
// do nothing
}
}
}
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
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 周期内的所有项目,员工不能重复被评估
rids
:=
map
[
string
]
bool
{}
for
i
:=
range
projects
{
...
...
@@ -167,24 +241,14 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
fmt
.
Sprintf
(
"有%d人已经在本周期其他项目内,需要将他们移除"
,
repeatNum
))
}
project
,
err
:=
projectRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
cycleTemplate
,
err
:=
cycleTemplateRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
TemplateId
,
"includeDeleted"
:
true
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
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
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
...
...
@@ -193,11 +257,11 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
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
)
cycle
,
err
:=
cycleRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
in
.
CycleId
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
minTime
:=
cycle
.
TimeStart
.
Local
()
maxTime
:=
cycle
.
TimeEnd
.
Local
()
...
...
@@ -209,27 +273,21 @@ 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
//}
if
project
.
State
==
domain
.
ProjectStateWaitConfig
{
project
.
State
=
domain
.
ProjectStateWaitActive
}
project
.
Recipients
=
in
.
Recipients
project
.
Template
=
cycleTemplate
.
Template
// 项目起始截止时间(环节中的时间暂未分开计算)
project
.
BeginTime
=
start
project
.
EndTime
=
end
for
i
:=
range
project
.
Template
.
LinkNodes
{
node
:=
project
.
Template
.
LinkNodes
[
i
]
node
.
KpiCycle
=
in
.
KpiCycle
// 设置周期
if
node
.
Type
==
domain
.
LinkNodeViewResult
{
node
.
TimeStart
=
&
kpiStart
node
.
TimeEnd
=
&
maxTime
// 绩效查看时间跟随周期截止时间
}
else
{
node
.
TimeStart
=
&
start
node
.
TimeEnd
=
&
end
}
}
project
,
err
=
projectRepository
.
Insert
(
project
)
if
err
!=
nil
{
...
...
@@ -239,6 +297,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
project
,
nil
}
}
func
(
rs
*
EvaluationProjectService
)
Get
(
in
*
command
.
GetProjectCommand
)
(
interface
{},
error
)
{
...
...
@@ -285,6 +344,7 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
}()
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
{
...
...
@@ -294,6 +354,17 @@ func (rs *EvaluationProjectService) Remove(in *command.DeleteProjectCommand) (in
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
// 查看任务过程,移除项目关联的所有任务
tasks
,
err
:=
taskRepository
.
Find
(
map
[
string
]
interface
{}{
"projectId"
:
in
.
Id
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
for
i
:=
range
tasks
{
if
_
,
err
:=
taskRepository
.
Remove
(
tasks
[
i
]);
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
())
}
...
...
@@ -314,6 +385,8 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
now
:=
time
.
Now
()
.
Unix
()
pmpUsers
:=
make
([]
*
domain
.
User
,
0
)
pmpUserIds
:=
make
([]
int64
,
0
)
for
i
:=
range
projects
{
...
...
@@ -322,7 +395,13 @@ func (rs *EvaluationProjectService) List(in *command.QueryProjectCommand) (inter
userId
,
_
:=
strconv
.
ParseInt
(
project
.
PmpIds
[
j
],
10
,
64
)
pmpUserIds
=
append
(
pmpUserIds
,
userId
)
}
// 当前时间超过截至时间显示【已结束】
if
now
>
project
.
EndTime
.
Unix
()
{
project
.
State
=
domain
.
ProjectStateDisable
}
}
if
len
(
pmpUserIds
)
>
0
{
userRepository
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
_
,
users
,
_
:=
userRepository
.
Find
(
map
[
string
]
interface
{}{
"ids"
:
pmpUserIds
,
"limit"
:
len
(
pmpUserIds
)})
...
...
@@ -342,29 +421,20 @@ 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
())
}
if
project
.
Template
==
nil
{
return
nil
,
application
.
ThrowError
(
application
.
BUSINESS_ERROR
,
"请添加评估模板"
)
}
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())
//}
//startMin := cycle.TimeStart
//maxTime := cycle.TimeEnd
project
.
State
=
domain
.
TemplateStateEnable
project
,
err
=
projectRepository
.
Insert
(
project
)
...
...
@@ -422,42 +492,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
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
{
...
...
pkg/domain/evaluation_project.go
查看文件 @
bb7ab43
...
...
@@ -8,7 +8,7 @@ const (
ProjectStateWaitConfig
int
=
0
// 项目状态-待完成配置
ProjectStateWaitActive
int
=
1
// 项目状态-待启用
ProjectStateEnable
int
=
2
// 项目状态-启用
ProjectStateDisable
int
=
3
// 项目状态-停用
ProjectStateDisable
int
=
3
// 项目状态-停用
(假状态)
)
// 项目的评估内容配置
...
...
@@ -25,6 +25,8 @@ type EvaluationProject struct {
PmpIds
[]
string
`json:"pmpIds" comment:"项目管理员ID"`
Recipients
[]
string
`json:"recipients" comment:"被评估人ID"`
Template
*
EvaluationTemplate
`json:"template" comment:"评估模板"`
BeginTime
time
.
Time
`json:"beginTime" comment:"项目起始时间"`
EndTime
time
.
Time
`json:"endTime" comment:"项目截至时间"`
CreatedAt
time
.
Time
`json:"createdAt" comment:"创建时间"`
UpdatedAt
time
.
Time
`json:"updatedAt" comment:"更新时间"`
DeletedAt
*
time
.
Time
`json:"deletedAt" comment:"删除时间"`
...
...
pkg/infrastructure/pg/models/evaluation_project.go
查看文件 @
bb7ab43
...
...
@@ -19,6 +19,8 @@ type EvaluationProject struct {
PmpIds
[]
string
`comment:"项目管理员ID"`
Recipients
[]
string
`comment:"被评估人ID"`
Template
*
domain
.
EvaluationTemplate
`comment:"评估模板"`
BeginTime
time
.
Time
`comment:"项目起始时间"`
EndTime
time
.
Time
`comment:"项目截至时间 "`
CreatedAt
time
.
Time
`comment:"创建时间"`
UpdatedAt
time
.
Time
`comment:"更新时间"`
DeletedAt
*
time
.
Time
`comment:"删除时间"`
...
...
pkg/infrastructure/pg/models/node_timer_task.go
已删除
100644 → 0
查看文件 @
718105b
package
models
import
(
"time"
)
type
NodeTimerTask
struct
{
tableName
struct
{}
`pg:"node_timer_task" comment:"流程节点定时任务"`
Id
int64
`comment:"ID"`
CompanyId
int64
`comment:"公司ID"`
CycleId
int64
`comment:"周期ID"`
ProjectId
int64
`comment:"项目ID"`
NodeId
int64
`comment:"流程ID"`
LastSentAt
*
time
.
Time
`comment:"最后一次发送时间"`
NextSentAt
*
time
.
Time
`comment:"下一次发送时间"`
CreatedAt
time
.
Time
`comment:"创建时间"`
UpdatedAt
time
.
Time
`comment:"更新时间"`
DeletedAt
*
time
.
Time
`comment:"删除时间"`
}
pkg/infrastructure/repository/pg_evaluation_project_repository.go
查看文件 @
bb7ab43
...
...
@@ -34,6 +34,8 @@ func (repo *EvaluationProjectRepository) TransformToDomain(m *models.EvaluationP
PmpIds
:
m
.
PmpIds
,
Recipients
:
m
.
Recipients
,
Template
:
m
.
Template
,
BeginTime
:
m
.
BeginTime
,
EndTime
:
m
.
EndTime
,
CreatedAt
:
m
.
CreatedAt
,
UpdatedAt
:
m
.
UpdatedAt
,
DeletedAt
:
m
.
DeletedAt
,
...
...
@@ -54,6 +56,8 @@ func (repo *EvaluationProjectRepository) TransformToModel(d *domain.EvaluationPr
PmpIds
:
d
.
PmpIds
,
Recipients
:
d
.
Recipients
,
Template
:
d
.
Template
,
BeginTime
:
d
.
BeginTime
,
EndTime
:
d
.
EndTime
,
CreatedAt
:
d
.
CreatedAt
,
UpdatedAt
:
d
.
UpdatedAt
,
DeletedAt
:
d
.
DeletedAt
,
...
...
@@ -166,6 +170,8 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int64
);
ok
{
query
.
Offset
(
int
(
v
))
}
// 按创建时间降序
query
.
Order
(
"created_at DESC"
)
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
...
...
pkg/port/beego/controllers/evaluation_project_controller.go
查看文件 @
bb7ab43
...
...
@@ -21,8 +21,6 @@ func (controller *ProjectController) CreateProject() {
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
))
}
}
...
...
@@ -35,7 +33,6 @@ func (controller *ProjectController) UpdateProject() {
}
else
{
ua
:=
middlewares
.
GetUser
(
controller
.
Ctx
)
in
.
CompanyId
=
ua
.
CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller
.
Response
(
ruService
.
Update
(
in
))
}
}
...
...
@@ -48,7 +45,6 @@ func (controller *ProjectController) UpdateProjectForTemplate() {
}
else
{
ua
:=
middlewares
.
GetUser
(
controller
.
Ctx
)
in
.
CompanyId
=
ua
.
CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller
.
Response
(
ruService
.
UpdateTemplate
(
in
))
}
}
...
...
@@ -86,7 +82,6 @@ func (controller *ProjectController) ListProject() {
}
ua
:=
middlewares
.
GetUser
(
controller
.
Ctx
)
in
.
CompanyId
=
ua
.
CompanyId
//in.CompanyId = middlewares.GetCompanyId(controller.Ctx)
controller
.
Response
(
ruService
.
List
(
in
))
}
}
...
...
pkg/utils/common.go
查看文件 @
bb7ab43
...
...
@@ -5,6 +5,7 @@ import (
timeconv
"github.com/Andrew-M-C/go.timeconv"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"math"
"reflect"
"strings"
"time"
...
...
@@ -53,24 +54,92 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time {
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
0
,
cycleCount
*
7
)
break
case
domain
.
KpiCycleOneMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
1
,
0
)
offsetMonth
:=
SubMonth
(
now0
,
start0
)
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
offsetMonth
,
0
)
if
nextTime
.
Before
(
now0
)
{
nextTime
=
timeconv
.
AddDate
(
nextTime
,
0
,
1
,
0
)
}
break
case
domain
.
KpiCycleTwoMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
2
,
0
)
offsetMonth
:=
SubMonth
(
now0
,
start0
)
multiple
:=
float64
(
offsetMonth
)
/
2
if
multiple
==
0
{
multiple
=
1
}
else
{
multiple
=
math
.
Ceil
(
multiple
)
}
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
int
(
multiple
)
*
2
,
0
)
if
nextTime
.
Before
(
now0
)
{
nextTime
=
timeconv
.
AddDate
(
nextTime
,
0
,
2
,
0
)
}
break
case
domain
.
KpiCycleThreeMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
3
,
0
)
offsetMonth
:=
SubMonth
(
now0
,
start0
)
multiple
:=
float64
(
offsetMonth
)
/
3
if
multiple
==
0
{
multiple
=
1
}
else
{
multiple
=
math
.
Ceil
(
multiple
)
}
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
int
(
multiple
)
*
3
,
0
)
if
nextTime
.
Before
(
now0
)
{
nextTime
=
timeconv
.
AddDate
(
nextTime
,
0
,
3
,
0
)
}
break
case
domain
.
KpiCycleSixMonth
:
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
6
,
0
)
offsetMonth
:=
SubMonth
(
now0
,
start0
)
multiple
:=
float64
(
offsetMonth
)
/
6
if
multiple
==
0
{
multiple
=
1
}
else
{
multiple
=
math
.
Ceil
(
multiple
)
}
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
int
(
multiple
)
*
6
,
0
)
if
nextTime
.
Before
(
now0
)
{
nextTime
=
timeconv
.
AddDate
(
nextTime
,
0
,
6
,
0
)
}
break
case
domain
.
KpiCycleYear
:
nextTime
=
timeconv
.
AddDate
(
start0
,
1
,
0
,
0
)
offsetMonth
:=
SubMonth
(
now0
,
start0
)
multiple
:=
float64
(
offsetMonth
)
/
12
if
multiple
==
0
{
multiple
=
1
}
else
{
multiple
=
math
.
Ceil
(
multiple
)
}
nextTime
=
timeconv
.
AddDate
(
start0
,
0
,
int
(
multiple
)
*
12
,
0
)
if
nextTime
.
Before
(
now0
)
{
nextTime
=
timeconv
.
AddDate
(
nextTime
,
0
,
12
,
0
)
}
break
}
return
nextTime
}
// SubMonth 计算日期相差多少月
func
SubMonth
(
t1
,
t2
time
.
Time
)
(
month
int
)
{
y1
:=
t1
.
Year
()
y2
:=
t2
.
Year
()
m1
:=
int
(
t1
.
Month
())
m2
:=
int
(
t2
.
Month
())
d1
:=
t1
.
Day
()
d2
:=
t2
.
Day
()
yearInterval
:=
y1
-
y2
// 如果 d1的 月-日 小于 d2的 月-日 那么 yearInterval-- 这样就得到了相差的年数
if
m1
<
m2
||
(
m1
==
m2
&&
d1
<
d2
)
{
yearInterval
--
}
// 获取月数差值
monthInterval
:=
(
m1
+
12
)
-
m2
if
d1
<
d2
{
monthInterval
--
}
monthInterval
%=
12
month
=
yearInterval
*
12
+
monthInterval
return
}
// NextTimeInc 0点时刻为标准计算
func
NextTimeInc
(
start
time
.
Time
,
kpiCycle
int
)
time
.
Time
{
year
,
month
,
day
:=
start
.
Date
()
...
...
请
注册
或
登录
后发表评论