示例#1
0
  /**
   * 根据不同状态,给用户不同的操作权限 权限的位数表示分别为:1删、2改、3查、4下载、5执行、6拷贝(另存为)、7审核,没有的功能设置为3 status: 目前能用的状态共5个,分别是: 2
   * 待审核 、3 已驳回、4 待执行、5 执行中、7 已完成
   */
  private String funcStatus(ExtractTask obj) {
    // 0无执行权限 1允许执行,没有的功能设置为3
    StringBuffer selectedColumns = null;
    int value = obj.getTaskStatus();

    switch (value) {
        //			case 2 :
        //				selectedColumns = new StringBuffer("111011"); break;
        //			case 4 :
        //				selectedColumns = new StringBuffer("011001"); break;
        //			case 5 :
        //				selectedColumns = new StringBuffer("001001"); break;
        //			case 6 : // 6 执行失败
        //				selectedColumns = new StringBuffer("101001"); break;
        //			case 7 : // 7 执行完成
        //				selectedColumns = new StringBuffer("101001"); break;
        //			case 8 : // 8 有数据
        //				selectedColumns = new StringBuffer("101101"); break;
        //			case 9 : // 9无数据
        //				selectedColumns = new StringBuffer("101001"); break;
        //			default :
        //				selectedColumns = new StringBuffer("333333");
      case 2: // 待审核
        selectedColumns = new StringBuffer("111011");
        break;
      case 3: // 已驳回
        selectedColumns = new StringBuffer("111011");
        break;
      case 4: // 待执行
        selectedColumns = new StringBuffer("111011");
        break;
      case 5: // 执行中
        selectedColumns = new StringBuffer("111011");
        break;
      case 6: // 6 执行失败
        selectedColumns = new StringBuffer("101001");
        break;
      case 7: // 已完成
        selectedColumns = new StringBuffer("111011");
        break;
      case 8: // 8 有数据
        selectedColumns = new StringBuffer("101101");
        break;
      case 9: // 9无数据
        selectedColumns = new StringBuffer("101001");
        break;
      default:
        selectedColumns = new StringBuffer("333333");
    }
    return selectedColumns.toString();
  }
示例#2
0
  public String saveAndSubmit() {
    HttpServletRequest request = Struts2Utils.getRequest();
    HttpSession session = Struts2Utils.getSession();
    // 1.新建  act=new  2.修改 act=modify 3.复制 act = copy
    String act = this.getQueryParameter(request, "act");
    // 获取groupId值
    String taskId = this.getQueryParameter(request, "taskId");
    String taskName = this.getQueryParameter(request, "extractName");
    String taskDesc = this.getQueryParameter(request, "extractDesc");
    String auditor = this.getQueryParameter(request, "auditor");
    String provinceId = this.getQueryParameter(request, "indArea");

    ExtractTask extractTask = null;
    if (StringUtils.isBlank(taskId)) {
      // 1.新建  act=new  //容器中没有就新建
      if (StringUtils.isBlank(act)) {
        //			if("new".equalsIgnoreCase(act)){
        extractTask = new ExtractTask();
        // 设置分群id
        taskId = UIDGenerator.generate().toString().substring(0, 19) + System.currentTimeMillis();
        extractTask.setId(taskId);
        // 设置客户分群状态    目前能用的状态共7个,分别是: 2 未提交  、4 等待执行、5 执行中、6 执行失败、7 执行完成、8 有数据、9无数据
        int taskStatus = 1; // 2 未提交
        extractTask.setTaskStatus(taskStatus);
        extractTask.setTaskName(taskName);
        extractTask.setTaskDesc(taskDesc);

        // 群创建人
        String createUser = securityManager.loginUser().getLoginName();
        //				securityManager.getAllRole().get(1).
        extractTask.setCreateUser(createUser);

      } else {
        throw new RuntimeException("无效操作!");
      }
    }

    System.out.println("taskId=" + taskId);
    // 分群条件关系   规则表达式
    String ruleRelationExp = this.getQueryParameter(request, "ruleRelationExp");
    String[] props = request.getParameterValues("attr");

    if (StringUtils.isBlank(ruleRelationExp)) {
      extractTask.setRuleRelationExp("");
    } else {
      extractTask.setRuleRelationExp(ruleRelationExp);
      ruleRelationExp = ruleRelationExp.replace("and", "+");
    }

    // 提取电话号码上限
    String upperLimit = this.getQueryParameter(request, "upperLimit");
    // 分群规则数据
    String[] ruleArrray = request.getParameterValues("rule");

    // 0415-2102

    if (HTMLFilter.isIntNumber(upperLimit)) {
      extractTask.setUpperLimit(Long.parseLong(upperLimit));
    } else {
      extractTask.setUpperLimit(0);
    }

    this.saveTaskRuleToContext(extractTask, ruleRelationExp, upperLimit, ruleArrray);

    /** 是否提取客户属性值 (1:表示是,0:表示否)默认为0 IS_EXTRACT_PROPS */
    //		if(StringUtils.isBlank(props.toString())){
    if (null == props) {
      /** 是否提取客户属性值 (1:表示是,0:表示否)默认为0 IS_EXTRACT_PROPS */
      extractTask.setIsExtractProps("0"); // 0:表示提取客户属性值
      extractTask.setExtractProps(null); // 将客户群提取的用户属性置空
    } else {
      extractTask.setIsExtractProps("1"); // 0:表示提取客户属性值
      this.saveTaskAttrToContext(extractTask, props);
    }

    if (StringUtils.isBlank(act) || "copy".equalsIgnoreCase(act)) {
      // 任务创建日期
      String createDate = DateUtil.getDateTime(Constants.DATE_PATTERN, new Date());
      extractTask.setCreateDate(createDate);
      // 修改日期
      String modifyDate = "-";
      extractTask.setModifyDate(modifyDate);
      extractTask.setTaskType("A");
      extractTask.setAuditUser(auditor);
      extractTask.setTaskSql(
          extractTaskService.getExtractTaskQueryString(extractTask).replace("'", "\""));
      extractTask.setProvinceId(provinceId);
      // 调用service.save方法,持久化数据
      try {
        extractTaskService.saveExtractTask(extractTask);
        session.setAttribute("status", "1");
      } catch (Exception e) {
        session.setAttribute("status", "0");
      }
    }
    // 跳转到客户分群列表界面
    return CrudActionSupport.RELOAD;
  }
