指标库:保存聚合指标
This commit is contained in:
parent
fdbfdeb8c4
commit
de3ca330ee
@ -129,4 +129,11 @@ public class TargetController {
|
|||||||
double result = Double.parseDouble(utilService.getTogethResult(new Date(), expression).get("res"));
|
double result = Double.parseDouble(utilService.getTogethResult(new Date(), expression).get("res"));
|
||||||
return R.ok(result);
|
return R.ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "保存聚合指标")
|
||||||
|
@PostMapping("/saveTogethTarget")
|
||||||
|
public R<?> saveTogetherTarget(@RequestBody JSONObject params) {
|
||||||
|
targetService.saveTogetherTarget(params);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,6 @@ public interface TargetService extends IService<Target> {
|
|||||||
void saveExpandTarget(JSONObject params);
|
void saveExpandTarget(JSONObject params);
|
||||||
|
|
||||||
void saveSingleTarget(JSONObject params);
|
void saveSingleTarget(JSONObject params);
|
||||||
|
|
||||||
|
void saveTogetherTarget(JSONObject params);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package iet.ustb.sf.service.impl;
|
package iet.ustb.sf.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
@ -558,6 +560,40 @@ public class TargetServiceImpl extends ServiceImpl<TargetMapper, Target>
|
|||||||
targetMapper.updateById(target);
|
targetMapper.updateById(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void saveTogetherTarget(JSONObject params) {
|
||||||
|
Target target = params.getJSONObject("target").toJavaObject(Target.class);
|
||||||
|
checkTarget(target);
|
||||||
|
JSONArray jsonArray = params.getJSONArray("expression");
|
||||||
|
String expression = String.join(",", jsonArray.toJavaList(String.class));
|
||||||
|
Map<String, String> map = utilService.getTogethResult(new Date(), expression);
|
||||||
|
target.setResultSql(map.get("expression"));
|
||||||
|
target.setCycle(map.get("cycle"));
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
if (StringUtils.isEmpty(target.getId())) {
|
||||||
|
target.setId(UUID.randomUUID().toString());
|
||||||
|
target.setCreateTime(now);
|
||||||
|
target.setCreateTime(now);
|
||||||
|
if (!StringUtils.isEmpty(target.getCategoryId())) {
|
||||||
|
categoryDeal(null, target);
|
||||||
|
}
|
||||||
|
target.setUpdateTime(now);
|
||||||
|
targetMapper.insert(target);
|
||||||
|
saveData(target);
|
||||||
|
} else {
|
||||||
|
categoryDealByUpdate(target);
|
||||||
|
Target oldTarget = targetMapper.selectById(target.getId());
|
||||||
|
if (!oldTarget.getResultSql().equals(target.getResultSql())) {
|
||||||
|
detailTogetherData(target);
|
||||||
|
}
|
||||||
|
target.setUpdateTime(now);
|
||||||
|
targetMapper.updateById(target);
|
||||||
|
updateMonitor(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指标变更后,修改对应的监控数据
|
* 指标变更后,修改对应的监控数据
|
||||||
*
|
*
|
||||||
@ -733,7 +769,9 @@ public class TargetServiceImpl extends ServiceImpl<TargetMapper, Target>
|
|||||||
CheckUtils.checkEmpty(String.valueOf(target.getIsKey()), "是否启用");
|
CheckUtils.checkEmpty(String.valueOf(target.getIsKey()), "是否启用");
|
||||||
CheckUtils.checkEmpty(target.getOrganization(), "组织");
|
CheckUtils.checkEmpty(target.getOrganization(), "组织");
|
||||||
CheckUtils.checkEmpty(target.getTopic(), "主题");
|
CheckUtils.checkEmpty(target.getTopic(), "主题");
|
||||||
CheckUtils.checkTableName(target.getTableName());
|
if (target.getType() != 2) {
|
||||||
|
CheckUtils.checkTableName(target.getTableName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user