Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
subsidy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8fab15d4
authored
Feb 28, 2022
by
邓敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
班级通知 添加短信模版
1 parent
899d8777
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
19 deletions
src/main/java/com/subsidy/common/constant/CourseNotification.java
src/main/java/com/subsidy/common/constant/SmsCode.java
src/main/java/com/subsidy/jobs/CourseNotificationJob.java
src/main/java/com/subsidy/service/impl/ClassNoticeServiceImpl.java
src/main/java/com/subsidy/common/constant/CourseNotification.java
View file @
8fab15d
...
@@ -5,10 +5,4 @@ public class CourseNotification {
...
@@ -5,10 +5,4 @@ public class CourseNotification {
public
static
final
String
UNSENT
=
"待发送"
;
public
static
final
String
UNSENT
=
"待发送"
;
public
static
final
String
SENT
=
"已发送"
;
public
static
final
String
SENT
=
"已发送"
;
public
static
final
String
ALL
=
"全部成员"
;
public
static
final
String
NOT_SIGNED_IN
=
"未签到成员"
;
public
static
final
String
UNFINISHED
=
"未完课成员"
;
}
}
src/main/java/com/subsidy/common/constant/SmsCode.java
0 → 100644
View file @
8fab15d
package
com
.
subsidy
.
common
.
constant
;
import
lombok.Getter
;
@Getter
public
enum
SmsCode
{
SIGN_IN
(
"SMS_234409992"
,
"签到通知"
),
TEST
(
"SMS_234414789"
,
"测试通知"
),
CLASS_START
(
"SMS_228017725"
,
"开课通知"
),
ALL
(
"SMS_228137810"
,
"全部成员"
),
NOT_SIGNED_IN
(
"SMS_234409992"
,
"未签到成员"
),
UNFINISHED
(
"SMS_234414789"
,
"未完课成员"
);
private
String
type
;
private
String
code
;
SmsCode
(
String
code
,
String
type
)
{
this
.
code
=
code
;
this
.
type
=
type
;
}
}
src/main/java/com/subsidy/jobs/CourseNotificationJob.java
View file @
8fab15d
package
com
.
subsidy
.
jobs
;
package
com
.
subsidy
.
jobs
;
import
com.subsidy.common.constant.CourseNotification
;
import
com.subsidy.common.constant.CourseNotification
;
import
com.subsidy.common.constant.SmsCode
;
import
com.subsidy.mapper.ClassNoticeMapper
;
import
com.subsidy.mapper.ClassNoticeMapper
;
import
com.subsidy.mapper.MemberMapper
;
import
com.subsidy.mapper.MemberMapper
;
import
com.subsidy.model.ClassNoticeDO
;
import
com.subsidy.model.ClassNoticeDO
;
...
@@ -12,8 +13,10 @@ import org.quartz.JobExecutionException;
...
@@ -12,8 +13,10 @@ import org.quartz.JobExecutionException;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* <p>
* <p>
...
@@ -36,22 +39,26 @@ public class CourseNotificationJob implements Job {
...
@@ -36,22 +39,26 @@ public class CourseNotificationJob implements Job {
private
SMSUtils
smsUtils
;
private
SMSUtils
smsUtils
;
@Override
@Override
public
void
execute
(
JobExecutionContext
jobExecutionContext
)
throws
JobExecutionException
{
public
void
execute
(
JobExecutionContext
jobExecutionContext
)
{
Map
<
String
,
Object
>
map
=
jobExecutionContext
.
getJobDetail
().
getJobDataMap
();
Map
<
String
,
Object
>
map
=
jobExecutionContext
.
getJobDetail
().
getJobDataMap
();
Map
<
String
,
Object
>
params
=
(
Map
<
String
,
Object
>)
map
.
get
(
"params"
);
Map
<
String
,
Object
>
params
=
(
Map
<
String
,
Object
>)
map
.
get
(
"params"
);
if
(
params
!=
null
)
{
if
(
params
!=
null
)
{
ClassNoticeDO
classNoticeDO
=
classNoticeMapper
.
selectById
((
Long
)
params
.
get
(
"id"
));
if
(
classNoticeDO
!=
null
)
{
List
<
MemberDO
>
list
=
memberMapper
.
getMemberList
((
Long
)
params
.
get
(
"classId"
));
List
<
MemberDO
>
list
=
memberMapper
.
getMemberList
((
Long
)
params
.
get
(
"classId"
));
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
MemberDO
memberDO
:
list
)
{
for
(
MemberDO
memberDO
:
list
)
{
if
(
memberDO
!=
null
)
{
if
(
memberDO
!=
null
)
{
// smsUtils.send(memberDO.getTelephone(), "");
Map
<
String
,
String
>
data
=
Arrays
.
stream
(
SmsCode
.
values
()).
collect
(
Collectors
.
toMap
(
SmsCode:
:
getType
,
SmsCode:
:
getCode
));
smsUtils
.
send
(
memberDO
.
getTelephone
(),
data
.
get
(
classNoticeDO
.
getNoticeType
()));
}
}
}
}
ClassNoticeDO
classNoticeDO
=
new
ClassNoticeDO
();
ClassNoticeDO
classNotice
=
new
ClassNoticeDO
();
classNoticeDO
.
setId
((
Long
)
params
.
get
(
"id"
));
classNotice
.
setId
(
classNoticeDO
.
getId
());
classNoticeDO
.
setStatus
(
CourseNotification
.
SENT
);
classNotice
.
setStatus
(
CourseNotification
.
SENT
);
classNoticeMapper
.
updateById
(
classNoticeDO
);
classNoticeMapper
.
updateById
(
classNotice
);
}
}
}
}
}
}
}
...
...
src/main/java/com/subsidy/service/impl/ClassNoticeServiceImpl.java
View file @
8fab15d
...
@@ -2,6 +2,7 @@ package com.subsidy.service.impl;
...
@@ -2,6 +2,7 @@ package com.subsidy.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.subsidy.common.constant.CourseNotification
;
import
com.subsidy.common.constant.CourseNotification
;
import
com.subsidy.common.constant.SmsCode
;
import
com.subsidy.common.exception.HttpException
;
import
com.subsidy.common.exception.HttpException
;
import
com.subsidy.dto.classNotice.SendNotificationDTO
;
import
com.subsidy.dto.classNotice.SendNotificationDTO
;
import
com.subsidy.jobs.CourseNotificationJob
;
import
com.subsidy.jobs.CourseNotificationJob
;
...
@@ -60,7 +61,7 @@ public class ClassNoticeServiceImpl extends ServiceImpl<ClassNoticeMapper, Class
...
@@ -60,7 +61,7 @@ public class ClassNoticeServiceImpl extends ServiceImpl<ClassNoticeMapper, Class
ClassDictDO
classDictDO
=
classDictService
.
getById
(
classNoticeDO
.
getClassId
());
ClassDictDO
classDictDO
=
classDictService
.
getById
(
classNoticeDO
.
getClassId
());
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
//
params.put("classId", classNoticeDO.getClassId());
params
.
put
(
"classId"
,
classNoticeDO
.
getClassId
());
params
.
put
(
"id"
,
classNoticeDO
.
getId
());
params
.
put
(
"id"
,
classNoticeDO
.
getId
());
String
name
=
classDictDO
.
getClassName
()+
"-"
+
classNoticeDO
.
getNoticeType
()+
"-"
+
classNoticeDO
.
getNoticeTime
();
String
name
=
classDictDO
.
getClassName
()+
"-"
+
classNoticeDO
.
getNoticeType
()+
"-"
+
classNoticeDO
.
getNoticeTime
();
quartzUtil
.
addSimpleJob
(
CourseNotificationJob
.
class
,
DateFormatUtil
.
parse
(
classNoticeDO
.
getNoticeTime
(),
"yyyy-MM-dd"
)
,
params
,
name
,
"CourseNotificationJob"
);
quartzUtil
.
addSimpleJob
(
CourseNotificationJob
.
class
,
DateFormatUtil
.
parse
(
classNoticeDO
.
getNoticeTime
(),
"yyyy-MM-dd"
)
,
params
,
name
,
"CourseNotificationJob"
);
...
@@ -93,25 +94,25 @@ public class ClassNoticeServiceImpl extends ServiceImpl<ClassNoticeMapper, Class
...
@@ -93,25 +94,25 @@ public class ClassNoticeServiceImpl extends ServiceImpl<ClassNoticeMapper, Class
@Override
@Override
public
void
sendNotification
(
SendNotificationDTO
sendNotificationDTO
)
{
public
void
sendNotification
(
SendNotificationDTO
sendNotificationDTO
)
{
if
(
sendNotificationDTO
.
getSendType
().
equals
(
CourseNotification
.
ALL
))
{
if
(
sendNotificationDTO
.
getSendType
().
equals
(
SmsCode
.
ALL
.
getType
()
))
{
List
<
MemberDO
>
list
=
memberMapper
.
getMemberList
(
sendNotificationDTO
.
getClassId
());
List
<
MemberDO
>
list
=
memberMapper
.
getMemberList
(
sendNotificationDTO
.
getClassId
());
if
(
list
!=
null
)
{
if
(
list
!=
null
)
{
for
(
MemberDO
memberDO
:
list
)
{
for
(
MemberDO
memberDO
:
list
)
{
smsUtils
.
send
(
memberDO
.
getTelephone
(),
""
);
smsUtils
.
send
(
memberDO
.
getTelephone
(),
SmsCode
.
ALL
.
getCode
()
);
}
}
}
}
}
else
if
(
sendNotificationDTO
.
getSendType
().
equals
(
CourseNotification
.
NOT_SIGNED_IN
))
{
}
else
if
(
sendNotificationDTO
.
getSendType
().
equals
(
SmsCode
.
NOT_SIGNED_IN
.
getType
()
))
{
List
<
MemberDO
>
list
=
memberMapper
.
getMemberListBySignInRecord
(
sendNotificationDTO
.
getClassId
());
List
<
MemberDO
>
list
=
memberMapper
.
getMemberListBySignInRecord
(
sendNotificationDTO
.
getClassId
());
if
(
list
!=
null
)
{
if
(
list
!=
null
)
{
for
(
MemberDO
memberDO
:
list
)
{
for
(
MemberDO
memberDO
:
list
)
{
smsUtils
.
send
(
memberDO
.
getTelephone
(),
""
);
smsUtils
.
send
(
memberDO
.
getTelephone
(),
SmsCode
.
NOT_SIGNED_IN
.
getCode
()
);
}
}
}
}
}
else
if
(
sendNotificationDTO
.
getSendType
().
equals
(
CourseNotification
.
UNFINISHED
))
{
}
else
if
(
sendNotificationDTO
.
getSendType
().
equals
(
SmsCode
.
UNFINISHED
.
getType
()
))
{
List
<
MemberDO
>
list
=
memberMapper
.
getUnfinishedMemberList
(
sendNotificationDTO
.
getClassId
());
List
<
MemberDO
>
list
=
memberMapper
.
getUnfinishedMemberList
(
sendNotificationDTO
.
getClassId
());
if
(
list
!=
null
)
{
if
(
list
!=
null
)
{
for
(
MemberDO
memberDO
:
list
)
{
for
(
MemberDO
memberDO
:
list
)
{
smsUtils
.
send
(
memberDO
.
getTelephone
(),
""
);
smsUtils
.
send
(
memberDO
.
getTelephone
(),
SmsCode
.
UNFINISHED
.
getCode
()
);
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment