切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
4271a4409b4e5282c7ff98b73c5ffb620d1fcd8a
1 个父辈
b76f817e
更新定时任务
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
19 行增加
和
31 行删除
main.go
pkg/application/node_task/node_task_service.go
pkg/application/notify/run.go
pkg/application/notify/sms.go
pkg/application/summary_evaluation/service/scheduled.go
main.go
查看文件 @
4271a44
...
...
@@ -7,7 +7,7 @@ import (
"github.com/beego/beego/v2/server/web"
serviceTask
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/node_task"
serviceSummary
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/service
"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify
"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
_
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/beego"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/port/consumer"
...
...
@@ -44,19 +44,5 @@ func startNodeTask() {
// 定时任务-间隔检查时间,发送周期评估
func
startSummaryEvaluation
()
{
go
func
()
{
duration
:=
10
*
time
.
Minute
if
constant
.
Env
!=
"prd"
{
duration
=
1
*
time
.
Minute
}
timer
:=
time
.
NewTimer
(
duration
)
for
{
<-
timer
.
C
err
:=
serviceSummary
.
TaskSendSummaryEvaluation
()
if
err
!=
nil
{
log
.
Logger
.
Error
(
err
.
Error
())
}
timer
.
Reset
(
duration
)
// 重置定时
}
}()
go
notify
.
RunTaskSmsNotify
()
}
...
...
pkg/application/node_task/node_task_service.go
查看文件 @
4271a44
...
...
@@ -2,10 +2,11 @@ package service
import
(
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
"strconv"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/command"
...
...
@@ -153,7 +154,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
// 创建发送任务
_
,
err
:=
staffAssessService
.
CreateStaffAssessTask
(
transactionContext
,
csat
)
if
err
!=
nil
{
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
return
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"创建发送任务"
+
err
.
Error
())
}
}
else
{
task
.
NextSentAt
=
nil
// 项目不存在,取消周期任务发送
...
...
pkg/application/notify/run.go
查看文件 @
4271a44
...
...
@@ -2,14 +2,14 @@ package notify
import
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
var
T
askSmsNotify
*
notifySms
var
t
askSmsNotify
*
notifySms
func
RunTaskSmsNotify
()
{
newSmsNotify
:=
notifySms
{}
newSmsNotify
.
regist
(
notifyStaffAssess
{})
newSmsNotify
.
regist
(
notifySummaryEvaluation
{})
newSmsNotify
.
runTask
()
taskSmsNotify
=
&
notifySms
{}
taskSmsNotify
.
init
()
taskSmsNotify
.
regist
(
notifyStaffAssess
{})
taskSmsNotify
.
regist
(
notifySummaryEvaluation
{})
taskSmsNotify
.
runTask
()
}
...
...
@@ -17,12 +17,12 @@ func RunTaskSmsNotify() {
func
AddNotifyStaffAssess
(
param
*
domain
.
StaffAssess
)
{
newNotify
:=
notifyStaffAssess
{}
newSms
:=
newNotify
.
makeNotify
(
param
)
T
askSmsNotify
.
addTask
(
newSms
)
t
askSmsNotify
.
addTask
(
newSms
)
}
// 周期自评短信通知 ,预创建待发送的短信消息
func
AddNotifySummaryEvaluation
(
param
*
domain
.
SummaryEvaluation
)
{
newNotify
:=
notifySummaryEvaluation
{}
newSms
:=
newNotify
.
makeNotify
(
param
)
T
askSmsNotify
.
addTask
(
newSms
)
t
askSmsNotify
.
addTask
(
newSms
)
}
...
...
pkg/application/notify/sms.go
查看文件 @
4271a44
...
...
@@ -42,7 +42,6 @@ func (notices *notifySms) addTask(task *domain.LogSms) {
// RunTask 执行短信通知任务
func
(
notices
*
notifySms
)
runTask
()
{
notices
.
init
()
timer
:=
time
.
NewTimer
(
notices
.
interval
)
for
{
select
{
...
...
@@ -64,6 +63,7 @@ func (notices *notifySms) runTask() {
}
}
// addNewSms 添加新的通知消息
func
(
notices
*
notifySms
)
addNewSms
(
newSms
*
domain
.
LogSms
)
error
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
...
...
@@ -86,6 +86,7 @@ func (notices *notifySms) addNewSms(newSms *domain.LogSms) error {
return
nil
}
// checkSendSms 检查发送短信通知
func
(
notices
*
notifySms
)
checkSendSms
()
error
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
...
...
@@ -122,7 +123,11 @@ func (notices *notifySms) checkSendSms() error {
return
nil
}
// sendSms 发送短信消息
func
(
notices
*
notifySms
)
sendSms
(
param
*
domain
.
LogSms
)
error
{
if
constant
.
Env
!=
"prd"
{
return
nil
}
//单开处理 数据保存操作,发一条短信更新一条数据
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
...
...
pkg/application/summary_evaluation/service/scheduled.go
查看文件 @
4271a44
...
...
@@ -7,7 +7,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
...
...
@@ -278,9 +277,6 @@ func TaskSendSummaryEvaluation() error {
// 发送短信通知
func
sendSmsEvalation
(
param
[]
domain
.
SummaryEvaluation
)
error
{
if
constant
.
Env
!=
"prd"
{
return
nil
}
for
i
:=
range
param
{
notify
.
AddNotifySummaryEvaluation
(
&
param
[
i
])
}
...
...
请
注册
或
登录
后发表评论