提交 e4de5626 编写于 作者: sq3536's avatar sq3536

增加domains数据集合过滤报表查询,仅支持sql模式

上级 2c5484a2
...@@ -80,6 +80,9 @@ public class FetchParam { ...@@ -80,6 +80,9 @@ public class FetchParam {
private List<String> metricIds; private List<String> metricIds;
private String metricId; private String metricId;
private List<String> domains;
private String domain;
@JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "startTime", format = "yyyy-MM-dd") @JSONField(name = "startTime", format = "yyyy-MM-dd")
......
...@@ -18,9 +18,9 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{ ...@@ -18,9 +18,9 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{
int replaceBatchByPG(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName); int replaceBatchByPG(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int clearBatch(@Param("list")List<ExecResult> var1, @Param("resultTableName") String tableName); int clearBatch(@Param("list")List<ExecResult> var1, @Param("resultTableName") String tableName);
List<ExecResult> sumResult(@Param("resultTableName") String tableName, @Param("ruleids")List<String> ruleids, @Param("dimfields")List<String> dimfields, @Param("from")Timestamp from,@Param("to")Timestamp to); List<ExecResult> sumResult(@Param("resultTableName") String tableName, @Param("ruleids")List<String> ruleids, @Param("dimfields")List<String> dimfields, @Param("domainsfields")List<String> domainsfields, @Param("from")Timestamp from,@Param("to")Timestamp to);
List<ExecResult> avgResult(@Param("resultTableName") String tableName, @Param("ruleids")List<String> ruleids, @Param("dimfields")List<String> dimfields, @Param("from")Timestamp from,@Param("to")Timestamp to); List<ExecResult> avgResult(@Param("resultTableName") String tableName, @Param("ruleids")List<String> ruleids, @Param("dimfields")List<String> dimfields, @Param("domainsfields")List<String> domainsfields, @Param("from")Timestamp from,@Param("to")Timestamp to);
Page<ExecResult> lookupResult(IPage page, @Param("resultTableName") String tableName, @Param("columns")String columns,@Param("ruleid")String ruleid, @Param("dimfield")String dimfield, @Param("from")Timestamp from, @Param("to")Timestamp to); Page<ExecResult> lookupResult(IPage page, @Param("resultTableName") String tableName, @Param("columns")String columns,@Param("ruleid")String ruleid, @Param("dimfield")String dimfield, @Param("domainsfield")String domainsfield, @Param("from")Timestamp from, @Param("to")Timestamp to);
} }
\ No newline at end of file
...@@ -315,7 +315,7 @@ public class BuildResultService { ...@@ -315,7 +315,7 @@ public class BuildResultService {
} }
if(tmpSet.size()>0) if(tmpSet.size()>0)
{ {
List<ExecResult> list = execResultExService.sumResult(dsName,tableName,new ArrayList<>(tmpSet),fetchParam.getDimValues(),startTime,endTime); List<ExecResult> list = execResultExService.sumResult(dsName,tableName,new ArrayList<>(tmpSet),fetchParam.getDimValues(),fetchParam.getDomains(),startTime,endTime);
list.forEach(item->{ list.forEach(item->{
ret.add(new BuildResult().setSqlResult(item)); ret.add(new BuildResult().setSqlResult(item));
}); });
...@@ -372,7 +372,7 @@ public class BuildResultService { ...@@ -372,7 +372,7 @@ public class BuildResultService {
} }
if(tmpSet.size()>0) if(tmpSet.size()>0)
{ {
List<ExecResult> list = execResultExService.avgResult(dsName,tableName,new ArrayList<>(tmpSet),fetchParam.getDimValues(),startTime,endTime); List<ExecResult> list = execResultExService.avgResult(dsName,tableName,new ArrayList<>(tmpSet),fetchParam.getDimValues(),fetchParam.getDomains(),startTime,endTime);
list.forEach(item->{ list.forEach(item->{
ret.add(new BuildResult().setSqlResult(item)); ret.add(new BuildResult().setSqlResult(item));
}); });
...@@ -428,7 +428,7 @@ public class BuildResultService { ...@@ -428,7 +428,7 @@ public class BuildResultService {
String dsName = args[0]; String dsName = args[0];
String tableName = args[1]; String tableName = args[1];
Page<ExecResult> page = execResultExService.lookupResult(fetchParam.getPage(), fetchParam.getSize(), dsName, tableName, "keyvaluefield", fetchParam.getMetricId(), fetchParam.getDimValue(), fetchParam.getStartTime(), fetchParam.getEndTime()); Page<ExecResult> page = execResultExService.lookupResult(fetchParam.getPage(), fetchParam.getSize(), dsName, tableName, "keyvaluefield", fetchParam.getMetricId(), fetchParam.getDimValue(), fetchParam.getDomain(), fetchParam.getStartTime(), fetchParam.getEndTime());
if(lookupResult.getTotal()==0||lookupResult.getTotal()==null) if(lookupResult.getTotal()==0||lookupResult.getTotal()==null)
lookupResult.setTotal((int)page.getTotalElements()); lookupResult.setTotal((int)page.getTotalElements());
page.getContent().forEach(item->{ page.getContent().forEach(item->{
......
...@@ -284,7 +284,7 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -284,7 +284,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
} }
public List<ExecResult> sumResult(String dsName ,String tableName, List<String> ruleids, List<String> dimfields, Timestamp from, Timestamp to) public List<ExecResult> sumResult(String dsName ,String tableName, List<String> ruleids, List<String> dimfields, List<String> domainsfields, Timestamp from, Timestamp to)
{ {
List<ExecResult> result = null; List<ExecResult> result = null;
try { try {
...@@ -292,7 +292,7 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -292,7 +292,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
dstDataSourceService.initDataSource(dsName); dstDataSourceService.initDataSource(dsName);
DynamicDataSourceContextHolder.push(dsName); DynamicDataSourceContextHolder.push(dsName);
} }
result = execResultExMapper.sumResult(tableName,ruleids,dimfields,from,to); result = execResultExMapper.sumResult(tableName,ruleids,dimfields,domainsfields,from,to);
} catch (Exception ex) { } catch (Exception ex) {
result = new ArrayList<>(); result = new ArrayList<>();
log.error("存储规则结果发生异常,详细错误信息:" + ex.getMessage()); log.error("存储规则结果发生异常,详细错误信息:" + ex.getMessage());
...@@ -305,7 +305,7 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -305,7 +305,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
return result; return result;
} }
public List<ExecResult> avgResult(String dsName ,String tableName, List<String> ruleids, List<String> dimfields, Timestamp from, Timestamp to) public List<ExecResult> avgResult(String dsName ,String tableName, List<String> ruleids, List<String> dimfields, List<String> domainsfields, Timestamp from, Timestamp to)
{ {
List<ExecResult> result = null; List<ExecResult> result = null;
try { try {
...@@ -313,7 +313,7 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -313,7 +313,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
dstDataSourceService.initDataSource(dsName); dstDataSourceService.initDataSource(dsName);
DynamicDataSourceContextHolder.push(dsName); DynamicDataSourceContextHolder.push(dsName);
} }
result = execResultExMapper.avgResult(tableName,ruleids,dimfields,from,to); result = execResultExMapper.avgResult(tableName,ruleids,dimfields,domainsfields,from,to);
} catch (Exception ex) { } catch (Exception ex) {
result = new ArrayList<>(); result = new ArrayList<>();
log.error("存储规则结果发生异常,详细错误信息:" + ex.getMessage()); log.error("存储规则结果发生异常,详细错误信息:" + ex.getMessage());
...@@ -326,7 +326,7 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -326,7 +326,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
return result; return result;
} }
public Page<ExecResult> lookupResult(int current, int size, String dsName, String tableName, String columns,String ruleid, String dimfield, Timestamp from, Timestamp to) { public Page<ExecResult> lookupResult(int current, int size, String dsName, String tableName, String columns,String ruleid, String dimfield, String domainsfield, Timestamp from, Timestamp to) {
if(StringUtils.isEmpty(columns)) if(StringUtils.isEmpty(columns))
columns="*"; columns="*";
...@@ -337,7 +337,7 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -337,7 +337,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
dstDataSourceService.initDataSource(dsName); dstDataSourceService.initDataSource(dsName);
DynamicDataSourceContextHolder.push(dsName); DynamicDataSourceContextHolder.push(dsName);
} }
com.baomidou.mybatisplus.extension.plugins.pagination.Page<ExecResult> pages=execResultExMapper.lookupResult(new com.baomidou.mybatisplus.extension.plugins.pagination.Page(current+1,size), tableName, columns, ruleid, dimfield, from, to); com.baomidou.mybatisplus.extension.plugins.pagination.Page<ExecResult> pages=execResultExMapper.lookupResult(new com.baomidou.mybatisplus.extension.plugins.pagination.Page(current+1,size), tableName, columns, ruleid, dimfield, domainsfield, from, to);
result = pages.getRecords(); result = pages.getRecords();
total=pages.getTotal(); total=pages.getTotal();
} catch (Exception ex) { } catch (Exception ex) {
......
...@@ -111,6 +111,12 @@ ...@@ -111,6 +111,12 @@
<foreach item="id" index="index" collection="dimfields" open="(" separator="," close=")"> <foreach item="id" index="index" collection="dimfields" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
<choose><when test="domainsfields != null">
and DOMAINSFIELD in
<foreach item="id" index="index" collection="domainsfields" open="(" separator="," close=")">
#{id}
</foreach>
</when></choose>
and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to} and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to}
group by ruleid,dimfield group by ruleid,dimfield
...@@ -126,6 +132,12 @@ ...@@ -126,6 +132,12 @@
<foreach item="id" index="index" collection="dimfields" open="(" separator="," close=")"> <foreach item="id" index="index" collection="dimfields" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
<choose><when test="domainsfields != null">
and DOMAINSFIELD in
<foreach item="id" index="index" collection="domainsfields" open="(" separator="," close=")">
#{id}
</foreach>
</when></choose>
and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to} and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to}
group by ruleid,dimfield group by ruleid,dimfield
...@@ -135,6 +147,9 @@ ...@@ -135,6 +147,9 @@
select ${columns} from ${resultTableName} where ruleid = #{ruleid} select ${columns} from ${resultTableName} where ruleid = #{ruleid}
and RETVALUE=1 and DIMFIELD = #{dimfield} and RETVALUE=1 and DIMFIELD = #{dimfield}
<choose><when test="domainsfield != null and domainsfield != ''">
and DOMAINSFIELD = #{domainsfield}
</when></choose>
and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to} and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to}
</select> </select>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册