@Override public TableInteRule insertTableRule(TableInteRule tableRule) throws BusinessException { Assert.notNull(tableRule, "表数据整合规则不允许为空"); // 1. 生成整合规则的主键Id String ruleId = this.buildId(""); // 2.新插入整合规则对应的字段 for (ColumnInteRule rule : tableRule.getColumnRules()) { rule.setRuleId(ruleId); rule.setId(buildId("")); this.columnInteRuleDao.save(rule); insertAllChildRules(rule); } // 3.增加整合日志 tableRule.setRuleId(ruleId); this.insertDataInteLog( tableRule, ruleId, DataLogState.LOG_INIT, DataInteLog.PROCESS_TYPE_MANUAL); // 4.新插入表整合规则功能 this.save(tableRule); return tableRule; }
/** * 插入所有的子规则以及对应的参数数据 * * @param rule * @throws BusinessException */ private void insertAllChildRules(ColumnInteRule rule) throws BusinessException { // 一级规则级参数 for (SubScriptPara param : rule.getScriptParams()) { param.setId(buildId("")); param.setColumnInteId(rule.getId()); param.setRuleId(rule.getRuleId()); subScriptParaDao.save(param); } // 二级规则级参数 for (SubRuleScript chdRule : rule.getSubRuleScript()) { chdRule.setId(buildId("")); chdRule.setRuleId(rule.getRuleId()); chdRule.setColumnRuleId(rule.getId()); subRuleScriptDao.save(chdRule); for (SubScriptPara ruleParm : chdRule.getSubScriptParams()) { ruleParm.setId(buildId("")); ruleParm.setSubRuleScriptId(chdRule.getId()); ruleParm.setRuleId(rule.getRuleId()); subScriptParaDao.save(ruleParm); } } }