コード例 #1
0
 public String getSql(DetailCompRule rule) {
   StringBuffer sql = new StringBuffer();
   sql.append(
       "insert into nms_comp_detail_rule(RULEID,RELATION,ISCONTAIN,EXPRESSION,BEGINBLOCK,ENDBLOCK,ISEXTRACONTAIN,EXTRABLOCK)values(");
   sql.append(rule.getRuleId());
   sql.append(",");
   sql.append(rule.getRelation());
   sql.append(",");
   sql.append(rule.getIsContain());
   sql.append(",'");
   sql.append(rule.getExpression());
   sql.append("','");
   sql.append(rule.getBeginBlock());
   sql.append("','");
   sql.append(rule.getEndBlock());
   sql.append("',");
   sql.append(rule.getIsExtraContain());
   sql.append(",'");
   sql.append(rule.getExtraBlock());
   sql.append("')");
   return sql.toString();
 }
コード例 #2
0
  public void saveDetailRule(int standard, int id) {

    int key = 0;
    if (id == -1) {
      key = GeneratorKey.getInstance().getKey();
    } else {
      key = id;
    }

    DetailCompRuleDao detailDao = new DetailCompRuleDao();
    String express = "";

    int relation = -1; // -1示意为无
    int isContain = 0;

    String beginBlock = "";
    String endBlock = "";
    String extraBlock = "";
    int isExtraContain = -1; // 表示无
    DetailCompRule vo = new DetailCompRule();
    if (standard == 0) {

      express = getParaValue("content");
      isContain = getParaIntValue("simple_config");
    } else if (standard == 1) {
      express = getParaValue("advance_value");
      isContain = getParaIntValue("advance_config");

    } else if (standard == 2) {
      express = getParaValue("custom_value");
      isContain = getParaIntValue("custom_config");
    }

    if (standard == 2) {
      beginBlock = getParaValue("begin");
      endBlock = getParaValue("end");
      isExtraContain = getParaIntValue("isExtraContain");
      extraBlock = getParaValue("extra");
      vo.setBeginBlock(beginBlock);
      vo.setEndBlock(endBlock);

      vo.setExtraBlock(extraBlock);
    }
    vo.setRuleId(key);
    vo.setRelation(relation);
    vo.setIsContain(isContain);
    vo.setExpression(express);
    vo.setIsExtraContain(isExtraContain);
    detailDao.save(vo);

    if (standard == 1 || standard == 2) {
      DBManager db = new DBManager();
      String[] selVals = null;
      String[] textVals = null;
      String selVal = getParaValue("selVal");
      String textVal = getParaValue("textVal");
      if (selVal != null && textVal != null) {
        selVals = new String[selVal.split(",").length];
        textVals = new String[textVal.split(",").length];
        selVals = selVal.split(",");
        textVals = textVal.split(",");
        if (selVals.length == textVals.length * 2) {

          try {
            for (int i = 0; i < selVals.length; i++) {

              if (i % 2 == 1) {
                vo.setIsContain(Integer.parseInt(selVals[i]));
                vo.setExpression(textVals[i / 2]);
                String sql = getSql(vo);
                db.addBatch(sql);
              } else {
                vo = new DetailCompRule();
                if (standard == 2) {
                  vo.setBeginBlock(beginBlock);
                  vo.setEndBlock(endBlock);
                  vo.setIsExtraContain(isExtraContain);
                  vo.setExtraBlock(extraBlock);
                }
                vo.setRuleId(key);
                vo.setRelation(Integer.parseInt(selVals[i]));
              }
            }
          } catch (Exception e) {
            e.printStackTrace();
          } finally {
            db.executeBatch();
          }
        }
      }
    }
  }