|
@@ -70,6 +70,9 @@ public class TestService {
|
|
|
@Autowired
|
|
|
DeviceCountDao deviceCountDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DeviceLevelCountDao deviceLevelCountDao;
|
|
|
+
|
|
|
private static Logger logger = LoggerFactory.getLogger(TestService.class);
|
|
|
|
|
|
public List<AccessControl> get(AccessControl data) {
|
|
@@ -274,6 +277,64 @@ public class TestService {
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
+ //===================================================模拟设备层级统计======================================================
|
|
|
+
|
|
|
+ public List<DeviceLevelCount> getDeviceLevelCount(long projectId) {
|
|
|
+ List<DeviceLevelCount> rootList = deviceLevelCountDao.getRoot(projectId);
|
|
|
+ List<DeviceLevelCount> ls = deviceLevelCountDao.getList(projectId);
|
|
|
+ List<DeviceLevelCount> list = new ArrayList<>();
|
|
|
+ if (rootList != null && rootList.size() > 0) {
|
|
|
+ for (DeviceLevelCount d : rootList) {
|
|
|
+ list.add(this.getNodeTreeById(d.getId(), ls));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int save(DeviceLevelCount deviceLevelCount) {
|
|
|
+ return deviceLevelCountDao.save(deviceLevelCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int update(DeviceLevelCount deviceLevelCount) {
|
|
|
+ return deviceLevelCountDao.update(deviceLevelCount);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int deleteDeviceLevelCount(long id) {
|
|
|
+ return deviceLevelCountDao.delete(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ private DeviceLevelCount getNodeTreeById(long id, List<DeviceLevelCount> list) {
|
|
|
+ DeviceLevelCount node = null;
|
|
|
+ List<DeviceLevelCount> deviceLevelCountList = list;
|
|
|
+ for (DeviceLevelCount data : deviceLevelCountList) {
|
|
|
+ if (data.getId() == id) {
|
|
|
+ node = data;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (node != null) {
|
|
|
+ node.setChildren(getChildNode(node.getId(), deviceLevelCountList));
|
|
|
+ }
|
|
|
+ return node;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DeviceLevelCount> getChildNode(long parentId, List<DeviceLevelCount> list) {
|
|
|
+ List<DeviceLevelCount> nodeList = new ArrayList<>();
|
|
|
+ nodeList.clear();
|
|
|
+ for (DeviceLevelCount data : list) {
|
|
|
+ if (data.getParentId() == parentId) {
|
|
|
+ nodeList.add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (nodeList.size() > 0) {
|
|
|
+ for (DeviceLevelCount data : nodeList) {
|
|
|
+ List<DeviceLevelCount> childList = getChildNode(data.getId(), list);
|
|
|
+ data.setChildren(childList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nodeList;
|
|
|
+ }
|
|
|
+
|
|
|
//=========================================================================================================
|
|
|
|
|
|
public List<Region> get(Region data) {
|