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

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

上级 c8564bb0
...@@ -16,6 +16,7 @@ import lombok.NoArgsConstructor; ...@@ -16,6 +16,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.util.DigestUtils; import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -47,7 +48,8 @@ public class FetchParam { ...@@ -47,7 +48,8 @@ public class FetchParam {
", displayType='" + displayType + '\'' + ", displayType='" + displayType + '\'' +
", dimDict='" + dimDict + '\'' + ", dimDict='" + dimDict + '\'' +
", dimValues=" + dimValues + ", dimValues=" + dimValues +
", dimItems=" + JSONObject.toJSONString(dimItems )+ ", dimItems=" + JSONObject.toJSONString(dimItems)+
", domains=" + JSONObject.toJSONString(getDomains())+
", dimValue='" + dimValue + '\'' + ", dimValue='" + dimValue + '\'' +
", includeChild=" + includeChild + ", includeChild=" + includeChild +
", metricIds=" + metricIds + ", metricIds=" + metricIds +
...@@ -86,6 +88,21 @@ public class FetchParam { ...@@ -86,6 +88,21 @@ public class FetchParam {
private String domain; private String domain;
public List<String> getDomains() {
if(ObjectUtils.isEmpty(domains) && domain!=null) {
domains = new ArrayList<>();
domains.add(domain);
}
return domains;
}
public String getDomain() {
if(domain==null && !ObjectUtils.isEmpty(domains)) {
domain = domains.get(0);
}
return 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")
private Timestamp startTime; private Timestamp startTime;
......
...@@ -21,6 +21,6 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{ ...@@ -21,6 +21,6 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{
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> 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("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("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("domainsfield")String domainsfield, @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("domainsfields")List<String> domainsfields, @Param("from")Timestamp from, @Param("to")Timestamp to);
} }
\ No newline at end of file
...@@ -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.getDomain(), fetchParam.getStartTime(), fetchParam.getEndTime()); Page<ExecResult> page = execResultExService.lookupResult(fetchParam.getPage(), fetchParam.getSize(), dsName, tableName, "keyvaluefield", fetchParam.getMetricId(), fetchParam.getDimValue(), fetchParam.getDomains(), 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->{
......
...@@ -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, String domainsfield, Timestamp from, Timestamp to) { public Page<ExecResult> lookupResult(int current, int size, String dsName, String tableName, String columns,String ruleid, String dimfield, List<String> domainsfields, 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, domainsfield, 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, domainsfields, from, to);
result = pages.getRecords(); result = pages.getRecords();
total=pages.getTotal(); total=pages.getTotal();
} catch (Exception ex) { } catch (Exception ex) {
......
...@@ -147,8 +147,11 @@ ...@@ -147,8 +147,11 @@
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 != ''"> <choose><when test="domainsfields != null">
and DOMAINSFIELD = #{domainsfield} and DOMAINSFIELD in
<foreach item="id" index="index" collection="domainsfields" open="(" separator="," close=")">
#{id}
</foreach>
</when></choose> </when></choose>
and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to} and TIMEFIELD<![CDATA[ >= ]]>#{from} and TIMEFIELD<![CDATA[ <= ]]>#{to}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册