切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
c0079c4fbade6f5960ea43f58f2cb917a4b4bb98
1 个父辈
8cb71eb7
更新
显示空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
255 行增加
和
11 行删除
pkg/application/notify/sms.go
pkg/application/notify/sms_staff_assess.go
pkg/application/notify/sms_summary_evaluation.go
pkg/domain/evaluation_item_used.go
pkg/domain/log_sms.go
pkg/infrastructure/pg/models/log_sms.go
pkg/infrastructure/repository/pg_log_sms_repository.go
pkg/port/beego/controllers/summary_evaluation_controller.go
pkg/application/notify/sms.go
查看文件 @
c0079c4
package
notify
// 短信通知
// 周期评估短信通知
// 条件:周期自评结束前4个小时,且还未完成评估填写
type
NotifySummaryEvaluation
struct
{}
// 每日自评短信通知
// 条件:每日自评结束前30分钟,且还未完成评估填写
type
NotifyStaffAssess
struct
{}
...
...
pkg/application/notify/sms_staff_assess.go
0 → 100644
查看文件 @
c0079c4
package
notify
import
(
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
// 短信通知
// 每日自评短信通知
// 条件:每日自评结束前30分钟,且还未完成评估填写
type
NotifyStaffAssess
struct
{
newSms
chan
*
domain
.
LogSms
interval
time
.
Duration
}
func
(
notices
*
NotifyStaffAssess
)
init
()
{
notices
.
newSms
=
make
(
chan
*
domain
.
LogSms
,
50
)
notices
.
interval
=
10
*
time
.
Minute
if
constant
.
Env
!=
"prd"
{
notices
.
interval
=
1
*
time
.
Minute
}
}
func
(
notices
*
NotifyStaffAssess
)
From
()
string
{
return
"StaffAssess"
}
// AddTask 添加待执行的短信通知任务
func
(
notices
*
NotifyStaffAssess
)
AddTask
(
index
int
,
phone
string
,
param
map
[
string
]
string
,
executeAt
time
.
Time
)
{
newSms
:=
&
domain
.
LogSms
{
Id
:
0
,
Phone
:
phone
,
TemplateId
:
5475050
,
Template
:
"您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦"
,
Value
:
param
,
Result
:
""
,
Status
:
domain
.
SmsWait
,
From
:
notices
.
From
(),
Index
:
index
,
ExecuteAt
:
executeAt
,
CreatedAt
:
time
.
Now
(),
}
notices
.
newSms
<-
newSms
}
// RunTask 执行短信通知任务
func
(
notices
*
NotifyStaffAssess
)
RunTask
()
{
notices
.
init
()
timer
:=
time
.
NewTimer
(
notices
.
interval
)
for
{
select
{
case
newSms
:=
<-
notices
.
newSms
:
err
:=
notices
.
addNewSms
(
newSms
)
if
err
!=
nil
{
e
:=
fmt
.
Sprintf
(
"添加短信通知任务:%+v %s"
,
newSms
,
err
)
log
.
Logger
.
Error
(
e
)
}
case
<-
timer
.
C
:
err
:=
notices
.
sendSms
()
if
err
!=
nil
{
log
.
Logger
.
Error
(
"发送短信通知任务:"
+
err
.
Error
())
}
timer
.
Reset
(
notices
.
interval
)
// 重置定时
}
}
}
func
(
notices
*
NotifyStaffAssess
)
addNewSms
(
newSms
*
domain
.
LogSms
)
error
{
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
})
err
=
logSmsRepo
.
Save
(
newSms
)
if
err
!=
nil
{
return
err
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
err
}
return
nil
}
func
(
notices
*
NotifyStaffAssess
)
sendSms
()
error
{
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
})
_
=
logSmsRepo
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
err
}
return
nil
}
...
...
pkg/application/notify/sms_summary_evaluation.go
0 → 100644
查看文件 @
c0079c4
package
notify
import
(
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// 周期评估短信通知
// 条件:周期自评结束前4个小时,且还未完成评估填写
type
NotifySummaryEvaluation
struct
{
}
func
(
notices
*
NotifySummaryEvaluation
)
Init
()
*
NotifySummaryEvaluation
{
return
&
NotifySummaryEvaluation
{}
}
func
(
notices
*
NotifySummaryEvaluation
)
From
()
string
{
return
"SummaryEvaluation"
}
// AddTask 添加待执行的短信通知任务
func
(
notices
*
NotifySummaryEvaluation
)
AddTask
(
index
string
,
phone
string
,
param
map
[
string
]
string
)
error
{
return
nil
}
// RunTask 执行短信通知任务
func
(
notice
*
NotifySummaryEvaluation
)
RunTask
()
error
{
return
nil
}
func
(
notice
*
NotifySummaryEvaluation
)
addNewSms
(
newSms
*
domain
.
LogSms
)
error
{
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
})
err
=
logSmsRepo
.
Save
(
newSms
)
if
err
!=
nil
{
return
err
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
err
}
return
nil
}
...
...
pkg/domain/evaluation_item_used.go
查看文件 @
c0079c4
...
...
@@ -20,8 +20,8 @@ type EvaluationItemUsed struct {
RuleType
int
//评估方式(0评级、1评分)
Rule
EvaluationRule
//评估的选项规则
Weight
float64
//"权重"
Required
int
// 必填项
EvaluatorId
int
// 项目评估人ID ( 0=无评估人、-1=HRBP、 >0 =员工的id )
Required
int
//必填项
EvaluatorId
int
//项目评估人ID ( 0=无评估人、-1=HRBP、 >0 =员工的id )
CreatedAt
time
.
Time
//数据创建时间
UpdatedAt
time
.
Time
//数据更新时间
}
...
...
pkg/domain/log_sms.go
查看文件 @
c0079c4
...
...
@@ -12,6 +12,9 @@ type LogSms struct {
Value
map
[
string
]
string
Result
string
Status
SmsStatus
From
string
//业务来源
Index
int
//业务数据索引
ExecuteAt
time
.
Time
CreatedAt
time
.
Time
}
...
...
@@ -41,4 +44,6 @@ func (sms *LogSms) SummaryEvaluationMessage(phone string, name string) {
type
LogSmsRepository
interface
{
Insert
(
param
*
LogSms
)
error
Save
(
param
*
LogSms
)
error
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
LogSms
,
error
)
}
...
...
pkg/infrastructure/pg/models/log_sms.go
查看文件 @
c0079c4
package
models
import
"time"
import
(
"time"
)
type
LogSms
struct
{
tableName
struct
{}
`comment:"记录短信消息" pg:"log_sms"`
...
...
@@ -11,4 +13,8 @@ type LogSms struct {
Value
map
[
string
]
string
`pg:"value"`
CreatedAt
time
.
Time
`pg:"created_at"`
Result
string
`pg:"result"`
Status
string
`pg:"status"`
From
string
`pg:"from"`
//业务来源
Index
int
`pg:"index"`
//业务数据索引
ExecuteAt
time
.
Time
`pg:"execute_at"`
}
...
...
pkg/infrastructure/repository/pg_log_sms_repository.go
查看文件 @
c0079c4
...
...
@@ -33,3 +33,76 @@ func (repo *LogSmsRepository) Insert(param *domain.LogSms) error {
}
return
nil
}
func
(
repo
*
LogSmsRepository
)
Save
(
param
*
domain
.
LogSms
)
error
{
m
:=
models
.
LogSms
{
Id
:
param
.
Id
,
Phone
:
param
.
Phone
,
TemplateId
:
param
.
TemplateId
,
Template
:
param
.
Template
,
Value
:
param
.
Value
,
CreatedAt
:
param
.
CreatedAt
,
Result
:
param
.
Result
,
}
tx
:=
repo
.
transactionContext
.
PgTx
_
,
err
:=
tx
.
Model
(
&
m
)
.
Insert
()
if
err
!=
nil
{
return
err
}
return
nil
}
func
(
repo
*
LogSmsRepository
)
Find
(
queryOptions
map
[
string
]
interface
{})
(
int
,
[]
*
domain
.
LogSms
,
error
)
{
tx
:=
repo
.
transactionContext
.
PgTx
var
m
[]
*
models
.
LogSms
query
:=
tx
.
Model
(
&
m
)
if
v
,
ok
:=
queryOptions
[
"limit"
]
.
(
int
);
ok
{
query
.
Limit
(
v
)
}
if
v
,
ok
:=
queryOptions
[
"offset"
]
.
(
int
);
ok
{
query
.
Offset
(
v
)
}
if
v
,
ok
:=
queryOptions
[
"form"
];
ok
{
query
.
Where
(
"from=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"index"
];
ok
{
query
.
Where
(
"index=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"status"
];
ok
{
query
.
Where
(
"status=?"
,
v
)
}
if
v
,
ok
:=
queryOptions
[
"executeAt"
];
ok
{
query
.
Where
(
"execute_at=?"
,
v
)
}
count
,
err
:=
query
.
SelectAndCount
()
if
err
!=
nil
{
return
0
,
nil
,
err
}
var
datas
[]
*
domain
.
LogSms
for
_
,
v
:=
range
m
{
d
:=
repo
.
TransformToDomain
(
v
)
datas
=
append
(
datas
,
d
)
}
return
count
,
datas
,
nil
}
func
(
repo
*
LogSmsRepository
)
TransformToDomain
(
d
*
models
.
LogSms
)
*
domain
.
LogSms
{
return
&
domain
.
LogSms
{
Id
:
d
.
Id
,
Phone
:
d
.
Phone
,
TemplateId
:
d
.
TemplateId
,
Template
:
d
.
Template
,
Value
:
d
.
Value
,
Result
:
d
.
Result
,
Status
:
domain
.
SmsStatus
(
d
.
Status
),
From
:
d
.
From
,
Index
:
d
.
Index
,
ExecuteAt
:
d
.
ExecuteAt
,
CreatedAt
:
d
.
CreatedAt
,
}
}
...
...
pkg/port/beego/controllers/summary_evaluation_controller.go
查看文件 @
c0079c4
...
...
@@ -300,6 +300,8 @@ func (c *SummaryEvaluationController) GetTargetUserEvaluationSuper() {
c
.
Response
(
nil
,
e
)
return
}
userReq
:=
middlewares
.
GetUser
(
c
.
Ctx
)
paramReq
.
CompanyId
=
int
(
userReq
.
CompanyId
)
data
,
err
:=
srv
.
GetTargetUserEvaluationSuper
(
paramReq
)
c
.
Response
(
data
,
err
)
}
...
...
请
注册
或
登录
后发表评论