@@ -29,24 +29,29 @@ public class NoticeSendService {
2929 private final InSiteNoticeSender inSiteNoticeSender ;
3030 private final MessageDetailService messageDetailService ;
3131
32- @ Async ("threadPoolTaskExecutor" )
33- public void send (String module , NoticeModel noticeModel ) {
32+ private void doSend (String module , NoticeModel noticeModel , String organizationId ) {
3433 setLanguage (noticeModel .getParamMap ().get ("Language" ));
35- boolean useTemplate = Boolean .getBoolean ((String ) noticeModel .getParamMap ().get ("useTemplate" ));
34+ boolean useTemplate = Boolean .parseBoolean (
35+ (String ) noticeModel .getParamMap ().getOrDefault ("useTemplate" , "false" ));
3636 String template = (String ) noticeModel .getParamMap ().get ("template" );
3737 try {
38- String organizationId = ( String ) noticeModel . getParamMap (). get ( "organizationId" );
39- List < MessageDetailDTO > messageDetails = messageDetailService .searchMessageByTypeAndOrgId (module , useTemplate , template , organizationId );
38+ List < MessageDetailDTO > messageDetails = messageDetailService
39+ .searchMessageByTypeAndOrgId (module , useTemplate , template , organizationId );
4040
4141 messageDetails .stream ()
42- .filter (messageDetail -> Strings .CS .equals (messageDetail .getEvent (), noticeModel .getEvent ()))
43- .forEach (messageDetail -> sendNotification (messageDetail , noticeModel ));
44-
42+ .filter (md -> Strings .CS .equals (md .getEvent (), noticeModel .getEvent ()))
43+ .forEach (md -> sendNotification (md , noticeModel ));
4544 } catch (Exception e ) {
4645 log .error ("Error sending notification" , e );
4746 }
4847 }
4948
49+ @ Async ("threadPoolTaskExecutor" )
50+ public void send (String module , NoticeModel noticeModel ) {
51+ String organizationId = (String ) noticeModel .getParamMap ().get ("organizationId" );
52+ doSend (module , noticeModel , organizationId );
53+ }
54+
5055 private void setLanguage (Object languageObj ) {
5156 String language = languageObj instanceof String ? (String ) languageObj : "" ;
5257 Locale locale = Locale .SIMPLIFIED_CHINESE ;
@@ -97,38 +102,13 @@ public void sendNotification(MessageDetailDTO messageDetail, NoticeModel noticeM
97102
98103 @ Async ("threadPoolTaskExecutor" )
99104 public void send (String organizationId , String module , NoticeModel noticeModel ) {
100- setLanguage (noticeModel .getParamMap ().get ("Language" ));
101- boolean useTemplate = Boolean .getBoolean ((String ) noticeModel .getParamMap ().get ("useTemplate" ));
102- String template = (String ) noticeModel .getParamMap ().get ("template" );
103- try {
104- List <MessageDetailDTO > messageDetails = messageDetailService .searchMessageByTypeAndOrgId (module , useTemplate , template , organizationId );
105-
106- messageDetails .stream ()
107- .filter (messageDetail -> Strings .CS .equals (messageDetail .getEvent (), noticeModel .getEvent ()))
108- .forEach (messageDetail -> sendNotification (messageDetail , noticeModel ));
109-
110- } catch (Exception e ) {
111- log .error ("Error sending notification" , e );
112- }
105+ doSend (module , noticeModel , organizationId );
113106 }
114107
115108 @ Async ("threadPoolTaskExecutor" )
116109 public void sendOther (String module , NoticeModel noticeModel , boolean excludeSelf ) {
117- setLanguage (noticeModel .getParamMap ().get ("Language" ));
118- boolean useTemplate = Boolean .parseBoolean ((String ) noticeModel .getParamMap ().get ("useTemplate" ));
119- String template = (String ) noticeModel .getParamMap ().get ("template" );
120110 noticeModel .setExcludeSelf (excludeSelf );
121- try {
122- String organizationId = (String ) noticeModel .getParamMap ().get ("organizationId" );
123- List <MessageDetailDTO > messageDetails = messageDetailService .searchMessageByTypeAndOrgId (module , useTemplate , template , organizationId )
124- .stream ()
125- .filter (messageDetail -> Strings .CS .equals (messageDetail .getEvent (), noticeModel .getEvent ()))
126- .toList ();
127-
128- messageDetails .forEach (messageDetail -> sendNotification (messageDetail , noticeModel ));
129-
130- } catch (Exception e ) {
131- log .error ("Error sending other notifications" , e );
132- }
111+ String organizationId = (String ) noticeModel .getParamMap ().get ("organizationId" );
112+ doSend (module , noticeModel , organizationId );
133113 }
134114}
0 commit comments