Examples of IMessageRecordDao


Examples of com.lgx8.common.dao.IMessageRecordDao

   
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IUserDao userDao = (IUserDao) ac.getBean("userDao");
    IMessageRecordDao messageRecordDao = (IMessageRecordDao) ac.getBean("messageRecordDao");
    if("1".equals(sendType))
    {
      String[] mbs = mobiles.split(",");
     
      for(String sendMobile : mbs)
      {
        SendSms.sendSms(sendMobile, content);
      }
    }else if("2".equals(sendType))
    {
      List<User> us = userDao.listUser(" from User u where u.id in ("+userIds+")");
      for(User u : us)
      {
        SendSms.sendSms(u.getMobile(), content);
        if(!StringUtil.isEmptyStr(mobiles))mobiles += ",";
        mobiles += u.getMobile();
      }
    }else if("3".equals(sendType))
    {
      String[] mids = merchantIds.split(",");
      for(int i =0 ; i < mids.length; i++)
      {
        List<User> us = userDao.listUser(" from User u where u.id in ("+userIds+") and u.usertype = " + uts.split(",")[i] +" and u.organizationid = " + mids[i]);
        for(User u : us)
        {
          SendSms.sendSms(u.getMobile(), content);
          if(!StringUtil.isEmptyStr(mobiles))mobiles += ",";
          mobiles += u.getMobile();
        }
      }
    }else if("4".equals(sendType))
    {
      String hql = " from User u where u.enabled = true and u.locked = false";
     
      String hql1 = "";
      String hql2 = "";
     
      if(rtUser.isMerchant())
      {
        hql1 += " and u.usertype = 2 and u.organizationid = " +rtUser.getOrganizationid() ;
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql1 += " and exists(from Merchant m where m.id = "+rtUser.getOrganizationid()+"  and m.areaNode = '"+areaNode+"')";
        }
       
        hql += hql1;
      }else if(rtUser.isOrganization())
      {
        hql2 += " and u.usertype = 3 and u.organizationid = " +rtUser.getOrganizationid() ;
       
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql2 += " and exists(from Organization o where o.id = "+rtUser.getOrganizationid()+"  and o.JGSZQY = '"+areaNode+"')";
        }
       
        hql += hql2;
      }else
      {
        hql1 += " and u.usertype = 2 ";
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql1 += " and exists(from Merchant m where m.id = u.organizationid  and m.areaNode = '"+areaNode+"')";
        }
        hql2 += " and u.usertype = 3 ";
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql2 += " and exists(from Organization o where o.id = u.organizationid  and o.JGSZQY = '"+areaNode+"')";
        }
       
        hql = hql + hql1 + " union " +hql + hql2;
      }
     
      List<User> us = userDao.listUser(hql);
      for(User u : us)
      {
        SendSms.sendSms(u.getMobile(), content);
        if(!StringUtil.isEmptyStr(mobiles))mobiles += ",";
        mobiles += u.getMobile();
       
        if(!StringUtil.isEmptyStr(users))users += ",";
        users += u.getTruename();
      }
    }else if("5".equals(sendType))
    {
      String hql = " from User u where u.enabled = true and u.locked = false and u.sex = 1";
     
      String hql1 = "";
      String hql2 = "";
     
      if(rtUser.isMerchant())
      {
        hql1 += " and u.usertype = 2 and u.organizationid = " +rtUser.getOrganizationid() ;
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql1 += " and exists(from Merchant m where m.id = "+rtUser.getOrganizationid()+"  and m.areaNode = '"+areaNode+"')";
        }
       
        hql += hql1;
      }else if(rtUser.isOrganization())
      {
        hql2 += " and u.usertype = 3 and u.organizationid = " +rtUser.getOrganizationid() ;
       
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql2 += " and exists(from Organization o where o.id = "+rtUser.getOrganizationid()+"  and o.JGSZQY = '"+areaNode+"')";
        }
       
        hql += hql2;
      }else
      {
        hql1 += " and u.usertype = 2 ";
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql1 += " and exists(from Merchant m where m.id = u.organizationid  and m.areaNode = '"+areaNode+"')";
        }
        hql2 += " and u.usertype = 3 ";
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql2 += " and exists(from Organization o where o.id = u.organizationid  and o.JGSZQY = '"+areaNode+"')";
        }
       
        hql = hql + hql1 + " union  " +hql + hql2;
      }
     
      List<User> us = userDao.listUser(hql);
      for(User u : us)
      {
        SendSms.sendSms(u.getMobile(), content);
        if(!StringUtil.isEmptyStr(mobiles))mobiles += ",";
        mobiles += u.getMobile();
       
        if(!StringUtil.isEmptyStr(users))users += ",";
        users += u.getTruename();
      }
    }else if("6".equals(sendType))
    {
      String hql = " from User u where u.enabled = true and u.locked = false  and u.sex = 2";
     
      String hql1 = "";
      String hql2 = "";
     
      if(rtUser.isMerchant())
      {
        hql1 += " and u.usertype = 2 and u.organizationid = " +rtUser.getOrganizationid() ;
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql1 += " and exists(from Merchant m where m.id = "+rtUser.getOrganizationid()+"  and m.areaNode = '"+areaNode+"')";
        }
       
        hql += hql1;
      }else if(rtUser.isOrganization())
      {
        hql2 += " and u.usertype = 3 and u.organizationid = " +rtUser.getOrganizationid() ;
       
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql2 += " and exists(from Organization o where o.id = "+rtUser.getOrganizationid()+"  and o.JGSZQY = '"+areaNode+"')";
        }
       
        hql += hql2;
      }else
      {
        hql1 += " and u.usertype = 2 ";
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql1 += " and exists(from Merchant m where m.id = u.organizationid  and m.areaNode = '"+areaNode+"')";
        }
        hql2 += " and u.usertype = 3 ";
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql2 += " and exists(from Organization o where o.id = u.organizationid  and o.JGSZQY = '"+areaNode+"')";
        }
       
        hql = hql + hql1 + " union " +hql + hql2;
      }
     
      List<User> us = userDao.listUser(hql);
      for(User u : us)
      {
        SendSms.sendSms(u.getMobile(), content);
        if(!StringUtil.isEmptyStr(mobiles))mobiles += ",";
        mobiles += u.getMobile();
       
        if(!StringUtil.isEmptyStr(users))users += ",";
        users += u.getTruename();
      }
    }else
    {
      String hql =  "";
      if("7".equals(sendType))
      {
         hql = " from User u where u.enabled = true and u.locked = false ";
        hql += " and u.usertype = 4 ";
       
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql += " and exists(from Organization o where o.jgfzr.id = u.id  and o.JGSZQY = '"+areaNode+"')";
        }else
        {
          hql += " and exists (from Organization o where o.jgfzr.id = u.id)";
        }
      }else if("8".equals(sendType))
      {
        hql = " from User u where u.enabled = true and u.locked = false ";
        hql += " and u.usertype = 3 ";
       
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql += " and exists(from Organization o where o.jgfzr.id = u.id  and o.JGSZQY = '"+areaNode+"')";
        }else
        {
          hql += " and exists (from Organization o where o.jgfzr.id = u.id)";
        }
      }else if("9".equals(sendType))
      {
        hql = " from User u where u.enabled = true and u.locked = false ";
       
        if(!StringUtil.isEmptyStr(areaNode))
        {
          hql += " and exists(from Merchant m where m.SJFRDB.id = u.id  and m.areaNode = '"+areaNode+"')";
        }else
        {
          hql += " and exists (from Merchant m where m.SJFRDB.id = u.id)";
        }
      }
     
      if(!StringUtil.isEmptyStr(hql))
      {
        List<User> us = userDao.listUser(hql);
        for(User u : us)
        {
          SendSms.sendSms(u.getMobile(), content);
          if(!StringUtil.isEmptyStr(mobiles))mobiles += ",";
          mobiles += u.getMobile();
         
          if(!StringUtil.isEmptyStr(users))users += ",";
          users += u.getTruename();
        }
      }
     
    }
   
    MessageRecord record = new MessageRecord();
    record.setContent(content);
    record.setMobiles(mobiles);
    record.setRecordDate(new Date());
    record.setSendDate(new Date());
    record.setSender(rtUser.getTruename());
    record.setSendId(rtUser.getId()+"");
    record.setSendType("1");
    record.setState("2");
    record.setUserIds(userIds);
    if("1".equals(sendType))record.setUsers(mobiles);
    else record.setUsers(users);
   
    messageRecordDao.createMessageRecord(record);
   
    response.setContentType("text/html; charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        request.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();
View Full Code Here

Examples of com.lgx8.common.dao.IMessageRecordDao

    Template temp = getConfiguration().getTemplate("messagerecord/MessageRecord.ftl");
   
    RunTimeUser rtUser = RunTimeUser.getRunTimeUser(request);
   
    ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    IMessageRecordDao messageRecordDao = (IMessageRecordDao) ac.getBean("messageRecordDao");
   
    String pageno = request.getParameter("pageno");
    //处理当前页
    if(pageno==null) {
      pageno = "1";
    }
    int pagenum = 1;
    try {
      pagenum = Integer.parseInt(pageno);
    } catch (Exception e1) {
      pagenum = 1;
    }
   
    String sender = request.getParameter("sender");
   
    String hql = " from MessageRecord m where 1=1 ";
   
    if(!StringUtil.isEmptyStr(sender))
    {
      hql += " and m.sender like '%"+sender+"%'";
    }
   
    if(rtUser.isMerchant() || rtUser.isOrganization())
    {
      hql += " and m.sendId = '"+rtUser.getId()+"'";
    }
   
    hql += " order by m.id desc";
   
    PageList page =  messageRecordDao.findByPage4Report(hql, new Object[]{}, pagenum, 15);
   
    if(page!=null&&page.getDataList().size()>0) {
      root.put("page", page);
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.