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

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

上级 c8564bb0
......@@ -16,6 +16,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.sql.Timestamp;
......@@ -47,7 +48,8 @@ public class FetchParam {
", displayType='" + displayType + '\'' +
", dimDict='" + dimDict + '\'' +
", dimValues=" + dimValues +
", dimItems=" + JSONObject.toJSONString(dimItems )+
", dimItems=" + JSONObject.toJSONString(dimItems)+
", domains=" + JSONObject.toJSONString(getDomains())+
", dimValue='" + dimValue + '\'' +
", includeChild=" + includeChild +
", metricIds=" + metricIds +
......@@ -86,6 +88,21 @@ public class FetchParam {
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")
@JSONField(name = "startTime", format = "yyyy-MM-dd")
private Timestamp startTime;
......
......@@ -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> 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 {
String dsName = args[0];
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)
lookupResult.setTotal((int)page.getTotalElements());
page.getContent().forEach(item->{
......
......@@ -326,7 +326,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
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))
columns="*";
......@@ -337,7 +337,7 @@ public class ExecResultExService extends ExecResultServiceImpl {
dstDataSourceService.initDataSource(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();
total=pages.getTotal();
} catch (Exception ex) {
......
......@@ -147,8 +147,11 @@
select ${columns} from ${resultTableName} where ruleid = #{ruleid}
and RETVALUE=1 and DIMFIELD = #{dimfield}
<choose><when test="domainsfield != null and domainsfield != ''">
and DOMAINSFIELD = #{domainsfield}
<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}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册