예제 #1
0
  @RequestMapping(value = Module.NEWS_MODULE + "/chooseTarget")
  public String chooseTarget(@RequestParam Map<String, Object> map, Map<String, Object> result) {

    String ntcId = (String) map.get("ntcId");
    String orgId = (String) map.get("orgId");
    String way = (String) map.get("way");

    RelNoticeUserKey key = new RelNoticeUserKey();
    key.setNtcId(ntcId);
    // way == 1 按照角色进行选择,way ==2 按照班级进行选择
    if ("1".equals(way)) {
      // 选择所有的角色进行显示
      OrgRole role = new OrgRole();
      List<OrgRole> roleList = orgRoleService.selectByOrgRole(role);

      // 从rel_notice_user表查询已匹配的角色,选出所有的roleId
      List<String> ntcUserKey = relNoticeUserMapper.selectSelective(key);

      if (roleList != null && ntcUserKey != null) {
        for (int i = 0; i < roleList.size(); i++) {
          for (int j = 0; j < ntcUserKey.size(); j++) {
            if (roleList.get(i).getRoleId().equals(ntcUserKey.get(j))) {
              roleList.get(i).setFlag((short) 1);
            }
          }
        }
      }
      result.put("roleList", roleList);

    } else if ("2".equals(way)) {
      // 选择所有的班级
      OrgUser orgUser = new OrgUser();
      orgUser.setOrgId(orgId);
      List<ClassInfo> classList = classInfoService.selectClassListByOrgId(orgUser);

      // 从rel_notice_user表查询已匹配的班级,选出所有的classId
      List<String> ntcUserKey = relNoticeUserMapper.selectSelectedClasses(key);

      if (classList != null && ntcUserKey != null) {
        for (int i = 0; i < classList.size(); i++) {
          for (int j = 0; j < ntcUserKey.size(); j++) {
            if (classList.get(i).getClassId().equals(ntcUserKey.get(j))) {
              classList.get(i).setStation("checked");
            }
          }
        }
      }
      result.put("classList", classList);
    }
    result.put("map", map);

    return Module.NEWS_MODULE + "/noticeChoosePeople";
  }
예제 #2
0
  @RequestMapping(value = Module.NEWS_MODULE + "/choose")
  public String choose(@RequestParam Map<String, Object> map, Map<String, Object> result) {

    String ntcId = (String) map.get("ntcId");
    String way = (String) map.get("way");
    RelNoticeUserKey key = new RelNoticeUserKey();
    key.setNtcId(ntcId);

    OrgRole role = new OrgRole();
    // 选择所有的角色进行显示
    List<OrgRole> roleList = orgRoleService.selectByOrgRole(role);

    // 从rel_notice_user表查询已匹配的角色,选出所有的roleId
    List<String> ntcUserKey = relNoticeUserMapper.selectSelective(key);
    if (roleList != null && ntcUserKey != null) {
      for (int i = 0; i < roleList.size(); i++) {
        for (int j = 0; j < ntcUserKey.size(); j++) {
          if (roleList.get(i).getRoleId().equals(ntcUserKey.get(j))) {
            roleList.get(i).setFlag((short) 1);
          }
        }
      }
    }
    result.put("roleList", roleList);
    result.put("map", map);

    return Module.NEWS_MODULE + "/noticeChoosePeople";
  }
예제 #3
0
  /**
   * 将消息和确定的被通知人插入到rel_ntc_user表
   *
   * @param map
   * @param result
   * @return
   */
  @RequestMapping(value = Module.NEWS_MODULE + "/saveNtcUser")
  public String saveNoticeUserInfo(
      @RequestParam Map<String, Object> map, Map<String, Object> result) {

    String id = (String) map.get("id");
    String way = (String) map.get("way");
    String ntcId = (String) map.get("ntcId");
    String[] ids = id.split(",");

    // 按照角色选择
    if ("1".equals(way)) {
      if (ids != null && (ids.length > 1 || (ids.length == 1 && !"".equals(ids[0])))) {
        relNoticeUserMapper.deleteRoleIdsNotNull(ntcId);
        for (int i = 0; i < ids.length; i++) {
          // 根据一个roleId 选择所有符合该id的用户
          List<String> userList = relUserRoleService.selectUserList(ids[i]);

          if (userList != null) {
            RelNoticeUserKey key = new RelNoticeUserKey();
            key.setNtcId(ntcId);
            key.setRoleId(ids[i]);
            for (String userId : userList) {
              key.setUserId(userId);
              relNoticeUserMapper.insertSelective(key);
            }
          }
        }
      } else {
        // 返回信息,提示数据库中不存在roleId
        relNoticeUserMapper.deleteRoleIdsNotNull(ntcId);
      }

    } else if ("2".equals(way)) {
      if (ids != null && (ids.length > 1 || (ids.length == 1 && !"".equals(ids[0])))) {
        relNoticeUserMapper.deleteClassIdsNotNull(ntcId);
        for (int i = 0; i < ids.length; i++) {
          // 根据classId 获得一个班级的学生信息
          List<Student> stuList = studentService.selectByClassId(ids[i]);
          if (stuList != null && !stuList.isEmpty()) {
            String[] stuIds = new String[stuList.size()];
            for (int j = 0; j < stuList.size(); j++) {
              stuIds[j] = stuList.get(j).getStuId();
            }
            // 根据学生的id获得监护人的信息
            List<StuGuardian> guardianList = stuGuardianService.selectByStuIds(stuIds);
            if (guardianList != null) {
              // 对所选班级中所有的监护人进行通知
              for (int j = 0; j < guardianList.size(); j++) {
                RelNoticeUserKey key = new RelNoticeUserKey();
                key.setNtcId(ntcId);
                key.setUserId(guardianList.get(j).getuserId());
                key.setClassId(ids[i]);
                relNoticeUserMapper.insertSelective(key);
              }
            }
          }
        }
      } else {
        relNoticeUserMapper.deleteClassIdsNotNull(ntcId);
      }
    }
    result.put("map", map);

    return "redirect:selectNoticeList.action";
  }