Przeglądaj źródła

修复 灌区拖拽后排序混乱的问题

zhaiyifei 8 miesięcy temu
rodzic
commit
cff7c0805f

+ 0 - 33
src/main/java/com/yunfeiyun/agmp/iotm/device/sf/service/IIotSfCommService.java

@@ -234,39 +234,6 @@ public class IIotSfCommService extends IotDeviceBaseServiceImpl implements IotDe
     }
 
     /**
-     * 获取灌区设备已存在的元素列表
-     *
-     * @param reqVo 请求对象,包含设备标识等信息
-     * @return TableDataInfo 包含响应码、消息、数据和总数
-     * @throws IotBizException 抛出业务异常,包含错误码和错误信息
-     */
-    public TableDataInfo getValveAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
-        TableDataInfo rspData = new TableDataInfo();
-        rspData.setCode(ErrorCode.SUCCESS.getCode());
-        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
-        rspData.setData(new ArrayList<>());
-        rspData.setTotal(0);
-
-        String devBid = reqVo.getDevBid();
-        if (StringUtils.isEmpty(devBid)) {
-            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备标识不能为空");
-        }
-
-        IotDevice findDevice = iotDeviceService.selectIotDeviceByDevBid(reqVo.getDevBid());
-        if (findDevice == null) {
-            throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
-        }
-
-        List<IotSfElementfactorAlreadyListResVo> resVoList = iotSfElementfactorService.getValveAlreadyElementList(reqVo);
-        if (resVoList != null && !resVoList.isEmpty()){
-            rspData.setData(resVoList);
-            rspData.setTotal(resVoList.size());
-        }
-        return rspData;
-    }
-
-
-    /**
      * 获取水肥机状态信息
      *
      * @param devBid 请求对象,包含设备标识等信息

+ 0 - 15
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotSfElementfactorService.java

@@ -117,20 +117,5 @@ public interface IIotSfElementfactorService {
 
     public List<IotSfElementfactorAlreadyListResVo> getGroupAlreadyElementList(IotSfElementfactorListReqVo reqVo);
 
-    /**
-     * 查询电磁阀已配置要素列表
-     * @param reqVo
-     * @return
-     */
-
-    public List<IotSfElementfactorAlreadyListResVo> getValveAlreadyElementList(IotSfElementfactorListReqVo reqVo);
-
-    /**
-     * 查询已配置要素列表
-     * @param reqVo
-     * @return
-     */
-
-    public IotSfElementfactorAlreadyListResVo getAlreadyElementByBid(String sfBid);
 }
 

+ 18 - 63
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotSfElementfactorServiceImpl.java

@@ -13,10 +13,7 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 @Slf4j
@@ -126,48 +123,33 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
      */
     @Override
     public List<IotSfElementfactorAlreadyListResVo> getAlreadyElementList(List<IotSfElementfactor> factorList) {
-        Map<String, IotSfElementfactorAlreadyListResVo> eleMap = new LinkedHashMap<>();
-        Map<String, IotSfElementfactor> tempMap = new LinkedHashMap<>();
-
-        for (IotSfElementfactor elementfactor : factorList) {
-            String sfBid = elementfactor.getSfBid();
-            tempMap.put(sfBid, elementfactor);
-        }
 
+        Map<String, IotSfElementfactorAlreadyListResVo> resultMap = new LinkedHashMap<>();
         for (IotSfElementfactor elementfactor : factorList) {
             String sfBid = elementfactor.getSfBid();
             String sfParentBid = elementfactor.getSfParentBid();
-
             IotSfElementfactorAlreadyListResVo eleResVo = new IotSfElementfactorAlreadyListResVo();
             BeanUtils.copyProperties(elementfactor, eleResVo);
-
-            // 表示是一级元素,直接添加
-            if(StringUtils.isEmpty(sfParentBid) && !eleMap.containsKey(sfBid)){
+            if(StringUtils.isEmpty(sfParentBid)){
                 eleResVo.setChildrenList(new ArrayList<>());
-                eleMap.put(sfBid, eleResVo);
-            }else{
-                // 表示不是一级元素,需要判断父元素是否已经存在
-                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<>());
+                resultMap.put(sfBid, eleResVo);
+            }
+        }
 
-                    parentReq.getChildrenList().add(eleResVo);
-                    eleMap.put(sfParentBid, parentReq);
-                }
+        for (IotSfElementfactor elementfactor : factorList) {
+            String sfParentBid = elementfactor.getSfParentBid();
+            if(StringUtils.isEmpty(sfParentBid)){
+                continue;
+            }
+            IotSfElementfactorAlreadyListResVo parentInfo = resultMap.get(sfParentBid);
+            if(parentInfo == null){
+                continue;
             }
+            IotSfElementfactorAlreadyListResVo childResVo = new IotSfElementfactorAlreadyListResVo();
+            BeanUtils.copyProperties(elementfactor, childResVo);
+            parentInfo.getChildrenList().add(childResVo);
         }
-        return new ArrayList<>(eleMap.values());
+        return new ArrayList<>(resultMap.values());
     }
 
     /**
@@ -244,31 +226,4 @@ public class IotSfElementfactorServiceImpl implements IIotSfElementfactorService
         List<IotSfElementfactor> elementfactorList = selectIotSfElementfactorList(reqVo);
         return getAlreadyElementList(elementfactorList);
     }
-
-    /**
-     * 查询电磁阀已配置要素列表
-     *
-     * @param reqVo
-     * @return
-     */
-    @Override
-    public List<IotSfElementfactorAlreadyListResVo> getValveAlreadyElementList(IotSfElementfactorListReqVo reqVo) {
-        List<IotSfElementfactor> elementfactorList = selectIotSfElementfactorListByValve(reqVo);
-        return getAlreadyElementList(elementfactorList);
-    }
-
-    /**
-     * 查询已配置要素列表
-     *
-     * @param sfBid@return
-     */
-    @Override
-    public IotSfElementfactorAlreadyListResVo getAlreadyElementByBid(String sfBid) {
-        List<IotSfElementfactor> elementfactorList = iotSfElementfactorMapper.getAlreadyElementByBid(sfBid);
-        List<IotSfElementfactorAlreadyListResVo> alreadyElementList = getAlreadyElementList(elementfactorList);
-        if(alreadyElementList != null && !alreadyElementList.isEmpty()){
-            return alreadyElementList.get(0);
-        }
-        return null;
-    }
 }