|
|
|
@ -16,11 +16,15 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.springblade.modules.monitor.service.impl; |
|
|
|
package org.springblade.modules.monitor.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.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.google.gson.JsonArray; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
@ -220,7 +224,79 @@ public class ConfigMonitorServiceImpl extends ServiceImpl<ConfigMonitorMapper, C |
|
|
|
return ForestNodeMerger.merge(baseMapper.tree()); |
|
|
|
return ForestNodeMerger.merge(baseMapper.tree()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<Long> getParentIdList(List<Long> parentIdList,Long parentId){ |
|
|
|
@Override |
|
|
|
|
|
|
|
public Object getWarnLinePoint(String parentId) { |
|
|
|
|
|
|
|
// 先查询该微服务
|
|
|
|
|
|
|
|
List resultList = new ArrayList(); |
|
|
|
|
|
|
|
ConfigMonitor monitor = baseMapper.selectOne(Wrappers.<ConfigMonitor>lambdaQuery().eq(ConfigMonitor::getId, parentId)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (monitor == null) { |
|
|
|
|
|
|
|
return resultList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
JSONObject monitorJson = new JSONObject(); |
|
|
|
|
|
|
|
monitorJson.put("parent", null); |
|
|
|
|
|
|
|
monitorJson.put("id", monitor.getId()); |
|
|
|
|
|
|
|
monitorJson.put("name", monitor.getMonitorType()); |
|
|
|
|
|
|
|
monitorJson.put("type", monitor.getType()); |
|
|
|
|
|
|
|
monitorJson.put("class_code", monitor.getClassCode()); |
|
|
|
|
|
|
|
monitorJson.put("status", monitor.getStatus()); |
|
|
|
|
|
|
|
monitorJson.put("icon", monitor.getIcon()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 递归查询该微服务下的所有设备
|
|
|
|
|
|
|
|
JSONArray allEquipArray = getChildList(monitorJson); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历设备组织返回数据
|
|
|
|
|
|
|
|
JSONObject resultObj = new JSONObject(); |
|
|
|
|
|
|
|
for (Object o : allEquipArray) { |
|
|
|
|
|
|
|
JSONObject item = JSONObject.parseObject(JSON.toJSONString(o)); |
|
|
|
|
|
|
|
resultObj.put("classCode", item.getString("class_code")); |
|
|
|
|
|
|
|
resultObj.put("lineData", getLineData(item)); |
|
|
|
|
|
|
|
resultList.add(resultObj); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultList.stream().distinct().collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JSONArray getChildList(JSONObject parent) { |
|
|
|
|
|
|
|
JSONArray resultArray = new JSONArray(); |
|
|
|
|
|
|
|
// 查询子等级的设备
|
|
|
|
|
|
|
|
List<ConfigMonitor> monitor1List = baseMapper.selectList(Wrappers.<ConfigMonitor>lambdaQuery().eq(ConfigMonitor::getParentId, parent.getLong("id"))); |
|
|
|
|
|
|
|
if (monitor1List == null || monitor1List.size() == 0) { |
|
|
|
|
|
|
|
resultArray.add(parent); |
|
|
|
|
|
|
|
return resultArray; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
for (ConfigMonitor monitor : monitor1List) { |
|
|
|
|
|
|
|
JSONObject monitorJson = new JSONObject(); |
|
|
|
|
|
|
|
monitorJson.put("parent", parent); |
|
|
|
|
|
|
|
monitorJson.put("id", monitor.getId()); |
|
|
|
|
|
|
|
monitorJson.put("name", monitor.getMonitorType()); |
|
|
|
|
|
|
|
monitorJson.put("type", monitor.getType()); |
|
|
|
|
|
|
|
monitorJson.put("class_code", monitor.getClassCode()); |
|
|
|
|
|
|
|
monitorJson.put("status", monitor.getStatus()); |
|
|
|
|
|
|
|
monitorJson.put("icon", monitor.getIcon()); |
|
|
|
|
|
|
|
resultArray.addAll(getChildList(monitorJson)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return resultArray; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JSONArray getLineData(JSONObject item) { |
|
|
|
|
|
|
|
JSONArray resultArray = new JSONArray(); |
|
|
|
|
|
|
|
JSONObject parent = item.getJSONObject("parent"); |
|
|
|
|
|
|
|
if (parent == null) { |
|
|
|
|
|
|
|
item.put("parent", "0"); |
|
|
|
|
|
|
|
resultArray.add(item); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
item.put("parent", parent.getString("id")); |
|
|
|
|
|
|
|
resultArray.add(item); |
|
|
|
|
|
|
|
for (Object lineDatum : getLineData(parent)) { |
|
|
|
|
|
|
|
resultArray.add(lineDatum); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return resultArray; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<Long> getParentIdList(List<Long> parentIdList, Long parentId) { |
|
|
|
parentIdList.add(parentId); |
|
|
|
parentIdList.add(parentId); |
|
|
|
if (parentId != 0) { |
|
|
|
if (parentId != 0) { |
|
|
|
LambdaQueryWrapper<ConfigMonitor> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
LambdaQueryWrapper<ConfigMonitor> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
@ -238,5 +314,4 @@ public class ConfigMonitorServiceImpl extends ServiceImpl<ConfigMonitorMapper, C |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|