切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
a3679b07387674171e2109a401d3bcc4a296f5f4
1 个父辈
9dab0ec5
更新
显示空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
96 行增加
和
8 行删除
pkg/application/notify/run.go
pkg/application/notify/sms.go
pkg/application/notify/sms_confirm_evaluation_score.go
pkg/application/summary_evaluation/service/service.go
pkg/infrastructure/repository/pg_log_sms_repository.go
pkg/application/notify/run.go
查看文件 @
a3679b0
package
notify
import
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
import
(
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 执行定时任务检查是否发送短信通知
var
taskSmsNotify
*
notifySms
...
...
@@ -28,3 +31,33 @@ func AddNotifySummaryEvaluation(param *domain.SummaryEvaluation) {
newSms
:=
newNotify
.
makeNotify
(
param
)
taskSmsNotify
.
addTask
(
newSms
)
}
// 确认周期评估短信提醒 ,预创建待发送的短信消息
func
AddNotifyConfirmEvaluationScore
(
param
*
domain
.
SummaryEvaluation
)
error
{
newNotify
:=
notifyConfirmEvaluationScore
{}
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
err
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
err
}
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
logSmsRepo
:=
factory
.
CreateLogSmsRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
cnt
,
_
,
err
:=
logSmsRepo
.
Find
(
map
[
string
]
interface
{}{
"from"
:
newNotify
.
from
(),
"index"
:
param
.
Id
,
"limit"
:
1
})
if
err
!=
nil
{
return
err
}
if
cnt
>
0
{
return
nil
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
err
}
newSms
:=
newNotify
.
makeNotify
(
param
)
return
taskSmsNotify
.
addTask
(
newSms
)
}
...
...
pkg/application/notify/sms.go
查看文件 @
a3679b0
...
...
@@ -36,13 +36,15 @@ func (notices *notifySms) regist(ifsend notifySendOrNot) {
notices
.
sendOrNot
[
ifsend
.
from
()]
=
ifsend
}
func
(
notices
*
notifySms
)
addTask
(
task
*
domain
.
LogSms
)
{
func
(
notices
*
notifySms
)
addTask
(
task
*
domain
.
LogSms
)
error
{
// notices.newSms <- task
err
:=
notices
.
addNewSms
(
task
)
if
err
!=
nil
{
e
:=
fmt
.
Sprintf
(
"添加短信通知任务:%+v %s"
,
task
,
err
)
log
.
Logger
.
Error
(
e
)
return
fmt
.
Errorf
(
"添加短信通知任务:%s"
,
err
)
}
return
nil
}
// RunTask 执行短信通知任务
...
...
pkg/application/notify/sms_confirm_evaluation_score.go
查看文件 @
a3679b0
...
...
@@ -3,6 +3,7 @@ package notify
import
(
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
...
...
@@ -21,8 +22,8 @@ func (notices notifyConfirmEvaluationScore) makeNotify(param *domain.SummaryEval
newSms
:=
domain
.
LogSms
{
Id
:
0
,
Phone
:
param
.
Executor
.
Account
,
TemplateId
:
5475050
,
Template
:
"您好,#name#,#periodName#成绩已出,请前往绩效系统PC端进行确认哦,逾期未确认可能会影响当月绩效工资哦~ "
,
TemplateId
:
5634326
,
Template
:
"您好,#name#,#periodName#成绩已出,请前往绩效系统PC端进行确认哦,超时未确认可能会影响当月绩效工资哦~ "
,
Value
:
map
[
string
]
string
{
"name"
:
param
.
Executor
.
UserName
,
"periodName"
:
param
.
CycleName
,
...
...
@@ -37,12 +38,53 @@ func (notices notifyConfirmEvaluationScore) makeNotify(param *domain.SummaryEval
return
&
newSms
}
// 适配规则:上级提交评估后 到10号晚23:59前,可以发送
// 适配规则 对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
func
(
notices
notifyConfirmEvaluationScore
)
ifSend
(
index
int
)
(
bool
,
error
)
{
//检查时间
//适配规则:上级提交评估后 到10号晚23:59前,可以发送
//
nowTime
:=
time
.
Now
()
if
nowTime
.
Day
()
>
10
{
return
false
,
nil
}
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
false
,
err
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
false
,
err
}
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
summaryEvaluationRepo
:=
factory
.
CreateSummaryEvaluationRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
summaryEvaluationData
,
err
:=
summaryEvaluationRepo
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
index
})
if
err
!=
nil
{
return
false
,
err
}
if
summaryEvaluationData
.
Types
==
domain
.
EvaluationFinish
{
return
false
,
nil
}
//已确认 成绩,不在发送成绩
if
summaryEvaluationData
.
CheckResult
==
domain
.
EvaluationCheckCompleted
{
return
false
,
nil
}
//检查数据 SummaryEvaluation ,types=5,并添加短信数据
//适配规则 对未确认的被评估人每隔6个小时进行提醒(23:00-7:00期间不提醒),直到确认
//计算下一条短信
smsMessage
:=
notices
.
makeNotify
(
summaryEvaluationData
)
nextTime
:=
nowTime
.
Add
(
6
*
time
.
Hour
)
smsMessage
.
ExecuteAt
=
notices
.
getTimeExecuteAt
(
nextTime
)
logSmsRepo
:=
factory
.
CreateLogSmsRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
err
=
logSmsRepo
.
Save
(
smsMessage
)
if
err
!=
nil
{
return
true
,
err
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
false
,
err
}
return
true
,
nil
}
...
...
pkg/application/summary_evaluation/service/service.go
查看文件 @
a3679b0
...
...
@@ -10,6 +10,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"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/notify"
roleService
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/role"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
...
...
@@ -821,10 +822,15 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"保存考核结果,"
+
err
.
Error
())
}
}
//添加确认绩效成绩提醒短信提醒
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//添加确认绩效成绩提醒短信提醒
err
=
notify
.
AddNotifyConfirmEvaluationScore
(
param
)
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
"创建短信提醒失败"
+
err
.
Error
())
}
return
nil
}
...
...
pkg/infrastructure/repository/pg_log_sms_repository.go
查看文件 @
a3679b0
...
...
@@ -68,7 +68,12 @@ func (repo *LogSmsRepository) Find(queryOptions map[string]interface{}) (int, []
if
v
,
ok
:=
queryOptions
[
"executeAtEnd"
];
ok
{
query
.
Where
(
"execute_at<=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"from"
];
ok
{
query
.
Where
(
"from=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"index"
];
ok
{
query
.
Where
(
"index=?"
,
v
)
}
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
...
...
请
注册
或
登录
后发表评论