Browse Source

空间未绑定楼层时新增失败问题bug修复

linhuili 3 years ago
parent
commit
8744bb8e5d

+ 9 - 6
src/main/java/com/persagy/proxy/object/service/impl/AdmSpaceServiceImpl.java

@@ -11,6 +11,7 @@ import java.util.stream.Collectors;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -85,13 +86,15 @@ public class AdmSpaceServiceImpl extends AbstractAdmBaseServiceImpl<AdmSpace> im
 
     @Override
     public List<AdmSpace> doInsertExt(InstanceUrlParam context, Class<AdmSpace> clazz, List<AdmSpace> voList) {
-        Map<String, List<AdmSpace>> spaceMapByFlId = voList.stream().collect(Collectors.groupingBy(AdmSpace::getFloorId));
+        Map<String, List<AdmSpace>> spaceMapByFlId = voList.stream().filter(admSpace -> StringUtils.isNotEmpty(admSpace.getFloorId())).collect(Collectors.groupingBy(AdmSpace::getFloorId));
         //查询空间中floorId 对应的floor
-        List<ObjectNode> floors = queryFloorsByFloorIds(context, spaceMapByFlId.keySet());
-        if(CollUtil.isNotEmpty(floors)){
-            //ArrayList<AdmFloor> floorList = CollUtil.newArrayList(JSONUtil.toList(floors.getData().toString(),AdmFloor.class));
-            //space.height = floor.infos.height
-            voList = processHeight(spaceMapByFlId, floors);
+        if(CollUtil.isNotEmpty(spaceMapByFlId)){
+            List<ObjectNode> floors = queryFloorsByFloorIds(context, spaceMapByFlId.keySet());
+            if(CollUtil.isNotEmpty(floors)){
+                //ArrayList<AdmFloor> floorList = CollUtil.newArrayList(JSONUtil.toList(floors.getData().toString(),AdmFloor.class));
+                //space.height = floor.infos.height
+                voList = processHeight(spaceMapByFlId, floors);
+            }
         }
         //插入空间
         List<AdmSpace> vosR = doInsert(context, clazz, voList);