指标库:聚合指标详情(点击聚合指标编辑)
This commit is contained in:
parent
de3ca330ee
commit
b2e140d6d5
@ -136,4 +136,11 @@ public class TargetController {
|
||||
targetService.saveTogetherTarget(params);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "聚合指标详情(点击聚合指标编辑)")
|
||||
@PostMapping("/getTogethDetail")
|
||||
public R<JSONObject> getTogethDetail(@RequestBody JSONObject params) {
|
||||
JSONObject result = targetService.getTogethDetail(params);
|
||||
return R.ok(result);
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,6 @@ public interface TargetService extends IService<Target> {
|
||||
void saveSingleTarget(JSONObject params);
|
||||
|
||||
void saveTogetherTarget(JSONObject params);
|
||||
|
||||
JSONObject getTogethDetail(JSONObject params);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package iet.ustb.sf.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -17,6 +16,7 @@ import iet.ustb.sf.service.TargetDataService;
|
||||
import iet.ustb.sf.service.TargetService;
|
||||
import iet.ustb.sf.service.UtilService;
|
||||
import iet.ustb.sf.util.CheckUtils;
|
||||
import iet.ustb.sf.vo.TogetherVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -594,6 +594,46 @@ public class TargetServiceImpl extends ServiceImpl<TargetMapper, Target>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getTogethDetail(JSONObject params) {
|
||||
String id = params.getString("id").trim();
|
||||
CheckUtils.checkEmpty(id, "指标ID");
|
||||
|
||||
Target target = targetMapper.selectById(id);
|
||||
ThrowUtils.throwIf(target == null, ErrorCode.PARAMS_ERROR, "指标不存在!");
|
||||
ThrowUtils.throwIf(target.getType() != 2, ErrorCode.PARAMS_ERROR, "该指标不是聚合指标!");
|
||||
|
||||
List<String> optionList = Arrays.asList(target.getResultSql().split(","));
|
||||
List<String> ids = optionList.stream()
|
||||
.filter(option -> option.length() > 1)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<Target> childTargetList = targetMapper.selectByIds(ids);
|
||||
Map<String, String> map = childTargetList.stream()
|
||||
.collect(Collectors.toMap(Target::getId, Target::getName));
|
||||
|
||||
List<TogetherVo> formulaList = new ArrayList<>();
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (String option : optionList) {
|
||||
if (option.length() > 1 && !map.containsKey(option)) {
|
||||
msg.append("ID为").append(option).append("的指标不存在,");
|
||||
}
|
||||
formulaList.add(TogetherVo.builder()
|
||||
.id(String.valueOf(formulaList.size()))
|
||||
.label(option.length() > 1 ? map.get(option) : option)
|
||||
.value(option)
|
||||
.type(option.length() > 1 ? "" : "danger")
|
||||
.build());
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("formulaList", formulaList);
|
||||
jsonObject.put("target", target);
|
||||
jsonObject.put("error", msg.isEmpty() ? "" : msg.substring(0, msg.length() - 1));
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指标变更后,修改对应的监控数据
|
||||
*
|
||||
|
27
src/main/java/iet/ustb/sf/vo/TogetherVo.java
Normal file
27
src/main/java/iet/ustb/sf/vo/TogetherVo.java
Normal file
@ -0,0 +1,27 @@
|
||||
package iet.ustb.sf.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* TogetherVo
|
||||
*
|
||||
* @author huangge1199
|
||||
* @since 2025/8/11 9:11:24
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class TogetherVo {
|
||||
|
||||
private String id;
|
||||
|
||||
private String label;
|
||||
|
||||
private String value;
|
||||
|
||||
private String type;
|
||||
}
|
Loading…
Reference in New Issue
Block a user