Пример #1
0
 /**
  * 明细规则配置
  *
  * @return
  * @throws Exception
  */
 public String updateDetailRule() throws Exception {
   RuleEditDto former = ruleComponent.queryRuleForCollectChangeInfo(rule);
   String ruleid = ruleComponent.updateDetailRule(rule);
   rule.setRule_id(ruleid);
   RuleEditDto newOne = ruleComponent.queryRuleForCollectChangeInfo(rule);
   saveSysChange(former, newOne);
   return JSON;
 }
Пример #2
0
  /**
   * 保存或修改条件规则
   *
   * @return
   * @throws Exception
   */
  public String updateRuleAndRuleEdit() throws Exception {
    String ruleInfo = request.getParameter("ruleEditDto");
    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
    RuleEditDto ruleEditDto = gson.fromJson(ruleInfo, RuleEditDto.class);
    // 规则对象
    RuleDefineDto rule = ruleEditDto.getRule();
    // 规则编辑对象
    List<TRuleEdit> ruleEdits = ruleEditDto.getRuleEdits();

    RuleEditDto former = ruleComponent.queryRuleForCollectChangeInfo(rule);
    rule.setRule_id(ruleComponent.updateRuleAndRuleEdit(rule, ruleEdits));
    RuleEditDto theNewOne = ruleComponent.queryRuleForCollectChangeInfo(rule);

    saveSysChange(former, theNewOne);

    return JSON_SUCCESS;
  }
Пример #3
0
  private void saveSysChange(RuleEditDto former, RuleEditDto theNewOne) throws Exception {
    if (former == null && theNewOne == null) {
      throw new ActionException("比较的两个对象都为空!");
    }
    if (former == null && theNewOne != null) {
      former = new RuleEditDto();
    } else if (theNewOne == null && former != null) {
      theNewOne = new RuleEditDto();
    }
    RuleDefineDto oldRuleObj = former.getRule();
    if (null != oldRuleObj) {
      oldRuleObj.setOptr_id(MemoryDict.getDictName(DictKey.OPTR, oldRuleObj.getOptr_id()));
    }
    RuleDefineDto newRuleObj = theNewOne.getRule();
    if (null != newRuleObj) {
      String optrId = newRuleObj.getOptr_id();
      newRuleObj.setOptr_id(MemoryDict.getDictName(DictKey.OPTR, optrId));
    }

    List<SSysChange> changes = new ArrayList<SSysChange>();
    String[] basicChangeFields =
        new String[] {
          "rule_id",
          "rule_name",
          "remark",
          "rule_type",
          "data_type",
          "cfg_type",
          "pre_billing_rule",
          "optr_id",
          "eff_date",
          "exp_date"
        };
    String basicChange = BeanHelper.beanchange(oldRuleObj, newRuleObj, basicChangeFields);
    // 两个肯定最多只有一个为空,因此下面的方法可行
    String key = theNewOne == null ? oldRuleObj.getRule_id() : theNewOne.getRule().getRule_id();
    String keyDesc =
        theNewOne == null ? oldRuleObj.getRule_name() : theNewOne.getRule().getRule_name();

    String optrId = getOptr().getOptr_id();

    if (!StringHelper.isEmpty(basicChange)) {
      // 两个肯定最多只有一个为空,因此下面的方法可行
      SSysChange change =
          new SSysChange(
              SysChangeType.RULE.toString(),
              ruleComponent.getDoneCOde(),
              key,
              keyDesc,
              "规则基本定义",
              basicChange,
              optrId,
              new Date());
      changes.add(change);
    }

    String detailChange = BeanHelper.beanchange(oldRuleObj, newRuleObj, "rule_str");
    if (!StringHelper.isEmpty(detailChange)) {
      // 两个肯定最多只有一个为空,因此下面的方法可行
      SSysChange change =
          new SSysChange(
              SysChangeType.RULE.toString(),
              ruleComponent.getDoneCOde(),
              key,
              keyDesc,
              "规则详细内容",
              detailChange,
              optrId,
              new Date());
      changes.add(change);
    }

    String countyChange = BeanHelper.beanchange(oldRuleObj, newRuleObj, "county_name");
    if (!StringHelper.isEmpty(countyChange)) {
      // 两个肯定最多只有一个为空,因此下面的方法可行
      SSysChange change =
          new SSysChange(
              SysChangeType.RULE.toString(),
              ruleComponent.getDoneCOde(),
              key,
              keyDesc,
              "规则适用分公司",
              countyChange,
              optrId,
              new Date());
      changes.add(change);
    }

    if (!changes.isEmpty()) {
      ruleComponent.getSSysChangeDao().save(changes.toArray(new SSysChange[changes.size()]));
    }
  }