示例#1
0
 /**
  * 删除*2013.09.05*
  *
  * @param keyId 参数
  * @throws Exception 异常
  */
 @Business
 public void deleteReportFile(String keyId) throws Exception {
   ISqlExecutor exec = SqlExecutorFacotry.getSqlExecutor();
   exec.executeNonQuery(
       exec.getSqlParser()
           .getDeleteCommandString(
               "BMP_REPORTFILE",
               new SqlCondition(
                   "FILE_ID", keyId, SqlLogicType.And, SqlRelationType.In, SqlParamType.String)));
 }
示例#2
0
  /**
   * 更新
   *
   * @param id 参数
   * @param state 状态
   * @return 结果
   * @throws Exception 异常
   */
  public int updateState(int id, int state) throws Exception {
    ISqlExecutor executor = SqlExecutorFacotry.getSqlExecutor();
    DbCommand cmd = new DbCommand(executor.getSqlParser(), DbCommandType.UpdateCommand);
    cmd.setTableName(tableInfo.tableName);
    cmd.addField("TASK_STATE", state);
    cmd.setFilter(
        new SqlCondition(
            "TASK_ID",
            Integer.toString(id),
            SqlLogicType.And,
            SqlRelationType.Equal,
            SqlParamType.Numeric));

    return update(cmd.toString());
  }
示例#3
0
  /**
   * 获取其他类型的对象的性能数据
   *
   * @param objXml 固定界面的对象的XML
   * @param type 对象类型
   * @param objID 对象ID
   * @return 性能数据XML
   * @throws Exception 异常
   */
  public String getElseObjCollValue(String objXml, String type, int objID) throws Exception {
    // 定义一个Document作为返回结果
    Document result_doc =
        DocumentHelper.parseText(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DataSource></DataSource>");

    // 解析objXml,获取从哪些表获取哪些数据等信息
    Document doc = DocumentHelper.parseText(objXml);
    List list = doc.selectNodes("ElseObject/" + type + "/DataTable");
    if (list != null) {
      Iterator it = list.iterator();
      while (it.hasNext()) {
        // 解析要查询的表及数据条数
        Element tableEle = (Element) it.next();
        String table = tableEle.attribute("table").getValue();
        String collValueNum = tableEle.attribute("collValueNum").getValue();

        // 在结果Document的根节点下添加表节点
        Element ele = result_doc.getRootElement().addElement("DATA_TABLE");
        ele.addAttribute("TABLE_NAME", table);

        // DVB_C类型的对象属性与其他类型的查询方式不同
        // 获取最近的collValueNum个采集时间
        String cmd = "";
        if ("DVB_C".equals(type)) {
          cmd =
              sqlExecutor
                  .getSqlParser()
                  .getSelectCommandString(
                      table,
                      Integer.parseInt(collValueNum),
                      false,
                      "COLL_TIME",
                      null,
                      "ORDER BY COLL_TIME DESC",
                      new SqlCondition(
                          "FREQ_ID",
                          "SELECT FREQ_ID FROM NMP_OBJDVBCTS WHERE OBJ_ID=" + objID + "",
                          SqlLogicType.And,
                          SqlRelationType.In,
                          SqlParamType.UnKnow,
                          true));
        } else {
          cmd =
              sqlExecutor
                  .getSqlParser()
                  .getSelectCommandString(
                      table,
                      Integer.parseInt(collValueNum),
                      false,
                      "COLL_TIME",
                      null,
                      "ORDER BY COLL_TIME DESC",
                      new SqlCondition(
                          "OBJ_ID",
                          String.valueOf(objID),
                          SqlLogicType.And,
                          SqlRelationType.Equal,
                          SqlParamType.Numeric));
        }

        // 将采集时间存入List
        final List<String> timeList = new ArrayList<String>();
        DefaultDal.read(
            cmd,
            new IReadHandle() {
              @Override
              public void handle(ResultSet timeRS) throws Exception {
                while (timeRS.next()) {
                  timeList.add(timeRS.getString("COLL_TIME"));
                }
              }
            });

        // 针对每个采集时间,从指定的表中获取数据
        if (timeList != null && timeList.size() > 0) {
          for (int k = 0; k < timeList.size(); k++) {
            // 如果是第一条,添加最大时间
            if (k == 0) {
              ele.addAttribute("max_time", timeList.get(k));
            }

            Document coll = null;
            if ("DVB_C".equals(type)) {
              coll =
                  sqlExecutor.fill(
                      "SELECT * FROM "
                          + table
                          + " WHERE FREQ_ID IN (SELECT FREQ_ID FROM NMP_OBJDVBCTS WHERE OBJ_ID="
                          + String.valueOf(objID)
                          + ") AND COLL_TIME='"
                          + timeList.get(k)
                          + "'",
                      "DataTable",
                      table);
            } else {
              coll =
                  sqlExecutor.fill(
                      "SELECT * FROM "
                          + table
                          + " WHERE OBJ_ID="
                          + String.valueOf(objID)
                          + " AND COLL_TIME='"
                          + timeList.get(k)
                          + "'",
                      "DataTable",
                      table);
            }

            // 组装结果
            ele.appendContent(coll.getRootElement());
          }
        }
      }
    }

    return result_doc.asXML();
  }