Пример #1
0
  public AbFmcar findByMobileAndUserId(String userId, String mobile) {
    StringBuffer sql = new StringBuffer("select b.* from ( ");
    sql.append(" select * from ab_fmcar_user where user_id = ? ");
    sql.append(" ) a");
    sql.append(" right join ( select * from ab_fmcar where mobile = ? ) b");
    sql.append(" on b.id=a.car_id");

    AbFmcar car = dao.findFirst(sql.toString(), userId, mobile);
    return car;
  }
Пример #2
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;
 }
Пример #3
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;
  }
Пример #4
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;
  }
Пример #5
0
  @Before(AccessAbInterceptor.class)
  public void saverz() {
    boolean flag = false;
    SysUser user = this.getModel(SysUser.class, "tb");
    SysUser loginUser = this.getSessionAttr("abuser");
    String name = this.getPara("abFmcar_driver");
    user.set("mc", name);
    user.set("tjsj", DateUtil.getCurrentDate());
    user.set("sfrzzt", "1");
    user.set(SysUser.ID, loginUser.get(SysUser.ID));
    user.update();

    // 保存车辆信息
    AbFmcar car = AbFmcar.dao.findByMobile(getPara("abFmcar_mobile"));
    boolean update = false;
    if (car == null) {
      car = new AbFmcar();
      car.set("id", StringUtil.getRandString32());
      update = false;
    } else update = true;
    car.set("driver", name);
    car.set("car_no", getPara("abFmcar_car_no"));
    car.set("mobile", getPara("abFmcar_mobile"));

    car.set("length", getPara("abFmcar_length"));
    car.set("type", getPara("abFmcar_type"));
    car.set("vv", getPara("abFmcar_vv"));
    if (update) {
      car.update();
    } else car.save();

    // 保存常跑城市
    AbFmcarCity.dao.delByCarId(car.getStr("id"));
    String citynames = getPara("runcity");
    String[] citys = citynames.split(",");
    AbFmcarCity cc = new AbFmcarCity();
    for (String n : citys) {
      cc.set("city_name", n);
      cc.set("car_id", car.get("id"));
      cc.set("id", StringUtil.getRandString32());
      cc.save();
    }
    flag = true;
    renderJson(flag);
  }
Пример #6
0
 public AbFmcar findByMobile(String mobile) {
   StringBuffer sql = new StringBuffer(" select * from ab_fmcar where mobile = ? ");
   AbFmcar car = dao.findFirst(sql.toString(), mobile);
   return car;
 }