Beispiel #1
0
  /**
   * 广播消息给指定家长的家长(过滤掉重复消息没有阅读的),避免发送多次
   *
   * @param msg
   * @return
   */
  public void pushMsgToParentByParentuuidListFilterNoreadCount(
      int type, String type_uuid, List<String> parentuuidlist, String msg) throws Exception {

    if (parentuuidlist.isEmpty()) {
      logger.warn(
          "pushMsgToParentByParentuuidListFilterNoreadCount parentuuidlist isEmpty,msg= " + msg);
      return;
    }
    String title = getPushMsgTitleByType(type);
    // 添加不在发送推送消息的bug.
    List<String> noReadUserlist = new ArrayList();
    List<PushMessage> pushMessageList = this.getPushMessageList(type, type_uuid, parentuuidlist);

    for (PushMessage pushMessage : pushMessageList) {

      noReadUserlist.add(pushMessage.getRevice_useruuid());
      if (SystemConstants.Read_flag_0.equals(pushMessage.getIsread())) { // 未读情况下,推送消息不在发送.
        if (pushMessage.getCount() == null) { // 计数.
          pushMessage.setCount(1);
        } else {
          pushMessage.setCount(pushMessage.getCount() + 1);
        }
      } else { //
        pushMessage.setCount(1);
      }
      pushMessage.setRel_uuid(type_uuid);
      pushMessage.setTitle(title + "(" + pushMessage.getCount() + ")");
      pushMessage.setMessage(PxStringUtil.getSubString(msg, 128));
    }

    Timestamp nowTime = TimeUtils.getCurrentTimestamp();

    for (int i = parentuuidlist.size() - 1; i >= 0; i--) {

      String o = parentuuidlist.get(i);
      if (noReadUserlist.contains(o)) { // 没有阅读的信息,只发一次.
        parentuuidlist.remove(i);
        continue;
      }

      if (StringUtils.isNotBlank(o)) {
        PushMessage pushMessage = new PushMessage();
        pushMessage.setRevice_useruuid(o);
        pushMessage.setType(type);
        pushMessage.setRel_uuid(type_uuid);
        pushMessage.setTitle(title);
        pushMessage.setMessage(PxStringUtil.getSubString(msg, msg_max_length));
        pushMessage.setCreate_time(nowTime);
        pushMessage.setIsread(0);

        this.nSimpleHibernateDao.save(pushMessage);
      }
    }

    this.logger.info("pushMsgToParentByClass count=" + parentuuidlist.size());

    this.pushMsgToAPPIservice.pushMsg_to_parent_app_byUserList(parentuuidlist, title, msg);
  }
Beispiel #2
0
  /**
   * 广播所有消息_给所有老师(group_uuid)
   *
   * @param msg
   * @return
   */
  public void pushMsgToAll_to_teacher(int type, String type_uuid, String group_uuid, String msg)
      throws Exception {
    String title = this.getPushMsgTitleByType(type);
    List<String> list =
        (List<String>)
            this.nSimpleHibernateDao
                .getHibernateTemplate()
                .find(
                    "select DISTINCT useruuid from UserGroupRelation where groupuuid=?",
                    group_uuid);

    Timestamp nowTime = TimeUtils.getCurrentTimestamp();

    for (String o : list) {

      if (StringUtils.isBlank(o)) continue;

      PushMessage pushMessage = new PushMessage();
      pushMessage.setGroup_uuid(group_uuid);
      pushMessage.setRevice_useruuid(o);
      pushMessage.setType(type);
      pushMessage.setRel_uuid(type_uuid);
      pushMessage.setTitle(title);

      pushMessage.setMessage(PxStringUtil.getSubString(msg, msg_max_length));
      pushMessage.setCreate_time(nowTime);
      pushMessage.setIsread(0);

      this.nSimpleHibernateDao.save(pushMessage);
    }
    this.logger.info("pushMsgToAll_to_teacher count=" + list.size());
    pushMsgToAPPIservice.pushMsgToAll_to_teacher_app(group_uuid, title, msg);
  }
Beispiel #3
0
  /**
   * 广播消息给指定家长的家长(过滤掉重复消息没有阅读的),避免发送多次
   *
   * @param msg
   * @return
   */
  public void pushMsgToParentByParentuuidListFilterNoread(
      int type, String type_uuid, List<String> parentuuidlist, String msg) throws Exception {
    String title = getPushMsgTitleByType(type);
    List<String> noReadUserlist =
        this.getPushMessageRevice_useruuidList(type, type_uuid, parentuuidlist);

    Timestamp nowTime = TimeUtils.getCurrentTimestamp();

    for (int i = parentuuidlist.size() - 1; i >= 0; i--) {

      String o = parentuuidlist.get(i);
      if (noReadUserlist.contains(o)) { // 没有阅读的信息,只发一次.
        parentuuidlist.remove(i);
        continue;
      }

      if (StringUtils.isBlank(o)) continue;
      PushMessage pushMessage = new PushMessage();
      pushMessage.setRevice_useruuid(o);
      pushMessage.setType(type);
      pushMessage.setRel_uuid(type_uuid);
      pushMessage.setTitle(title);
      pushMessage.setMessage(PxStringUtil.getSubString(msg, msg_max_length));
      pushMessage.setCreate_time(nowTime);
      pushMessage.setIsread(0);

      this.nSimpleHibernateDao.save(pushMessage);
    }

    this.logger.info("pushMsgToParentByClass count=" + parentuuidlist.size());
    this.pushMsgToAPPIservice.pushMsg_to_parent_app_byUserList(parentuuidlist, title, msg);
  }
