Browse Source

通知对象

tags/正式3.13.3
雍文秀 1 year ago
parent
commit
d1ac26ae3a

+ 41
- 3
sapi/src/main/java/com/xhkjedu/sapi/controller/notice/NoticeController.java View File

@@ -14,8 +14,8 @@ import com.xhkjedu.sapi.vo.notice.NoticeVo;
14 14
 import org.springframework.web.bind.annotation.*;
15 15
 
16 16
 import javax.annotation.Resource;
17
-import java.util.List;
18
-import java.util.Map;
17
+import java.util.*;
18
+import java.util.stream.Collectors;
19 19
 
20 20
 /**
21 21
 * @author ywx
@@ -175,13 +175,51 @@ public class NoticeController {
175 175
         Integer noticeid = nu.getNoticeid();
176 176
         Integer page = nu.getPage();
177 177
         Integer pageSize = nu.getPageSize();
178
-        N_Utils.validation(new Object[]{noticeid, "通知id", 1, page, "显示页码", 1, pageSize, "显示条数"});
178
+        N_Utils.validation(new Object[]{noticeid, "通知id", 1, page, "显示页码", 1, pageSize, "显示条数", 1});
179 179
         PageHelper.startPage(page, pageSize);
180 180
         List<Map> list = noticeService.listUser(nu);
181 181
         PageResult pageResult = PageUtil.getPageResult(new PageInfo(list));
182
+        List<Map> list1 = (List<Map>) pageResult.getList();
183
+        Map<Object, List<Map>> gMap = list1.stream().collect(Collectors.groupingBy(m -> m.get("gradeid")));
184
+        List<Map<String, Object>> grades = new ArrayList<>();
185
+        for (Map.Entry<Object, List<Map>> entry : gMap.entrySet()) {
186
+            Map<String, Object> g = new LinkedHashMap<>();
187
+            g.put("gradeid", entry.getKey());
188
+            //List<Map<Object, List<Map>>> subjectClass = new ArrayList<>();
189
+            /*List<Map> subjectClass = entry.getValue();
190
+            Map<String, List<Map>> collect = users.stream().collect(Collectors.groupingBy(m -> m.get("subjectid").toString() + m.get("classid")));
191
+            for (Map.Entry<String, List<Map>> uentry : collect.entrySet()) {
192
+                List<Map> value = uentry.getValue();
193
+                Map map = value.get(0);
194
+                Map sc = new LinkedHashMap();
195
+                sc.put("subjectid", map.get("subjectid"));
196
+                sc.put("classid", map.get("classid"));
197
+                sc.put("name", map.get("name"));
198
+                sc.put("users", value);
199
+                subjectClass.add(sc);
200
+            }*/
201
+            g.put("subjectClass", entry.getValue());
202
+            grades.add(g);
203
+        }
204
+        pageResult.setList(grades);
182 205
         return new ResultVo(0, "获取通知对象成功", pageResult);
183 206
     }
184 207
 
208
+    /**
209
+     * @Description 获取通知科目和班级
210
+     * @Date 2023/12/25 14:20
211
+     * @Author YWX
212
+     * @Param [nu]
213
+     * @Return com.xhkjedu.vo.ResultVo
214
+     **/
215
+    @PostMapping("/list_sc")
216
+    public ResultVo listSubjectAndClass(@RequestBody TNoticeUser nu) {
217
+        Integer noticeid = nu.getNoticeid();
218
+        N_Utils.validation(new Object[]{noticeid, "通知id", 1});
219
+        Map map = noticeService.listSubjectAndClass(noticeid);
220
+        return new ResultVo(0, "获取通知科目和班级成功", map);
221
+    }
222
+
185 223
     /*
186 224
      * @Description 处理班级通知到学生个人
187 225
      * @Date 2023/12/18 17:41:09

+ 3
- 0
sapi/src/main/java/com/xhkjedu/sapi/mapper/notice/NoticeUserMapper.java View File

@@ -33,4 +33,7 @@ public interface NoticeUserMapper extends TkMapper<TNoticeUser> {
33 33
 
34 34
     //删除通知对象
35 35
     void deleteByNoticeId(@Param("noticeid") Integer noticeid);
36
+
37
+    //获取通知科目和班级
38
+    List<TNoticeUser> listSubjectAndClass(@Param("noticeid") Integer noticeid);
36 39
 }

+ 39
- 0
sapi/src/main/java/com/xhkjedu/sapi/service/notice/NoticeService.java View File

@@ -252,4 +252,43 @@ public class NoticeService {
252 252
             }
253 253
         }
254 254
     }
255
+
256
+    /**
257
+     * @Description 获取通知科目和班级
258
+     * @Date 2023/12/25 14:19
259
+     * @Author YWX
260
+     * @Param [noticeid]
261
+     * @Return java.util.Map
262
+     **/
263
+    public Map listSubjectAndClass(Integer noticeid) {
264
+        Map<String, Object> map = new LinkedHashMap<>();
265
+        List<TNoticeUser> users = noticeUserMapper.listSubjectAndClass(noticeid);
266
+        List<Map<String, Integer>> grades = new ArrayList<>();
267
+        List<Map<String, Object>> subjects = new ArrayList<>();
268
+        List<Map<String, Object>> classes = new ArrayList<>();
269
+        for (TNoticeUser user : users) {
270
+            String subjectid = user.getSubjectid();
271
+            Integer gradeid = user.getGradeid();
272
+            Map<String, Integer> g = new LinkedHashMap<>();
273
+            g.put("gradeid", gradeid);
274
+            grades.add(g);
275
+            Map<String, Object> sc = new LinkedHashMap<>();
276
+            String username = user.getUsername();
277
+            if (N_Utils.isEmpty(subjectid)) {
278
+                sc.put("gradeid", gradeid);
279
+                sc.put("classid", user.getClassid());
280
+                sc.put("classname", username);
281
+                classes.add(sc);
282
+            } else {
283
+                sc.put("subjectid", subjectid);
284
+                sc.put("subjectname", username);
285
+                subjects.add(sc);
286
+            }
287
+        }
288
+        grades.sort(Comparator.comparing(m -> m.get("gradeid")));
289
+        map.put("grades", grades.stream().distinct().collect(Collectors.toList()));
290
+        map.put("subjects", subjects.stream().distinct().collect(Collectors.toList()));
291
+        map.put("classes", classes);
292
+        return map;
293
+    }
255 294
 }

+ 8
- 0
sapi/src/main/resources/mapper/notice/NoticeUserMapper.xml View File

@@ -47,4 +47,12 @@
47 47
         <if test="nu.readed!=null and nu.readed!=-1">and nu.readed=#{nu.readed}</if>
48 48
         <if test="nu.username!=null and nu.username!=''">and u.username like '%${nu.username}%'</if>
49 49
     </select>
50
+    <!--获取通知科目和班级-->
51
+    <select id="listSubjectAndClass" resultType="com.xhkjedu.sapi.model.notice.TNoticeUser">
52
+        select nu.gradeid,nu.classid,nu.subjectid
53
+        ,if(nu.classid is not null,(select c.classname from t_class c where c.classid=nu.classid)
54
+            ,(select s.subjectname from t_subject s where s.subjectid=nu.subjectid))username
55
+        from t_notice_user nu where noticeid=#{noticeid}
56
+        group by nu.gradeid,nu.classid,nu.subjectid
57
+    </select>
50 58
 </mapper>

Loading…
Cancel
Save