|
@@ -1,5 +1,6 @@
|
|
|
package com.yunfeiyun.agmp.iots.service.impl;
|
|
package com.yunfeiyun.agmp.iots.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumSfElementType;
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumSfElementType;
|
|
|
import com.yunfeiyun.agmp.iots.domain.IotSfElementfactorAlreadyListResVo;
|
|
import com.yunfeiyun.agmp.iots.domain.IotSfElementfactorAlreadyListResVo;
|
|
@@ -98,6 +99,32 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
|
|
|
// return new ArrayList<>(eleMap.values());
|
|
// return new ArrayList<>(eleMap.values());
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|
|
+// /**
|
|
|
|
|
+// * 查询已配置要素列表
|
|
|
|
|
+// *
|
|
|
|
|
+// * @param factorList@return
|
|
|
|
|
+// */
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public List<IotSfElementfactorAlreadyListResVo> getAlreadyElementList(List<IotSfElementfactor> factorList) {
|
|
|
|
|
+// Map<String, IotSfElementfactorAlreadyListResVo> eleMap = new LinkedHashMap<>();
|
|
|
|
|
+// for (IotSfElementfactor elementfactor : factorList) {
|
|
|
|
|
+// String sfBid = elementfactor.getSfBid();
|
|
|
|
|
+// String sfParentBid = elementfactor.getSfParentBid();
|
|
|
|
|
+//
|
|
|
|
|
+// IotSfElementfactorAlreadyListResVo eleResVo = new IotSfElementfactorAlreadyListResVo();
|
|
|
|
|
+// BeanUtils.copyProperties(elementfactor, eleResVo);
|
|
|
|
|
+//
|
|
|
|
|
+// IotSfElementfactorAlreadyListResVo parentInfo = eleMap.get(sfParentBid);
|
|
|
|
|
+// if(parentInfo == null){
|
|
|
|
|
+// eleResVo.setChildrenList(new ArrayList<>());
|
|
|
|
|
+// eleMap.put(sfBid, eleResVo);
|
|
|
|
|
+// }else{
|
|
|
|
|
+// parentInfo.getChildrenList().add(eleResVo);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// return new ArrayList<>(eleMap.values());
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询已配置要素列表
|
|
* 查询已配置要素列表
|
|
|
*
|
|
*
|
|
@@ -106,6 +133,13 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
|
|
|
@Override
|
|
@Override
|
|
|
public List<IotSfElementfactorAlreadyListResVo> getAlreadyElementList(List<IotSfElementfactor> factorList) {
|
|
public List<IotSfElementfactorAlreadyListResVo> getAlreadyElementList(List<IotSfElementfactor> factorList) {
|
|
|
Map<String, IotSfElementfactorAlreadyListResVo> eleMap = new LinkedHashMap<>();
|
|
Map<String, IotSfElementfactorAlreadyListResVo> eleMap = new LinkedHashMap<>();
|
|
|
|
|
+ Map<String, IotSfElementfactor> tempMap = new LinkedHashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (IotSfElementfactor elementfactor : factorList) {
|
|
|
|
|
+ String sfBid = elementfactor.getSfBid();
|
|
|
|
|
+ tempMap.put(sfBid, elementfactor);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for (IotSfElementfactor elementfactor : factorList) {
|
|
for (IotSfElementfactor elementfactor : factorList) {
|
|
|
String sfBid = elementfactor.getSfBid();
|
|
String sfBid = elementfactor.getSfBid();
|
|
|
String sfParentBid = elementfactor.getSfParentBid();
|
|
String sfParentBid = elementfactor.getSfParentBid();
|
|
@@ -113,12 +147,30 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
|
|
|
IotSfElementfactorAlreadyListResVo eleResVo = new IotSfElementfactorAlreadyListResVo();
|
|
IotSfElementfactorAlreadyListResVo eleResVo = new IotSfElementfactorAlreadyListResVo();
|
|
|
BeanUtils.copyProperties(elementfactor, eleResVo);
|
|
BeanUtils.copyProperties(elementfactor, eleResVo);
|
|
|
|
|
|
|
|
- IotSfElementfactorAlreadyListResVo parentInfo = eleMap.get(sfParentBid);
|
|
|
|
|
- if(parentInfo == null){
|
|
|
|
|
|
|
+ // 表示是一级元素,直接添加
|
|
|
|
|
+ if(StringUtils.isEmpty(sfParentBid) && !eleMap.containsKey(sfBid)){
|
|
|
eleResVo.setChildrenList(new ArrayList<>());
|
|
eleResVo.setChildrenList(new ArrayList<>());
|
|
|
eleMap.put(sfBid, eleResVo);
|
|
eleMap.put(sfBid, eleResVo);
|
|
|
}else{
|
|
}else{
|
|
|
- parentInfo.getChildrenList().add(eleResVo);
|
|
|
|
|
|
|
+ // 表示不是一级元素,需要判断父元素是否已经存在
|
|
|
|
|
+ IotSfElementfactorAlreadyListResVo parentInfo = eleMap.get(sfParentBid);
|
|
|
|
|
+ // 如果父类已经添加,直接添加到父类的childrenList中
|
|
|
|
|
+ if(parentInfo != null){
|
|
|
|
|
+ parentInfo.getChildrenList().add(eleResVo);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 如果父类没有添加,需要先添加父类,再添加当前元素
|
|
|
|
|
+ IotSfElementfactor parentElement = tempMap.get(sfParentBid);
|
|
|
|
|
+ // 如果父类不存在,直接跳过
|
|
|
|
|
+ if(parentElement == null){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ IotSfElementfactorAlreadyListResVo parentReq = new IotSfElementfactorAlreadyListResVo();
|
|
|
|
|
+ BeanUtils.copyProperties(parentElement, parentReq);
|
|
|
|
|
+ parentReq.setChildrenList(new ArrayList<>());
|
|
|
|
|
+
|
|
|
|
|
+ parentReq.getChildrenList().add(eleResVo);
|
|
|
|
|
+ eleMap.put(sfParentBid, parentReq);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return new ArrayList<>(eleMap.values());
|
|
return new ArrayList<>(eleMap.values());
|