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

调整报表

上级 d5044ff5
package cn.ibizlab.core.extensions.dto; package cn.ibizlab.core.extensions.dto;
import cn.ibizlab.core.analysis.domain.DAMetric; import cn.ibizlab.core.analysis.domain.DAMetric;
import cn.ibizlab.util.dict.Catalog;
import cn.ibizlab.util.dict.CodeItem; import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.dict.Option;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
...@@ -12,6 +14,7 @@ import lombok.Getter; ...@@ -12,6 +14,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor; 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.StringUtils; import org.springframework.util.StringUtils;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -27,6 +30,31 @@ import java.util.*; ...@@ -27,6 +30,31 @@ import java.util.*;
@Accessors(chain = true) @Accessors(chain = true)
public class FetchParam { public class FetchParam {
@JsonIgnore
@JSONField(serialize = false)
public String getId() {
String str = "FetchParam{" +
"reportId='" + reportId + '\'' +
", chartId='" + chartId + '\'' +
", buildId='" + buildId + '\'' +
", displayType='" + displayType + '\'' +
", dimDict='" + dimDict + '\'' +
", dimValues=" + dimValues +
", dimValue='" + dimValue + '\'' +
", includeChild=" + includeChild +
", metricIds=" + metricIds +
", metricId='" + metricId + '\'' +
", startTime=" + startTime +
", endTime=" + endTime +
", page=" + page +
", size=" + size +
", total=" + total +
", group='" + group + '\'' +
'}';
return DigestUtils.md5DigestAsHex(str.getBytes());
}
private String reportId; private String reportId;
private String chartId; private String chartId;
private String buildId; private String buildId;
...@@ -36,7 +64,7 @@ public class FetchParam { ...@@ -36,7 +64,7 @@ public class FetchParam {
private String displayType = "default"; private String displayType = "default";
private String dimDict = "DST_cl_dst_region"; private String dimDict;
private List<String> dimValues; private List<String> dimValues;
private String dimValue; private String dimValue;
private boolean includeChild = true; private boolean includeChild = true;
...@@ -73,7 +101,7 @@ public class FetchParam { ...@@ -73,7 +101,7 @@ public class FetchParam {
if(metricIds == null) if(metricIds == null)
{ {
metricIds = new ArrayList<>(); metricIds = new ArrayList<>();
if(StringUtils.isEmpty(metricId)) if(!StringUtils.isEmpty(metricId))
metricIds.add(metricId); metricIds.add(metricId);
} }
return metricIds; return metricIds;
...@@ -81,16 +109,20 @@ public class FetchParam { ...@@ -81,16 +109,20 @@ public class FetchParam {
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
private CodeItem dimItem; private Catalog dict;
@JsonIgnore
@JSONField(serialize = false)
private Option dimItem;
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public CodeItem getDimItem() public Option getDimItem()
{ {
return dimItem; return dimItem;
} }
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public FetchParam setDimItem(CodeItem dimItem) public FetchParam setDimItem(Option dimItem)
{ {
this.dimItem = dimItem; this.dimItem = dimItem;
return this; return this;
......
package cn.ibizlab.core.extensions.dto; package cn.ibizlab.core.extensions.dto;
import cn.ibizlab.core.analysis.domain.DAMetric; import cn.ibizlab.core.analysis.domain.DAMetric;
import cn.ibizlab.util.dict.Catalog;
import cn.ibizlab.util.dict.CodeItem; import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
...@@ -107,6 +108,17 @@ public class FetchResult { ...@@ -107,6 +108,17 @@ public class FetchResult {
@JSONField(serialize = false) @JSONField(serialize = false)
private String group; private String group;
private Catalog dict;
private String selectValue;
@JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "startTime", format = "yyyy-MM-dd")
private Timestamp startTime;
@JsonFormat(pattern = "yyyy-MM-dd", locale = "zh", timezone = "GMT+8")
@JSONField(name = "endTime", format = "yyyy-MM-dd")
private Timestamp endTime;
public static FetchResult from(FetchParam fetchParam) public static FetchResult from(FetchParam fetchParam)
{ {
FetchResult fetchResult=new FetchResult(); FetchResult fetchResult=new FetchResult();
...@@ -117,6 +129,7 @@ public class FetchResult { ...@@ -117,6 +129,7 @@ public class FetchResult {
fetchResult.setVmConfigs(fetchParam.getVmConfigs()); fetchResult.setVmConfigs(fetchParam.getVmConfigs());
} }
fetchResult.setGroup(StringUtils.isEmpty(fetchParam.getGroup())?"分项":fetchParam.getGroup()); fetchResult.setGroup(StringUtils.isEmpty(fetchParam.getGroup())?"分项":fetchParam.getGroup());
fetchResult.setDict(fetchParam.getDict()).setSelectValue(fetchParam.getDimValue()).setStartTime(fetchParam.getStartTime()).setEndTime(fetchParam.getEndTime());
return fetchResult; return fetchResult;
} }
......
...@@ -14,6 +14,7 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{ ...@@ -14,6 +14,7 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{
int replaceBatch(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName); int replaceBatch(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int replaceBatchByOracle(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName); int replaceBatchByOracle(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
int replaceBatchByDameng(@Param("list") List<ExecResult> var1 , @Param("resultTableName") String tableName);
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);
......
...@@ -9,14 +9,13 @@ import cn.ibizlab.core.analysis.service.IDAMetricService; ...@@ -9,14 +9,13 @@ import cn.ibizlab.core.analysis.service.IDAMetricService;
import cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl; import cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl;
import cn.ibizlab.core.dict.extensions.service.DictDstService; import cn.ibizlab.core.dict.extensions.service.DictDstService;
import cn.ibizlab.core.extensions.cql.ExecResultRepository; import cn.ibizlab.core.extensions.cql.ExecResultRepository;
import cn.ibizlab.core.extensions.dto.BuildResult; import cn.ibizlab.core.extensions.dto.*;
import cn.ibizlab.core.extensions.dto.FetchParam;
import cn.ibizlab.core.extensions.dto.FetchItem;
import cn.ibizlab.core.extensions.dto.VMConfig;
import cn.ibizlab.core.rule.domain.ExecResult; import cn.ibizlab.core.rule.domain.ExecResult;
import cn.ibizlab.core.rule.service.IExecResultService; import cn.ibizlab.core.rule.service.IExecResultService;
import cn.ibizlab.util.dict.Catalog;
import cn.ibizlab.util.dict.CodeItem; import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.dict.CodeList; import cn.ibizlab.util.dict.CodeList;
import cn.ibizlab.util.dict.Option;
import cn.ibizlab.util.helper.Setting; import cn.ibizlab.util.helper.Setting;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
...@@ -27,10 +26,13 @@ import com.datastax.driver.core.Row; ...@@ -27,10 +26,13 @@ import com.datastax.driver.core.Row;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -102,6 +104,8 @@ public class BuildResultService { ...@@ -102,6 +104,8 @@ public class BuildResultService {
vmConfig = daReport.getConfig(); vmConfig = daReport.getConfig();
if(!StringUtils.isEmpty(daReport.getDict())) if(!StringUtils.isEmpty(daReport.getDict()))
fetchParam.setDimDict(daReport.getDict()); fetchParam.setDimDict(daReport.getDict());
else
fetchParam.setDimDict("CL_DST_REGION");
if(!StringUtils.isEmpty(daReport.getGroup())) if(!StringUtils.isEmpty(daReport.getGroup()))
fetchParam.setGroup(daReport.getGroup()); fetchParam.setGroup(daReport.getGroup());
...@@ -114,6 +118,8 @@ public class BuildResultService { ...@@ -114,6 +118,8 @@ public class BuildResultService {
vmConfig = daChart.getConfig(); vmConfig = daChart.getConfig();
if(!StringUtils.isEmpty(daChart.getDict())) if(!StringUtils.isEmpty(daChart.getDict()))
fetchParam.setDimDict(daChart.getDict()); fetchParam.setDimDict(daChart.getDict());
else
fetchParam.setDimDict("CL_DST_REGION");
if(!StringUtils.isEmpty(daChart.getGroup())) if(!StringUtils.isEmpty(daChart.getGroup()))
fetchParam.setGroup(daChart.getGroup()); fetchParam.setGroup(daChart.getGroup());
...@@ -123,9 +129,11 @@ public class BuildResultService { ...@@ -123,9 +129,11 @@ public class BuildResultService {
if(!StringUtils.isEmpty(vmConfig)) { if(!StringUtils.isEmpty(vmConfig)) {
builds = VMConfig.getBuilds(vmConfig); builds = VMConfig.getBuilds(vmConfig);
List<String> ids= new ArrayList<>();
builds.values().forEach(set->ids.addAll(set));
fetchParam.setVmConfigs(JSONArray.parseArray(vmConfig,VMConfig.class)); fetchParam.setVmConfigs(JSONArray.parseArray(vmConfig,VMConfig.class));
Map<String, DAMetric> metricMap = new LinkedHashMap<>(); Map<String, DAMetric> metricMap = new LinkedHashMap<>();
daMetricService.list(Wrappers.<DAMetric>lambdaQuery().in(DAMetric::getMetricId,fetchParam.getMetricIds())).forEach(item->{ daMetricService.list(Wrappers.<DAMetric>lambdaQuery().in(DAMetric::getMetricId,ids)).forEach(item->{
metricMap.put(item.getMetricId(),item); metricMap.put(item.getMetricId(),item);
fetchParam.getMetricIds().add(item.getMetricId()); fetchParam.getMetricIds().add(item.getMetricId());
}); });
...@@ -163,26 +171,35 @@ public class BuildResultService { ...@@ -163,26 +171,35 @@ public class BuildResultService {
fetchParam.setMetrics(metricMap); fetchParam.setMetrics(metricMap);
} }
if( (!StringUtils.isEmpty(fetchParam.getDimDict())) && (!StringUtils.isEmpty(fetchParam.getDimValue())) && fetchParam.isIncludeChild() && fetchParam.getDimValues() == null) if(!StringUtils.isEmpty(fetchParam.getDimDict()))
{ {
List<String> dimValues = new ArrayList<>(); List<String> dimValues = new ArrayList<>();
CodeList dict = dictDstService.getCodeListCatalog(fetchParam.getDimDict()); Catalog dict = dictDstService.getDictCatalog(fetchParam.getDimDict());
if(StringUtils.isEmpty(fetchParam.getGroup())) if(StringUtils.isEmpty(fetchParam.getGroup()))
fetchParam.setGroup(dict.getName()); fetchParam.setGroup(dict.getName());
if(dict!=null) Assert.notNull(dict,"未找到数据字典"+fetchParam.getDimDict());
Assert.notEmpty(dict.getOptions(),"未找到数据字典"+fetchParam.getDimDict());
fetchParam.setDict(dict);
Option dimItem = null;
if(StringUtils.isEmpty(fetchParam.getDimValue())) {
dimItem = dict.getOptions().get(0);
fetchParam.setDimValue(dimItem.getValue().toString());
}
else
{ {
CodeItem dimItem= dict.findChildren(fetchParam.getDimValue()); dimItem= dict.findCodeItem(fetchParam.getDimValue());
if(dimItem!=null) { }
fetchParam.setDimItem(dimItem); Assert.notNull(dimItem,"未找到数据字典项"+fetchParam.getDimDict()+"."+fetchParam.getDimValue());
if(dimItem.getChildren()!=null) fetchParam.setDimItem(dimItem);
{ if(fetchParam.isIncludeChild()&&dimItem.getChildren()!=null)
dimItem.getChildren().forEach(codeItem -> { {
dimValues.add(codeItem.getValue().toString()); dimItem.getChildren().forEach(codeItem -> {
}); dimValues.add(codeItem.getValue().toString());
} });
}
} }
dimValues.add(fetchParam.getDimValue()); dimValues.add(fetchParam.getDimValue());
fetchParam.setDimValues(dimValues); fetchParam.setDimValues(dimValues);
...@@ -258,7 +275,7 @@ public class BuildResultService { ...@@ -258,7 +275,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.sumResult(dsName,tableName,new ArrayList<>(tmpSet),fetchParam.getDimValues(),startTime,endTime);
list.forEach(item->{ list.forEach(item->{
ret.add(new BuildResult().setSqlResult(item)); ret.add(new BuildResult().setSqlResult(item));
}); });
...@@ -315,7 +332,7 @@ public class BuildResultService { ...@@ -315,7 +332,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.avgResult(dsName,tableName,new ArrayList<>(tmpSet),fetchParam.getDimValues(),startTime,endTime);
list.forEach(item->{ list.forEach(item->{
ret.add(new BuildResult().setSqlResult(item)); ret.add(new BuildResult().setSqlResult(item));
}); });
...@@ -330,6 +347,7 @@ public class BuildResultService { ...@@ -330,6 +347,7 @@ public class BuildResultService {
} }
@Cacheable( value="dataAnalyse",key="'rows:lookup:'+#p0.getId()")
public List<String> lookup(FetchParam fetchParam) { public List<String> lookup(FetchParam fetchParam) {
List<String> ret = new ArrayList<>(); List<String> ret = new ArrayList<>();
if(!StringUtils.isEmpty(cassandraHost)) if(!StringUtils.isEmpty(cassandraHost))
...@@ -375,6 +393,7 @@ public class BuildResultService { ...@@ -375,6 +393,7 @@ public class BuildResultService {
} }
@Cacheable( value="dataAnalyse",key="'rows:dr:'+#p0.getId()")
public List<FetchItem> getResult(FetchParam fetchParam) public List<FetchItem> getResult(FetchParam fetchParam)
{ {
...@@ -431,10 +450,10 @@ public class BuildResultService { ...@@ -431,10 +450,10 @@ public class BuildResultService {
int no=1; int no=1;
if(fetchParam.isIncludeChild()&&fetchParam.getDimItem()!=null&&fetchParam.getDimItem().getChildren()!=null) if(fetchParam.isIncludeChild()&&fetchParam.getDimItem()!=null&&fetchParam.getDimItem().getChildren()!=null)
{ {
for(CodeItem item:fetchParam.getDimItem().getChildren()) for(Option item:fetchParam.getDimItem().getChildren())
{ {
dims.add(item.getValue().toString()); dims.add(item.getValue().toString());
FetchItem obj=new FetchItem().setNo(no).setDimId(item.getValue().toString()).setDimName(item.getText()).setDisplayType(fetchParam.getDisplayType()); FetchItem obj=new FetchItem().setNo(no).setDimId(item.getValue().toString()).setDimName(item.getLabel()).setDisplayType(fetchParam.getDisplayType());
for(DAMetric metric:fetchParam.getMetrics().values()) for(DAMetric metric:fetchParam.getMetrics().values())
{ {
...@@ -681,4 +700,18 @@ public class BuildResultService { ...@@ -681,4 +700,18 @@ public class BuildResultService {
return dimsObj; return dimsObj;
} }
@Cacheable( value="dataAnalyse",key="'rows:ar:'+#p0.getId()")
public FetchResult getAnalyseResult(FetchParam fetchParam)
{
List<FetchItem> rows = this.getResult(fetchParam);
return FetchResult.from(fetchParam).setRows(rows);
}
@CacheEvict( value = "dataAnalyse",allEntries = true)
public void reset()
{
}
} }
...@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier; ...@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -80,6 +81,7 @@ public class DABuildExService extends DABuildServiceImpl { ...@@ -80,6 +81,7 @@ public class DABuildExService extends DABuildServiceImpl {
@Qualifier("AnalyseEntityServiceImpl") @Qualifier("AnalyseEntityServiceImpl")
private BaseEntityService analyseEntityServiceImpl; private BaseEntityService analyseEntityServiceImpl;
@Override @Override
protected Class currentModelClass() { protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1); return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
...@@ -121,7 +123,10 @@ public class DABuildExService extends DABuildServiceImpl { ...@@ -121,7 +123,10 @@ public class DABuildExService extends DABuildServiceImpl {
* @return * @return
*/ */
@Override @Override
@CacheEvict(value ={"dabuild","dabuilddims"}, key = "'row:'+#p0.buildId") @Caching( evict = {
@CacheEvict(value ={"dabuild","dabuilddims"}, key = "'row:'+#p0.buildId"),
@CacheEvict( value="dataAnalyse",allEntries = true)
})
public DABuild run(DABuild et) { public DABuild run(DABuild et) {
if(!StringUtils.isEmpty(et.getBuildId())) if(!StringUtils.isEmpty(et.getBuildId()))
{ {
......
...@@ -212,8 +212,10 @@ public class ExecResultExService extends ExecResultServiceImpl { ...@@ -212,8 +212,10 @@ public class ExecResultExService extends ExecResultServiceImpl {
DataSource ds = dynamicDSMap.get(dsName); DataSource ds = dynamicDSMap.get(dsName);
if (ds instanceof DruidDataSource) { if (ds instanceof DruidDataSource) {
DruidDataSource druidDataSource = (DruidDataSource) dynamicDSMap.get(dsName); DruidDataSource druidDataSource = (DruidDataSource) dynamicDSMap.get(dsName);
if ("oracle".equals(druidDataSource.getDbType())||"dm".equals(druidDataSource.getDbType())||"gbase".equalsIgnoreCase(druidDataSource.getDbType())) { if ("oracle".equals(druidDataSource.getDbType())||"gbase".equalsIgnoreCase(druidDataSource.getDbType())) {
return execResultExMapper.replaceBatchByOracle(execResults, tableName); return execResultExMapper.replaceBatchByOracle(execResults, tableName);
} else if ("dameng".equals(druidDataSource.getDbType())||"dm".equals(druidDataSource.getDbType())) {
return execResultExMapper.replaceBatchByDameng(execResults, tableName);
} else if ("mysql".equals(druidDataSource.getDbType())) { } else if ("mysql".equals(druidDataSource.getDbType())) {
return execResultExMapper.replaceBatch(execResults, tableName); return execResultExMapper.replaceBatch(execResults, tableName);
} else if ("postgresql".equals(druidDataSource.getDbType())) { } else if ("postgresql".equals(druidDataSource.getDbType())) {
......
...@@ -63,6 +63,21 @@ ...@@ -63,6 +63,21 @@
VALUES (B.ru_execresultid,B.ru_execresultname, B.createdate, B.updatedate, B.ruleid, B.rulename, B.retvalue, B.keyvaluefield,B.dimfield, B.metricfield,B.domainsfield,B.timefield,B.ext1field,B.ext2field, B.businesscat, B.systemId) VALUES (B.ru_execresultid,B.ru_execresultname, B.createdate, B.updatedate, B.ruleid, B.rulename, B.retvalue, B.keyvaluefield,B.dimfield, B.metricfield,B.domainsfield,B.timefield,B.ext1field,B.ext2field, B.businesscat, B.systemId)
</insert> </insert>
<insert id="replaceBatchByDameng" parameterType="java.util.List">
<foreach collection='list' item='item' index='index' separator=';'>
MERGE INTO ${resultTableName} A USING (
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,#{item.systemId} as systemid from dual
) B ON (A.ru_execresultid = B.ru_execresultid) WHEN MATCHED THEN
UPDATE SET A.ru_execresultname=B.ru_execresultname, A.updatedate=B.updatedate, A.ruleid=B.ruleid, A.rulename=B.rulename, A.retvalue=B.retvalue, A.keyvaluefield=B.keyvaluefield,
A.dimfield=B.dimfield, A.metricfield=B.metricfield,A.domainsfield=B.domainsfield,A.timefield=B.timefield,A.ext1field=B.ext1field,A.ext2field=B.ext2field, A.businesscat=B.businesscat, A.systemid=B.systemid
WHEN NOT MATCHED THEN
INSERT ( ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat, systemid )
VALUES (B.ru_execresultid,B.ru_execresultname, B.createdate, B.updatedate, B.ruleid, B.rulename, B.retvalue, B.keyvaluefield,B.dimfield, B.metricfield,B.domainsfield,B.timefield,B.ext1field,B.ext2field, B.businesscat, B.systemId)
</foreach>
</insert>
<insert id="replaceBatchByPG" parameterType="java.util.List"> <insert id="replaceBatchByPG" parameterType="java.util.List">
INSERT INTO ${resultTableName} INSERT INTO ${resultTableName}
(ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat , systemid ) (ru_execresultid,ru_execresultname, createdate, updatedate, ruleid, rulename, retvalue, keyvaluefield,dimfield, metricfield,domainsfield,timefield,ext1field,ext2field, businesscat , systemid )
...@@ -86,7 +101,7 @@ ...@@ -86,7 +101,7 @@
</delete> </delete>
<select id="sumResult" > <select id="sumResult" resultType="cn.ibizlab.core.rule.domain.ExecResult" >
select ruleid, 1 as retvalue,dimfield,sum(metricfield) as metricfield from ${resultTableName} where ruleid in select ruleid, 1 as retvalue,dimfield,sum(metricfield) as metricfield from ${resultTableName} where ruleid in
<foreach item="id" index="index" collection="ruleids" open="(" separator="," close=")"> <foreach item="id" index="index" collection="ruleids" open="(" separator="," close=")">
...@@ -101,7 +116,7 @@ ...@@ -101,7 +116,7 @@
</select> </select>
<select id="avgResult" > <select id="avgResult" resultType="cn.ibizlab.core.rule.domain.ExecResult" >
select ruleid, 1 as retvalue,dimfield,avg(metricfield) as metricfield from ${resultTableName} where ruleid in select ruleid, 1 as retvalue,dimfield,avg(metricfield) as metricfield from ${resultTableName} where ruleid in
<foreach item="id" index="index" collection="ruleids" open="(" separator="," close=")"> <foreach item="id" index="index" collection="ruleids" open="(" separator="," close=")">
......
...@@ -4,7 +4,12 @@ import cn.ibizlab.core.analysis.domain.DAReport; ...@@ -4,7 +4,12 @@ import cn.ibizlab.core.analysis.domain.DAReport;
import cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl; import cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl;
import cn.ibizlab.core.dict.domain.DictOption; import cn.ibizlab.core.dict.domain.DictOption;
import cn.ibizlab.core.dict.service.impl.DictOptionServiceImpl; import cn.ibizlab.core.dict.service.impl.DictOptionServiceImpl;
import cn.ibizlab.core.extensions.dto.FetchItem;
import cn.ibizlab.core.extensions.dto.FetchParam;
import cn.ibizlab.core.extensions.dto.FetchResult;
import cn.ibizlab.core.extensions.service.BuildResultService;
import cn.ibizlab.core.extensions.service.DACoreService; import cn.ibizlab.core.extensions.service.DACoreService;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -14,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -14,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -36,6 +42,17 @@ public class DAGridCoreResource { ...@@ -36,6 +42,17 @@ public class DAGridCoreResource {
@Lazy @Lazy
private DictOptionServiceImpl dictOptionService; private DictOptionServiceImpl dictOptionService;
@Autowired
private BuildResultService buildResultService;
@RequestMapping(method = RequestMethod.GET, value = {"/dst/report/{reportId}/{dimValue}","/dst/report/{reportId}"})
public ResponseEntity<FetchResult> getReportdatas(@PathVariable(name = "reportId") String reportId, @PathVariable(name = "dimValue",required = false) String dimValue,
@RequestParam(name = "startTime",required = false) String startTime,
@RequestParam(name = "endTime",required = false) String endTime) {
FetchParam param=new FetchParam().setReportId(reportId).setDimValue(dimValue).setStartTime(DataObject.getTimestampValue(startTime,null)).setEndTime(DataObject.getTimestampValue(endTime,null));
return ResponseEntity.ok(buildResultService.getAnalyseResult(param));
}
@RequestMapping(method = RequestMethod.POST, value = "/ibizutil/reportdatas") @RequestMapping(method = RequestMethod.POST, value = "/ibizutil/reportdatas")
public ResponseEntity<JSONObject> getReportdatas(@RequestBody JSONObject data) { public ResponseEntity<JSONObject> getReportdatas(@RequestBody JSONObject data) {
JSONObject responseJson = new JSONObject(); JSONObject responseJson = new JSONObject();
......
...@@ -10,6 +10,8 @@ import lombok.Getter; ...@@ -10,6 +10,8 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -29,4 +31,23 @@ public class Catalog ...@@ -29,4 +31,23 @@ public class Catalog
@JsonProperty("items") @JsonProperty("items")
private List<Option> options = new ArrayList<>(); private List<Option> options = new ArrayList<>();
public Option findCodeItem(Object value)
{
return findCodeItem(value,this.options);
}
public Option findCodeItem(Object value,List<Option> options){
for(Option codeItem : options){
if(value != null && codeItem.getValue() != null && value.equals(codeItem.getValue()))
return codeItem;
else if (!ObjectUtils.isEmpty(codeItem.getChildren()))
{
Option rt=findCodeItem(value,codeItem.getChildren());
if(rt!=null)
return rt;
}
}
return null;
}
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册