示例#3
0
  private ExtractTask saveTaskRuleToContext(
      ExtractTask extractTask, String ruleRelationExp, String upperLimit, String[] ruleArrray) {

    // 根据groupId 获取客户分群对象容器类
    //	CustomGroup customGroup = context.get(groupId);
    if (StringUtils.isBlank(ruleRelationExp)) {
      extractTask.setRuleRelationExp("");
    } else {
      extractTask.setRuleRelationExp(ruleRelationExp);
    }

    if (HTMLFilter.isIntNumber(upperLimit)) {
      extractTask.setUpperLimit(Long.parseLong(upperLimit));
    } else {
      extractTask.setUpperLimit(0);
    }

    List<String[]> ruleList = new ArrayList<String[]>();
    for (int i = 0; i < ruleArrray.length; i++) {
      // [ruleCoce:120]
      // [ruleName:PROVINCE_USERINFO_D-LOGON_SOFTCLIENT_CNT]
      // [operator:<] [leftOperand:sdf][rightOperand: ]

      String ruleStr = ruleArrray[i];
      int beginIndex = ruleStr.indexOf("{");
      int endIndex = ruleStr.lastIndexOf("}");
      String[] jsonRuleArray = ruleStr.substring(beginIndex + 1, endIndex).split("',");
      ruleList.add(jsonRuleArray);
    }

    List<TaskRule> taskRuleList = new ArrayList<TaskRule>();
    // 客户群规则
    TaskRule taskRule = null;
    for (int i = 0; i < ruleList.size(); i++) {
      String[] rules = ruleList.get(i);
      taskRule = new TaskRule();
      taskRule.setId(UIDGenerator.generate().toString());
      taskRule.setExtractTask(extractTask);
      for (int j = 0; j < rules.length; j++) {
        String[] rule = rules[j].split(":'"); // ruleCode:'3265
        String key = rule[0].replaceAll("\"", "").replaceAll("'", "");
        String value = checkValue(rule);
        if ("ruleCode".equals(key)) {
          taskRule.setRuleCode(value);
        }
        if ("ruleName".equals(key)) {
          taskRule.setRuleName(value);
        }
        if ("operator".equals(key)) {
          taskRule.setOperator(value);
        }
        if ("leftOperand".equals(key)) {
          taskRule.setLeftOperand(value);
        }
        if ("rightOperand".equals(key)) {
          taskRule.setRightOperand(value);
        }
        if ("startDate".equals(key)) {
          taskRule.setStartDate(value.replaceAll("-", ""));
        }
        if ("endDate".equals(key)) {
          taskRule.setEndDate(value.replaceAll("-", ""));
        }
        if ("tableId".equals(key)) {
          taskRule.setTableId(value);
        }
        if ("clusterOpt".equals(key)) {
          taskRule.setClusterOperator(value);
        }
        if ("customTable".equals(key)) { // 存的是table的id
          CustomTable obj = new CustomTable();
          obj.setId(value);
          taskRule.setCustomTable(obj);
        }
        if ("ruleDesc".equals(key)) {
          taskRule.setRuleDesc(value);
        }
        //			logger.info("key = " + key + " value = " + value);
        System.out.println("key = " + key + " value = " + value);

        System.out.println("raskRule = " + taskRule);
      }
      CustomTable customTable =
          extractTableService.queryCustomTableAndField(
              taskRule.getCustomTable().getId(), taskRule.getRuleName());

      taskRule.setCustomTable(customTable);

      taskRuleList.add(taskRule);
    }

    extractTask.setTaskRules(taskRuleList);
    System.out.println("over json");
    // context.put(customGroup);将对象放入容器中
    return extractTask;
  }