Package com.sogou.qadev.service.cynthia.bean

Examples of com.sogou.qadev.service.cynthia.bean.QueryCondition


          //时间字段可能大于 或小于
          if (key.equals("createTime") || key.equals("lastModifyTime")) {
            List<String> timeList = requestPair.get(key);
            if (timeList.size() > 0) {
              if (timeList.size() == 1) {
                QueryCondition qc = new QueryCondition();
                qc.setQueryField(key);
                qc.setQueryMethod(">=");
                Timestamp t1 = Date.valueOf(timeList.get(0)).toTimestamp();
                qc.setQueryValue("'" + t1.toString() + "'");
                allQueryConditions.add(qc);
              }else if (timeList.size() == 2) {
                Timestamp t1 = Date.valueOf(timeList.get(0)).toTimestamp();
                Timestamp t2 = Date.valueOf(timeList.get(1)).toTimestamp();
                Timestamp tmp = null;
               
                if (t1.after(t2)) {
                  tmp = t1;
                  t1 = t2;
                  t2 = tmp;
                }
                QueryCondition qc = new QueryCondition();
                qc.setQueryField(key);
                qc.setQueryMethod(">=");
                qc.setQueryValue("'" + t1.toString() + "'");
                allQueryConditions.add(qc);
               
                qc = new QueryCondition();
                qc.setQueryField(key);
                qc.setQueryMethod("<=");
                qc.setQueryValue("'" + t2.toString() + "'");
                allQueryConditions.add(qc);
              }
            }
          }else {
            //其它字段都是等于
            String value = requestPair.get(key).get(0);
            if (CommonUtil.isPosNum(key)) {
              if (template == null) {
                continue;
              }
              key = FieldNameCache.getInstance().getFieldName(key ,templateId.getValue());
            }
            QueryCondition qc = new QueryCondition();
            qc.setQueryField(key);
            String queryValue = "";
            if (key.equals("title") || key.equals("description")) {
              //标题 描述以like查询
              qc.setQueryMethod("like");
              queryValue = "'%" + value + "%'";
            }else {
              if (value.indexOf(",") != -1) {
                //以逗号隔开的为in查询
                qc.setQueryMethod("in");
                StringBuffer valueBuffer = new StringBuffer();
                valueBuffer.append("(");
                String[] allValues = value.split(",");
                for(String v : allValues){
                  valueBuffer.append("'").append(v).append("',");
                }
                valueBuffer = valueBuffer.deleteCharAt(valueBuffer.length() -1);
                valueBuffer.append(")");
                queryValue = valueBuffer.toString();
              }else {
                qc.setQueryMethod("=");
                queryValue = "'" + value + "'";
              }
            }
            qc.setQueryValue(queryValue);
            allQueryConditions.add(qc);
          }
        }
      } catch (Exception e) {
        // TODO: handle exception
View Full Code Here


     }
    
     Data[] allDatas = null;
     if(dataIds != null && dataIds.length > 0){
       List<QueryCondition> allQueryConditions = new ArrayList<QueryCondition>();
       QueryCondition qc = new QueryCondition("id", "in", "(" + dataIds[0] +")");
       allQueryConditions.add(qc);
       allDatas = das.getDataFilter().queryDatas(filter.getXml(), 1, 10000, allQueryConditions)//取选中的数据
     }else if (beforeNum > 0) {
       allDatas = das.getDataFilter().queryDatas(filter.getXml(), 1, beforeNum,null)//取前beforeNum条
    }else {
View Full Code Here

    Set<String> queryFieldSet = new HashSet<String>();
    //查询所有id;
    queryFieldSet.add("id");
    List<QueryCondition> queryConList = new ArrayList<QueryCondition>();
    if (startTimestamp != null) {
      queryConList.add(new QueryCondition("createTime",">=","'"+startTimestamp.toString() + "'"));
    }
    if (endTimestamp != null) {
      queryConList.add(new QueryCondition("createTime","<=","'"+endTimestamp.toString() + "'"));
    }
    if (templateId != null) {
      queryConList.add(new QueryCondition("templateId","=","'"+templateId.getValue() + "'"));
    }
    queryConList.add(new QueryCondition("is_valid","=","1"));
   
    String idSql = DataFilterMemory.getQuerySql(tablesList, queryFieldSet, whereStr, null, isCurrent, templateId, queryConList);
    StringBuffer idBuffer = new StringBuffer();
    List<Map<String, String>> allIdList = DbPoolConnection.getInstance().getResultSetListBySql(idSql);
   
View Full Code Here

    Set<String> queryFieldSet = new HashSet<String>();
    queryFieldSet.add(FieldNameCache.getInstance().getFieldName(taskFieldIdStr, templateId.getValue()));
    List<QueryCondition> queryConList = new ArrayList<QueryCondition>();
    //指定单条任务
    if (taskIdStr != null && !taskIdStr.equals("")) {
      queryConList.add(new QueryCondition("id","=","'" + taskIdStr + "'"));
    }
   
    queryConList.add(new QueryCondition("templateId","=","'" + templateId.getValue() + "'"));
    queryConList.add(new QueryCondition("is_valid","=","1"));
   
    String idSql = DataFilterMemory.getQuerySql(tablesList, queryFieldSet, whereStr, orderFieldMap, isCurrent,templateId, queryConList);
    List<Map<String , String>> allIdMap = DbPoolConnection.getInstance().getResultSetListBySql(idSql);
    StringBuffer idBuffer = new StringBuffer();
   
View Full Code Here

      Set<String> queryFieldSet = new HashSet<String>();
      //查询所有id;
      queryFieldSet.add("id");
      List<QueryCondition> queryConList = new ArrayList<QueryCondition>();
      if (startTimestamp != null) {
        queryConList.add(new QueryCondition("createTime",">=","'"+startTimestamp.toString() + "'"));
      }
      if (endTimestamp != null) {
        queryConList.add(new QueryCondition("createTime","<=","'"+endTimestamp.toString() + "'"));
      }
      if (templateId != null) {
        queryConList.add(new QueryCondition("templateId","=","'"+templateId.getValue() + "'"));
      }
     
     
      if (statisticVal.indexOf(",") != -1) {
        StringBuffer queryValBuffer = new StringBuffer();
        String[] valArr = statisticVal.split(",");
        for (String val : valArr) {
          queryValBuffer.append(queryValBuffer.length() > 0 ? "," : "").append("'" + val + "'");
        }
        queryConList.add(new QueryCondition(fieldColName,"in"," (" + queryValBuffer.toString() + ")"));
      }else {
        queryConList.add(new QueryCondition(fieldColName,"=","'"+statisticVal + "'"));
      }
     
     
      String idSql = DataFilterMemory.getQuerySql(tablesList, queryFieldSet, whereStr, null, isCurrent, templateId, queryConList);
      List<Map<String, String>> allIdList = DbPoolConnection.getInstance().getResultSetListBySql(idSql);
     
      for (Map<String, String> map : allIdList) {
        allIdSet.add(map.get("id"));
      }
    }
   
    StringBuffer idBuffer = new StringBuffer();
    for (String id : allIdSet) {
      idBuffer.append(idBuffer.length() > 0 ? "," : "").append("'" + id + "'");
    }
   
    List<QueryCondition> allQueryList = new ArrayList<QueryCondition>();
    QueryCondition queryCondition = new QueryCondition("id","in"," (" + idBuffer.toString() + ") ");
    allQueryList.add(queryCondition);
    String sql = QueryUtil.getQuerySql(templateId,allQueryList);
    return sql;
  }
View Full Code Here

TOP

Related Classes of com.sogou.qadev.service.cynthia.bean.QueryCondition

Copyright © 2018 www.massapicom. 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.