提交 ba2b6c04 编写于 作者: zhouweidong's avatar zhouweidong

规则执行结果动态存储

上级 a156fddd
......@@ -12,8 +12,9 @@ public interface DbEntityMapper extends BaseMapper<EntityObj>{
List<EntityObj> search(@Param("sql") String sql, @Param("ew") Wrapper<EntityObj> wrapper);
Integer searchCount(@Param("sql") String sql, @Param("ew") Wrapper<EntityObj> wrapper);
int replaceBatch(List<ExecResult> var1);
int clearBatch(List<ExecResult> var1);
int replaceBatch(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int replaceBatchByOracle(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int clearBatch(@Param("list")List<ExecResult> var1, @Param("resultTableName") String tableName);
}
\ No newline at end of file
......@@ -60,6 +60,8 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
public static final String Setting_ResultDataSource = "resultDataSource";
public static final String Setting_ResultTableName = "resultTableName";
public static final String Default_ResultDataSource = "default";
public static final String Default_ResultTableName = "IBZRULERESULT";
@Autowired
private DbEntityService dbEntityService;
......
......@@ -166,20 +166,31 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
}
}
@Override
public int saveResultBatch(List<ExecResult> var1) {
return 0;
}
@Override
public int clearResultBatch(List<ExecResult> var1) {
return 0;
}
@Autowired
private DbEntityMapper dbEntityMapper;
@Override
public int saveResultBatch(List<ExecResult> var1)
public int saveResultBatch(List<ExecResult> var1,String tableName)
{
return dbEntityMapper.replaceBatch(var1);
return dbEntityMapper.replaceBatch(var1,tableName);
}
@Override
public int clearResultBatch(List<ExecResult> var1)
public int saveResultBatchByOracle(List<ExecResult> var1,String tableName) {
return dbEntityMapper.replaceBatchByOracle(var1,tableName);
}
public int clearResultBatch(List<ExecResult> var1,String tableName)
{
return dbEntityMapper.clearBatch(var1);
return dbEntityMapper.clearBatch(var1,tableName);
}
@Autowired
......
......@@ -15,9 +15,9 @@
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<insert id="replaceBatch" parameterType="java.util.List" databaseId="mysql">
<insert id="replaceBatch" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator=";">
INSERT INTO IBZRULERESULT
INSERT INTO ${resultTableName}
(ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat )
VALUES
(#{item.id}, #{item.name}, now(), now(), #{item.ruleId}, #{item.ruleName}, #{item.retValue}, #{item.keyValueField}, #{item.dimField}, #{item.metricField},
......@@ -30,8 +30,8 @@
</insert>
<!--t1.BUSINESSCAT, t1.CREATEDATE, t1.DIMFIELD, t1.DOMAINSFIELD, t1.EXT1FIELD, t1.EXT2FIELD, t1.KEYVALUEFIELD, t1.METRICFIELD,
t1.RETVALUE, t1.RULEID, t1.RULENAME, t1.RU_EXECRESULTID, t1.RU_EXECRESULTNAME, t1.SYSTEMID, t1.TIMEFIELD, t1.UPDATEDATE-->
<insert id="replaceBatch" parameterType="java.util.List" databaseId="oracle" >
MERGE INTO IBZRULERESULT A USING (
<insert id="replaceBatchByOracle" parameterType="java.util.List">
MERGE INTO ${resultTableName} A USING (
<foreach collection='list' item='item' index='index' separator='UNION ALL'>
select #{item.id} as ru_execresultid, #{item.name} as ru_execresultname, sysdate as createdate, sysdate as updatedate, #{item.ruleId} as ruleid, #{item.ruleName} as rulename,#{item.retValue} as retvalue, #{item.keyValueField} as keyvaluefield, #{item.dimField} as dimfield,
#{item.metricField} as metricfield,#{item.domainsField} as domainsfield,#{item.timeField} as timefield, #{item.ext1Field} as ext1field,#{item.ext2Field} as ext2field,#{item.businessCat} as businesscat from dual
......@@ -45,7 +45,7 @@
</insert>
<delete id="clearBatch" parameterType="java.util.List" >
delete from IBZRULERESULT where (ru_execresultid) in
delete from ${resultTableName} where (ru_execresultid) in
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
(#{item.id})
</foreach>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册