提交 d5044ff5 编写于 作者: xuhui961310148's avatar xuhui961310148

报表字典代码值调整,缓存键值设置修改,绩效考核功能添加

上级 f80d0072
......@@ -13,7 +13,8 @@ public class FetchMetricDatasParam {
private String reportid;
// 表格展示类型:默认为普通模式(单位数据以行进行展示),2. LIST_BOX表示单位数据以列的形式展示,
private String tableDisplayType = "default";
private String dimcodelist = "DST_cl_dst_region";
// private String dimcodelist = "DST_cl_dst_region";
private String dimcodelist = "cl_dst_region";
private List<String> metricids;
private List<String> dimField;
private String dimval;
......
......@@ -61,7 +61,8 @@ public class DACoreService {
* @param param
* @return
*/
@Cacheable( value="onFetchMetricDatas",keyGenerator="keyGenerator")
// @Cacheable( value="onFetchMetricDatas",keyGenerator="keyGenerator")
@Cacheable( value="onFetchMetricDatas",key="'onFetchMetricDatas:'+#p0.getMetricids() + '||' + #p0.getDimval() + '||' + #p0.getStarttime() + '||' + #p0.getEndtime()")
public List<HashMap<String,Object>> onFetchMetricDatas(FetchMetricDatasParam param) {
List<HashMap<String,Object>> execResults = new ArrayList<HashMap<String,Object>>();
try {
......@@ -86,7 +87,8 @@ public class DACoreService {
* @param param
* @return
*/
@Cacheable( value="onFetchReportDatas",keyGenerator="keyGenerator")
// @Cacheable( value="onFetchReportDatas",keyGenerator="keyGenerator")
@Cacheable( value="onFetchReportDatas",key="'onFetchReportDatas:'+#p0.getReportid() + '||' + #p0.getDimval() + '||' + #p0.getStarttime() + '||' + #p0.getEndtime()")
public Map<String, Object> onFetchReportDatas(FetchMetricDatasParam param) {
Map<String, Object> resultMap = new HashMap<String,Object>();
try {
......@@ -118,7 +120,8 @@ public class DACoreService {
* @param param
* @return
*/
@Cacheable( value="onFetchKeyValueField",keyGenerator="keyGenerator")
// @Cacheable( value="onFetchKeyValueField",keyGenerator="keyGenerator")
@Cacheable( value="onFetchKeyValueField",key="'onFetchKeyValueField:' + #p0.getPagingCurrent() + '||' + #p0.getRuleid() + '||' + #p0.getDimval() + '||' + #p0.getStarttime() + '||' + #p0.getEndtime()")
public Map<String, String> onFetchKeyValueField(FetchMetricDatasParam param) {
Map<String, String> resultMap = new HashMap<String,String>();
try {
......@@ -186,7 +189,8 @@ public class DACoreService {
* @param end
* @return
*/
@Cacheable( value="reportinspec",keyGenerator="keyGenerator")
// @Cacheable( value="reportinspec",keyGenerator="keyGenerator")
@Cacheable( value="reportinspec",key="'reportinspec:' + #p0 + '||' + #p1 + '||' + #p2 + '||' + #p3 + '||' + #p4 + '||' + #p5")
public Map<String, String> getKeyvaluefields(long lPagingCurrent, String ruleid, String dimval, Timestamp start, Timestamp end)
{
Map<String, String> result = null;
......@@ -207,13 +211,15 @@ public class DACoreService {
return result;
}
@Cacheable( value="reportshow",keyGenerator="keyGenerator")
// @Cacheable( value="reportshow",keyGenerator="keyGenerator")
@Cacheable( value="reportshow",key="'reportshow:' + #p0 + '||' + #p1 + '||' + #p2 + '||' + #p3 + '||' + #p4 + '||' + #p5")
public List<HashMap<String,Object>> getResultIds(List<String> metricList, String dimcodelist,String dimval, Timestamp start, Timestamp end)
{
return this.getResultIds(metricList, dimcodelist, dimval, true, start, end);
}
@Cacheable( value="reportshow", keyGenerator="keyGenerator")
// @Cacheable( value="reportshow", keyGenerator="keyGenerator")
@Cacheable( value="reportshow",key="'reportshow:' + #p0 + '||' + #p1 + '||' + #p2 + '||' + #p3 + '||' + #p4 + '||' + #p5 + '||' + #p6")
public List<HashMap<String,Object>> getResultIds(List<String> metricList, String dimcodelist, String dimval, boolean includeChild, Timestamp start, Timestamp end)
{
QueryWrapper<DAMetric> sf=new QueryWrapper<>();
......@@ -583,6 +589,242 @@ public class DACoreService {
}
/**
* 根据报表ID查询绩效考核的相应数据
*
* @return
*/
@Cacheable( value="getPerformanceReportData",key="'getPerformanceReportData:' + #p0 + '||' + #p1 + '||' + #p2 + '||' + #p3")
public Map<String, Object> getPerformanceReportData(DAReport report, List<String> dimfieldList, Timestamp timeLoadStartTime,Timestamp timeLoadEndTime) {
Map<String, Object> dataMap = new HashMap<String, Object>();
if (report != null){
DAReport daReport = report;
String strVMCFG = daReport.getConfig();
if (StringUtils.isEmpty(strVMCFG)) {
throw new BadRequestAlertException("报表配置不存在", "", "");
}
List<String> ruleidList = getRuleids(JSONArray.parseArray(strVMCFG));
Timestamp startTime = timeLoadStartTime == null ? this.getDefaultStartTimestamp() : timeLoadStartTime;
Timestamp endTime = timeLoadEndTime == null ? this.getDefaultEndTimestamp() : timeLoadEndTime;
JSONArray jsonArray = new JSONArray();
List<ExecResult> execResults = getPerformanceData(ruleidList, dimfieldList, startTime, endTime);
List<ExecResult> performancePieceDatas = sumPerformancePiece(ruleidList, 1, dimfieldList, startTime, endTime);
jsonArray.add(execResults);
dataMap.put("headData", getVMCFG(strVMCFG, "JXKH"));
dataMap.put("erportdata", execResults);
dataMap.put("ruleidList", ruleidList);
dataMap.put("performancePieceDatas", performancePieceDatas);
}else {
throw new BadRequestAlertException("报表不存在", "", "");
}
return dataMap;
}
/**
* 获取绩效考核数据
* @param metricList
* @param dimfieldList
* @param start
* @param end
* @return
*/
@Cacheable( value="getPerformanceData",key="'getPerformanceData:' + #p0 + '||' + #p1 + '||' + #p2 + '||' + #p3")
public List<ExecResult> getPerformanceData(List<String> metricList, List<String> dimfieldList, Timestamp start, Timestamp end) {
List<ExecResult> list = new ArrayList<ExecResult>();
List<String> sum=new ArrayList<String>();
List<String> avg=new ArrayList<String>();
List<String> sum_yoy=new ArrayList<>();
List<String> sum_mom=new ArrayList<>();
List<String> sum_y3=new ArrayList<>();
List<DAMetric> sum_per=new ArrayList<>();
List<String> avg_yoy=new ArrayList<>();
List<String> avg_mom=new ArrayList<>();
List<String> avg_y3=new ArrayList<>();
List<DAMetric> avg_per=new ArrayList<>();
QueryWrapper<DAMetric> queryWrapper = new QueryWrapper<>();
queryWrapper.in("da_metricid", metricList);
List<DAMetric> metricAllList = this.daMetricExService.list(queryWrapper);
for(DAMetric metric:metricAllList)
{
if("AVG".equals(metric.getMetricType()))
{
avg.add(metric.getMetricId());
if("YOY".equals(metric.getExtOp()))
avg_yoy.add(metric.getMetricId());
else if("MOM".equals(metric.getExtOp()))
avg_mom.add(metric.getMetricId());
else if("Y3".equals(metric.getExtOp()))
avg_y3.add(metric.getMetricId());
else if("PER".equals(metric.getExtOp()) || "PER_ORI".equals(metric.getExtOp()))
avg_per.add(metric);
}
else
{
sum.add(metric.getMetricId());
if("YOY".equals(metric.getExtOp()))
sum_yoy.add(metric.getMetricId());
else if("MOM".equals(metric.getExtOp()))
sum_mom.add(metric.getMetricId());
else if("Y3".equals(metric.getExtOp()))
sum_y3.add(metric.getMetricId());
else if("PER".equals(metric.getExtOp()) || "PER_ORI".equals(metric.getExtOp()))
sum_per.add(metric);
}
}
if (dimfieldList == null || dimfieldList.size() == 0) {
return list;
}
if (sum.size() > 0) {
List<ExecResult> listsum = execResultRepository.sum(sum, 1, dimfieldList, start, end);
list.addAll(listsum);
}
if(avg.size()>0)
{
List<ExecResult> listavg=execResultRepository.avg(avg, 1, dimfieldList, start, end);
list.addAll(listavg);
}
//同比
List<ExecResult> list_yoy=new ArrayList<>();
if(sum_yoy.size()>0)
{
List<ExecResult> listsum=execResultRepository.sum(sum_yoy, 1, dimfieldList, getLastYear(start), getLastYear(end));
list_yoy.addAll(listsum);
}
if(avg_yoy.size()>0)
{
List<ExecResult> listavg=execResultRepository.avg(avg_yoy, 1, dimfieldList, getLastYear(start), getLastYear(end));
list_yoy.addAll(listavg);
}
List<ExecResult> list_all_yoy = new ArrayList<>();
for(ExecResult res:list_yoy)
{
// HashMap<String,Object> obj=dimsSet.get(res.getDimfield());
Double now = res.getMetricfield();
Double last=res.getMetricfield();
if(last==0d)
{
last=1d;
if(now==0d)
now=1d;
}
Double d=(now-last)/last;
d=d*100;
//DecimalFormat df = new DecimalFormat("#.00");
BigDecimal b = new BigDecimal(d);
d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
res.setMetricfield(d);
list_all_yoy.add(res);
// obj.put(res.getRuleid(), d);
}
list.addAll(list_all_yoy);
//环比
List<ExecResult> list_mom=new ArrayList<>();
if(sum_mom.size()>0)
{
List<ExecResult> listsum=execResultRepository.sum(sum_mom, 1, dimfieldList, getLastMonth(start), getLastMonth(end));
list_mom.addAll(listsum);
}
if(avg_mom.size()>0)
{
List<ExecResult> listavg=execResultRepository.avg(avg_mom, 1, dimfieldList, getLastMonth(start), getLastMonth(end));
list_mom.addAll(listavg);
}
List<ExecResult> list_all_mom=new ArrayList<>();
for(ExecResult res:list_mom)
{
// if(!dimsSet.containsKey(res.getDimfield()))
// continue;
// HashMap<String,Object> obj=dimsSet.get(res.getDimfield());
Double now=res.getMetricfield();
Double last=res.getMetricfield();
if(last==0d)
{
last=1d;
if(now==0d)
now=1d;
}
Double d=(now-last)/last;
d=d*100;
//DecimalFormat df = new DecimalFormat("#.00");
BigDecimal b = new BigDecimal(d);
d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
res.setMetricfield(d);
list_all_mom.add(res);
// obj.put(res.getRuleid(), d);
}
list.addAll(list_all_mom);
//占比
sum_per.addAll(avg_per);
for(DAMetric res:sum_per)
{
Map<String, ExecResult> cur_map = new HashMap<>();
Map<String, ExecResult> per_map = new HashMap<>();
for(ExecResult execResult : list)
{
if ((execResult.getRuleid()).equals(res.getMetricId())) {
cur_map.put(execResult.getDimfield(), execResult);
} else if ((execResult.getRuleid()).equals(res.getRefMetric())) {
per_map.put(execResult.getDimfield(), execResult);
}
}
for (String pcrid:dimfieldList) {
boolean isPerOri = false;
if("PER_ORI".equalsIgnoreCase(res.getExtOp()))
isPerOri = true;
if (cur_map.containsKey(pcrid) && per_map.containsKey(pcrid)) {
Double cur = cur_map.get(pcrid).getMetricfield();
Double per = per_map.get(pcrid).getMetricfield();
if(per==0d)
per=1d;
Double d=(cur)/per;
// d=d*100;
if(!isPerOri) {
d = d * 100;
}
BigDecimal b = new BigDecimal(d);
d = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
cur_map.get(pcrid).setMetricfield(d);
}
}
}
return list;
}
/**
* 获取绩效考核数据 (案件数)
* @param ruleids
* @param retValue
* @param dims
* @param start
* @param end
* @return
*/
@Cacheable( value="getPerformanceData",key="'getPerformanceData:' + #p0 + '||' + #p2 + '||' + #p3 + '||' + #p4")
public List<ExecResult> sumPerformancePiece(List<String> ruleids, Integer retValue, List<String> dims, Timestamp start, Timestamp end) {
List<ExecResult> listsum = execResultRepository.sumPerformancePiece(ruleids, 1, dims, start, end);
return listsum;
}
/**
* 获取以单位为表头的表格数据结构
* @param execResults
......@@ -752,9 +994,11 @@ public class DACoreService {
* @return
*/
public String getDict(DAReport daReport) {
String strDict = "DST_cl_dst_region";
// String strDict = "DST_cl_dst_region";
String strDict = "cl_dst_region";
if (daReport != null && !StringUtils.isEmpty(daReport.getDict())) {
strDict = "DST_"+daReport.getDict();
// strDict = "DST_"+daReport.getDict();
strDict = daReport.getDict();
}
return strDict;
}
......
......@@ -95,4 +95,33 @@ public class DACoreResource {
return ResponseEntity.status(HttpStatus.OK).body(resultMap);
}
/**
* 获取绩效数据
* @param param
* @return
*/
@RequestMapping(method = RequestMethod.POST, value="/dst/analyse/reportdata/fetchperformancedata")
public Map<String, Object> fetchPerformanceData(@Validated @RequestBody FetchMetricDatasParam param) {
if(param == null){
return new HashMap<String,Object>();
}
String id = param.getReportid();
if (StringUtils.isEmpty(id)) {
return new HashMap<String,Object>();
}
//获取表头及表单名称
DAReport daReport = daReportService.getById(id);
String vmcfg = daReport != null ? daReport.getConfig() : "";
String reportname = daReport != null ? daReport.getReportName() : "";
//获取表格数据
// getData(id);
Map<String, Object> resultMap = new HashMap<String, Object>();
resultMap = daCoreService.getPerformanceReportData(daReport, param.getDimField(), param.getStarttime(), param.getEndtime());
resultMap.put("vmcfg",vmcfg);
resultMap.put("reportname",reportname);
resultMap.put("dataDict", daReport.getDict());
// resultMap.put("resportdata",jsonObject);
return resultMap;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册