Exemplo n.º 1
0
 // 查询熟车,放然要把黑名单除外
 public List<AbFmcar> findByUserId(String userId, String groupId) {
   StringBuffer sql =
       new StringBuffer(
           "select * from ab_fmcar where id in ( select car_id from ab_fmcar_user where user_id = ? %s) and mobile not in (select mobile from sys_mobile_blank where userid = ?)");
   String abGroup = "";
   if (groupId == null || groupId.equals("")) {
     abGroup = "";
   } else {
     abGroup = " and group_id='" + groupId + "' ";
   }
   List<AbFmcar> list = dao.find(String.format(sql.toString(), abGroup), userId, userId);
   return list;
 }
Exemplo n.º 2
0
  public List<AbFmcar> findByFields(
      Map<String, String> fields, String[] citys, String userId, String groupid) {
    ArrayList<Object> params = new ArrayList<Object>();
    StringBuffer sql = new StringBuffer("");

    sql.append("select * from ab_fmcar where 1=1 ");

    if (fields.size() != 0) {
      Set<String> set = fields.keySet();
      for (String key : set) {
        sql.append("and " + key + " = ? ");
      }
    }

    params.addAll(fields.values());

    sql.append(" and id in ( ");

    if (citys != null && citys.length > 0) {
      sql.append("  select a.car_id from ( ");
      sql.append(" 	select car_id from ab_fmcar_user  where user_id = ? ");
      if (groupid != null) sql.append(" and group_id= ?");
      sql.append("  ) a inner join ( ");
      sql.append(" 	select car_id from ab_fmcar_city where  city_name in ( ");
      for (int i = 0; i < (citys.length - 1); i++) {
        sql.append("?,");
      }
      sql.append("?)");
      sql.append("  ) b on a.car_id = b.car_id ");

      params.add(userId);
      if (groupid != null) params.add(groupid);
      params.addAll(Arrays.asList(citys));
    } else {
      sql.append(" select car_id from ab_fmcar_user  where user_id = ? ");

      params.add(userId);
      if (groupid != null) {
        sql.append(" and group_id= ?");
        params.add(groupid);
      }
    }

    sql.append(" )");

    List<AbFmcar> list = dao.find(sql.toString(), params.toArray());

    return list;
  }
Exemplo n.º 3
0
  public List<AbFmcar> findByFields(Map<String, String> fields) {
    StringBuffer sql = new StringBuffer("select * from ab_fmcar where 1=1 ");

    if (fields.size() != 0) {
      Set<String> set = fields.keySet();
      for (String key : set) {
        sql.append("and " + key + " = ? ");
      }
    }

    Object[] params = fields.values().toArray();

    List<AbFmcar> list = dao.find(sql.toString(), params);

    return list;
  }