Beispiel #4
0
  /**
   * 广播所有android消息_给所有家长
   *
   * @param msg
   * @return
   */
  public void pushMsg_to_teacher(int type, String type_uuid, String user_uuid, String msg)
      throws Exception {
    String title = getPushMsgTitleByType(type);
    if (StringUtils.isBlank(user_uuid)) return;
    PushMessage pushMessage = new PushMessage();
    // pushMessage.setGroup_uuid(group_uuid);
    pushMessage.setRevice_useruuid(user_uuid);
    pushMessage.setType(type);
    pushMessage.setRel_uuid(type_uuid);
    pushMessage.setTitle(title);
    pushMessage.setMessage(PxStringUtil.getSubString(msg, msg_max_length));
    pushMessage.setCreate_time(TimeUtils.getCurrentTimestamp());
    pushMessage.setIsread(0);

    this.nSimpleHibernateDao.save(pushMessage);
    this.pushMsgToAPPIservice.pushMsg_to_teacher_app(user_uuid, title, msg);
  }
Beispiel #5
0
  /**
   * 广播消息给指定老师
   *
   * @param msg
   * @return
   */
  public void pushMsgToTeacherByuseruuidList(
      int type, String type_uuid, String group_uuid, List<String> useruuid, String msg)
      throws Exception {
    String title = getPushMsgTitleByType(type);

    Timestamp nowTime = TimeUtils.getCurrentTimestamp();

    for (String o : useruuid) {
      PushMessage pushMessage = new PushMessage();
      pushMessage.setGroup_uuid(group_uuid);
      pushMessage.setRevice_useruuid(o);
      pushMessage.setType(type);
      pushMessage.setRel_uuid(type_uuid);
      pushMessage.setTitle(title);
      pushMessage.setMessage(PxStringUtil.getSubString(msg, msg_max_length));
      pushMessage.setCreate_time(nowTime);
      pushMessage.setIsread(0);
      this.nSimpleHibernateDao.save(pushMessage);
    }

    this.logger.info("pushMsgToTeacherByuseruuidList count=" + useruuid.size());
    this.pushMsgToAPPIservice.pushMsg_to_teacher_app_byUserList(useruuid, title, msg);
  }
Beispiel #6
0
  /**
   * 根据回复内容,推送给对应老师或家长
   *
   * @param msg
   * @return
   */
  public void pushMsg_replay_to_classNews_to_teacherOrParent(String type_uuid, String msg)
      throws Exception {

    Session session = this.nSimpleHibernateDao.getSession();
    String sql = " SELECT t1.uuid,t1.create_useruuid,t1.usertype,t1.groupuuid";
    sql += " FROM px_classnews t1 ";
    sql += " where t1.uuid='" + type_uuid + "'  ";
    Query query = session.createSQLQuery(sql);
    query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
    List<Map> list = query.list();

    if (list.size() == 0) return;

    Map obj = list.get(0);
    if (obj.get("usertype") == null) {
      logger.error("px_classnews usertype is null,uuid" + type_uuid);
      return;
    }

    if ("1".equals((obj.get("usertype").toString()))) {
      // 家长,暂时不开发通知
      return;
    }

    boolean isSendPushMsg = true;
    List users = new ArrayList();
    users.add(obj.get("create_useruuid"));

    List<PushMessage> listPushMessage =
        this.getPushMessageList(SystemConstants.common_type_hudong, type_uuid, users);
    PushMessage pushMessage = null;
    if (listPushMessage.size() > 0) {
      pushMessage = listPushMessage.get(0);
    }
    //		PushMessage pushMessage = (PushMessage) this.nSimpleHibernateDao
    //				.getObjectByAttribute(PushMessage.class, "rel_uuid", type_uuid);
    if (pushMessage == null) {
      pushMessage = new PushMessage();
      pushMessage.setCount(1);
    } else { // 已经发过消息的情况下,只修改对应的内容.不新加数据.
      if (SystemConstants.Read_flag_0.equals(pushMessage.getIsread())) { // 未读情况下,推送消息不在发送.
        isSendPushMsg = false;
        if (pushMessage.getCount() == null) { // 计数.
          pushMessage.setCount(1);
        } else {
          pushMessage.setCount(pushMessage.getCount() + 1);
        }
      } else { //
        pushMessage.setCount(1);
      }
    }
    pushMessage.setGroup_uuid((String) obj.get("groupuuid"));
    pushMessage.setRevice_useruuid((String) obj.get("create_useruuid"));
    pushMessage.setType(SystemConstants.common_type_hudong);
    pushMessage.setRel_uuid(type_uuid);
    pushMessage.setTitle("互动(" + pushMessage.getCount() + ")");
    pushMessage.setMessage(PxStringUtil.getSubString(msg, 128));
    pushMessage.setCreate_time(TimeUtils.getCurrentTimestamp());
    pushMessage.setIsread(SystemConstants.Read_flag_0);

    this.nSimpleHibernateDao.save(pushMessage);
    if (isSendPushMsg) { // 不重复发送消息
      if ("1".equals((obj.get("usertype").toString()))) {
        // 家长
        this.pushMsgToAPPIservice.pushMsg_to_parent_app(
            pushMessage.getRevice_useruuid(), pushMessage.getTitle(), msg);
      } else {
        // 老师
        this.pushMsgToAPPIservice.pushMsg_to_teacher_app(
            pushMessage.getRevice_useruuid(), pushMessage.getTitle(), msg);
      }
    }
  }