|
@@ -33,11 +33,7 @@ public class NoticeService {
|
33
|
33
|
@Resource
|
34
|
34
|
private NoticeMapper noticeMapper;
|
35
|
35
|
@Resource
|
36
|
|
- private NoticeTeacherMapper noticeTeacherMapper;
|
37
|
|
- @Resource
|
38
|
|
- private NoticeClassMapper noticeClassMapper;
|
39
|
|
- @Resource
|
40
|
|
- private NoticeSchoolMapper noticeSchoolMapper;
|
|
36
|
+ private NoticeUserMapper noticeUserMapper;
|
41
|
37
|
@Resource
|
42
|
38
|
private MsgMapper msgMapper;
|
43
|
39
|
@Resource
|
|
@@ -61,12 +57,10 @@ public class NoticeService {
|
61
|
57
|
});
|
62
|
58
|
noticeMapper.insertList(noticeList);
|
63
|
59
|
|
64
|
|
- List<TNoticeTeacher> teacherList = new ArrayList<>();
|
65
|
|
- List<TNoticeClass> classList = new ArrayList<>();
|
66
|
|
- List<TNoticeSchool> schoolList = new ArrayList<>();
|
|
60
|
+ List<TNoticeUser> teacherList = new ArrayList<>();
|
67
|
61
|
noticeList.forEach(n -> {
|
68
|
62
|
Integer noticeid = n.getId();
|
69
|
|
- List<TNoticeTeacher> teachers = n.getTeachers().stream().distinct().collect(Collectors.toList());
|
|
63
|
+ List<TNoticeUser> teachers = n.getUsers().stream().distinct().collect(Collectors.toList());
|
70
|
64
|
teachers.forEach(t -> {
|
71
|
65
|
t.setNoticeid(noticeid);
|
72
|
66
|
t.setReaded(0);
|
|
@@ -74,26 +68,9 @@ public class NoticeService {
|
74
|
68
|
t.setSchoolid(schoolid);
|
75
|
69
|
});
|
76
|
70
|
teacherList.addAll(teachers);
|
77
|
|
-
|
78
|
|
- List<TNoticeClass> classes = n.getClasses();
|
79
|
|
- classes.forEach(c -> {
|
80
|
|
- c.setNoticeid(noticeid);
|
81
|
|
- c.setCreateid(createid);
|
82
|
|
- c.setCreatetime(createtime);
|
83
|
|
- });
|
84
|
|
- classList.addAll(classes);
|
85
|
|
-
|
86
|
|
- TNoticeSchool ns = new TNoticeSchool();
|
87
|
|
- ns.setNoticeid(noticeid);
|
88
|
|
- ns.setSchoolid(schoolid);
|
89
|
|
- ns.setCreateid(createid);
|
90
|
|
- ns.setCreatetime(createtime);
|
91
|
|
- schoolList.add(ns);
|
92
|
71
|
});
|
93
|
72
|
|
94
|
|
- if (N_Utils.isListNotEmpty(teacherList)) noticeTeacherMapper.insertList(teacherList);//通知教师关联信息
|
95
|
|
- if (N_Utils.isListNotEmpty(classList)) noticeClassMapper.insertList(classList);//通知班级关联信息
|
96
|
|
- if (N_Utils.isListNotEmpty(schoolList)) noticeSchoolMapper.insertList(schoolList);//通知学校关联信息
|
|
73
|
+ if (N_Utils.isListNotEmpty(teacherList)) noticeUserMapper.insertList(teacherList);//通知教师关联信息
|
97
|
74
|
}
|
98
|
75
|
|
99
|
76
|
if (N_Utils.isListNotEmpty(msgList)) {//短信
|
|
@@ -105,11 +82,10 @@ public class NoticeService {
|
105
|
82
|
msgs.add(msg);
|
106
|
83
|
}
|
107
|
84
|
} else {//通知对象2老师
|
108
|
|
- List<Integer> userids = msgList.stream().map(m -> m.getUserid()).distinct().collect(Collectors.toList());
|
|
85
|
+ List<Integer> userids = msgList.stream().map(TMsg::getUserid).distinct().collect(Collectors.toList());
|
109
|
86
|
List<UserVo> users = userMapper.listPhoneByUserIds(userids);//根据用户ids查找手机号
|
110
|
|
- Map<Integer, TMsg> msgMap = msgList.stream().collect(Collectors.toMap(m -> m.getUserid(), m -> m));
|
111
|
|
- for (int i = 0; i < users.size(); i++) {
|
112
|
|
- UserVo u = users.get(i);
|
|
87
|
+ Map<Integer, TMsg> msgMap = msgList.stream().collect(Collectors.toMap(TMsg::getUserid, m -> m));
|
|
88
|
+ for (UserVo u : users) {
|
113
|
89
|
String userphone = u.getUserphone();
|
114
|
90
|
if (N_Utils.isEmpty(userphone)) continue;
|
115
|
91
|
TMsg m = msgMap.get(u.getUserid());
|
|
@@ -122,8 +98,8 @@ public class NoticeService {
|
122
|
98
|
msgMapper.insertList(msgs);//短信保存到数据库
|
123
|
99
|
|
124
|
100
|
//发短信
|
125
|
|
- Integer pageSize = 2000;//手机号,多个手机号为用半角 , 分开,如13899999999,13688888888(最多2000个,必填)
|
126
|
|
- Map<String, List<TMsg>> mcollect = msgs.stream().collect(Collectors.groupingBy(s -> s.getMsgtxt()
|
|
101
|
+ int pageSize = 2000;//手机号,多个手机号为用半角 , 分开,如13899999999,13688888888(最多2000个,必填)
|
|
102
|
+ Map<String, List<TMsg>> mcollect = msgs.stream().collect(Collectors.groupingBy(TMsg::getMsgtxt
|
127
|
103
|
, LinkedHashMap::new, Collectors.toList()));
|
128
|
104
|
for (Map.Entry<String, List<TMsg>> entry : mcollect.entrySet()) {
|
129
|
105
|
List<TMsg> list = entry.getValue();
|
|
@@ -131,7 +107,7 @@ public class NoticeService {
|
131
|
107
|
for (int i = 0; i < list.size(); i += pageSize) {
|
132
|
108
|
ZtMsgVo vo = new ZtMsgVo();
|
133
|
109
|
String userphone = list.stream().skip(i).limit(pageSize)
|
134
|
|
- .map(s -> s.getUserphone()).collect(Collectors.joining(","));
|
|
110
|
+ .map(TMsg::getUserphone).collect(Collectors.joining(","));
|
135
|
111
|
vo.setMobile(userphone);
|
136
|
112
|
vo.setContent(msgtxt);
|
137
|
113
|
SMSSender.sendSms(vo);
|
|
@@ -140,7 +116,7 @@ public class NoticeService {
|
140
|
116
|
}
|
141
|
117
|
}
|
142
|
118
|
} catch (Exception e) {
|
143
|
|
- log.error("批量添加通知和短信失败", e.getMessage());
|
|
119
|
+ log.error("批量添加通知和短信失败:{}", e.getMessage());
|
144
|
120
|
}
|
145
|
121
|
}
|
146
|
122
|
|
|
@@ -154,52 +130,68 @@ public class NoticeService {
|
154
|
130
|
Integer examid = examVo.getExamid();
|
155
|
131
|
String examname = examVo.getExamname();
|
156
|
132
|
Integer schoolid = examVo.getSchoolid();
|
|
133
|
+ Integer gradeid = examVo.getGradeid();
|
157
|
134
|
try {
|
158
|
135
|
List<TNotice> noticeList = new ArrayList<>();
|
159
|
|
- List<TNoticeClass> classList = new ArrayList<>();
|
160
|
|
- List<TNoticeTeacher> teacherList = new ArrayList<>();
|
|
136
|
+ List<TNoticeUser> stuList = new ArrayList<>();
|
|
137
|
+ List<TNoticeUser> teacherList = new ArrayList<>();
|
161
|
138
|
List<TMsg> msgList = new ArrayList<>();
|
162
|
139
|
String noticetitle = examname + "-考试公告";
|
163
|
140
|
List<Map> classes = eClassMapper.listByExamId(examid);
|
164
|
141
|
String classids = classes.stream().map(c -> c.get("classid").toString()).collect(Collectors.joining(","));
|
165
|
142
|
List<UserVo> teachers = userMapper.listTeacherByClassIds(classids);//获取考试班级任教老师
|
166
|
143
|
if (notice == 1) {
|
167
|
|
- for (Map s : classes) {
|
168
|
|
- TNoticeClass nt = new TNoticeClass();
|
169
|
|
- nt.setClassid((Integer) s.get("classid"));
|
170
|
|
- classList.add(nt);
|
|
144
|
+ for (UserVo student : students) {
|
|
145
|
+ TNoticeUser nu = new TNoticeUser();
|
|
146
|
+ nu.setUserid(student.getUserid());
|
|
147
|
+ nu.setGradeid(gradeid);
|
|
148
|
+ nu.setClassid(student.getClassid());
|
|
149
|
+ stuList.add(nu);
|
171
|
150
|
}
|
172
|
151
|
TNotice n = new TNotice();
|
173
|
152
|
n.setNoticetitle(noticetitle);
|
174
|
153
|
n.setNoticecontent(examcomm);
|
175
|
|
- n.setNoticetype(1);
|
176
|
|
- n.setClasses(classList);
|
|
154
|
+ n.setNoticetype(3);
|
|
155
|
+ n.setUsers(stuList);
|
177
|
156
|
noticeList.add(n);
|
178
|
157
|
|
179
|
158
|
for (UserVo t : teachers) {
|
180
|
|
- TNoticeTeacher nt = new TNoticeTeacher();
|
181
|
|
- nt.setTeacherid(t.getUserid());
|
|
159
|
+ TNoticeUser nt = new TNoticeUser();
|
|
160
|
+ nt.setUserid(t.getUserid());
|
|
161
|
+ nt.setGradeid(gradeid);
|
|
162
|
+ nt.setSubjectid(t.getSubjectid());
|
182
|
163
|
teacherList.add(nt);
|
183
|
164
|
}
|
184
|
165
|
TNotice n2 = new TNotice();
|
185
|
166
|
n2.setNoticetitle(noticetitle);
|
186
|
167
|
n2.setNoticecontent(examcomm);
|
187
|
168
|
n2.setNoticetype(2);
|
188
|
|
- n2.setTeachers(teacherList);
|
|
169
|
+ n2.setUsers(teacherList);
|
189
|
170
|
noticeList.add(n2);
|
190
|
171
|
}
|
191
|
172
|
if (msg == 1) {
|
192
|
173
|
String msgtxt = noticetitle + "\n" + ExamUtil.htmlRemoveTag(examcomm);
|
193
|
|
- List<String> userphones = students.stream().filter(s -> N_Utils.isNotEmpty(s.getUserphone()))
|
194
|
|
- .map(s -> s.getUserphone()).collect(Collectors.toList());
|
|
174
|
+ List<String> userphones = new ArrayList<>();
|
|
175
|
+ for (UserVo student : students) {
|
|
176
|
+ if (N_Utils.isNotEmpty(student.getUserphone())) {
|
|
177
|
+ String sUserphone = student.getUserphone();
|
|
178
|
+ userphones.add(sUserphone);
|
|
179
|
+ }
|
|
180
|
+ }
|
195
|
181
|
for (String userphone : userphones) {
|
196
|
182
|
TMsg m = new TMsg();
|
197
|
183
|
m.setMsgtxt(msgtxt);
|
198
|
184
|
m.setUserphone(userphone);
|
199
|
185
|
msgList.add(m);
|
200
|
186
|
}
|
201
|
|
- userphones = teachers.stream().filter(s -> N_Utils.isNotEmpty(s.getUserphone()))
|
202
|
|
- .map(s -> s.getUserphone()).collect(Collectors.toList());
|
|
187
|
+ List<String> list = new ArrayList<>();
|
|
188
|
+ for (UserVo s : teachers) {
|
|
189
|
+ String sUserphone = s.getUserphone();
|
|
190
|
+ if (N_Utils.isNotEmpty(sUserphone)) {
|
|
191
|
+ list.add(sUserphone);
|
|
192
|
+ }
|
|
193
|
+ }
|
|
194
|
+ userphones = list;
|
203
|
195
|
for (String userphone : userphones) {
|
204
|
196
|
TMsg m = new TMsg();
|
205
|
197
|
m.setMsgtxt(msgtxt);
|
|
@@ -217,12 +209,10 @@ public class NoticeService {
|
217
|
209
|
});
|
218
|
210
|
noticeMapper.insertList(noticeList);
|
219
|
211
|
|
220
|
|
- List<TNoticeTeacher> nteacherList = new ArrayList<>();
|
221
|
|
- List<TNoticeClass> nclassList = new ArrayList<>();
|
222
|
|
- List<TNoticeSchool> schoolList = new ArrayList<>();
|
|
212
|
+ List<TNoticeUser> nteacherList = new ArrayList<>();
|
223
|
213
|
noticeList.forEach(n -> {
|
224
|
214
|
Integer noticeid = n.getId();
|
225
|
|
- List<TNoticeTeacher> cteachers = n.getTeachers().stream().distinct().collect(Collectors.toList());
|
|
215
|
+ List<TNoticeUser> cteachers = n.getUsers().stream().distinct().collect(Collectors.toList());
|
226
|
216
|
cteachers.forEach(t -> {
|
227
|
217
|
t.setNoticeid(noticeid);
|
228
|
218
|
t.setReaded(0);
|
|
@@ -230,26 +220,9 @@ public class NoticeService {
|
230
|
220
|
t.setSchoolid(schoolid);
|
231
|
221
|
});
|
232
|
222
|
nteacherList.addAll(cteachers);
|
233
|
|
-
|
234
|
|
- List<TNoticeClass> nclasses = n.getClasses();
|
235
|
|
- nclasses.forEach(c -> {
|
236
|
|
- c.setNoticeid(noticeid);
|
237
|
|
- c.setCreateid(createid);
|
238
|
|
- c.setCreatetime(createtime);
|
239
|
|
- });
|
240
|
|
- nclassList.addAll(nclasses);
|
241
|
|
-
|
242
|
|
- TNoticeSchool ns = new TNoticeSchool();
|
243
|
|
- ns.setNoticeid(noticeid);
|
244
|
|
- ns.setSchoolid(schoolid);
|
245
|
|
- ns.setCreateid(createid);
|
246
|
|
- ns.setCreatetime(createtime);
|
247
|
|
- schoolList.add(ns);
|
248
|
223
|
});
|
249
|
224
|
|
250
|
|
- if (N_Utils.isListNotEmpty(nteacherList)) noticeTeacherMapper.insertList(teacherList);//通知教师关联信息
|
251
|
|
- if (N_Utils.isListNotEmpty(nclassList)) noticeClassMapper.insertList(classList);//通知班级关联信息
|
252
|
|
- if (N_Utils.isListNotEmpty(schoolList)) noticeSchoolMapper.insertList(schoolList);//通知学校关联信息
|
|
225
|
+ if (N_Utils.isListNotEmpty(nteacherList)) noticeUserMapper.insertList(teacherList);//通知教师关联信息
|
253
|
226
|
}
|
254
|
227
|
|
255
|
228
|
if (N_Utils.isListNotEmpty(msgList)) {//短信
|
|
@@ -262,8 +235,8 @@ public class NoticeService {
|
262
|
235
|
msgMapper.insertList(msgs);//短信保存到数据库
|
263
|
236
|
|
264
|
237
|
//发短信
|
265
|
|
- Integer pageSize = 2000;//手机号,多个手机号为用半角 , 分开,如13899999999,13688888888(最多2000个,必填)
|
266
|
|
- Map<String, List<TMsg>> mcollect = msgs.stream().collect(Collectors.groupingBy(s -> s.getMsgtxt()
|
|
238
|
+ int pageSize = 2000;//手机号,多个手机号为用半角 , 分开,如13899999999,13688888888(最多2000个,必填)
|
|
239
|
+ Map<String, List<TMsg>> mcollect = msgs.stream().collect(Collectors.groupingBy(TMsg::getMsgtxt
|
267
|
240
|
, LinkedHashMap::new, Collectors.toList()));
|
268
|
241
|
for (Map.Entry<String, List<TMsg>> entry : mcollect.entrySet()) {
|
269
|
242
|
List<TMsg> list = entry.getValue();
|
|
@@ -271,7 +244,7 @@ public class NoticeService {
|
271
|
244
|
for (int i = 0; i < list.size(); i += pageSize) {
|
272
|
245
|
ZtMsgVo vo = new ZtMsgVo();
|
273
|
246
|
String userphone = list.stream().skip(i).limit(pageSize)
|
274
|
|
- .map(s -> s.getUserphone()).collect(Collectors.joining(","));
|
|
247
|
+ .map(TMsg::getUserphone).collect(Collectors.joining(","));
|
275
|
248
|
vo.setMobile(userphone);
|
276
|
249
|
vo.setContent(msgtxt);
|
277
|
250
|
SMSSender.sendSms(vo);
|
|
@@ -280,7 +253,7 @@ public class NoticeService {
|
280
|
253
|
}
|
281
|
254
|
}
|
282
|
255
|
} catch (Exception e) {
|
283
|
|
- log.error("批量添加通知和短信(发布考试用)失败", e.getMessage());
|
|
256
|
+ log.error("批量添加通知和短信(发布考试用)失败:{}", e.getMessage());
|
284
|
257
|
}
|
285
|
258
|
}
|
286
|
259
|
}
|